mobility-toolbox-js 3.0.0-beta.32 → 3.0.0-beta.34

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 (56) hide show
  1. package/api/HttpAPI.js +1 -3
  2. package/api/RealtimeAPI.d.ts +5 -5
  3. package/api/RealtimeAPI.js +3 -3
  4. package/api/WebSocketAPI.js +0 -1
  5. package/common/controls/StopFinderControlCommon.d.ts +1 -1
  6. package/common/controls/StopFinderControlCommon.js +1 -1
  7. package/common/styles/realtimeDefaultStyle.js +0 -5
  8. package/common/styles/realtimeHeadingStyle.js +0 -5
  9. package/common/styles/realtimeSimpleStyle.d.ts +0 -1
  10. package/common/styles/realtimeSimpleStyle.js +0 -1
  11. package/common/utils/RealtimeEngine.d.ts +214 -0
  12. package/common/utils/RealtimeEngine.js +555 -0
  13. package/common/utils/getLayersAsFlatArray.d.ts +0 -1
  14. package/common/utils/getLayersAsFlatArray.js +0 -1
  15. package/common/utils/realtimeConfig.d.ts +1 -1
  16. package/common/utils/realtimeConfig.js +0 -1
  17. package/common/utils/renderTrajectories.d.ts +1 -0
  18. package/common/utils/renderTrajectories.js +1 -0
  19. package/common/utils/sortAndFilterDepartures.d.ts +1 -0
  20. package/common/utils/sortAndFilterDepartures.js +1 -0
  21. package/maplibre/controls/CopyrightControl.d.ts +9 -6
  22. package/maplibre/controls/CopyrightControl.js +11 -8
  23. package/maplibre/layers/Layer.d.ts +7 -6
  24. package/maplibre/layers/Layer.js +1 -2
  25. package/maplibre/layers/RealtimeLayer.d.ts +54 -111
  26. package/maplibre/layers/RealtimeLayer.js +126 -114
  27. package/maplibre/utils/getSourceCoordinates.d.ts +1 -0
  28. package/maplibre/utils/getSourceCoordinates.js +5 -4
  29. package/mbt.js +5329 -13530
  30. package/mbt.js.map +4 -4
  31. package/mbt.min.js +68 -71
  32. package/mbt.min.js.map +4 -4
  33. package/ol/controls/CopyrightControl.d.ts +13 -5
  34. package/ol/controls/CopyrightControl.js +13 -5
  35. package/ol/controls/RoutingControl.d.ts +30 -19
  36. package/ol/controls/RoutingControl.js +33 -48
  37. package/ol/controls/StopFinderControl.d.ts +23 -4
  38. package/ol/controls/StopFinderControl.js +22 -3
  39. package/ol/layers/MaplibreLayer.d.ts +22 -9
  40. package/ol/layers/MaplibreLayer.js +22 -9
  41. package/ol/layers/MaplibreStyleLayer.d.ts +35 -27
  42. package/ol/layers/MaplibreStyleLayer.js +36 -29
  43. package/ol/layers/RealtimeLayer.d.ts +76 -125
  44. package/ol/layers/RealtimeLayer.js +134 -169
  45. package/ol/mixins/PropertiesLayerMixin.d.ts +4 -6
  46. package/ol/mixins/PropertiesLayerMixin.js +0 -2
  47. package/ol/renderers/RealtimeLayerRenderer.js +6 -31
  48. package/ol/styles/fullTrajectoryDelayStyle.js +5 -7
  49. package/ol/styles/fullTrajectoryStyle.d.ts +1 -2
  50. package/ol/styles/fullTrajectoryStyle.js +5 -7
  51. package/ol/styles/routingStyle.d.ts +0 -1
  52. package/ol/styles/routingStyle.js +2 -7
  53. package/package.json +34 -32
  54. package/types/common.d.ts +2 -1
  55. package/common/mixins/RealtimeLayerMixin.d.ts +0 -267
  56. package/common/mixins/RealtimeLayerMixin.js +0 -751
