mobility-toolbox-js 3.0.0-beta.9 → 3.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/HttpAPI.d.ts +5 -16
- package/api/HttpAPI.js +0 -11
- package/api/RealtimeAPI.d.ts +221 -176
- package/api/RealtimeAPI.js +317 -258
- package/api/RoutingAPI.d.ts +21 -11
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +20 -14
- package/api/StopsAPI.js +17 -11
- package/api/WebSocketAPI.d.ts +60 -66
- package/api/WebSocketAPI.js +164 -164
- package/api/index.js +1 -1
- package/api/typedefs.d.ts +0 -102
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +12 -12
- package/common/controls/StopFinderControlCommon.js +31 -31
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +157 -163
- package/common/mixins/RealtimeLayerMixin.js +401 -393
- package/common/styles/realtimeDefaultStyle.js +6 -6
- package/common/styles/realtimeHeadingStyle.js +5 -5
- package/common/typedefs.d.ts +13 -6
- package/common/typedefs.js +7 -1
- package/common/utils/compareDepartures.d.ts +2 -2
- package/common/utils/compareDepartures.js +2 -2
- package/common/utils/debounceWebsocketMessages.d.ts +1 -1
- package/common/utils/getMapGlCopyrights.d.ts +1 -1
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getVehiclePosition.d.ts +5 -4
- package/common/utils/getVehiclePosition.js +9 -3
- package/common/utils/renderTrajectories.d.ts +1 -1
- package/common/utils/renderTrajectories.js +6 -6
- package/common/utils/sortAndFilterDepartures.d.ts +1 -1
- package/common/utils/sortAndFilterDepartures.js +1 -1
- package/common/utils/sortByDelay.d.ts +2 -2
- package/common/utils/sortByDelay.js +5 -1
- package/maplibre/layers/Layer.d.ts +1 -1
- package/maplibre/layers/Layer.js +1 -1
- package/maplibre/layers/RealtimeLayer.d.ts +87 -66
- package/maplibre/layers/RealtimeLayer.js +30 -6
- package/maplibre/utils/getSourceCoordinates.js +5 -5
- package/mbt.js +20988 -13287
- package/mbt.js.map +4 -4
- package/mbt.min.js +61 -58
- package/mbt.min.js.map +4 -4
- package/ol/controls/RoutingControl.d.ts +82 -89
- package/ol/controls/RoutingControl.js +217 -219
- package/ol/controls/StopFinderControl.d.ts +3 -3
- package/ol/controls/StopFinderControl.js +2 -2
- package/ol/index.d.ts +1 -0
- package/ol/index.js +1 -0
- package/ol/layers/Layer.d.ts +101 -0
- package/ol/layers/Layer.js +25 -0
- package/ol/layers/MaplibreLayer.d.ts +121 -24
- package/ol/layers/MaplibreLayer.js +98 -27
- package/ol/layers/MaplibreStyleLayer.d.ts +93 -91
- package/ol/layers/MaplibreStyleLayer.js +281 -257
- package/ol/layers/RealtimeLayer.d.ts +119 -121
- package/ol/layers/RealtimeLayer.js +143 -134
- package/ol/layers/VectorLayer.d.ts +18 -0
- package/ol/layers/VectorLayer.js +32 -0
- package/ol/layers/index.d.ts +2 -0
- package/ol/layers/index.js +3 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +32 -34
- package/ol/mixins/PropertiesLayerMixin.d.ts +60 -51
- package/ol/mixins/PropertiesLayerMixin.js +114 -79
- package/ol/mixins/index.d.ts +1 -0
- package/ol/mixins/index.js +2 -0
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -20
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
- package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
- package/ol/renderers/RealtimeLayerRenderer.d.ts +6 -6
- package/ol/renderers/RealtimeLayerRenderer.js +56 -51
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
- package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
- package/package.json +31 -31
- package/setupTests.js +3 -4
- package/types/common.d.ts +55 -48
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +91 -93
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
- package/ol/layers/MapGlLayer.d.ts +0 -144
- package/ol/layers/MapGlLayer.js +0 -144
|
@@ -18,7 +18,7 @@ class StopFinderControlCommon {
|
|
|
18
18
|
* @param {StopsSearchParams} [options.apiParams={ limit: 20 }] Request parameters. See [Stops service documentation](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
|
|
19
19
|
*/
|
|
20
20
|
constructor(options) {
|
|
21
|
-
const { apiParams,
|
|
21
|
+
const { apiKey, apiParams, placeholder, url } = options || {};
|
|
22
22
|
this.apiParams = Object.assign({ limit: 20 }, (apiParams || {}));
|
|
23
23
|
this.placeholder = placeholder || 'Search for a stop...';
|
|
24
24
|
const apiOptions = { apiKey };
|
|
@@ -30,26 +30,16 @@ class StopFinderControlCommon {
|
|
|
30
30
|
this.createElement(options);
|
|
31
31
|
this.options = options;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Clear the search field and close the control.
|
|
35
|
+
*/
|
|
36
|
+
clear() {
|
|
37
|
+
if (!this.suggestionsElt || !this.inputElt || !this.clearElt) {
|
|
36
38
|
return;
|
|
37
39
|
}
|
|
38
|
-
this.
|
|
40
|
+
this.inputElt.value = '';
|
|
39
41
|
this.suggestionsElt.innerHTML = '';
|
|
40
|
-
|
|
41
|
-
var _a, _b;
|
|
42
|
-
const suggElt = document.createElement('div');
|
|
43
|
-
suggElt.innerHTML = (_a = suggestion === null || suggestion === void 0 ? void 0 : suggestion.properties) === null || _a === void 0 ? void 0 : _a.name;
|
|
44
|
-
suggElt.onclick = (evt) => {
|
|
45
|
-
var _a, _b;
|
|
46
|
-
(_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.onSuggestionClick) === null || _b === void 0 ? void 0 : _b.call(_a, suggestion, evt);
|
|
47
|
-
};
|
|
48
|
-
Object.assign(suggElt.style, {
|
|
49
|
-
padding: '5px 12px',
|
|
50
|
-
});
|
|
51
|
-
(_b = this.suggestionsElt) === null || _b === void 0 ? void 0 : _b.appendChild(suggElt);
|
|
52
|
-
});
|
|
42
|
+
this.clearElt.style.display = 'none';
|
|
53
43
|
}
|
|
54
44
|
createElement({ element }) {
|
|
55
45
|
// Create input element
|
|
@@ -61,7 +51,7 @@ class StopFinderControlCommon {
|
|
|
61
51
|
var _a;
|
|
62
52
|
(_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
63
53
|
this.abortController = new AbortController();
|
|
64
|
-
// @ts-
|
|
54
|
+
// @ts-expect-error - Improve ts
|
|
65
55
|
this.search(evt.target.value, this.abortController);
|
|
66
56
|
};
|
|
67
57
|
Object.assign(this.inputElt.style, {
|
|
@@ -72,38 +62,48 @@ class StopFinderControlCommon {
|
|
|
72
62
|
this.suggestionsElt = document.createElement('div');
|
|
73
63
|
Object.assign(this.suggestionsElt.style, {
|
|
74
64
|
backgroundColor: 'white',
|
|
75
|
-
overflowY: 'auto',
|
|
76
65
|
cursor: 'pointer',
|
|
66
|
+
overflowY: 'auto',
|
|
77
67
|
});
|
|
78
68
|
element.appendChild(this.suggestionsElt);
|
|
79
69
|
this.clearElt = document.createElement('div');
|
|
80
70
|
Object.assign(this.clearElt.style, {
|
|
71
|
+
cursor: 'pointer',
|
|
81
72
|
display: 'none',
|
|
73
|
+
fontSize: '200%',
|
|
74
|
+
padding: '0 10px',
|
|
82
75
|
position: 'absolute',
|
|
83
76
|
right: '0',
|
|
84
|
-
padding: '0 10px',
|
|
85
|
-
fontSize: '200%',
|
|
86
|
-
cursor: 'pointer',
|
|
87
77
|
});
|
|
88
78
|
this.clearElt.innerHTML = '×';
|
|
89
79
|
this.clearElt.onclick = () => this.clear();
|
|
90
80
|
element.appendChild(this.clearElt);
|
|
91
81
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
clear() {
|
|
96
|
-
if (!this.suggestionsElt || !this.inputElt || !this.clearElt) {
|
|
82
|
+
render(featureCollection) {
|
|
83
|
+
const suggestions = (featureCollection === null || featureCollection === void 0 ? void 0 : featureCollection.features) || [];
|
|
84
|
+
if (!this.suggestionsElt) {
|
|
97
85
|
return;
|
|
98
86
|
}
|
|
99
|
-
this.
|
|
87
|
+
this.suggestionsElt.style.display = suggestions.length ? 'block' : 'none';
|
|
100
88
|
this.suggestionsElt.innerHTML = '';
|
|
101
|
-
|
|
89
|
+
suggestions.forEach((suggestion) => {
|
|
90
|
+
var _a, _b;
|
|
91
|
+
const suggElt = document.createElement('div');
|
|
92
|
+
suggElt.innerHTML = (_a = suggestion === null || suggestion === void 0 ? void 0 : suggestion.properties) === null || _a === void 0 ? void 0 : _a.name;
|
|
93
|
+
suggElt.onclick = (evt) => {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
(_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.onSuggestionClick) === null || _b === void 0 ? void 0 : _b.call(_a, suggestion, evt);
|
|
96
|
+
};
|
|
97
|
+
Object.assign(suggElt.style, {
|
|
98
|
+
padding: '5px 12px',
|
|
99
|
+
});
|
|
100
|
+
(_b = this.suggestionsElt) === null || _b === void 0 ? void 0 : _b.appendChild(suggElt);
|
|
101
|
+
});
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Launch a search.
|
|
105
105
|
*
|
|
106
|
-
* @param {String}
|
|
106
|
+
* @param {String} q The query to search for.
|
|
107
107
|
* @param {AbortController} abortController Abort controller used to cancel the request.
|
|
108
108
|
* @return {Promise<Array<GeoJSONFeature>>} An array of GeoJSON features with coordinates in [EPSG:4326](http://epsg.io/4326).
|
|
109
109
|
*/
|
package/common/index.d.ts
CHANGED
package/common/index.js
CHANGED
|
@@ -1,64 +1,65 @@
|
|
|
1
|
-
import GeoJSON from 'ol/format/GeoJSON';
|
|
2
|
-
import { EventsKey } from 'ol/events';
|
|
3
1
|
import { Coordinate } from 'ol/coordinate';
|
|
2
|
+
import { EventsKey } from 'ol/events';
|
|
3
|
+
import GeoJSON from 'ol/format/GeoJSON';
|
|
4
4
|
import { Options } from 'ol/layer/Layer';
|
|
5
5
|
import { RealtimeAPI } from '../../api';
|
|
6
|
-
import { AnyCanvas, AnyLayerClass, AnyMap, AnyRealtimeLayer, LayerGetFeatureInfoOptions, RealtimeGeneralizationLevel, RealtimeMode, RealtimeMot, RealtimeRenderState, RealtimeStyleFunction, RealtimeStyleOptions, RealtimeTenant, RealtimeTrainId, ViewState, AnyLayer, LayerGetFeatureInfoResponse } from '../../types';
|
|
7
|
-
import { RealtimeTrajectory } from '../../api/typedefs';
|
|
8
6
|
import { WebSocketAPIMessageEventData } from '../../api/WebSocketAPI';
|
|
7
|
+
import { AnyCanvas, AnyLayer, AnyLayerable, AnyMap, AnyRealtimeLayer, LayerGetFeatureInfoOptions, LayerGetFeatureInfoResponse, RealtimeGeneralizationLevel, RealtimeMode, RealtimeMot, RealtimeRenderState, RealtimeStyleFunction, RealtimeStyleOptions, RealtimeTenant, RealtimeTrainId, RealtimeTrajectory, ViewState } from '../../types';
|
|
9
8
|
import { FilterFunction, SortFunction } from '../typedefs';
|
|
10
|
-
export type RealtimeLayerMixinOptions =
|
|
11
|
-
debug?: boolean;
|
|
12
|
-
mode?: RealtimeMode;
|
|
9
|
+
export type RealtimeLayerMixinOptions = {
|
|
13
10
|
api?: RealtimeAPI;
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
bbox?: (number | string)[];
|
|
13
|
+
bboxParameters?: Record<string, boolean | boolean[] | number | number[] | string | string[]>;
|
|
14
|
+
buffer?: number[];
|
|
15
|
+
canvas?: HTMLCanvasElement;
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
filter?: FilterFunction;
|
|
18
|
+
generalizationLevelByZoom?: RealtimeGeneralizationLevel[];
|
|
19
|
+
getGeneralizationLevelByZoom?: (zoom: number, generalizationLevelByZoom: RealtimeGeneralizationLevel[]) => RealtimeGeneralizationLevel;
|
|
20
|
+
getMotsByZoom?: (zoom: number, motsByZoom: RealtimeMot[][]) => RealtimeMot[];
|
|
21
|
+
getRenderTimeIntervalByZoom?: (zoom: number, renderTimeIntervalByZoom: number[]) => number;
|
|
22
|
+
hoverVehicleId?: RealtimeTrainId;
|
|
16
23
|
isUpdateBboxOnMoveEnd?: boolean;
|
|
24
|
+
live?: boolean;
|
|
25
|
+
minZoomInterpolation?: number;
|
|
26
|
+
mode?: RealtimeMode;
|
|
17
27
|
motsByZoom?: RealtimeMot[][];
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
speed?: number;
|
|
28
|
+
onStart?: (realtimeLayer: AnyRealtimeLayer) => void;
|
|
29
|
+
onStop?: (realtimeLayer: AnyRealtimeLayer) => void;
|
|
30
|
+
pingIntervalMs?: number;
|
|
22
31
|
pixelRatio?: number;
|
|
23
|
-
|
|
32
|
+
prefix?: string;
|
|
33
|
+
renderTimeIntervalByZoom?: number[];
|
|
24
34
|
selectedVehicleId?: RealtimeTrainId;
|
|
25
|
-
filter?: FilterFunction;
|
|
26
35
|
sort?: SortFunction;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
canvas?: HTMLCanvasElement;
|
|
36
|
+
speed?: number;
|
|
37
|
+
style?: RealtimeStyleFunction;
|
|
30
38
|
styleOptions?: RealtimeStyleOptions;
|
|
31
|
-
|
|
39
|
+
tenant?: RealtimeTenant;
|
|
40
|
+
time?: number;
|
|
41
|
+
url?: string;
|
|
32
42
|
useDebounce?: boolean;
|
|
43
|
+
useRequestAnimationFrame?: boolean;
|
|
33
44
|
useThrottle?: boolean;
|
|
34
|
-
|
|
35
|
-
getGeneralizationLevelByZoom?: (zoom: number, generalizationLevelByZoom: RealtimeGeneralizationLevel[]) => RealtimeGeneralizationLevel;
|
|
36
|
-
getRenderTimeIntervalByZoom?: (zoom: number, renderTimeIntervalByZoom: number[]) => number;
|
|
37
|
-
onStart?: (realtimeLayer: AnyRealtimeLayer) => void;
|
|
38
|
-
onStop?: (realtimeLayer: AnyRealtimeLayer) => void;
|
|
39
|
-
url?: string;
|
|
40
|
-
apiKey?: string;
|
|
41
|
-
prefix?: string;
|
|
42
|
-
bbox?: (number | string)[];
|
|
43
|
-
buffer?: number[];
|
|
44
|
-
pingIntervalMs?: number;
|
|
45
|
-
bboxParameters?: {
|
|
46
|
-
[index: string]: string | number | boolean | string[] | boolean[] | number[];
|
|
47
|
-
};
|
|
48
|
-
};
|
|
45
|
+
} & Options;
|
|
49
46
|
/**
|
|
50
47
|
* RealtimeLayerInterface.
|
|
51
48
|
* @private
|
|
52
49
|
*/
|
|
53
50
|
export declare class RealtimeLayerInterface {
|
|
54
51
|
/**
|
|
55
|
-
*
|
|
52
|
+
* Request the stopSequence and the fullTrajectory informations for a vehicle.
|
|
53
|
+
*
|
|
54
|
+
* @param {string} id The vehicle identifier (the train_id property).
|
|
55
|
+
* @param {RealtimeMode} mode The mode to request. If not defined, the layer´s mode propetrty will be used.
|
|
56
|
+
* @return {Promise<{stopSequence: RealtimeStopSequence, fullTrajectory: RealtimeFullTrajectory>} A promise that will be resolved with the trajectory informations.
|
|
56
57
|
*/
|
|
57
|
-
|
|
58
|
+
getTrajectoryInfos(id: string, mode: RealtimeMode): void;
|
|
58
59
|
/**
|
|
59
|
-
*
|
|
60
|
+
* Render the trajectories
|
|
60
61
|
*/
|
|
61
|
-
|
|
62
|
+
renderTrajectories(): void;
|
|
62
63
|
/**
|
|
63
64
|
* Set the Realtime api's bbox.
|
|
64
65
|
*
|
|
@@ -67,17 +68,13 @@ export declare class RealtimeLayerInterface {
|
|
|
67
68
|
*/
|
|
68
69
|
setBbox(extent: [number, number, number, number], zoom: number): void;
|
|
69
70
|
/**
|
|
70
|
-
*
|
|
71
|
+
* Start the clock.
|
|
71
72
|
*/
|
|
72
|
-
|
|
73
|
+
start(): void;
|
|
73
74
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* @param {string} id The vehicle identifier (the train_id property).
|
|
77
|
-
* @param {RealtimeMode} mode The mode to request. If not defined, the layer´s mode propetrty will be used.
|
|
78
|
-
* @return {Promise<{stopSequence: StopSequence, fullTrajectory: FullTrajectory>} A promise that will be resolved with the trajectory informations.
|
|
75
|
+
* Stop the clock.
|
|
79
76
|
*/
|
|
80
|
-
|
|
77
|
+
stop(): void;
|
|
81
78
|
}
|
|
82
79
|
/**
|
|
83
80
|
* Mixin for RealtimeLayerInterface.
|
|
@@ -86,106 +83,75 @@ export declare class RealtimeLayerInterface {
|
|
|
86
83
|
* @return {Class} A class that implements {RealtimeLayerInterface} class and extends Base;
|
|
87
84
|
* @private
|
|
88
85
|
*/
|
|
89
|
-
declare function RealtimeLayerMixin<T extends
|
|
86
|
+
declare function RealtimeLayerMixin<T extends AnyLayerable>(Base: T): {
|
|
90
87
|
new (options: RealtimeLayerMixinOptions): {
|
|
91
88
|
[x: string]: any;
|
|
92
|
-
|
|
93
|
-
trajectories?: {
|
|
94
|
-
[key: string]: GeoJSONFeature;
|
|
95
|
-
} | undefined;
|
|
96
|
-
canvas?: AnyCanvas | undefined;
|
|
97
|
-
mode: RealtimeMode;
|
|
89
|
+
[x: symbol]: any;
|
|
98
90
|
api: RealtimeAPI;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
live?: boolean | undefined;
|
|
105
|
-
speed?: number | undefined;
|
|
106
|
-
filter?: Function | undefined;
|
|
107
|
-
sort?: Function | undefined;
|
|
108
|
-
style?: RealtimeStyleFunction | undefined;
|
|
109
|
-
styleOptions?: RealtimeStyleOptions | undefined;
|
|
110
|
-
pixelRatio?: number | undefined;
|
|
111
|
-
minZoomInterpolation: number;
|
|
112
|
-
isUpdateBboxOnMoveEnd: boolean;
|
|
113
|
-
hoverVehicleId?: string | undefined;
|
|
114
|
-
selectedVehicleId?: string | undefined;
|
|
115
|
-
renderState?: RealtimeRenderState | undefined;
|
|
116
|
-
useRequestAnimationFrame?: boolean | undefined;
|
|
117
|
-
useDebounce?: boolean | undefined;
|
|
118
|
-
useThrottle?: boolean | undefined;
|
|
119
|
-
mots?: RealtimeMot[] | undefined;
|
|
120
|
-
motsByZoom: RealtimeMot[][];
|
|
121
|
-
generalizationLevel?: RealtimeGeneralizationLevel | undefined;
|
|
122
|
-
generalizationLevelByZoom: RealtimeGeneralizationLevel[];
|
|
123
|
-
renderTimeIntervalByZoom: number[];
|
|
91
|
+
bboxParameters?: Record<string, boolean | boolean[] | number | number[] | string | string[]>;
|
|
92
|
+
canvas?: AnyCanvas;
|
|
93
|
+
debounceRenderTrajectories: (viewState: ViewState, noInterpolate?: boolean) => void;
|
|
94
|
+
debug: boolean;
|
|
95
|
+
filter?: FilterFunction;
|
|
124
96
|
format: GeoJSON;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
updateTimeDelay?: number | undefined;
|
|
128
|
-
visibilityRef: EventsKey;
|
|
129
|
-
selectedVehicle: GeoJSONFeature;
|
|
130
|
-
getMotsByZoom: (zoom: number) => RealtimeMot[];
|
|
97
|
+
generalizationLevel?: RealtimeGeneralizationLevel;
|
|
98
|
+
generalizationLevelByZoom: RealtimeGeneralizationLevel[];
|
|
131
99
|
getGeneralizationLevelByZoom: (zoom: number) => RealtimeGeneralizationLevel;
|
|
100
|
+
getMotsByZoom: (zoom: number) => RealtimeMot[];
|
|
132
101
|
getRenderTimeIntervalByZoom: (zoom: number) => number;
|
|
102
|
+
hoverVehicleId?: RealtimeTrainId;
|
|
103
|
+
isUpdateBboxOnMoveEnd: boolean;
|
|
104
|
+
live?: boolean;
|
|
105
|
+
minZoomInterpolation: number;
|
|
106
|
+
mode: RealtimeMode;
|
|
107
|
+
mots?: RealtimeMot[];
|
|
108
|
+
motsByZoom: RealtimeMot[][];
|
|
109
|
+
onStart?: (realtimeLayer: AnyLayer) => void;
|
|
110
|
+
onStop?: (realtimeLayer: AnyLayer) => void;
|
|
111
|
+
pixelRatio?: number;
|
|
112
|
+
renderState?: RealtimeRenderState;
|
|
113
|
+
renderTimeIntervalByZoom: number[];
|
|
114
|
+
requestId?: number;
|
|
115
|
+
selectedVehicle: RealtimeTrajectory;
|
|
116
|
+
selectedVehicleId?: RealtimeTrainId;
|
|
117
|
+
sort?: SortFunction;
|
|
118
|
+
speed?: number;
|
|
119
|
+
style?: RealtimeStyleFunction;
|
|
120
|
+
styleOptions?: RealtimeStyleOptions;
|
|
121
|
+
tenant: RealtimeTenant;
|
|
133
122
|
throttleRenderTrajectories: (viewState: ViewState, noInterpolate?: boolean) => void;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
123
|
+
time?: Date;
|
|
124
|
+
trajectories?: Record<RealtimeTrainId, RealtimeTrajectory>;
|
|
125
|
+
updateTimeDelay?: number;
|
|
126
|
+
updateTimeInterval?: number;
|
|
127
|
+
useDebounce?: boolean;
|
|
128
|
+
useRequestAnimationFrame?: boolean;
|
|
129
|
+
useThrottle?: boolean;
|
|
130
|
+
visibilityRef: EventsKey;
|
|
137
131
|
/**
|
|
138
|
-
*
|
|
139
|
-
*
|
|
132
|
+
* Add a trajectory.
|
|
133
|
+
* @param {RealtimeTrajectory} trajectory The trajectory to add.
|
|
140
134
|
* @private
|
|
141
135
|
*/
|
|
142
|
-
|
|
136
|
+
addTrajectory(trajectory: RealtimeTrajectory): void;
|
|
143
137
|
attachToMap(map: AnyMap): void;
|
|
144
|
-
detachFromMap(): void;
|
|
145
|
-
start(): void;
|
|
146
|
-
/**
|
|
147
|
-
* Start the clock.
|
|
148
|
-
* @private
|
|
149
|
-
*/
|
|
150
|
-
startUpdateTime(): void;
|
|
151
|
-
stop(): void;
|
|
152
138
|
/**
|
|
153
|
-
*
|
|
154
|
-
* @private
|
|
155
|
-
*/
|
|
156
|
-
stopUpdateTime(): void;
|
|
157
|
-
/**
|
|
158
|
-
* Launch renderTrajectories. it avoids duplicating code in renderTrajectories method.
|
|
139
|
+
* Define layer's properties.
|
|
159
140
|
*
|
|
160
|
-
* @param {object} viewState The view state of the map.
|
|
161
|
-
* @param {number[2]} viewState.center Center coordinate of the map in mercator coordinate.
|
|
162
|
-
* @param {number[4]} viewState.extent Extent of the map in mercator coordinates.
|
|
163
|
-
* @param {number[2]} viewState.size Size ([width, height]) of the canvas to render.
|
|
164
|
-
* @param {number} [viewState.rotation = 0] Rotation of the map to render.
|
|
165
|
-
* @param {number} viewState.resolution Resolution of the map to render.
|
|
166
|
-
* @param {boolean} noInterpolate If true trajectories are not interpolated but
|
|
167
|
-
* drawn at the last known coordinate. Use this for performance optimization
|
|
168
|
-
* during map navigation.
|
|
169
141
|
* @private
|
|
170
142
|
*/
|
|
171
|
-
|
|
143
|
+
defineProperties(options: RealtimeLayerMixinOptions): void;
|
|
144
|
+
detachFromMap(): void;
|
|
172
145
|
/**
|
|
173
|
-
*
|
|
174
|
-
* This function must be overrided by children to provide the correct parameters.
|
|
146
|
+
* Request feature information for a given coordinate.
|
|
175
147
|
*
|
|
176
|
-
* @param {
|
|
177
|
-
* @param {
|
|
178
|
-
* @param {number
|
|
179
|
-
* @param {number
|
|
180
|
-
* @
|
|
181
|
-
* @param {number} viewState.resolution Resolution of the map to render.
|
|
182
|
-
* @param {boolean} noInterpolate If true trajectories are not interpolated but
|
|
183
|
-
* drawn at the last known coordinate. Use this for performance optimization
|
|
184
|
-
* during map navigation.
|
|
185
|
-
* @private
|
|
148
|
+
* @param {ol/coordinate~Coordinate} coordinate Coordinate.
|
|
149
|
+
* @param {Object} options Options See child classes to see which options are supported.
|
|
150
|
+
* @param {number} [options.resolution=1] The resolution of the map.
|
|
151
|
+
* @param {number} [options.nb=Infinity] The max number of vehicles to return.
|
|
152
|
+
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
|
|
186
153
|
*/
|
|
187
|
-
|
|
188
|
-
setBbox(extent: [number, number, number, number], zoom: number): void;
|
|
154
|
+
getFeatureInfoAtCoordinate(coordinate: Coordinate, options: LayerGetFeatureInfoOptions): Promise<LayerGetFeatureInfoResponse>;
|
|
189
155
|
/**
|
|
190
156
|
* Get the duration before the next update depending on zoom level.
|
|
191
157
|
*
|
|
@@ -193,32 +159,46 @@ declare function RealtimeLayerMixin<T extends AnyLayerClass>(Base: T): {
|
|
|
193
159
|
* @param {number} zoom
|
|
194
160
|
*/
|
|
195
161
|
getRefreshTimeInMs(zoom?: number | undefined): number;
|
|
162
|
+
/**
|
|
163
|
+
* Request the stopSequence and the fullTrajectory informations for a vehicle.
|
|
164
|
+
*
|
|
165
|
+
* @param {string} id The vehicle identifier (the train_id property).
|
|
166
|
+
* @return {Promise<{stopSequence: RealtimeStopSequence, fullTrajectory: RealtimeFullTrajectory>} A promise that will be resolved with the trajectory informations.
|
|
167
|
+
*/
|
|
168
|
+
getTrajectoryInfos(id: RealtimeTrainId): Promise<{
|
|
169
|
+
fullTrajectory: WebSocketAPIMessageEventData<import("../../types").RealtimeStopSequence[]> | WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory>;
|
|
170
|
+
stopSequence: WebSocketAPIMessageEventData<import("../../types").RealtimeStopSequence[]> | WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory>;
|
|
171
|
+
}>;
|
|
196
172
|
/**
|
|
197
173
|
* Get vehicle.
|
|
198
174
|
* @param {function} filterFc A function use to filter results.
|
|
199
175
|
* @return {Array<Object>} Array of vehicle.
|
|
200
176
|
*/
|
|
201
|
-
getVehicle(filterFc: FilterFunction):
|
|
177
|
+
getVehicle(filterFc: FilterFunction): RealtimeTrajectory[];
|
|
178
|
+
highlightVehicle(id: RealtimeTrainId): void;
|
|
202
179
|
/**
|
|
203
|
-
*
|
|
180
|
+
* Callback on websocket's deleted_vehicles channel events.
|
|
181
|
+
* It removes the trajectory from the list.
|
|
204
182
|
*
|
|
205
|
-
* @
|
|
206
|
-
* @
|
|
207
|
-
* @param {number} [options.resolution=1] The resolution of the map.
|
|
208
|
-
* @param {number} [options.nb=Infinity] The max number of vehicles to return.
|
|
209
|
-
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
|
|
183
|
+
* @private
|
|
184
|
+
* @override
|
|
210
185
|
*/
|
|
211
|
-
|
|
186
|
+
onDeleteTrajectoryMessage(data: WebSocketAPIMessageEventData<RealtimeTrainId>): void;
|
|
187
|
+
onDocumentVisibilityChange(): void;
|
|
212
188
|
/**
|
|
213
|
-
*
|
|
189
|
+
* Callback on websocket's trajectory channel events.
|
|
190
|
+
* It adds a trajectory to the list.
|
|
214
191
|
*
|
|
215
|
-
* @
|
|
216
|
-
* @return {Promise<{stopSequence: StopSequence, fullTrajectory: FullTrajectory>} A promise that will be resolved with the trajectory informations.
|
|
192
|
+
* @private
|
|
217
193
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
194
|
+
onTrajectoryMessage(data: WebSocketAPIMessageEventData<RealtimeTrajectory>): void;
|
|
195
|
+
/**
|
|
196
|
+
* On zoomend we adjust the time interval of the update of vehicles positions.
|
|
197
|
+
*
|
|
198
|
+
* @param evt Event that triggered the function.
|
|
199
|
+
* @private
|
|
200
|
+
*/
|
|
201
|
+
onZoomEnd(): void;
|
|
222
202
|
/**
|
|
223
203
|
* Remove all trajectories that are in the past.
|
|
224
204
|
*/
|
|
@@ -235,39 +215,53 @@ declare function RealtimeLayerMixin<T extends AnyLayerClass>(Base: T): {
|
|
|
235
215
|
* @return {boolean} if the trajectory must be displayed or not.
|
|
236
216
|
* @private
|
|
237
217
|
*/
|
|
238
|
-
purgeTrajectory(trajectory:
|
|
218
|
+
purgeTrajectory(trajectory: RealtimeTrajectory, extent: [number, number, number, number], zoom: number): boolean;
|
|
219
|
+
removeTrajectory(trajectoryOrId: RealtimeTrainId | RealtimeTrajectory): void;
|
|
239
220
|
/**
|
|
240
|
-
*
|
|
241
|
-
*
|
|
221
|
+
* Render the trajectories requesting an animation frame and cancelling the previous one.
|
|
222
|
+
* This function must be overrided by children to provide the correct parameters.
|
|
223
|
+
*
|
|
224
|
+
* @param {object} viewState The view state of the map.
|
|
225
|
+
* @param {number[2]} viewState.center Center coordinate of the map in mercator coordinate.
|
|
226
|
+
* @param {number[4]} viewState.extent Extent of the map in mercator coordinates.
|
|
227
|
+
* @param {number[2]} viewState.size Size ([width, height]) of the canvas to render.
|
|
228
|
+
* @param {number} [viewState.rotation = 0] Rotation of the map to render.
|
|
229
|
+
* @param {number} viewState.resolution Resolution of the map to render.
|
|
230
|
+
* @param {boolean} noInterpolate If true trajectories are not interpolated but
|
|
231
|
+
* drawn at the last known coordinate. Use this for performance optimization
|
|
232
|
+
* during map navigation.
|
|
242
233
|
* @private
|
|
243
234
|
*/
|
|
244
|
-
|
|
245
|
-
removeTrajectory(trajectoryOrId: RealtimeTrajectory | RealtimeTrainId): void;
|
|
235
|
+
renderTrajectories(viewState: undefined | ViewState, noInterpolate: boolean | undefined): void;
|
|
246
236
|
/**
|
|
247
|
-
*
|
|
237
|
+
* Launch renderTrajectories. it avoids duplicating code in renderTrajectories method.
|
|
248
238
|
*
|
|
249
|
-
* @param
|
|
239
|
+
* @param {object} viewState The view state of the map.
|
|
240
|
+
* @param {number[2]} viewState.center Center coordinate of the map in mercator coordinate.
|
|
241
|
+
* @param {number[4]} viewState.extent Extent of the map in mercator coordinates.
|
|
242
|
+
* @param {number[2]} viewState.size Size ([width, height]) of the canvas to render.
|
|
243
|
+
* @param {number} [viewState.rotation = 0] Rotation of the map to render.
|
|
244
|
+
* @param {number} viewState.resolution Resolution of the map to render.
|
|
245
|
+
* @param {boolean} noInterpolate If true trajectories are not interpolated but
|
|
246
|
+
* drawn at the last known coordinate. Use this for performance optimization
|
|
247
|
+
* during map navigation.
|
|
250
248
|
* @private
|
|
251
249
|
*/
|
|
252
|
-
|
|
253
|
-
|
|
250
|
+
renderTrajectoriesInternal(viewState: ViewState, noInterpolate?: boolean): boolean;
|
|
251
|
+
selectVehicle(id: RealtimeTrainId): void;
|
|
252
|
+
setBbox(extent: [number, number, number, number], zoom: number): void;
|
|
253
|
+
start(): void;
|
|
254
254
|
/**
|
|
255
|
-
*
|
|
256
|
-
* It adds a trajectory to the list.
|
|
257
|
-
*
|
|
255
|
+
* Start the clock.
|
|
258
256
|
* @private
|
|
259
257
|
*/
|
|
260
|
-
|
|
258
|
+
startUpdateTime(): void;
|
|
259
|
+
stop(): void;
|
|
261
260
|
/**
|
|
262
|
-
*
|
|
263
|
-
* It removes the trajectory from the list.
|
|
264
|
-
*
|
|
261
|
+
* Stop the clock.
|
|
265
262
|
* @private
|
|
266
|
-
* @override
|
|
267
263
|
*/
|
|
268
|
-
|
|
269
|
-
highlightVehicle(id: RealtimeTrainId): void;
|
|
270
|
-
selectVehicle(id: RealtimeTrainId): void;
|
|
264
|
+
stopUpdateTime(): void;
|
|
271
265
|
};
|
|
272
266
|
} & T;
|
|
273
267
|
export default RealtimeLayerMixin;
|