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.
Files changed (87) hide show
  1. package/api/HttpAPI.d.ts +5 -16
  2. package/api/HttpAPI.js +0 -11
  3. package/api/RealtimeAPI.d.ts +221 -176
  4. package/api/RealtimeAPI.js +317 -258
  5. package/api/RoutingAPI.d.ts +21 -11
  6. package/api/RoutingAPI.js +17 -7
  7. package/api/StopsAPI.d.ts +20 -14
  8. package/api/StopsAPI.js +17 -11
  9. package/api/WebSocketAPI.d.ts +60 -66
  10. package/api/WebSocketAPI.js +164 -164
  11. package/api/index.js +1 -1
  12. package/api/typedefs.d.ts +0 -102
  13. package/api/typedefs.js +27 -42
  14. package/common/controls/StopFinderControlCommon.d.ts +12 -12
  15. package/common/controls/StopFinderControlCommon.js +31 -31
  16. package/common/index.d.ts +1 -1
  17. package/common/index.js +1 -1
  18. package/common/mixins/RealtimeLayerMixin.d.ts +157 -163
  19. package/common/mixins/RealtimeLayerMixin.js +401 -393
  20. package/common/styles/realtimeDefaultStyle.js +6 -6
  21. package/common/styles/realtimeHeadingStyle.js +5 -5
  22. package/common/typedefs.d.ts +13 -6
  23. package/common/typedefs.js +7 -1
  24. package/common/utils/compareDepartures.d.ts +2 -2
  25. package/common/utils/compareDepartures.js +2 -2
  26. package/common/utils/debounceWebsocketMessages.d.ts +1 -1
  27. package/common/utils/getMapGlCopyrights.d.ts +1 -1
  28. package/common/utils/getMapGlCopyrights.js +3 -3
  29. package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
  30. package/common/utils/getRealtimeModeSuffix.js +1 -0
  31. package/common/utils/getVehiclePosition.d.ts +5 -4
  32. package/common/utils/getVehiclePosition.js +9 -3
  33. package/common/utils/renderTrajectories.d.ts +1 -1
  34. package/common/utils/renderTrajectories.js +6 -6
  35. package/common/utils/sortAndFilterDepartures.d.ts +1 -1
  36. package/common/utils/sortAndFilterDepartures.js +1 -1
  37. package/common/utils/sortByDelay.d.ts +2 -2
  38. package/common/utils/sortByDelay.js +5 -1
  39. package/maplibre/layers/Layer.d.ts +1 -1
  40. package/maplibre/layers/Layer.js +1 -1
  41. package/maplibre/layers/RealtimeLayer.d.ts +87 -66
  42. package/maplibre/layers/RealtimeLayer.js +30 -6
  43. package/maplibre/utils/getSourceCoordinates.js +5 -5
  44. package/mbt.js +20988 -13287
  45. package/mbt.js.map +4 -4
  46. package/mbt.min.js +61 -58
  47. package/mbt.min.js.map +4 -4
  48. package/ol/controls/RoutingControl.d.ts +82 -89
  49. package/ol/controls/RoutingControl.js +217 -219
  50. package/ol/controls/StopFinderControl.d.ts +3 -3
  51. package/ol/controls/StopFinderControl.js +2 -2
  52. package/ol/index.d.ts +1 -0
  53. package/ol/index.js +1 -0
  54. package/ol/layers/Layer.d.ts +101 -0
  55. package/ol/layers/Layer.js +25 -0
  56. package/ol/layers/MaplibreLayer.d.ts +121 -24
  57. package/ol/layers/MaplibreLayer.js +98 -27
  58. package/ol/layers/MaplibreStyleLayer.d.ts +93 -91
  59. package/ol/layers/MaplibreStyleLayer.js +281 -257
  60. package/ol/layers/RealtimeLayer.d.ts +119 -121
  61. package/ol/layers/RealtimeLayer.js +143 -134
  62. package/ol/layers/VectorLayer.d.ts +18 -0
  63. package/ol/layers/VectorLayer.js +32 -0
  64. package/ol/layers/index.d.ts +2 -0
  65. package/ol/layers/index.js +3 -0
  66. package/ol/mixins/MobilityLayerMixin.d.ts +32 -34
  67. package/ol/mixins/PropertiesLayerMixin.d.ts +60 -51
  68. package/ol/mixins/PropertiesLayerMixin.js +114 -79
  69. package/ol/mixins/index.d.ts +1 -0
  70. package/ol/mixins/index.js +2 -0
  71. package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -20
  72. package/ol/renderers/MaplibreLayerRenderer.js +142 -114
  73. package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
  74. package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
  75. package/ol/renderers/RealtimeLayerRenderer.d.ts +6 -6
  76. package/ol/renderers/RealtimeLayerRenderer.js +56 -51
  77. package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
  78. package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
  79. package/package.json +31 -31
  80. package/setupTests.js +3 -4
  81. package/types/common.d.ts +55 -48
  82. package/types/index.d.ts +1 -1
  83. package/types/realtime.d.ts +91 -93
  84. package/types/routing.d.ts +60 -60
  85. package/types/stops.d.ts +62 -62
  86. package/ol/layers/MapGlLayer.d.ts +0 -144
  87. package/ol/layers/MapGlLayer.js +0 -144