@@ -4,11 +4,10 @@ import { Vector as VectorLayer } from 'ol/layer';
4
4
  import Layer from 'ol/layer/Layer';
5
5
  import { Vector as VectorSource } from 'ol/source';
6
6
  import Source from 'ol/source/Source';
7
- import RealtimeLayerMixin from '../../common/mixins/RealtimeLayerMixin';
7
+ import RealtimeEngine from '../../common/utils/RealtimeEngine';
8
8
  import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
9
9
  import RealtimeLayerRenderer from '../renderers/RealtimeLayerRenderer';
10
10
  import { fullTrajectoryStyle } from '../styles';
11
- /** @private */
12
11
  const format = new GeoJSON();
13
12
  /**
14
13
  * An OpenLayers layer able to display data from the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
@@ -24,63 +23,53 @@ const format = new GeoJSON();
24
23
  *
25
24
  *
26
25
  * @see <a href="/api/class/src/api/RealtimeAPI%20js~RealtimeAPI%20html">RealtimeAPI</a>
26
+ * @see <a href="/example/ol-realtime">OpenLayers Realtime layer example</a>
27
+ *
27
28
  *
28
29
  * @extends {ol/layer/Layer~Layer}
29
30
  *
31
+ *
30
32
  * @classproperty {boolean} allowRenderWhenAnimating - Allow rendering of the layer when the map is animating.
31
33
  * @public
32
34
  */
