mobility-toolbox-js 3.0.0-beta.7 → 3.0.0-beta.9

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.
Files changed (88) hide show
  1. package/api/HttpAPI.d.ts +31 -0
  2. package/api/RealtimeAPI.d.ts +359 -0
  3. package/api/RealtimeAPI.js +96 -89
  4. package/api/RoutingAPI.d.ts +37 -0
  5. package/api/StopsAPI.d.ts +38 -0
  6. package/api/WebSocketAPI.d.ts +153 -0
  7. package/api/index.d.ts +3 -0
  8. package/api/typedefs.d.ts +178 -0
  9. package/common/controls/StopFinderControlCommon.d.ts +53 -0
  10. package/common/index.d.ts +2 -0
  11. package/common/mixins/RealtimeLayerMixin.d.ts +273 -0
  12. package/common/styles/index.d.ts +4 -0
  13. package/common/styles/realtimeDefaultStyle.d.ts +36 -0
  14. package/common/styles/realtimeDelayStyle.d.ts +12 -0
  15. package/common/styles/realtimeHeadingStyle.d.ts +12 -0
  16. package/common/styles/realtimeSimpleStyle.d.ts +4 -0
  17. package/common/typedefs.d.ts +212 -0
  18. package/common/utils/compareDepartures.d.ts +10 -0
  19. package/common/utils/constants.d.ts +5 -0
  20. package/common/utils/createCanvas.d.ts +10 -0
  21. package/common/utils/createDefaultCopyrightElt.d.ts +5 -0
  22. package/common/utils/createDefaultStopFinderElt.d.ts +5 -0
  23. package/common/utils/createRealtimeFilters.d.ts +12 -0
  24. package/common/utils/debounceDeparturesMessages.d.ts +12 -0
  25. package/common/utils/debounceWebsocketMessages.d.ts +11 -0
  26. package/common/utils/getLayersAsFlatArray.d.ts +3 -0
  27. package/common/utils/getLayersAsFlatArray.js +5 -1
  28. package/common/utils/getMapGlCopyrights.d.ts +17 -0
  29. package/common/utils/getRealtimeModeSuffix.d.ts +9 -0
  30. package/common/utils/getUrlWithParams.d.ts +8 -0
  31. package/common/utils/getVehiclePosition.d.ts +16 -0
  32. package/common/utils/index.d.ts +16 -0
  33. package/common/utils/realtimeConfig.d.ts +64 -0
  34. package/common/utils/removeDuplicate.d.ts +9 -0
  35. package/common/utils/renderTrajectories.d.ts +16 -0
  36. package/common/utils/sortAndFilterDepartures.d.ts +15 -0
  37. package/common/utils/sortByDelay.d.ts +3 -0
  38. package/common/utils/timeUtils.d.ts +23 -0
  39. package/common/utils/toMercatorExtent.d.ts +5 -0
  40. package/iife.d.ts +2 -0
  41. package/index.d.ts +9 -0
  42. package/maplibre/controls/CopyrightControl.d.ts +35 -0
  43. package/maplibre/controls/index.d.ts +1 -0
  44. package/maplibre/index.d.ts +5 -0
  45. package/maplibre/layers/Layer.d.ts +28 -0
  46. package/maplibre/layers/RealtimeLayer.d.ts +160 -0
  47. package/maplibre/layers/RealtimeLayer.js +2 -2
  48. package/maplibre/layers/index.d.ts +2 -0
  49. package/maplibre/utils/getMercatorResolution.d.ts +7 -0
  50. package/maplibre/utils/getSourceCoordinates.d.ts +7 -0
  51. package/maplibre/utils/index.d.ts +2 -0
  52. package/mbt.js +137 -114
  53. package/mbt.js.map +3 -3
  54. package/mbt.min.js +13 -13
  55. package/mbt.min.js.map +3 -3
  56. package/ol/controls/CopyrightControl.d.ts +31 -0
  57. package/ol/controls/CopyrightControl.js +18 -8
  58. package/ol/controls/RoutingControl.d.ts +209 -0
  59. package/ol/controls/RoutingControl.js +3 -0
  60. package/ol/controls/StopFinderControl.d.ts +37 -0
  61. package/ol/controls/StopFinderControl.js +3 -0
  62. package/ol/controls/index.d.ts +3 -0
  63. package/ol/index.d.ts +6 -0
  64. package/ol/layers/MapGlLayer.d.ts +144 -0
  65. package/ol/layers/MapGlLayer.js +3 -1
  66. package/ol/layers/MaplibreLayer.d.ts +63 -0
  67. package/ol/layers/MaplibreStyleLayer.d.ts +235 -0
  68. package/ol/layers/MaplibreStyleLayer.js +1 -1
  69. package/ol/layers/RealtimeLayer.d.ts +285 -0
  70. package/ol/layers/RealtimeLayer.js +13 -7
  71. package/ol/layers/index.d.ts +3 -0
  72. package/ol/mixins/MobilityLayerMixin.d.ts +98 -0
  73. package/ol/mixins/MobilityLayerMixin.js +1 -4
  74. package/ol/mixins/PropertiesLayerMixin.d.ts +127 -0
  75. package/ol/mixins/PropertiesLayerMixin.js +5 -4
  76. package/ol/renderers/MaplibreLayerRenderer.d.ts +20 -0
  77. package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +20 -0
  78. package/ol/renderers/RealtimeLayerRenderer.d.ts +22 -0
  79. package/ol/renderers/RealtimeLayerRenderer.js +9 -9
  80. package/ol/styles/fullTrajectoryDelayStyle.d.ts +6 -0
  81. package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
  82. package/ol/styles/index.d.ts +3 -0
  83. package/ol/styles/routingStyle.d.ts +4 -0
  84. package/ol/utils/getFeatureInfoAtCoordinate.d.ts +8 -0
  85. package/ol/utils/getFeatureInfoAtCoordinate.js +1 -1
  86. package/ol/utils/index.d.ts +1 -0
  87. package/package.json +1 -1
  88. package/setupTests.d.ts +1 -0
