mobility-toolbox-js 3.0.0-beta.2 → 3.0.0-beta.21
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 +20 -0
- package/api/HttpAPI.js +0 -11
- package/api/RealtimeAPI.d.ts +404 -0
- package/api/RealtimeAPI.js +342 -276
- package/api/RoutingAPI.d.ts +47 -0
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +44 -0
- package/api/StopsAPI.js +16 -10
- package/api/WebSocketAPI.d.ts +147 -0
- package/api/WebSocketAPI.js +164 -164
- package/api/index.d.ts +3 -0
- package/api/index.js +1 -1
- package/api/typedefs.d.ts +76 -0
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +53 -0
- package/common/controls/StopFinderControlCommon.js +31 -31
- package/common/index.d.ts +2 -0
- package/common/index.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +267 -0
- package/common/mixins/RealtimeLayerMixin.js +401 -393
- package/common/styles/index.d.ts +4 -0
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.js +6 -6
- package/common/styles/realtimeDelayStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.js +5 -5
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/typedefs.d.ts +219 -0
- package/common/typedefs.js +7 -1
- package/common/utils/compareDepartures.d.ts +10 -0
- package/common/utils/compareDepartures.js +2 -2
- package/common/utils/constants.d.ts +5 -0
- package/common/utils/createCanvas.d.ts +10 -0
- package/common/utils/createDefaultCopyrightElt.d.ts +5 -0
- package/common/utils/createDefaultStopFinderElt.d.ts +5 -0
- package/common/utils/createRealtimeFilters.d.ts +12 -0
- package/common/utils/debounceDeparturesMessages.d.ts +12 -0
- package/common/utils/debounceWebsocketMessages.d.ts +11 -0
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.js +5 -1
- package/common/utils/getMapGlCopyrights.d.ts +17 -0
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getUrlWithParams.d.ts +8 -0
- package/common/utils/getVehiclePosition.d.ts +17 -0
- package/common/utils/getVehiclePosition.js +9 -3
- package/common/utils/index.d.ts +16 -0
- package/common/utils/realtimeConfig.d.ts +64 -0
- package/common/utils/removeDuplicate.d.ts +9 -0
- package/common/utils/renderTrajectories.d.ts +16 -0
- package/common/utils/renderTrajectories.js +6 -6
- package/common/utils/sortAndFilterDepartures.d.ts +15 -0
- package/common/utils/sortAndFilterDepartures.js +1 -1
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.js +5 -1
- package/common/utils/timeUtils.d.ts +23 -0
- package/common/utils/toMercatorExtent.d.ts +5 -0
- package/iife.d.ts +2 -0
- package/index.d.ts +9 -0
- package/maplibre/controls/CopyrightControl.d.ts +35 -0
- package/maplibre/controls/index.d.ts +1 -0
- package/maplibre/index.d.ts +5 -0
- package/maplibre/layers/Layer.d.ts +28 -0
- package/maplibre/layers/Layer.js +1 -1
- package/maplibre/layers/RealtimeLayer.d.ts +181 -0
- package/maplibre/layers/RealtimeLayer.js +29 -5
- package/maplibre/layers/index.d.ts +2 -0
- package/maplibre/utils/getMercatorResolution.d.ts +7 -0
- package/maplibre/utils/getSourceCoordinates.d.ts +7 -0
- package/maplibre/utils/getSourceCoordinates.js +5 -5
- package/maplibre/utils/index.d.ts +2 -0
- package/mbt.js +22103 -14430
- package/mbt.js.map +4 -4
- package/mbt.min.js +61 -58
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.js +18 -8
- package/ol/controls/RoutingControl.d.ts +202 -0
- package/ol/controls/RoutingControl.js +220 -219
- package/ol/controls/StopFinderControl.d.ts +37 -0
- package/ol/controls/StopFinderControl.js +4 -1
- package/ol/controls/index.d.ts +3 -0
- package/ol/index.d.ts +7 -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 +160 -0
- package/ol/layers/MaplibreLayer.js +97 -27
- package/ol/layers/MaplibreStyleLayer.d.ts +237 -0
- package/ol/layers/MaplibreStyleLayer.js +291 -267
- package/ol/layers/RealtimeLayer.d.ts +283 -0
- package/ol/layers/RealtimeLayer.js +143 -128
- package/ol/layers/VectorLayer.d.ts +18 -0
- package/ol/layers/VectorLayer.js +31 -0
- package/ol/layers/index.d.ts +5 -0
- package/ol/layers/index.js +3 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +96 -0
- package/ol/mixins/MobilityLayerMixin.js +1 -4
- package/ol/mixins/PropertiesLayerMixin.d.ts +135 -0
- package/ol/mixins/PropertiesLayerMixin.js +112 -140
- package/ol/mixins/index.d.ts +1 -0
- package/ol/mixins/index.js +2 -0
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -0
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
- package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
- package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
- package/ol/renderers/RealtimeLayerRenderer.js +58 -53
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +6 -0
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/routingStyle.d.ts +4 -0
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +8 -0
- package/ol/utils/getFeatureInfoAtCoordinate.js +12 -18
- package/ol/utils/index.d.ts +1 -0
- package/package.json +31 -31
- package/setupTests.d.ts +1 -0
- 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.js +0 -142
|
@@ -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
|
|
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.js
CHANGED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import { Coordinate } from 'ol/coordinate';
|
|
2
|
+
import { EventsKey } from 'ol/events';
|
|
3
|
+
import GeoJSON from 'ol/format/GeoJSON';
|
|
4
|
+
import { Options } from 'ol/layer/Layer';
|
|
5
|
+
import { RealtimeAPI } from '../../api';
|
|
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';
|
|
8
|
+
import { FilterFunction, SortFunction } from '../typedefs';
|
|
9
|
+
export type RealtimeLayerMixinOptions = {
|
|
10
|
+
api?: RealtimeAPI;
|
|
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;
|
|
23
|
+
isUpdateBboxOnMoveEnd?: boolean;
|
|
24
|
+
live?: boolean;
|
|
25
|
+
minZoomInterpolation?: number;
|
|
26
|
+
mode?: RealtimeMode;
|
|
27
|
+
motsByZoom?: RealtimeMot[][];
|
|
28
|
+
onStart?: (realtimeLayer: AnyRealtimeLayer) => void;
|
|
29
|
+
onStop?: (realtimeLayer: AnyRealtimeLayer) => void;
|
|
30
|
+
pingIntervalMs?: number;
|
|
31
|
+
pixelRatio?: number;
|
|
32
|
+
prefix?: string;
|
|
33
|
+
renderTimeIntervalByZoom?: number[];
|
|
34
|
+
selectedVehicleId?: RealtimeTrainId;
|
|
35
|
+
sort?: SortFunction;
|
|
36
|
+
speed?: number;
|
|
37
|
+
style?: RealtimeStyleFunction;
|
|
38
|
+
styleOptions?: RealtimeStyleOptions;
|
|
39
|
+
tenant?: RealtimeTenant;
|
|
40
|
+
time?: number;
|
|
41
|
+
url?: string;
|
|
42
|
+
useDebounce?: boolean;
|
|
43
|
+
useRequestAnimationFrame?: boolean;
|
|
44
|
+
useThrottle?: boolean;
|
|
45
|
+
} & Options;
|
|
46
|
+
/**
|
|
47
|
+
* RealtimeLayerInterface.
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
export declare class RealtimeLayerInterface {
|
|
51
|
+
/**
|
|
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.
|
|
57
|
+
*/
|
|
58
|
+
getTrajectoryInfos(id: string, mode: RealtimeMode): void;
|
|
59
|
+
/**
|
|
60
|
+
* Render the trajectories
|
|
61
|
+
*/
|
|
62
|
+
renderTrajectories(): void;
|
|
63
|
+
/**
|
|
64
|
+
* Set the Realtime api's bbox.
|
|
65
|
+
*
|
|
66
|
+
* @param {Array<number>} extent Extent to request, [minX, minY, maxX, maxY].
|
|
67
|
+
* @param {number} zoom Zoom level to request. Must be an integer.
|
|
68
|
+
*/
|
|
69
|
+
setBbox(extent: [number, number, number, number], zoom: number): void;
|
|
70
|
+
/**
|
|
71
|
+
* Start the clock.
|
|
72
|
+
*/
|
|
73
|
+
start(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Stop the clock.
|
|
76
|
+
*/
|
|
77
|
+
stop(): void;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Mixin for RealtimeLayerInterface.
|
|
81
|
+
*
|
|
82
|
+
* @param {Class} Base A class to extend with {RealtimeLayerInterface} functionnalities.
|
|
83
|
+
* @return {Class} A class that implements {RealtimeLayerInterface} class and extends Base;
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
declare function RealtimeLayerMixin<T extends AnyLayerable>(Base: T): {
|
|
87
|
+
new (options: RealtimeLayerMixinOptions): {
|
|
88
|
+
[x: string]: any;
|
|
89
|
+
[x: symbol]: any;
|
|
90
|
+
api: RealtimeAPI;
|
|
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;
|
|
96
|
+
format: GeoJSON;
|
|
97
|
+
generalizationLevel?: RealtimeGeneralizationLevel;
|
|
98
|
+
generalizationLevelByZoom: RealtimeGeneralizationLevel[];
|
|
99
|
+
getGeneralizationLevelByZoom: (zoom: number) => RealtimeGeneralizationLevel;
|
|
100
|
+
getMotsByZoom: (zoom: number) => RealtimeMot[];
|
|
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;
|
|
122
|
+
throttleRenderTrajectories: (viewState: ViewState, noInterpolate?: boolean) => void;
|
|
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;
|
|
131
|
+
/**
|
|
132
|
+
* Add a trajectory.
|
|
133
|
+
* @param {RealtimeTrajectory} trajectory The trajectory to add.
|
|
134
|
+
* @private
|
|
135
|
+
*/
|
|
136
|
+
addTrajectory(trajectory: RealtimeTrajectory): void;
|
|
137
|
+
attachToMap(map: AnyMap): void;
|
|
138
|
+
/**
|
|
139
|
+
* Define layer's properties.
|
|
140
|
+
*
|
|
141
|
+
* @private
|
|
142
|
+
*/
|
|
143
|
+
defineProperties(options: RealtimeLayerMixinOptions): void;
|
|
144
|
+
detachFromMap(): void;
|
|
145
|
+
/**
|
|
146
|
+
* Request feature information for a given coordinate.
|
|
147
|
+
*
|
|
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.
|
|
153
|
+
*/
|
|
154
|
+
getFeatureInfoAtCoordinate(coordinate: Coordinate, options: LayerGetFeatureInfoOptions): Promise<LayerGetFeatureInfoResponse>;
|
|
155
|
+
/**
|
|
156
|
+
* Get the duration before the next update depending on zoom level.
|
|
157
|
+
*
|
|
158
|
+
* @private
|
|
159
|
+
* @param {number} zoom
|
|
160
|
+
*/
|
|
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
|
+
}>;
|
|
172
|
+
/**
|
|
173
|
+
* Get vehicle.
|
|
174
|
+
* @param {function} filterFc A function use to filter results.
|
|
175
|
+
* @return {Array<Object>} Array of vehicle.
|
|
176
|
+
*/
|
|
177
|
+
getVehicle(filterFc: FilterFunction): RealtimeTrajectory[];
|
|
178
|
+
highlightVehicle(id: RealtimeTrainId): void;
|
|
179
|
+
/**
|
|
180
|
+
* Callback on websocket's deleted_vehicles channel events.
|
|
181
|
+
* It removes the trajectory from the list.
|
|
182
|
+
*
|
|
183
|
+
* @private
|
|
184
|
+
* @override
|
|
185
|
+
*/
|
|
186
|
+
onDeleteTrajectoryMessage(data: WebSocketAPIMessageEventData<RealtimeTrainId>): void;
|
|
187
|
+
onDocumentVisibilityChange(): void;
|
|
188
|
+
/**
|
|
189
|
+
* Callback on websocket's trajectory channel events.
|
|
190
|
+
* It adds a trajectory to the list.
|
|
191
|
+
*
|
|
192
|
+
* @private
|
|
193
|
+
*/
|
|
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;
|
|
202
|
+
/**
|
|
203
|
+
* Remove all trajectories that are in the past.
|
|
204
|
+
*/
|
|
205
|
+
purgeOutOfDateTrajectories(): void;
|
|
206
|
+
/**
|
|
207
|
+
* Determine if the trajectory is useless and should be removed from the list or not.
|
|
208
|
+
* By default, this function exclude vehicles:
|
|
209
|
+
* - that have their trajectory outside the current extent and
|
|
210
|
+
* - that aren't in the MOT list.
|
|
211
|
+
*
|
|
212
|
+
* @param {RealtimeTrajectory} trajectory
|
|
213
|
+
* @param {Array<number>} extent
|
|
214
|
+
* @param {number} zoom
|
|
215
|
+
* @return {boolean} if the trajectory must be displayed or not.
|
|
216
|
+
* @private
|
|
217
|
+
*/
|
|
218
|
+
purgeTrajectory(trajectory: RealtimeTrajectory, extent: [number, number, number, number], zoom: number): boolean;
|
|
219
|
+
removeTrajectory(trajectoryOrId: RealtimeTrainId | RealtimeTrajectory): void;
|
|
220
|
+
/**
|
|
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.
|
|
233
|
+
* @private
|
|
234
|
+
*/
|
|
235
|
+
renderTrajectories(viewState: undefined | ViewState, noInterpolate: boolean | undefined): void;
|
|
236
|
+
/**
|
|
237
|
+
* Launch renderTrajectories. it avoids duplicating code in renderTrajectories method.
|
|
238
|
+
*
|
|
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.
|
|
248
|
+
* @private
|
|
249
|
+
*/
|
|
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
|
+
/**
|
|
255
|
+
* Start the clock.
|
|
256
|
+
* @private
|
|
257
|
+
*/
|
|
258
|
+
startUpdateTime(): void;
|
|
259
|
+
stop(): void;
|
|
260
|
+
/**
|
|
261
|
+
* Stop the clock.
|
|
262
|
+
* @private
|
|
263
|
+
*/
|
|
264
|
+
stopUpdateTime(): void;
|
|
265
|
+
};
|
|
266
|
+
} & T;
|
|
267
|
+
export default RealtimeLayerMixin;
|