33
- // @ts-expect-error
34
- class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
35
+ class RealtimeLayer extends MobilityLayerMixin(Layer) {
35
36
  /**
36
37
  * Constructor.
37
38
  *
38
39
  * @param {RealtimeLayerOptions} options
39
40
  * @param {boolean} [options.allowRenderWhenAnimating=false] Allow rendering of the layer when the map is animating.
40
- * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
41
- * @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The geOps Realtime API url.
42
- *
41
+ * @param {string} options.apiKey Access key for [geOps APIs](https://developer.geops.io/).
42
+ * @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The [geOps Realtime API](https://developer.geops.io/apis/realtime/) url.
43
+ * @public
43
44
  */
44
45
  constructor(options) {
45
46
  // We use a group to be able to add custom vector layer in extended class.
46
47
  // For example TrajservLayer use a vectorLayer to display the complete trajectory.
47
48
  super(Object.assign({ source: new Source({}) }, options));
48
- /** @private */
49
49
  this.allowRenderWhenAnimating = false;
50
- /** @private */
50
+ this.maxNbFeaturesRequested = 100;
51
+ this.engine = new RealtimeEngine(Object.assign({ getViewState: this.getViewState.bind(this), onRender: this.onRealtimeEngineRender.bind(this) }, options));
51
52
  this.allowRenderWhenAnimating = !!options.allowRenderWhenAnimating;
52
53
  // We store the layer used to highlight the full Trajectory
53
- /** @private */
54
54
  this.vectorLayer = new VectorLayer({
55
55
  source: new VectorSource({ features: [] }),
56
56
  style: (feature, resolution) => {
57
- return (options.fullTrajectoryStyle || fullTrajectoryStyle)(feature, resolution, this.styleOptions);
57
+ return (options.fullTrajectoryStyle || fullTrajectoryStyle)(feature, resolution, this.engine.styleOptions);
58
58
  },
59
59
  updateWhileAnimating: this.allowRenderWhenAnimating,
60
60
  updateWhileInteracting: true,
61
61
  });
62
- // Options the last render run did happen. If something changes
63
- // we have to render again
64
- /** @private */
65
- this.renderState = {
66
- center: [0, 0],
67
- rotation: 0,
68
- zoom: undefined,
69
- };
70
- /** @private */
71
62
  this.onZoomEndDebounced = debounce(this.onZoomEnd, 100);
72
- /** @private */
73
63
  this.onMoveEndDebounced = debounce(this.onMoveEnd, 100);
74
64
  }
75
- /** @private */
76
65
  attachToMap(map) {
77
66
  super.attachToMap(map);
67
+ this.engine.attachToMap();
78
68
  if (this.map) {
79
69
  // If the layer is visible we start the rendering clock
80
70
  if (this.getVisible()) {
81
- this.start();
71
+ this.engine.start();
82
72
  }
83
- // @ts-expect-error - bad ts check RealtimeLayer is a BaseLayer
84
73
  const index = this.map.getLayers().getArray().indexOf(this);
85
74
  this.map.getLayers().insertAt(index, this.vectorLayer);
86
75
  this.olEventsKeys.push(...this.map.on(['moveend', 'change:target'],
@@ -95,15 +84,14 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
95
84
  if (this.currentZoom !== zoom) {
96
85
  this.onZoomEndDebounced(evt);
97
86
  }
98
- /** @private */
99
87
  this.currentZoom = zoom;
100
88
  this.onMoveEndDebounced(evt);
101
89
  }), this.on('change:visible', (evt) => {
102
90
  if (evt.target.getVisible()) {
103
- this.start();
91
+ this.engine.start();
104
92
  }
105
93
  else {
106
- this.stop();
94
+ this.engine.stop();
107
95
  }
108
96
  }), this.on('propertychange', (evt) => {
109
97
  // We apply every property change event related to visiblity to the vectorlayer
@@ -115,53 +103,74 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
115
103
  }
116
104
  /**
117
105
  * Create a copy of the RealtimeLayer.
118
- * @param {Object} newOptions Options to override
106
+ *
107
+ * @param {Object} newOptions Options to override. See constructor.
119
108
  * @return {RealtimeLayer} A RealtimeLayer
109
+ * @public
120
110
  */
121
111
  clone(newOptions) {
122
112
  return new RealtimeLayer(Object.assign(Object.assign({}, this.options), newOptions));
123
113
  }
124
- /**
125
- * @private
126
- */
127
114
  createRenderer() {
128
115
  return new RealtimeLayerRenderer(this);
129
116
  }
130
- /**
131
- * Render the trajectories using current map's size, resolution and rotation.
132
- * @param {boolean} noInterpolate if true, renders the vehicles without interpolating theirs positions.
133
- * @overrides
134
- * @private
135
- */
136
117
  /**
137
118
  * Destroy the container of the tracker.
138
- * @private
139
119
  */
140
120
  detachFromMap() {
141
121
  var _a;
142
122
  (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeLayer(this.vectorLayer);
123
+ this.engine.detachFromMap();
143
124
  super.detachFromMap();
144
125
  }
145
126
  /**
146
- * Return the delay in ms before the next rendering.
147
- * @private
127
+ * Get some informations about a trajectory.
128
+ *
129
+ * @param {RealtimeTrainId} id A vehicle's id.
130
+ * @returns
148
131
  */
149
- getRefreshTimeInMs() {
132
+ getTrajectoryInfos(id) {
133
+ var _a, _b;
134
+ // When a vehicle is selected, we request the complete stop sequence and the complete full trajectory.
135
+ // Then we combine them in one response and send them to inherited layers.
136
+ const promises = [
137
+ this.engine.api.getStopSequence(id),
138
+ this.engine.api.getFullTrajectory(id, this.engine.mode, this.engine.getGeneralizationLevelByZoom(Math.floor(((_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getView()) === null || _b === void 0 ? void 0 : _b.getZoom()) || 0))),
139
+ ];
140
+ return Promise.all(promises).then(([stopSequence, fullTrajectory]) => {
141
+ const response = {
142
+ fullTrajectory,
143
+ stopSequence,
144
+ };
145
+ return response;
146
+ });
147
+ }
148
+ getViewState() {
150
149
  var _a;
151
- return super.getRefreshTimeInMs(((_a = this.map.getView()) === null || _a === void 0 ? void 0 : _a.getZoom()) || 0);
150
+ if (!((_a = this.map) === null || _a === void 0 ? void 0 : _a.getView())) {
151
+ return {};
152
+ }
153
+ const view = this.map.getView();
154
+ return {
155
+ center: view.getCenter(),
156
+ extent: view.calculateExtent(),
157
+ pixelRatio: this.engine.pixelRatio,
158
+ resolution: view.getResolution(),
159
+ rotation: view.getRotation(),
160
+ size: this.map.getSize(),
161
+ visible: this.getVisible(),
162
+ zoom: view.getZoom(),
163
+ };
152
164
  }
153
165
  highlight(feature) {
154
- this.highlightVehicle(feature === null || feature === void 0 ? void 0 : feature.get('train_id'));
166
+ const id = feature === null || feature === void 0 ? void 0 : feature.get('train_id');
167
+ if (this.hoverVehicleId !== id) {
168
+ this.hoverVehicleId = id;
169
+ this.engine.renderTrajectories(true);
170
+ }
155
171
  }
156
- /**
157
- * On move end we update the websocket with the new bbox.
158
- *
159
- * @private
160
- * @override
161
- */
162
172
  /**
163
173
  * Highlight the trajectory of journey.
164
- * @private
165
174
  */
166
175
  highlightTrajectory(id) {
167
176
  var _a, _b, _c, _d;
@@ -169,8 +178,8 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
169
178
  (_b = (_a = this.vectorLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear(true);
170
179
  return Promise.resolve([]);
171
180
  }
172
- return this.api
173
- .getFullTrajectory(id, this.mode, this.getGeneralizationLevelByZoom(Math.floor(((_d = (_c = this.map) === null || _c === void 0 ? void 0 : _c.getView()) === null || _d === void 0 ? void 0 : _d.getZoom()) || 0)))
181
+ return this.engine.api
182
+ .getFullTrajectory(id, this.engine.mode, this.engine.getGeneralizationLevelByZoom(Math.floor(((_d = (_c = this.map) === null || _c === void 0 ? void 0 : _c.getView()) === null || _d === void 0 ? void 0 : _d.getZoom()) || 0)))
174
183
  .then((data) => {
175
184
  var _a, _b, _c, _d, _e;
176
185
  const fullTrajectory = data.content;
@@ -190,144 +199,100 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
190
199
  return [];
191
200
  });
192
201
  }
202
+ onMoveEnd() {
203
+ if (!this.engine.isUpdateBboxOnMoveEnd || !this.getVisible()) {
204
+ return;
205
+ }
206
+ this.engine.setBbox();
207
+ }
193
208
  /**
194
- * Function called on moveend event only when the zoom has changed.
195
- *
196
- * @param {ol/MapEvent~MapEvent} evt Moveend event.
197
- * @private
198
- * @override
209
+ * Callback when the RealtimeEngine has rendered successfully.
199
210
  */
200
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
201
- onMoveEnd(evt) {
202
- if (!this.isUpdateBboxOnMoveEnd || !this.getVisible()) {
203
- return;
211
+ onRealtimeEngineRender(renderState, viewState) {
212
+ this.renderedViewState = Object.assign({}, viewState);
213
+ // @ts-expect-error - we are in the same class
214
+ const { container } = this.getRenderer();
215
+ if (container) {
216
+ container.style.transform = '';
204
217
  }
205
- this.setBbox();
206
218
  }
207
- // eslint-disable-next-line no-unused-vars
208
219
  onZoomEnd() {
209
- super.onZoomEnd();
210
- if (!this.isUpdateBboxOnMoveEnd || !this.getVisible()) {
220
+ this.engine.onZoomEnd();
221
+ if (!this.engine.isUpdateBboxOnMoveEnd || !this.getVisible()) {
211
222
  return;
212
223
  }
213
224
  if (this.selectedVehicleId) {
214
225
  this.highlightTrajectory(this.selectedVehicleId);
215
226
  }
216
227
  }
217
- /**
218
- * Remove the trajectory form the list if necessary.
219
- *
220
- * @private
221
- */
222
- purgeTrajectory(trajectory, extent, zoom) {
223
- var _a;
224
- const center = (_a = this.map.getView()) === null || _a === void 0 ? void 0 : _a.getCenter();
225
- if (!extent && !center) {
226
- // In that case the view is not zoomed yet so we can't calculate the extent of the map,
227
- // it will trigger a js error on calculateExtent function.
228
- return false;
229
- }
230
- return super.purgeTrajectory(trajectory, extent || this.map.getView().calculateExtent(), zoom || this.map.getView().getZoom() || 0);
231
- }
232
- // /**
233
- // * Update the cursor style when hovering a vehicle.
234
- // *
235
- // * @private
236
- // * @override
237
- // */
238
- // onFeatureHover(
239
- // features: Feature[],
240
- // layer: RealtimeLayer,
241
- // coordinate: Coordinate,
242
- // ) {
243
- // super.onFeatureHover(features, layer, coordinate);
244
- // this.map.getTargetElement().style.cursor = features.length
245
- // ? 'pointer'
246
- // : 'auto';
247
- // }
248
- // /**
249
- // * Display the complete trajectory of the vehicle.
250
- // *
251
- // * @private
252
- // * @override
253
- // */
254
- // onFeatureClick(
255
- // features: Feature[],
256
- // layer: RealtimeLayer,
257
- // coordinate: Coordinate,
258
- // ) {
259
- // super.onFeatureClick(features, layer, coordinate);
260
- // this.highlightTrajectory(this.selectedVehicleId);
261
- // }
262
- // @ts-expect-error
263
- renderTrajectories(noInterpolate) {
264
- if (!this.map) {
265
- return;
266
- }
267
- const view = this.map.getView();
268
- // it could happen that the view is set but without center yet,
269
- // so the calcualteExtent will trigger an error.
270
- if (!(view === null || view === void 0 ? void 0 : view.getCenter())) {
271
- return;
228
+ select(feature) {
229
+ const id = feature === null || feature === void 0 ? void 0 : feature.get('train_id');
230
+ if (this.selectedVehicleId !== id) {
231
+ this.selectedVehicleId = id;
232
+ this.engine.renderTrajectories(true);
272
233
  }
273
- super.renderTrajectories({
274
- center: view.getCenter(),
275
- extent: view.calculateExtent(),
276
- pixelRatio: this.pixelRatio,
277
- resolution: view.getResolution(),
278
- rotation: view.getRotation(),
279
- size: this.map.getSize(),
280
- zoom: view.getZoom(),
281
- }, noInterpolate);
234
+ this.highlightTrajectory(id);
282
235
  }
283
- /**
284
- * Launch renderTrajectories. it avoids duplicating code in renderTrajectories methhod.
285
- * @private
286
- * @override
287
- */
288
- renderTrajectoriesInternal(viewState, noInterpolate) {
289
- var _a;
290
- if (!((_a = this.map) === null || _a === void 0 ? void 0 : _a.getView())) {
291
- return false;
292
- }
293
- let isRendered = false;
294
- const blockRendering = this.allowRenderWhenAnimating
236
+ shouldRender() {
237
+ return this.allowRenderWhenAnimating
295
238
  ? false
296
239
  : this.map.getView().getAnimating() ||
297
240
  this.map.getView().getInteracting();
298
- // Don't render the map when the map is animating or interacting.
299
- isRendered = blockRendering
300
- ? false
301
- : super.renderTrajectoriesInternal(viewState, noInterpolate);
302
- // We update the current render state.
303
- if (isRendered) {
304
- /** @private */
305
- this.renderedViewState = Object.assign({}, viewState);
306
- // @ts-expect-error - we are in the same class
307
- const { container } = this.getRenderer();
308
- if (container) {
309
- container.style.transform = '';
310
- }
311
- }
312
- return isRendered;
313
241
  }
314
- select(feature) {
315
- this.selectVehicle(feature === null || feature === void 0 ? void 0 : feature.get('train_id'));
316
- this.highlightTrajectory(feature === null || feature === void 0 ? void 0 : feature.get('train_id'));
242
+ /**
243
+ * Start the rendering.
244
+ *
245
+ * @public
246
+ */
247
+ start() {
248
+ this.engine.start();
317
249
  }
318
250
  /**
319
- * Send the current bbox to the websocket
251
+ * Stop the rendering.
320
252
  *
321
- * @private
253
+ * @public
322
254
  */
323
- setBbox(extent, zoom) {
324
- var _a, _b, _c, _d;
325
- const extentt = extent ||
326
- ((_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getView()) === null || _b === void 0 ? void 0 : _b.calculateExtent());
327
- if (!extentt) {
328
- return;
329
- }
330
- super.setBbox(extentt, zoom || ((_d = (_c = this.map) === null || _c === void 0 ? void 0 : _c.getView()) === null || _d === void 0 ? void 0 : _d.getZoom()) || 0);
255
+ stop() {
256
+ this.engine.stop();
257
+ }
258
+ get api() {
259
+ return this.engine.api;
260
+ }
261
+ set api(api) {
262
+ this.engine.api = api;
263
+ }
264
+ get canvas() {
265
+ return this.engine.canvas;
266
+ }
267
+ get filter() {
268
+ return this.engine.filter;
269
+ }
270
+ get hoverVehicleId() {
271
+ return this.engine.hoverVehicleId;
272
+ }
273
+ set hoverVehicleId(id) {
274
+ this.engine.hoverVehicleId = id;
275
+ }
276
+ get mode() {
277
+ return this.engine.mode;
278
+ }
279
+ set mode(mode) {
280
+ this.engine.mode = mode;
281
+ }
282
+ get pixelRatio() {
283
+ return this.engine.pixelRatio;
284
+ }
285
+ get selectedVehicleId() {
286
+ return this.engine.selectedVehicleId;
287
+ }
288
+ set selectedVehicleId(id) {
289
+ this.engine.selectedVehicleId = id;
290
+ }
291
+ get sort() {
292
+ return this.engine.sort;
293
+ }
294
+ get trajectories() {
295
+ return this.engine.trajectories;
331
296
  }
332
297
  }
333
298
  export default RealtimeLayer;
@@ -3,7 +3,7 @@ import { EventsKey } from 'ol/events';
3
3
  import { Layer } from 'ol/layer';
4
4
  import type { Options } from 'ol/layer/Layer';
5
5
  import type { Layerable } from './MobilityLayerMixin';
6
- export type PropertiesLayerMixinOptions = Options & Record<string, any> & {
6
+ export type PropertiesLayerMixinOptions = {
7
7
  children?: any[];
8
8
  copyrights?: string[];
9
9
  disabled?: boolean;
@@ -14,7 +14,7 @@ export type PropertiesLayerMixinOptions = Options & Record<string, any> & {
14
14
  name?: string;
15
15
  properties?: Record<string, any>;
16
16
  visible?: boolean;
17
- };
17
+ } & Options & Record<string, any>;
18
18
  /**
19
19
  * This mixin adds some properties to access ol custom properties easily.
20
20
  */
@@ -37,7 +37,6 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
37
37
  * @deprecated
38
38
  */
39
39
  flat(): any[];
40
- /** @private */
41
40
  onChildrenChange(oldValue: Layer[]): void;
42
41
  setMapInternal(map: Map): void;
43
42
  /** @deprecated */
@@ -49,7 +48,6 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
49
48
  /** @deprecated */
50
49
  disabled: boolean;
51
50
  /** @deprecated */
52
- /** @deprecated */
53
51
  readonly group: string;
54
52
  /** @deprecated */
55
53
  hitTolerance: number;
@@ -86,7 +84,7 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
86
84
  getBackground: () => import("ol/layer/Base").BackgroundColor | false;
87
85
  getClassName: () => string;
88
86
  getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
89
- getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
87
+ getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer" /** @deprecated */).default>;
90
88
  getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
91
89
  getExtent: () => import("ol/extent").Extent | undefined;
92
90
  getMaxResolution: () => number;
@@ -116,7 +114,7 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
116
114
  } | null;
117
115
  hasProperties: () => boolean;
118
116
  notify: (key: string, oldValue: any) => void;
119
- addChangeListener: (key: string, listener: import("ol/events" /** @deprecated */).Listener) => void;
117
+ addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
120
118
  removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
121
119
  set: (key: string, value: any, silent?: boolean | undefined) => void;
122
120
  setProperties: (values: {
@@ -65,7 +65,6 @@ function PropertiesLayerMixin(Base) {
65
65
  deprecated('Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead.');
66
66
  return getLayersAsFlatArray(this);
67
67
  }
68
- /** @private */
69
68
  onChildrenChange(oldValue) {
70
69
  // Set the parent property
71
70
  (oldValue || []).forEach((child) => {
@@ -120,7 +119,6 @@ function PropertiesLayerMixin(Base) {
120
119
  this.set('disabled', newValue);
121
120
  }
122
121
  /** @deprecated */
123
- /** @deprecated */
124
122
  get group() {
125
123
  deprecated("Layer.group is deprecated. Use the Layer.get('group') method instead.");
126
124
  return this.get('group');
@@ -1,20 +1,17 @@
1
- import { buffer, containsCoordinate } from 'ol/extent';
2
1
  import GeoJSON from 'ol/format/GeoJSON';
3
2
  import CanvasLayerRenderer from 'ol/renderer/canvas/Layer';
4
3
  import { composeCssTransform } from 'ol/transform';
5
- /** @private */
6
4
  const format = new GeoJSON();
7
5
  /**
8
6
  * This class is a renderer for Maplibre Layer to be able to use the native ol
9
7
  * functionnalities like map.getFeaturesAtPixel or map.hasFeatureAtPixel.
10
8
  * @private
11
9
  */
12
- // @ts-expect-error
13
10
  export default class RealtimeLayerRenderer extends CanvasLayerRenderer {
14
11
  forEachFeatureAtCoordinate(coordinate, frameState, hitTolerance, callback) {
15
12
  const features = this.getFeaturesAtCoordinate(coordinate, hitTolerance);
16
13
  features.forEach((feature) => {
17
- // @ts-expect-error
14
+ // @ts-expect-error defintion to fix
18
15
  callback(feature, this.layer_, feature.getGeometry());
19
16
  });
20
17
  return features === null || features === void 0 ? void 0 : features[0];
@@ -43,37 +40,15 @@ export default class RealtimeLayerRenderer extends CanvasLayerRenderer {
43
40
  return Promise.resolve(this.getFeaturesAtCoordinate(coordinate));
44
41
  }
45
42
  getFeaturesAtCoordinate(coordinate, hitTolerance = 5) {
46
- var _a;
47
43
  if (!coordinate) {
48
44
  return [];
49
45
  }
50
46
  const layer = this.getLayer();
51
- const map = layer.getMapInternal();
52
- const resolution = ((_a = map === null || map === void 0 ? void 0 : map.getView()) === null || _a === void 0 ? void 0 : _a.getResolution()) || 1;
53
- const nb = 10;
54
- const ext = buffer([...coordinate, ...coordinate], hitTolerance * resolution);
55
- let features = [];
56
- let trajectories = Object.values(layer.trajectories || {});
57
- if (layer.sort) {
58
- // @ts-expect-error
59
- trajectories = trajectories.sort(this.sort);
60
- }
61
- const vehicles = [];
62
- for (let i = 0; i < trajectories.length; i += 1) {
63
- const trajectory = trajectories[i];
64
- if (
65
- // @ts-expect-error coordinate is added by the RealtimeLayer
66
- trajectory.properties.coordinate &&
67
- // @ts-expect-error coordinate is added by the RealtimeLayer
68
- containsCoordinate(ext, trajectory.properties.coordinate)) {
69
- vehicles.push(trajectories[i]);
70
- }
71
- if (vehicles.length === nb) {
72
- break;
73
- }
74
- }
75
- features = vehicles.map((vehicle) => format.readFeature(vehicle));
76
- return features;
47
+ const featureCollection = layer.engine.getVehiclesAtCoordinate(coordinate, {
48
+ hitTolerance,
49
+ nb: layer.maxNbFeaturesRequested,
50
+ });
51
+ return format.readFeatures(featureCollection);
77
52
  }
78
53
  // eslint-disable-next-line class-methods-use-this
79
54
  prepareFrame() {
@@ -1,31 +1,29 @@
1
- import { Style, Fill, Stroke, Circle } from 'ol/style';
2
- /** @private */
1
+ import { Circle, Fill, Stroke, Style } from 'ol/style';
3
2
  const stroke = new Style({
4
- zIndex: 2,
5
3
  image: new Circle({
6
- radius: 5,
7
4
  fill: new Fill({
8
5
  color: '#000000',
9
6
  }),
7
+ radius: 5,
10
8
  }),
11
9
  stroke: new Stroke({
12
10
  color: '#000000',
13
11
  width: 6,
14
12
  }),
13
+ zIndex: 2,
15
14
  });
16
- /** @private */
17
15
  const fill = new Style({
18
- zIndex: 3,
19
16
  image: new Circle({
20
- radius: 4,
21
17
  fill: new Fill({
22
18
  color: '#a0a0a0',
23
19
  }),
20
+ radius: 4,
24
21
  }),
25
22
  stroke: new Stroke({
26
23
  color: '#a0a0a0',
27
24
  width: 4,
28
25
  }),
26
+ zIndex: 3,
29
27
  });
30
28
  /**
31
29
  * @private
@@ -1,5 +1,4 @@
1
- import type { FeatureLike } from 'ol/Feature';
2
1
  import { Style } from 'ol/style';
3
- /** @private */
2
+ import type { FeatureLike } from 'ol/Feature';
4
3
  declare const fullTrajectorystyle: (feature: FeatureLike, resolution: number, options: any) => Style[];
5
4
  export default fullTrajectorystyle;
@@ -1,19 +1,17 @@
1
- import { Style, Fill, Stroke, Circle } from 'ol/style';
2
- /** @private */
1
+ import { Circle, Fill, Stroke, Style } from 'ol/style';
3
2
  const borderStyle = new Style({
4
- zIndex: 2,
5
3
  image: new Circle({
6
- radius: 5,
7
4
  fill: new Fill({
8
5
  color: '#000000',
9
6
  }),
7
+ radius: 5,
10
8
  }),
11
9
  stroke: new Stroke({
12
10
  color: '#000000',
13
11
  width: 6,
14
12
  }),
13
+ zIndex: 2,
15
14
  });
16
- /** @private */
17
15
  const fullTrajectorystyle = (feature, resolution, options) => {
18
16
  let lineColor = '#ffffff'; // white
19
17
  const type = feature.get('type');
@@ -27,17 +25,17 @@ const fullTrajectorystyle = (feature, resolution, options) => {
27
25
  const style = [
28
26
  borderStyle,
29
27
  new Style({
30
- zIndex: 3,
31
28
  image: new Circle({
32
- radius: 4,
33
29
  fill: new Fill({
34
30
  color: lineColor,
35
31
  }),
32
+ radius: 4,
36
33
  }),
37
34
  stroke: new Stroke({
38
35
  color: lineColor,
39
36
  width: 4,
40
37
  }),
38
+ zIndex: 3,
41
39
  }),
42
40
  ];
43
41
  return style;
@@ -1,4 +1,3 @@
1
1
  import { StyleFunction } from 'ol/style/Style';
2
- /** @private */
3
2
  declare const routingStyle: StyleFunction;
4
3
  export default routingStyle;