@@ -1,17 +1,17 @@
1
+ import debounce from 'lodash.debounce';
1
2
  import GeoJSON from 'ol/format/GeoJSON';
2
3
  import { Vector as VectorLayer } from 'ol/layer';
3
- import Source from 'ol/source/Source';
4
- import { Vector as VectorSource } from 'ol/source';
5
- import debounce from 'lodash.debounce';
6
4
  import Layer from 'ol/layer/Layer';
5
+ import { Vector as VectorSource } from 'ol/source';
6
+ import Source from 'ol/source/Source';
7
7
  import RealtimeLayerMixin from '../../common/mixins/RealtimeLayerMixin';
8
- import { fullTrajectoryStyle } from '../styles';
9
8
  import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
10
9
  import RealtimeLayerRenderer from '../renderers/RealtimeLayerRenderer';
10
+ import { fullTrajectoryStyle } from '../styles';
11
11
  /** @private */
12
12
  const format = new GeoJSON();
13
13
  /**
14
- * Responsible for loading and display data from the geOps realtime API.
14
+ * An OpenLayers layer able to display data from the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
15
15
  *
16
16
  * @example
17
17
  * import { RealtimeLayer } from 'mobility-toolbox-js/ol';
@@ -30,7 +30,7 @@ const format = new GeoJSON();
30
30
  * @classproperty {boolean} allowRenderWhenAnimating - Allow rendering of the layer when the map is animating.
31
31
  * @public
32
32
  */
33
- // @ts-ignore
33
+ // @ts-expect-error
34
34
  class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
35
35
  /**
36
36
  * Constructor.
@@ -38,7 +38,7 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
38
38
  * @param {RealtimeLayerOptions} options
39
39
  * @param {boolean} [options.allowRenderWhenAnimating=false] Allow rendering of the layer when the map is animating.
40
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.
41
+ * @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The geOps Realtime API url.
42
42
  *
43
43
  */
44
44
  constructor(options) {
@@ -52,48 +52,42 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
52
52
  // We store the layer used to highlight the full Trajectory
53
53
  /** @private */
54
54
  this.vectorLayer = new VectorLayer({
55
- updateWhileAnimating: this.allowRenderWhenAnimating,
56
- updateWhileInteracting: true,
57
55
  source: new VectorSource({ features: [] }),
58
56
  style: (feature, resolution) => {
59
57
  return (options.fullTrajectoryStyle || fullTrajectoryStyle)(feature, resolution, this.styleOptions);
60
58
  },
59
+ updateWhileAnimating: this.allowRenderWhenAnimating,
60
+ updateWhileInteracting: true,
61
61
  });
62
62
  // Options the last render run did happen. If something changes
63
63
  // we have to render again
64
64
  /** @private */
65
65
  this.renderState = {
66
66
  center: [0, 0],
67
- zoom: undefined,
68
67
  rotation: 0,
68
+ zoom: undefined,
69
69
  };
70
70
  /** @private */
71
71
  this.onZoomEndDebounced = debounce(this.onZoomEnd, 100);
72
72
  /** @private */
73
73
  this.onMoveEndDebounced = debounce(this.onMoveEnd, 100);
74
74
  }