@@ -0,0 +1,273 @@
1
+ import GeoJSON from 'ol/format/GeoJSON';
2
+ import { EventsKey } from 'ol/events';
3
+ import { Coordinate } from 'ol/coordinate';
4
+ import { Options } from 'ol/layer/Layer';
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
+ import { WebSocketAPIMessageEventData } from '../../api/WebSocketAPI';
9
+ import { FilterFunction, SortFunction } from '../typedefs';
10
+ export type RealtimeLayerMixinOptions = Options & {
11
+ debug?: boolean;
12
+ mode?: RealtimeMode;
13
+ api?: RealtimeAPI;
14
+ tenant?: RealtimeTenant;
15
+ minZoomInterpolation?: number;
16
+ isUpdateBboxOnMoveEnd?: boolean;
17
+ motsByZoom?: RealtimeMot[][];
18
+ generalizationLevelByZoom?: RealtimeGeneralizationLevel[];
19
+ renderTimeIntervalByZoom?: number[];
20
+ style?: RealtimeStyleFunction;
21
+ speed?: number;
22
+ pixelRatio?: number;
23
+ hoverVehicleId?: RealtimeTrainId;
24
+ selectedVehicleId?: RealtimeTrainId;
25
+ filter?: FilterFunction;
26
+ sort?: SortFunction;
27
+ time?: number;
28
+ live?: boolean;
29
+ canvas?: HTMLCanvasElement;
30
+ styleOptions?: RealtimeStyleOptions;
31
+ useRequestAnimationFrame?: boolean;
32
+ useDebounce?: boolean;
33
+ useThrottle?: boolean;
34
+ getMotsByZoom?: (zoom: number, motsByZoom: RealtimeMot[][]) => RealtimeMot[];
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
+ };
49
+ /**
50
+ * RealtimeLayerInterface.
51
+ * @private
52
+ */
53
+ export declare class RealtimeLayerInterface {
54
+ /**
55
+ * Start the clock.
56
+ */
57
+ start(): void;
58
+ /**
59
+ * Stop the clock.
60
+ */
61
+ stop(): void;
62
+ /**
63
+ * Set the Realtime api's bbox.
64
+ *
65
+ * @param {Array<number>} extent Extent to request, [minX, minY, maxX, maxY].
66
+ * @param {number} zoom Zoom level to request. Must be an integer.
67
+ */
68
+ setBbox(extent: [number, number, number, number], zoom: number): void;
69
+ /**
70
+ * Render the trajectories
71
+ */
72
+ renderTrajectories(): void;
73
+ /**
74
+ * Request the stopSequence and the fullTrajectory informations for a vehicle.
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.
79
+ */
80
+ getTrajectoryInfos(id: string, mode: RealtimeMode): void;
81
+ }
82
+ /**
83
+ * Mixin for RealtimeLayerInterface.
84
+ *
85
+ * @param {Class} Base A class to extend with {RealtimeLayerInterface} functionnalities.
86
+ * @return {Class} A class that implements {RealtimeLayerInterface} class and extends Base;
87
+ * @private
88
+ */
89
+ declare function RealtimeLayerMixin<T extends AnyLayerClass>(Base: T): {
90
+ new (options: RealtimeLayerMixinOptions): {
91
+ [x: string]: any;
92
+ debug: boolean;
93
+ trajectories?: {
94
+ [key: string]: GeoJSONFeature;
95
+ } | undefined;
96
+ canvas?: AnyCanvas | undefined;
97
+ mode: RealtimeMode;
98
+ api: RealtimeAPI;
99
+ tenant: RealtimeTenant;
100
+ bboxParameters?: {
101
+ [index: string]: string | number | boolean | string[] | number[] | boolean[];
102
+ } | undefined;
103
+ time?: Date | undefined;
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[];
124
+ format: GeoJSON;
125
+ requestId?: number | undefined;
126
+ updateTimeInterval?: number | undefined;
127
+ updateTimeDelay?: number | undefined;
128
+ visibilityRef: EventsKey;
129
+ selectedVehicle: GeoJSONFeature;
130
+ getMotsByZoom: (zoom: number) => RealtimeMot[];
131
+ getGeneralizationLevelByZoom: (zoom: number) => RealtimeGeneralizationLevel;
132
+ getRenderTimeIntervalByZoom: (zoom: number) => number;
133
+ throttleRenderTrajectories: (viewState: ViewState, noInterpolate?: boolean) => void;
134
+ debounceRenderTrajectories: (viewState: ViewState, noInterpolate?: boolean) => void;
135
+ onStart?: ((realtimeLayer: AnyLayer) => void) | undefined;
136
+ onStop?: ((realtimeLayer: AnyLayer) => void) | undefined;
137
+ /**
138
+ * Define layer's properties.
139
+ *
140
+ * @private
141
+ */
142
+ defineProperties(options: RealtimeLayerMixinOptions): void;
143
+ 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
+ /**
153
+ * Stop the clock.
154
+ * @private
155
+ */
156
+ stopUpdateTime(): void;
157
+ /**
158
+ * Launch renderTrajectories. it avoids duplicating code in renderTrajectories method.
159
+ *
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
+ * @private
170
+ */
171
+ renderTrajectoriesInternal(viewState: ViewState, noInterpolate?: boolean): boolean;
172
+ /**
173
+ * Render the trajectories requesting an animation frame and cancelling the previous one.
174
+ * This function must be overrided by children to provide the correct parameters.
175
+ *
176
+ * @param {object} viewState The view state of the map.
177
+ * @param {number[2]} viewState.center Center coordinate of the map in mercator coordinate.
178
+ * @param {number[4]} viewState.extent Extent of the map in mercator coordinates.
179
+ * @param {number[2]} viewState.size Size ([width, height]) of the canvas to render.
180
+ * @param {number} [viewState.rotation = 0] Rotation of the map to render.
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
186
+ */
187
+ renderTrajectories(viewState: ViewState | undefined, noInterpolate: boolean | undefined): void;
188
+ setBbox(extent: [number, number, number, number], zoom: number): void;
189
+ /**
190
+ * Get the duration before the next update depending on zoom level.
191
+ *
192
+ * @private
193
+ * @param {number} zoom
194
+ */
195
+ getRefreshTimeInMs(zoom?: number | undefined): number;
196
+ /**
197
+ * Get vehicle.
198
+ * @param {function} filterFc A function use to filter results.
199
+ * @return {Array<Object>} Array of vehicle.
200
+ */
201
+ getVehicle(filterFc: FilterFunction): GeoJSONFeature[];
202
+ /**
203
+ * Request feature information for a given coordinate.
204
+ *
205
+ * @param {ol/coordinate~Coordinate} coordinate Coordinate.
206
+ * @param {Object} options Options See child classes to see which options are supported.
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.
210
+ */
211
+ getFeatureInfoAtCoordinate(coordinate: Coordinate, options: LayerGetFeatureInfoOptions): Promise<LayerGetFeatureInfoResponse>;
212
+ /**
213
+ * Request the stopSequence and the fullTrajectory informations for a vehicle.
214
+ *
215
+ * @param {string} id The vehicle identifier (the train_id property).
216
+ * @return {Promise<{stopSequence: StopSequence, fullTrajectory: FullTrajectory>} A promise that will be resolved with the trajectory informations.
217
+ */
218
+ getTrajectoryInfos(id: RealtimeTrainId): Promise<{
219
+ stopSequence: WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory> | WebSocketAPIMessageEventData<GeoJSONFeature[]>;
220
+ fullTrajectory: WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory> | WebSocketAPIMessageEventData<GeoJSONFeature[]>;
221
+ }>;
222
+ /**
223
+ * Remove all trajectories that are in the past.
224
+ */
225
+ purgeOutOfDateTrajectories(): void;
226
+ /**
227
+ * Determine if the trajectory is useless and should be removed from the list or not.
228
+ * By default, this function exclude vehicles:
229
+ * - that have their trajectory outside the current extent and
230
+ * - that aren't in the MOT list.
231
+ *
232
+ * @param {RealtimeTrajectory} trajectory
233
+ * @param {Array<number>} extent
234
+ * @param {number} zoom
235
+ * @return {boolean} if the trajectory must be displayed or not.
236
+ * @private
237
+ */
238
+ purgeTrajectory(trajectory: GeoJSONFeature, extent: [number, number, number, number], zoom: number): boolean;
239
+ /**
240
+ * Add a trajectory.
241
+ * @param {RealtimeTrajectory} trajectory The trajectory to add.
242
+ * @private
243
+ */
244
+ addTrajectory(trajectory: GeoJSONFeature): void;
245
+ removeTrajectory(trajectoryOrId: RealtimeTrajectory | RealtimeTrainId): void;
246
+ /**
247
+ * On zoomend we adjust the time interval of the update of vehicles positions.
248
+ *
249
+ * @param evt Event that triggered the function.
250
+ * @private
251
+ */
252
+ onZoomEnd(): void;
253
+ onDocumentVisibilityChange(): void;
254
+ /**
255
+ * Callback on websocket's trajectory channel events.
256
+ * It adds a trajectory to the list.
257
+ *
258
+ * @private
259
+ */
260
+ onTrajectoryMessage(data: WebSocketAPIMessageEventData<RealtimeTrajectory>): void;
261
+ /**
262
+ * Callback on websocket's deleted_vehicles channel events.
263
+ * It removes the trajectory from the list.
264
+ *
265
+ * @private
266
+ * @override
267
+ */
268
+ onDeleteTrajectoryMessage(data: WebSocketAPIMessageEventData<RealtimeTrainId>): void;
269
+ highlightVehicle(id: RealtimeTrainId): void;
270
+ selectVehicle(id: RealtimeTrainId): void;
271
+ };
272
+ } & T;
273
+ export default RealtimeLayerMixin;
@@ -0,0 +1,4 @@
1
+ export { default as realtimeDefaultStyle } from "./realtimeDefaultStyle";
2
+ export { default as realtimeDelayStyle } from "./realtimeDelayStyle";
3
+ export { default as realtimeSimpleStyle } from "./realtimeSimpleStyle";
4
+ export * from "./realtimeDefaultStyle";
@@ -0,0 +1,36 @@
1
+ import type { RealtimeStyleFunction } from '../../types';
2
+ /**
3
+ * Draw circle delay background
4
+ *
5
+ * @private
6
+ */
7
+ export declare const getDelayBgCanvas: (origin: number, radius: number, color: string) => import("../../types").AnyCanvas | null;
8
+ /**
9
+ * Draw delay text
10
+ *
11
+ * @private
12
+ */
13
+ export declare const getDelayTextCanvas: (text: string, fontSize: number, font: string, delayColor: string, delayOutlineColor?: string, pixelRatio?: number) => import("../../types").AnyCanvas | null;
14
+ /**
15
+ * Draw colored circle with black border
16
+ *
17
+ * @private
18
+ */
19
+ export declare const getCircleCanvas: (origin: number, radius: number, color: string, hasStroke: boolean, hasDash: boolean, pixelRatio: number) => import("../../types").AnyCanvas | null;
20
+ /**
21
+ * Draw text in the circle
22
+ *
23
+ * @private
24
+ */
25
+ export declare const getTextCanvas: (text: string, origin: number, textSize: number, fillColor: string, strokeColor: string, hasStroke: boolean, pixelRatio: number, getTextFont: (fontSize: number, text?: string) => string) => import("../../types").AnyCanvas | null;
26
+ /**
27
+ * A tracker style that take in account the delay.
28
+ *
29
+ * @param {RealtimeTrajectory} trajectory The trajectory to render.
30
+ * @param {ViewState} viewState The view state of the map.
31
+ * @param {RealtimeStyleOptions} options Some options to change the rendering
32
+ * @return a canvas
33
+ * @private
34
+ */
35
+ declare const realtimeDefaultStyle: RealtimeStyleFunction;
36
+ export default realtimeDefaultStyle;
@@ -0,0 +1,12 @@
1
+ import type { RealtimeStyleFunction } from '../../types';
2
+ /**
3
+ * A tracker style that display the delay as backgroundColor.
4
+ *
5
+ * @param {*} trajectory The trajectory to render.
6
+ * @param {*} viewState The view state of the map.
7
+ * @param {*} options Some options to change the rendering
8
+ * @return a canvas
9
+ * @private
10
+ */
11
+ declare const realtimeDelayStyle: RealtimeStyleFunction;
12
+ export default realtimeDelayStyle;
@@ -0,0 +1,12 @@
1
+ import type { RealtimeStyleFunction } from '../../types';
2
+ /**
3
+ * A tracker style that take in account the delay.
4
+ *
5
+ * @param {RealtimeTrajectory} trajectory The trajectory to render.
6
+ * @param {ViewState} viewState The view state of the map.
7
+ * @param {RealtimeStyleOptions} options Some options to change the rendering
8
+ * @return a canvas
9
+ * @private
10
+ */
11
+ declare const realtimeHeadingStyle: RealtimeStyleFunction;
12
+ export default realtimeHeadingStyle;
@@ -0,0 +1,4 @@
1
+ import type { RealtimeStyleFunction } from '../../types';
2
+ /** @private */
3
+ declare const realtimeSimpleStyle: RealtimeStyleFunction;
4
+ export default realtimeSimpleStyle;
@@ -0,0 +1,212 @@
1
+ export default dummy;
2
+ export type FilterFunction = Function;
3
+ export type SortFunction = Function;
4
+ export type ViewState = {
5
+ /**
6
+ * A time in ms.
7
+ */
8
+ time: number | undefined;
9
+ /**
10
+ * A center in mercator coordinate.
11
+ */
12
+ center: number[2] | undefined;
13
+ /**
14
+ * An Extent in mercator coordinates.
15
+ */
16
+ extent: any;
17
+ /**
18
+ * A size ([width, height]).
19
+ */
20
+ size: any;
21
+ /**
22
+ * A rotation in radians.
23
+ */
24
+ rotation: number;
25
+ /**
26
+ * A resolution.
27
+ */
28
+ resolution: number;
29
+ /**
30
+ * A zoom level.
31
+ */
32
+ zoom: number;
33
+ /**
34
+ * A pixel ratio.
35
+ */
36
+ pixelRatio: number | undefined;
37
+ };
38
+ export type FeatureInfo = {
39
+ /**
40
+ * A layer.
41
+ */
42
+ layer: Layer;
43
+ /**
44
+ * An array of features.
45
+ */
46
+ features: Feature[];
47
+ /**
48
+ * The coordinate where to find the featue.
49
+ */
50
+ coordinate: any;
51
+ };
52
+ export type MaplibreLayerOptions = {
53
+ /**
54
+ * Access key for [geOps apis](https://developer.geops.io/).
55
+ */
56
+ apiKey: string;
57
+ /**
58
+ * geOps Maps api key name.
59
+ */
60
+ apiKeyName: string;
61
+ /**
62
+ * Maplibre map options.
63
+ */
64
+ mapOptions: maplibregl.MapOptions;
65
+ /**
66
+ * geOps Maps api style.
67
+ */
68
+ style: string;
69
+ /**
70
+ * geOps Maps api url.
71
+ */
72
+ url: string;
73
+ };
74
+ export type ControlCommonOptions = {
75
+ /**
76
+ * Whether the control is active or not.
77
+ */
78
+ active?: boolean | undefined;
79
+ /**
80
+ * The HTML element used to render the control.
81
+ */
82
+ element: HTMLElement;
83
+ /**
84
+ * The HTML element where to render the element property. Default is the map's element.
85
+ */
86
+ target: HTMLElement;
87
+ /**
88
+ * Render function called whenever the control needs to be rerendered.
89
+ */
90
+ render: Function;
91
+ };
92
+ export type LayerCommonOptions = {
93
+ /**
94
+ * Identifier of the layer. Must be unique.
95
+ */
96
+ key: string;
97
+ /**
98
+ * Name of the layer.
99
+ */
100
+ name: string;
101
+ /**
102
+ * Group of the layer.
103
+ */
104
+ group: string;
105
+ /**
106
+ * List of copyrights.
107
+ */
108
+ copyrights: string[];
109
+ /**
110
+ * List of children layers.
111
+ */
112
+ children: Layer[];
113
+ /**
114
+ * Define if the layer is currently display on the map.
115
+ */
116
+ visible: boolean;
117
+ /**
118
+ * Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
119
+ */
120
+ disabled: boolean;
121
+ /**
122
+ * Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
123
+ */
124
+ hittolerance: number;
125
+ /**
126
+ * - Custom properties.
127
+ */
128
+ properties: Object;
129
+ /**
130
+ * - The map used to display the layer.
131
+ */
132
+ map: AnyMap;
133
+ };
134
+ export type VehiclePosition = {
135
+ /**
136
+ * Coordinate of the vehicle position in Mercator .
137
+ */
138
+ coord: any;
139
+ /**
140
+ * An angle in radians representing the direction (from the true north) towards which the vehicle is facing.
141
+ */
142
+ rotation: number;
143
+ };
144
+ /**
145
+ * /Map~Map|maplibregl.Map} AnyMap
146
+ */
147
+ type dummy = ol;
148
+ /**
149
+ * @typedef {function} FilterFunction
150
+ * @param {Vehicle} vehicle Vehicle to filter.
151
+ * @returns boolean
152
+ */
153
+ /**
154
+ * @typedef {function} SortFunction
155
+ * @param {any} a Object a to compare.
156
+ * @param {any} b Object b to compare.
157
+ * @returns number
158
+ */
159
+ /**
160
+ * @typedef {Object} ViewState
161
+ * @property {number|undefined} time A time in ms.
162
+ * @property {number[2]|undefined} center A center in mercator coordinate.
163
+ * @property {number[4]} extent An Extent in mercator coordinates.
164
+ * @property {number[2]} size A size ([width, height]).
165
+ * @property {number} rotation A rotation in radians.
166
+ * @property {number} resolution A resolution.
167
+ * @property {number} zoom A zoom level.
168
+ * @property {number|undefined} pixelRatio A pixel ratio.
169
+ */
170
+ /**
171
+ * @typedef {Object} FeatureInfo
172
+ * @property {Layer} layer A layer.
173
+ * @property {Feature[]} features An array of features.
174
+ * @property {number[2]} coordinate The coordinate where to find the featue.
175
+ */
176
+ /**
177
+ * @typedef {ol/Map~Map|maplibregl.Map} AnyMap
178
+ */
179
+ /**
180
+ * @typedef {Object} MaplibreLayerOptions
181
+ * @property {string} apiKey Access key for [geOps apis](https://developer.geops.io/).
182
+ * @property {string} apiKeyName geOps Maps api key name.
183
+ * @property {maplibregl.MapOptions} options.mapOptions Maplibre map options.
184
+ * @property {string} style geOps Maps api style.
185
+ * @property {string} url geOps Maps api url.
186
+ */
187
+ /**
188
+ * @typedef {Object} ControlCommonOptions
189
+ * @property {boolean} [active = true] Whether the control is active or not.
190
+ * @property {HTMLElement} element The HTML element used to render the control.
191
+ * @property {HTMLElement} target The HTML element where to render the element property. Default is the map's element.
192
+ * @property {function} render Render function called whenever the control needs to be rerendered.
193
+ */
194
+ /**
195
+ * @typedef {Object} LayerCommonOptions
196
+ * @property {string!} key Identifier of the layer. Must be unique.
197
+ * @property {string!} name Name of the layer.
198
+ * @property {string!} group Group of the layer.
199
+ * @property {string[]!} copyrights List of copyrights.
200
+ * @property {Layer[]!} children List of children layers.
201
+ * @property {boolean!} visible Define if the layer is currently display on the map.
202
+ * @property {boolean!} disabled Define if the layer is currently display on the map but can't be seen (extent, zoom ,data restrictions).
203
+ * @property {number!} hittolerance Hit-detection tolerance in css pixels. Pixels inside the radius around the given position will be checked for features.
204
+ * @property {Object!} properties - Custom properties.
205
+ * @property {AnyMap!} map - The map used to display the layer.
206
+ */
207
+ /**
208
+ * @typedef {Object} VehiclePosition
209
+ * @property {number[2]} coord Coordinate of the vehicle position in Mercator .
210
+ * @property {number!} rotation An angle in radians representing the direction (from the true north) towards which the vehicle is facing.
211
+ */
212
+ declare function dummy(): void;
@@ -0,0 +1,10 @@
1
+ import { RealtimeDeparture } from '../../types';
2
+ /**
3
+ * Compare two given departures for sort alogithm,
4
+ * @param {Departure} a First departure.
5
+ * @param {Departure} b Second departure.
6
+ * @param {boolean} [sortByMinArrivalTime=false] Sort departures by arrival time.
7
+ * @private
8
+ */
9
+ declare const compareDepartures: (a: RealtimeDeparture, b: RealtimeDeparture, sortByMinArrivalTime?: boolean) => number;
10
+ export default compareDepartures;
@@ -0,0 +1,5 @@
1
+ export declare const VECTOR_TILE_FEATURE_PROPERTY = "vectorTileFeature";
2
+ declare const _default: {
3
+ VECTOR_TILE_FEATURE_PROPERTY: string;
4
+ };
5
+ export default _default;
@@ -0,0 +1,10 @@
1
+ import { AnyCanvas } from '../../types';
2
+ /**
3
+ * This function try to create a canvas element and return it.
4
+ * it uses document.createElement('canvas') if document is available
5
+ * or new OffscreenCanvas(width, height) if OffscreenCanvas is avalaible (for web worker)
6
+ * or it returns null if neither is available.
7
+ * @private
8
+ */
9
+ declare const createCanvas: (width: number, height: number) => AnyCanvas | null;
10
+ export default createCanvas;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @private
3
+ */
4
+ declare const createDefaultCopyrightElement: () => HTMLDivElement;
5
+ export default createDefaultCopyrightElement;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @private
3
+ */
4
+ declare const createDefaultStopFinderElement: () => HTMLDivElement;
5
+ export default createDefaultStopFinderElement;
@@ -0,0 +1,12 @@
1
+ import { RealtimeTrajectory } from '../../types';
2
+ /**
3
+ * Return a filter functions based on some parameters of a vehicle.
4
+ *
5
+ * @param {string|Array<string>} line - A list of vehicle's name to filter. Names can be separated by a comma. Ex: 'S1,S2,S3'
6
+ * @param {string|Array<string} route - A list of vehicle's route (contained in route_identifier property) to filter. Indentifiers can be separated by a comma. Ex: 'id1,id2,id3'
7
+ * @param {string|Array<string} operator A list of vehicle's operator to filter. Operators can be separated by a comma. Ex: 'SBB,DB'
8
+ * @param {Regexp} regexLine - A regex aplly of vehcile's name.
9
+ * @private
10
+ */
11
+ declare const createRealtimeFilters: (line: string | string[], route: string | string[], operator: string | string[], regexLine: string | string[]) => ((trajectory: RealtimeTrajectory) => boolean) | null;
12
+ export default createRealtimeFilters;
@@ -0,0 +1,12 @@
1
+ import type { RealtimeDeparture, RealtimeDepartureExtended } from '../../types';
2
+ import type { WebSocketAPIMessageCallback } from '../../api/WebSocketAPI';
3
+ /**
4
+ * This function returns a WebSocket api callback, and call the onDeparturesUpdate function with the list of current departures to display.
5
+ * @param {function(departures: RealtimeDeparture[])} onDeparturesUpdate callback when list of departures changes, called after 100 ms
6
+ * @param {boolean} [sortByMinArrivalTime = true] Sort departures by arrival time
7
+ * @param {number} [maxDepartureAge = 30] max departure age of departures in minutes
8
+ * @param {number} [timeout = 100] debounce timeout in ms
9
+ * @private
10
+ */
11
+ declare const debounceDeparturesMessages: (onDeparturesUpdate: (departures: RealtimeDepartureExtended[]) => {}, sortByMinArrivalTime?: boolean, maxDepartureAge?: number, timeout?: number) => WebSocketAPIMessageCallback<RealtimeDeparture>;
12
+ export default debounceDeparturesMessages;
@@ -0,0 +1,11 @@
1
+ import type { WebSocketAPIMessageCallback } from '../../api/WebSocketAPI';
2
+ /**
3
+ * This function returns a WebSocket api callback, and call the onUpdate function with the list of of subscribed objects changes.
4
+ *
5
+ * @param {function(objects: any[])} onUpdate callback when list of subscribed objects changes, called after 100 ms
6
+ * @param {function(object: any)} [getObjectId = true] function returning the id of an object
7
+ * @param {number} [timeout = 100] debounce timeout in ms
8
+ * @private
9
+ */
10
+ declare const debounceWebsocketMessages: (onUpdate: (objects: any[]) => void, getObjectId?: ((object: any) => string) | undefined, timeout?: number) => WebSocketAPIMessageCallback<any>;
11
+ export default debounceWebsocketMessages;
@@ -0,0 +1,3 @@
1
+ /** @private */
2
+ declare const getLayersAsFlatArray: (layersOrLayer: any | any[]) => any[];
3
+ export default getLayersAsFlatArray;
@@ -7,8 +7,12 @@ const getLayersAsFlatArray = (layersOrLayer) => {
7
7
  }
8
8
  let flatLayers = [];
9
9
  layers.forEach((layer) => {
10
+ var _a, _b;
10
11
  flatLayers.push(layer);
11
- const children = layer.children || layer.get('children') || {};
12
+ // Handle children property and ol.layer.Group
13
+ const children = layer.children ||
14
+ layer.get('children') ||
15
+ ((_b = (_a = layer.getLayers) === null || _a === void 0 ? void 0 : _a.call(layer)) === null || _b === void 0 ? void 0 : _b.getArray());
12
16
  flatLayers = flatLayers.concat(getLayersAsFlatArray(children || []));
13
17
  });
14
18
  return flatLayers;