75
- /**
76
- * @private
77
- */
78
- createRenderer() {
79
- return new RealtimeLayerRenderer(this);
80
- }
81
75
  /** @private */
82
76
  attachToMap(map) {
83
77
  super.attachToMap(map);
84
78
  if (this.map) {
85
79
  // If the layer is visible we start the rendering clock
86
- if (this.visible) {
80
+ if (this.getVisible()) {
87
81
  this.start();
88
82
  }
89
- // @ts-expect-error - bad ts check RealtimeLayer is a BaseLayer
83
+ // @ts-expect-error - bad ts check RealtimeLayer is a BaseLayer
90
84
  const index = this.map.getLayers().getArray().indexOf(this);
91
85
  this.map.getLayers().insertAt(index, this.vectorLayer);
92
- this.olListenersKeys.push(...this.map.on(['moveend', 'change:target'],
93
- // @ts-expect-error - bad ol definitions
86
+ this.olEventsKeys.push(...this.map.on(['moveend', 'change:target'],
87
+ // @ts-expect-error - bad ol definitions
94
88
  (evt) => {
95
89
  const view = (evt.map || evt.target).getView();
96
- if (view.getAnimating() || view.getInteracting()) {
90
+ if (!view || (view === null || view === void 0 ? void 0 : view.getAnimating()) || (view === null || view === void 0 ? void 0 : view.getInteracting())) {
97
91
  return;
98
92
  }
99
93
  const zoom = view.getZoom();
@@ -105,7 +99,7 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
105
99
  this.currentZoom = zoom;
106
100
  this.onMoveEndDebounced(evt);
107
101
  }), this.on('change:visible', (evt) => {
108
- if (evt.target.visible) {
102
+ if (evt.target.getVisible()) {
109
103
  this.start();
110
104
  }
111
105
  else {
@@ -120,13 +114,18 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
120
114
  }
121
115
  }
122
116
  /**
123
- * Destroy the container of the tracker.
117
+ * Create a copy of the RealtimeLayer.
118
+ * @param {Object} newOptions Options to override
119
+ * @return {RealtimeLayer} A RealtimeLayer
120
+ */
121
+ clone(newOptions) {
122
+ return new RealtimeLayer(Object.assign(Object.assign({}, this.options), newOptions));
123
+ }
124
+ /**
124
125
  * @private
125
126
  */
126
- detachFromMap() {
127
- var _a;
128
- (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeLayer(this.vectorLayer);
129
- super.detachFromMap();
127
+ createRenderer() {
128
+ return new RealtimeLayerRenderer(this);
130
129
  }
131
130
  /**
132
131
  * Render the trajectories using current map's size, resolution and rotation.
@@ -134,63 +133,25 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
134
133
  * @overrides
135
134
  * @private
136
135
  */
137
- // @ts-ignore
138
- renderTrajectories(noInterpolate) {
139
- if (!this.map) {
140
- return;
141
- }
142
- const view = this.map.getView();
143
- // it could happen that the view is set but without center yet,
144
- // so the calcualteExtent will trigger an error.
145
- if (!view.getCenter()) {
146
- return;
147
- }
148
- super.renderTrajectories({
149
- size: this.map.getSize(),
150
- center: view.getCenter(),
151
- extent: view.calculateExtent(),
152
- resolution: view.getResolution(),
153
- rotation: view.getRotation(),
154
- zoom: view.getZoom(),
155
- pixelRatio: this.pixelRatio,
156
- }, noInterpolate);
157
- }
158
136
  /**
159
- * Launch renderTrajectories. it avoids duplicating code in renderTrajectories methhod.
137
+ * Destroy the container of the tracker.
160
138
  * @private
161
- * @override
162
139
  */
163
- renderTrajectoriesInternal(viewState, noInterpolate) {
164
- if (!this.map) {
165
- return false;
166
- }
167
- let isRendered = false;
168
- const blockRendering = this.allowRenderWhenAnimating
169
- ? false
170
- : this.map.getView().getAnimating() ||
171
- this.map.getView().getInteracting();
172
- // Don't render the map when the map is animating or interacting.
173
- isRendered = blockRendering
174
- ? false
175
- : super.renderTrajectoriesInternal(viewState, noInterpolate);
176
- // We update the current render state.
177
- if (isRendered) {
178
- /** @private */
179
- this.renderedViewState = Object.assign({}, viewState);
180
- // @ts-expect-error - we are in the same class
181
- const { container } = this.getRenderer();
182
- if (container) {
183
- container.style.transform = '';
184
- }
185
- }
186
- return isRendered;
140
+ detachFromMap() {
141
+ var _a;
142
+ (_a = this.map) === null || _a === void 0 ? void 0 : _a.removeLayer(this.vectorLayer);
143
+ super.detachFromMap();
187
144
  }
188
145
  /**
189
146
  * Return the delay in ms before the next rendering.
190
147
  * @private
191
148
  */
192
149
  getRefreshTimeInMs() {
193
- return super.getRefreshTimeInMs(this.map.getView().getZoom());
150
+ var _a;
151
+ return super.getRefreshTimeInMs(((_a = this.map.getView()) === null || _a === void 0 ? void 0 : _a.getZoom()) || 0);
152
+ }
153
+ highlight(feature) {
154
+ this.highlightVehicle(feature === null || feature === void 0 ? void 0 : feature.get('train_id'));
194
155
  }
195
156
  /**
196
157
  * On move end we update the websocket with the new bbox.
@@ -198,12 +159,36 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
198
159
  * @private
199
160
  * @override
200
161
  */
201
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
202
- onMoveEnd(evt) {
203
- if (!this.isUpdateBboxOnMoveEnd || !this.visible) {
204
- return;
162
+ /**
163
+ * Highlight the trajectory of journey.
164
+ * @private
165
+ */
166
+ highlightTrajectory(id) {
167
+ var _a, _b, _c, _d;
168
+ if (!id) {
169
+ (_b = (_a = this.vectorLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear(true);
170
+ return Promise.resolve([]);
205
171
  }
206
- this.setBbox();
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)))
174
+ .then((data) => {
175
+ var _a, _b, _c, _d, _e;
176
+ const fullTrajectory = data.content;
177
+ if (!((_a = fullTrajectory === null || fullTrajectory === void 0 ? void 0 : fullTrajectory.features) === null || _a === void 0 ? void 0 : _a.length)) {
178
+ return [];
179
+ }
180
+ const features = format.readFeatures(fullTrajectory);
181
+ (_c = (_b = this.vectorLayer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.clear(true);
182
+ if (features.length) {
183
+ (_e = (_d = this.vectorLayer) === null || _d === void 0 ? void 0 : _d.getSource()) === null || _e === void 0 ? void 0 : _e.addFeatures(features);
184
+ }
185
+ return features;
186
+ })
187
+ .catch(() => {
188
+ var _a, _b;
189
+ (_b = (_a = this.vectorLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear(true);
190
+ return [];
191
+ });
207
192
  }
208
193
  /**
209
194
  * Function called on moveend event only when the zoom has changed.
@@ -212,22 +197,37 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
212
197
  * @private
213
198
  * @override
214
199
  */
200
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
201
+ onMoveEnd(evt) {
202
+ if (!this.isUpdateBboxOnMoveEnd || !this.getVisible()) {
203
+ return;
204
+ }
205
+ this.setBbox();
206
+ }
215
207
  // eslint-disable-next-line no-unused-vars
216
208
  onZoomEnd() {
217
209
  super.onZoomEnd();
218
- if (!this.isUpdateBboxOnMoveEnd || !this.visible) {
210
+ if (!this.isUpdateBboxOnMoveEnd || !this.getVisible()) {
219
211
  return;
220
212
  }
221
213
  if (this.selectedVehicleId) {
222
214
  this.highlightTrajectory(this.selectedVehicleId);
223
215
  }
224
216
  }
225
- highlight(feature) {
226
- this.highlightVehicle(feature === null || feature === void 0 ? void 0 : feature.get('train_id'));
227
- }
228
- select(feature) {
229
- this.selectVehicle(feature === null || feature === void 0 ? void 0 : feature.get('train_id'));
230
- this.highlightTrajectory(feature === null || feature === void 0 ? void 0 : feature.get('train_id'));
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
231
  }
232
232
  // /**
233
233
  // * Update the cursor style when hovering a vehicle.
@@ -259,19 +259,61 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
259
259
  // super.onFeatureClick(features, layer, coordinate);
260
260
  // this.highlightTrajectory(this.selectedVehicleId);
261
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;
272
+ }
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);
282
+ }
262
283
  /**
263
- * Remove the trajectory form the list if necessary.
264
- *
284
+ * Launch renderTrajectories. it avoids duplicating code in renderTrajectories methhod.
265
285
  * @private
286
+ * @override
266
287
  */
267
- purgeTrajectory(trajectory, extent, zoom) {
268
- const center = this.map.getView().getCenter();
269
- if (!extent && !center) {
270
- // In that case the view is not zoomed yet so we can't calculate the extent of the map,
271
- // it will trigger a js error on calculateExtent function.
288
+ renderTrajectoriesInternal(viewState, noInterpolate) {
289
+ var _a;
290
+ if (!((_a = this.map) === null || _a === void 0 ? void 0 : _a.getView())) {
272
291
  return false;
273
292
  }
274
- return super.purgeTrajectory(trajectory, extent || this.map.getView().calculateExtent(), zoom || this.map.getView().getZoom() || 0);
293
+ let isRendered = false;
294
+ const blockRendering = this.allowRenderWhenAnimating
295
+ ? false
296
+ : this.map.getView().getAnimating() ||
297
+ 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
+ }
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'));
275
317
  }
276
318
  /**
277
319
  * Send the current bbox to the websocket
@@ -279,46 +321,13 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
279
321
  * @private
280
322
  */
281
323
  setBbox(extent, zoom) {
282
- super.setBbox(extent ||
283
- this.map.getView().calculateExtent(), zoom || this.map.getView().getZoom() || 0);
284
- }
285
- /**
286
- * Highlight the trajectory of journey.
287
- * @private
288
- */
289
- highlightTrajectory(id) {
290
- var _a, _b;
291
- if (!id) {
292
- this.vectorLayer.getSource().clear(true);
293
- return Promise.resolve([]);
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;
294
329
  }
295
- return this.api
296
- .getFullTrajectory(id, this.mode, this.getGeneralizationLevelByZoom(Math.floor(((_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getView()) === null || _b === void 0 ? void 0 : _b.getZoom()) || 0)))
297
- .then((data) => {
298
- var _a;
299
- const fullTrajectory = data.content;
300
- if (!((_a = fullTrajectory === null || fullTrajectory === void 0 ? void 0 : fullTrajectory.features) === null || _a === void 0 ? void 0 : _a.length)) {
301
- return [];
302
- }
303
- const features = format.readFeatures(fullTrajectory);
304
- this.vectorLayer.getSource().clear(true);
305
- if (features.length) {
306
- this.vectorLayer.getSource().addFeatures(features);
307
- }
308
- return features;
309
- })
310
- .catch(() => {
311
- this.vectorLayer.getSource().clear(true);
312
- return [];
313
- });
314
- }
315
- /**
316
- * Create a copy of the RealtimeLayer.
317
- * @param {Object} newOptions Options to override
318
- * @return {RealtimeLayer} A RealtimeLayer
319
- */
320
- clone(newOptions) {
321
- return new RealtimeLayer(Object.assign(Object.assign({}, this.options), newOptions));
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);
322
331
  }
323
332
  }
324
333
  export default RealtimeLayer;
@@ -0,0 +1,18 @@
1
+ import { Coordinate } from 'ol/coordinate';
2
+ import { LayerGetFeatureInfoResponse } from '../../types';
3
+ import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
4
+ import Layer from './Layer';
5
+ /**
6
+ * @deprecated
7
+ */
8
+ declare class VectorLayer extends Layer {
9
+ /**
10
+ * @deprecated
11
+ */
12
+ clone(newOptions: MobilityLayerOptions): VectorLayer;
13
+ /**
14
+ * @deprecated
15
+ */
16
+ getFeatureInfoAtCoordinate(coordinate: Coordinate): Promise<LayerGetFeatureInfoResponse>;
17
+ }
18
+ export default VectorLayer;
@@ -0,0 +1,32 @@
1
+ import Layer from './Layer';
2
+ /**
3
+ * @deprecated
4
+ */
5
+ class VectorLayer extends Layer {
6
+ /**
7
+ * @deprecated
8
+ */
9
+ clone(newOptions) {
10
+ return new VectorLayer(Object.assign(Object.assign({}, this.options), newOptions));
11
+ }
12
+ /**
13
+ * @deprecated
14
+ */
15
+ getFeatureInfoAtCoordinate(coordinate) {
16
+ let features = [];
17
+ if (this.map) {
18
+ const pixel = this.map.getPixelFromCoordinate(coordinate);
19
+ features =
20
+ this.map.getFeaturesAtPixel(pixel, {
21
+ hitTolerance: this.hitTolerance || 5,
22
+ layerFilter: (l) => l === this.olLayer,
23
+ }) || [];
24
+ }
25
+ return Promise.resolve({
26
+ coordinate,
27
+ features,
28
+ layer: this,
29
+ });
30
+ }
31
+ }
32
+ export default VectorLayer;
@@ -1,3 +1,5 @@
1
1
  export { default as MaplibreLayer } from "./MaplibreLayer";
2
2
  export { default as MaplibreStyleLayer } from "./MaplibreStyleLayer";
3
3
  export { default as RealtimeLayer } from "./RealtimeLayer";
4
+ export { default as Layer } from "./Layer";
5
+ export { default as VectorLayer } from "./VectorLayer";
@@ -1,3 +1,6 @@
1
1
  export { default as MaplibreLayer } from './MaplibreLayer';
2
2
  export { default as MaplibreStyleLayer } from './MaplibreStyleLayer';
3
3
  export { default as RealtimeLayer } from './RealtimeLayer';
4
+ // Deprecated export
5
+ export { default as Layer } from './Layer';
6
+ export { default as VectorLayer } from './VectorLayer';
@@ -1,57 +1,53 @@
1
1
  import { Layer } from 'ol/layer';
2
2
  import { PropertiesLayerMixinOptions } from './PropertiesLayerMixin';
3
- export type MobilityLayerOptions = PropertiesLayerMixinOptions & {
4
- [x: string]: any;
5
- };
6
- type GConstructor<T = {}> = new (...args: any[]) => T;
3
+ export type MobilityLayerOptions = PropertiesLayerMixinOptions & Record<string, any>;
4
+ type GConstructor<T = object> = new (...args: any[]) => T;
7
5
  export type Layerable = GConstructor<Omit<Layer, keyof string>>;
8
6
  declare function MobilityLayerMixin<TBase extends Layerable>(Base: TBase): {
9
7
  new (...args: any[]): {
10
- options?: PropertiesLayerMixinOptions | undefined;
11
- olListenersKeys: import("ol/events").EventsKey[];
12
- children: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>[];
8
+ olEventsKeys: import("ol/events").EventsKey[];
9
+ options?: PropertiesLayerMixinOptions;
10
+ attachToMap(map: import("ol").Map): void;
11
+ detachFromMap(): void;
12
+ flat(): any[];
13
+ onChildrenChange(oldValue: Layer[]): void;
14
+ setMapInternal: ((map: import("ol").Map) => void) & ((map: import("ol").default | null) => void);
15
+ children: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
13
16
  get copyrights(): string;
14
17
  set copyrights(newCopyrights: string | string[]);
15
18
  disabled: boolean;
16
19
  readonly group: string;
17
- readonly hitTolerance: boolean;
20
+ readonly hitTolerance: number;
18
21
  readonly key: string;
19
- readonly map: import("ol/Map").default;
22
+ readonly map: import("ol").Map;
20
23
  readonly name: string;
21
- olLayer: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>;
22
- parent: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>;
24
+ olLayer: Layer;
25
+ parent: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
23
26
  visible: boolean;
24
- setMapInternal: ((map: import("ol/Map").default) => void) & ((map: import("ol/Map").default | null) => void);
25
- onChildrenChange(oldValue: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>[]): void;
26
- attachToMap(map: import("ol/Map").default): void;
27
- detachFromMap(): void;
28
- flat(): any[];
29
- addEventListener: (type: string, listener: import("ol/events").Listener) => void;
30
- removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
31
27
  on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
32
- render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
33
28
  once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
34
29
  un: import("ol/layer/Layer").LayerOnSignature<void>;
35
- getSource: () => import("ol/source/Source").default | null;
36
- getRenderSource: () => import("ol/source/Source").default | null;
37
- getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<import("ol/Feature").FeatureLike[]>;
38
- getData: (pixel: import("ol/pixel").Pixel) => Float32Array | Uint8ClampedArray | Uint8Array | DataView | null;
39
- isVisible: (view?: import("ol/View").default | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
40
- getAttributions: (view?: import("ol/View").default | import("ol/View").ViewStateLayerStateExtent | undefined) => string[];
30
+ render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
31
+ getSource: () => import("ol/source").Source | null;
32
+ getRenderSource: () => import("ol/source").Source | null;
33
+ getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<Array<import("ol/Feature").FeatureLike>>;
34
+ getData: (pixel: import("ol/pixel").Pixel) => Uint8ClampedArray | Uint8Array | Float32Array | DataView | null;
35
+ isVisible: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => boolean;
36
+ getAttributions: (view?: import("ol").View | import("ol/View").ViewStateLayerStateExtent | undefined) => Array<string>;
41
37
  unrender: () => void;
42
38
  getDeclutter: () => string;
43
39
  renderDeclutter: (frameState: import("ol/Map").FrameState, layerState: import("ol/layer/Layer").State) => void;
44
40
  renderDeferred: (frameState: import("ol/Map").FrameState) => void;
45
- getMapInternal: () => import("ol/Map").default | null;
46
- setMap: (map: import("ol/Map").default | null) => void;
47
- setSource: (source: import("ol/source/Source").default | null) => void;
41
+ getMapInternal: () => import("ol").default | null;
42
+ setMap: (map: import("ol").default | null) => void;
43
+ setSource: (source: import("ol/source").Source | null) => void;
48
44
  getRenderer: () => import("ol/renderer/Layer").default<any> | null;
49
45
  hasRenderer: () => boolean;
50
- getBackground: () => false | import("ol/layer/Base").BackgroundColor;
46
+ getBackground: () => import("ol/layer/Base").BackgroundColor | false;
51
47
  getClassName: () => string;
52
48
  getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
53
- getLayersArray: (array?: Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Layer<import("ol/source/Source").default, import("ol/renderer/Layer").default<any>>[];
54
- getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => import("ol/layer/Layer").State[];
49
+ getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
50
+ getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
55
51
  getExtent: () => import("ol/extent").Extent | undefined;
56
52
  getMaxResolution: () => number;
57
53
  getMinResolution: () => number;
@@ -71,7 +67,7 @@ declare function MobilityLayerMixin<TBase extends Layerable>(Base: TBase): {
71
67
  setVisible: (visible: boolean) => void;
72
68
  setZIndex: (zindex: number) => void;
73
69
  get: (key: string) => any;
74
- getKeys: () => string[];
70
+ getKeys: () => Array<string>;
75
71
  getProperties: () => {
76
72
  [x: string]: any;
77
73
  };
@@ -89,9 +85,11 @@ declare function MobilityLayerMixin<TBase extends Layerable>(Base: TBase): {
89
85
  unset: (key: string, silent?: boolean | undefined) => void;
90
86
  changed: () => void;
91
87
  getRevision: () => number;
92
- dispatchEvent: (event: string | import("ol/events/Event").default) => boolean | undefined;
93
- getListeners: (type: string) => import("ol/events").Listener[] | undefined;
88
+ addEventListener: (type: string, listener: import("ol/events").Listener) => void;
89
+ dispatchEvent: (event: import("ol/events/Event").default | string) => boolean | undefined;
90
+ getListeners: (type: string) => Array<import("ol/events").Listener> | undefined;
94
91
  hasListener: (type?: string | undefined) => boolean;
92
+ removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
95
93
  dispose: () => void;
96
94
  };
97
95
  } & TBase;