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
@@ -8,13 +8,13 @@ import { FilterFunction } from '../../common/typedefs';
8
8
  import { LayerGetFeatureInfoResponse } from '../../types';
9
9
  import MaplibreStyleLayerRenderer from '../renderers/MaplibreStyleLayerRenderer';
10
10
  import MaplibreLayer, { MaplibreLayerOptions } from './MaplibreLayer';
11
- export type MaplibreStyleLayerOptions = MaplibreLayerOptions & {
11
+ export type MaplibreStyleLayerOptions = {
12
12
  beforeId?: string;
13
13
  layers?: maplibregl.AddLayerObject[];
14
14
  layersFilter?: FilterFunction;
15
15
  maplibreLayer?: MaplibreLayer;
16
16
  queryRenderedLayersFilter?: FilterFunction;
17
- };
17
+ } & MaplibreLayerOptions;
18
18
  declare const MaplibreStyleLayer_base: {
19
19
  new (...args: any[]): {
20
20
  olEventsKeys: import("ol/events").EventsKey[];
@@ -106,22 +106,26 @@ declare const MaplibreStyleLayer_base: {
106
106
  };
107
107
  } & typeof Layer;
108
108
  /**
109
- * Layer for visualizing a specific set of layer from a MapboxLayer.
109
+ * Layer that helps show/hide a specific subset of style layers of a [MaplibreLayer](./MaplibreLayer.js~MaplibreLayer.html).
110
110
  *
111
111
  * @example
112
- * import { MapboxLayer, MapboxStyleLayer } from 'mobility-toolbox-js/ol';
112
+ * import { MaplibreLayer, MaplibreStyleLayer } from 'mobility-toolbox-js/ol';
113
113
  *
114
- * const maplibreLayer = new MapboxLayer({
115
- * url: 'https://maps.geops.io/styles/travic_v2/style.json?key=[yourApiKey]',
114
+ * const maplibreLayer = new MaplibreLayer({
115
+ * apiKey: 'yourApiKey',
116
116
  * });
117
117
  *
118
- * const layer = new MapboxStyleLayer({
118
+ * const layer = new MaplibreStyleLayer({
119
119
  * maplibreLayer: maplibreLayer,
120
- * styleLayersFilter: () => {},
120
+ * layersFilter: (layer) => {
121
+ * // show/hide only style layers related to stations
122
+ * return /station/.test(layer.id);
123
+ * },
121
124
  * });
122
125
  *
123
- * @classproperty {ol/Map~Map} map - The map where the layer is displayed.
126
+ * @see <a href="/example/ol-maplibre-style-layer">OpenLayers MaplibreStyle layer example</a>
124
127
  * @extends {ol/layer/Layer~Layer}
128
+ * @public
125
129
  */
126
130
  declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
127
131
  highlightedFeatures: Feature[];
@@ -130,16 +134,16 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
130
134
  * Constructor.
131
135
  *
132
136
  * @param {Object} options
133
- * @param {MapboxLayer} [options.maplibreLayer] The MaplibreLayer to use.
134
- * @param {maplibregl.SourceSpecification[]} [options.sources] The source to add to the style on load.
137
+ * @param {string} [options.beforeId] The style layer id to use when the options.layers property is defined, unsused otherwise.
135
138
  * @param {maplibregl.AddLayerObject[]} [options.layers] The layers to add to the style on load.
136
139
  * @param {FilterFunction} [options.layersFilter] Filter function to decide which style layer to apply visiblity on. If not provided, the 'layers' property is used.
140
+ * @param {MaplibreLayer} [options.maplibreLayer] The MaplibreLayer to use.
137
141
  * @param {FilterFunction} [options.queryRenderedLayersFilter] Filter function to decide which style layer are available for query.
142
+ * @param {{[id: string]:maplibregl.SourceSpecification}} [options.sources] The sources to add to the style on load.
143
+ * @public
138
144
  */
139
145
  constructor(options?: MaplibreStyleLayerOptions);
140
- /** @private */
141
146
  addLayers(): void;
142
- /** @private */
143
147
  addSources(): void;
144
148
  applyLayoutVisibility(evt?: ObjectEvent): void;
145
149
  /**
@@ -149,9 +153,11 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
149
153
  */
150
154
  attachToMap(map: Map): void;
151
155
  /**
152
- * Create a copy of the MapboxStyleLayer.
153
- * @param {Object} newOptions Options to override.
154
- * @return {MapboxStyleLayer} A MapboxStyleLayer.
156
+ * Create a copy of the MaplibreStyleLayer.
157
+ *
158
+ * @param {Object} newOptions Options to override. See constructor.
159
+ * @return {MapboxStyleLayer} A MaplibreStyleLayer.
160
+ * @public
155
161
  */
156
162
  clone(newOptions: MaplibreStyleLayerOptions): MaplibreStyleLayer;
157
163
  createRenderer(): MaplibreStyleLayerRenderer;
@@ -164,33 +170,32 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
164
170
  * Request feature information for a given coordinate.
165
171
  * @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
166
172
  * @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
173
+ * @deprecated Use getFeatureInfoAtCoordinate([layer], coordinate) from mobility-toolbox-ol package instead.
167
174
  */
168
175
  getFeatureInfoAtCoordinate(coordinate: Coordinate): Promise<LayerGetFeatureInfoResponse>;
169
176
  /**
170
177
  * Highlight a list of features.
171
178
  * @param {Array<ol/Feature~Feature>} [features=[]] Features to highlight.
172
- * @private
179
+ * @deprecated Use layer.setFeatureState(features, {hover: true|false}) instead.
173
180
  */
174
181
  highlight(features?: Feature[]): void;
175
182
  /**
176
183
  * On Maplibre map load callback function. Add style layers and dynaimc filters.
177
- * @private
178
184
  */
179
185
  onLoad(): void;
180
- /** @private */
181
186
  removeLayers(): void;
182
- /** @private */
183
187
  removeSources(): void;
184
188
  /**
185
189
  * Select a list of features.
186
190
  * @param {Array<ol/Feature~Feature>} [features=[]] Features to select.
187
- * @private
191
+ * @deprecated Use layer.setFeatureState(features, {selected: true|false}) instead.
188
192
  */
189
193
  select(features?: Feature[]): void;
190
194
  /**
191
- * Set the feature state of the features.
192
- * @param {Array<ol/Feature~Feature>} features
193
- * @param {{[key:string]:boolean}} state The feature state
195
+ * Set the [feature state](https://maplibre.org/maplibre-style-spec/expressions/#feature-state) of the features.
196
+ *
197
+ * @param {ol/Feature~Feature[]} features
198
+ * @param {{[key: string]: any}} state The feature state
194
199
  * @public
195
200
  */
196
201
  setFeatureState(features: Feature[], state: FeatureState): void;
@@ -198,15 +203,18 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
198
203
  * Set if features are hovered or not.
199
204
  * @param {Array<ol/Feature~Feature>} features
200
205
  * @param {boolean} state Is the feature hovered
201
- * @private
206
+ * @deprecated Use layer.setFeatureState(features, {hover: true|false}) instead.
202
207
  */
203
208
  setHoverState(features: Feature[], state: boolean): void;
204
209
  get beforeId(): string;
205
- set beforeId(newValue: string[]);
210
+ set beforeId(newValue: string | undefined);
206
211
  get layers(): maplibregl.AddLayerObject[];
207
212
  set layers(newValue: maplibregl.AddLayerObject[]);
208
213
  get layersFilter(): (layer: maplibregl.LayerSpecification) => boolean;
209
214
  set layersFilter(newValue: (layer: maplibregl.LayerSpecification) => boolean);
215
+ /**
216
+ * @deprecated Use MaplibreStyleLayer.maplibreLayer instead.
217
+ */
210
218
  get mapboxLayer(): MaplibreLayer | undefined;
211
219
  get maplibreLayer(): MaplibreLayer;
212
220
  set maplibreLayer(newValue: MaplibreLayer);
@@ -215,7 +223,7 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
215
223
  get sources(): Record<string, maplibregl.SourceSpecification>;
216
224
  set sources(newValue: Record<string, maplibregl.SourceSpecification>);
217
225
  /**
218
- * @deprecated
226
+ * @deprecated Use MaplibreStyleLayer.layer instead.
219
227
  */
220
228
  get styleLayer(): maplibregl.AddLayerObject;
221
229
  /**
@@ -13,33 +13,39 @@ if (typeof window !== 'undefined' &&
13
13
  }, 1000);
14
14
  }
15
15
  /**
16
- * Layer for visualizing a specific set of layer from a MapboxLayer.
16
+ * Layer that helps show/hide a specific subset of style layers of a [MaplibreLayer](./MaplibreLayer.js~MaplibreLayer.html).
17
17
  *
18
18
  * @example
19
- * import { MapboxLayer, MapboxStyleLayer } from 'mobility-toolbox-js/ol';
19
+ * import { MaplibreLayer, MaplibreStyleLayer } from 'mobility-toolbox-js/ol';
20
20
  *
21
- * const maplibreLayer = new MapboxLayer({
22
- * url: 'https://maps.geops.io/styles/travic_v2/style.json?key=[yourApiKey]',
21
+ * const maplibreLayer = new MaplibreLayer({
22
+ * apiKey: 'yourApiKey',
23
23
  * });
24
24
  *
25
- * const layer = new MapboxStyleLayer({
25
+ * const layer = new MaplibreStyleLayer({
26
26
  * maplibreLayer: maplibreLayer,
27
- * styleLayersFilter: () => {},
27
+ * layersFilter: (layer) => {
28
+ * // show/hide only style layers related to stations
29
+ * return /station/.test(layer.id);
30
+ * },
28
31
  * });
29
32
  *
30
- * @classproperty {ol/Map~Map} map - The map where the layer is displayed.
33
+ * @see <a href="/example/ol-maplibre-style-layer">OpenLayers MaplibreStyle layer example</a>
31
34
  * @extends {ol/layer/Layer~Layer}
35
+ * @public
32
36
  */
33
37
  class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
34
38
  /**
35
39
  * Constructor.
36
40
  *
37
41
  * @param {Object} options
38
- * @param {MapboxLayer} [options.maplibreLayer] The MaplibreLayer to use.
39
- * @param {maplibregl.SourceSpecification[]} [options.sources] The source to add to the style on load.
42
+ * @param {string} [options.beforeId] The style layer id to use when the options.layers property is defined, unsused otherwise.
40
43
  * @param {maplibregl.AddLayerObject[]} [options.layers] The layers to add to the style on load.
41
44
  * @param {FilterFunction} [options.layersFilter] Filter function to decide which style layer to apply visiblity on. If not provided, the 'layers' property is used.
45
+ * @param {MaplibreLayer} [options.maplibreLayer] The MaplibreLayer to use.
42
46
  * @param {FilterFunction} [options.queryRenderedLayersFilter] Filter function to decide which style layer are available for query.
47
+ * @param {{[id: string]:maplibregl.SourceSpecification}} [options.sources] The sources to add to the style on load.
48
+ * @public
43
49
  */
44
50
  constructor(options = {
45
51
  mapLibreOptions: { style: { layers: [], sources: {}, version: 8 } },
@@ -69,9 +75,7 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
69
75
  super(Object.assign({ source: new Source({}) }, options));
70
76
  this.highlightedFeatures = [];
71
77
  this.selectedFeatures = [];
72
- /**
73
- * @private
74
- */
78
+ this.beforeId = options.beforeId;
75
79
  this.onLoad = this.onLoad.bind(this);
76
80
  if (!this.layersFilter && this.layers) {
77
81
  this.layersFilter = (layer) => {
@@ -79,7 +83,6 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
79
83
  };
80
84
  }
81
85
  }
82
- /** @private */
83
86
  addLayers() {
84
87
  var _a;
85
88
  if (!((_a = this.maplibreLayer) === null || _a === void 0 ? void 0 : _a.mapLibreMap) || !Array.isArray(this.layers)) {
@@ -99,7 +102,6 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
99
102
  this.applyLayoutVisibility();
100
103
  }
101
104
  }
102
- /** @private */
103
105
  addSources() {
104
106
  var _a;
105
107
  if (!((_a = this.maplibreLayer) === null || _a === void 0 ? void 0 : _a.mapLibreMap) || !this.sources) {
@@ -198,9 +200,11 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
198
200
  }));
199
201
  }
200
202
  /**
201
- * Create a copy of the MapboxStyleLayer.
202
- * @param {Object} newOptions Options to override.
203
- * @return {MapboxStyleLayer} A MapboxStyleLayer.
203
+ * Create a copy of the MaplibreStyleLayer.
204
+ *
205
+ * @param {Object} newOptions Options to override. See constructor.
206
+ * @return {MapboxStyleLayer} A MaplibreStyleLayer.
207
+ * @public
204
208
  */
205
209
  clone(newOptions) {
206
210
  return new MaplibreStyleLayer(Object.assign(Object.assign({}, this.options), newOptions));
@@ -225,6 +229,7 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
225
229
  * Request feature information for a given coordinate.
226
230
  * @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
227
231
  * @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
232
+ * @deprecated Use getFeatureInfoAtCoordinate([layer], coordinate) from mobility-toolbox-ol package instead.
228
233
  */
229
234
  getFeatureInfoAtCoordinate(coordinate) {
230
235
  var _a;
@@ -241,6 +246,7 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
241
246
  let layers = this.layers || [];
242
247
  if (this.layersFilter) {
243
248
  layers = mapLibreMap.getStyle().layers.filter(this.layersFilter);
249
+ console.log(layers);
244
250
  }
245
251
  if (this.queryRenderedLayersFilter) {
246
252
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -275,11 +281,11 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
275
281
  /**
276
282
  * Highlight a list of features.
277
283
  * @param {Array<ol/Feature~Feature>} [features=[]] Features to highlight.
278
- * @private
284
+ * @deprecated Use layer.setFeatureState(features, {hover: true|false}) instead.
279
285
  */
280
286
  highlight(features = []) {
281
287
  var _a;
282
- deprecated(`Deprecated. Use layer.setFeatureState(features, {highlighted: true}) instead.`);
288
+ deprecated(`Deprecated. Use layer.setFeatureState(features, {hover: true}) instead.`);
283
289
  // Filter out selected features
284
290
  const filtered = ((_a = this.highlightedFeatures) === null || _a === void 0 ? void 0 : _a.filter((feature) => !(this.selectedFeatures || [])
285
291
  .map((feat) => feat.getId())
@@ -292,7 +298,6 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
292
298
  }
293
299
  /**
294
300
  * On Maplibre map load callback function. Add style layers and dynaimc filters.
295
- * @private
296
301
  */
297
302
  onLoad() {
298
303
  var _a;
@@ -309,7 +314,6 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
309
314
  }
310
315
  this.applyLayoutVisibility();
311
316
  }
312
- /** @private */
313
317
  removeLayers() {
314
318
  var _a;
315
319
  if (!((_a = this.maplibreLayer) === null || _a === void 0 ? void 0 : _a.mapLibreMap) || !Array.isArray(this.layers)) {
@@ -325,7 +329,6 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
325
329
  });
326
330
  }
327
331
  }
328
- /** @private */
329
332
  removeSources() {
330
333
  var _a;
331
334
  if (!((_a = this.maplibreLayer) === null || _a === void 0 ? void 0 : _a.mapLibreMap) || !this.sources) {
@@ -343,7 +346,7 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
343
346
  /**
344
347
  * Select a list of features.
345
348
  * @param {Array<ol/Feature~Feature>} [features=[]] Features to select.
346
- * @private
349
+ * @deprecated Use layer.setFeatureState(features, {selected: true|false}) instead.
347
350
  */
348
351
  select(features = []) {
349
352
  deprecated(`Deprecated. Use layer.setFeatureState(features, {selected: true}) instead.`);
@@ -352,9 +355,10 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
352
355
  this.setHoverState(this.selectedFeatures || [], true);
353
356
  }
354
357
  /**
355
- * Set the feature state of the features.
356
- * @param {Array<ol/Feature~Feature>} features
357
- * @param {{[key:string]:boolean}} state The feature state
358
+ * Set the [feature state](https://maplibre.org/maplibre-style-spec/expressions/#feature-state) of the features.
359
+ *
360
+ * @param {ol/Feature~Feature[]} features
361
+ * @param {{[key: string]: any}} state The feature state
358
362
  * @public
359
363
  */
360
364
  setFeatureState(features, state) {
@@ -382,7 +386,7 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
382
386
  * Set if features are hovered or not.
383
387
  * @param {Array<ol/Feature~Feature>} features
384
388
  * @param {boolean} state Is the feature hovered
385
- * @private
389
+ * @deprecated Use layer.setFeatureState(features, {hover: true|false}) instead.
386
390
  */
387
391
  setHoverState(features, state) {
388
392
  deprecated(`Deprecated. Use layer.setFeatureState(features, {hover: ${state}}) instead.`);
@@ -406,6 +410,9 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
406
410
  set layersFilter(newValue) {
407
411
  this.set('layersFilter', newValue);
408
412
  }
413
+ /**
414
+ * @deprecated Use MaplibreStyleLayer.maplibreLayer instead.
415
+ */
409
416
  get mapboxLayer() {
410
417
  deprecated('Deprecated. Use maplibreLayer instead.');
411
418
  return this.get('maplibreLayer');
@@ -445,10 +452,10 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
445
452
  this.set('sources', newValue);
446
453
  }
447
454
  /**
448
- * @deprecated
455
+ * @deprecated Use MaplibreStyleLayer.layer instead.
449
456
  */
450
457
  get styleLayer() {
451
- deprecated('MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead.');
458
+ deprecated('Deprecated. Use MaplibreStyleLayer.layer instead.');
452
459
  return this.layers[0];
453
460
  }
454
461
  /**
@@ -1,92 +1,23 @@
1
+ import { DebouncedFunc } from 'lodash';
1
2
  import { Map, MapEvent } from 'ol';
2
3
  import Feature, { FeatureLike } from 'ol/Feature';
3
- import GeoJSON from 'ol/format/GeoJSON';
4
4
  import { Vector as VectorLayer } from 'ol/layer';
5
5
  import Layer from 'ol/layer/Layer';
6
6
  import { ObjectEvent } from 'ol/Object';
7
+ import { Vector as VectorSource } from 'ol/source';
7
8
  import Source from 'ol/source/Source';
9
+ import { State } from 'ol/View';
8
10
  import { WebSocketAPIMessageEventData } from '../../api/WebSocketAPI';
9
- import { RealtimeLayerMixinOptions } from '../../common/mixins/RealtimeLayerMixin';
10
- import { RealtimeFullTrajectory, RealtimeTrainId, RealtimeTrajectory, ViewState } from '../../types';
11
+ import RealtimeEngine, { RealtimeEngineOptions } from '../../common/utils/RealtimeEngine';
12
+ import { RealtimeAPI } from '../../maplibre';
13
+ import { RealtimeFullTrajectory, RealtimeMode, RealtimeRenderState, RealtimeTrainId, ViewState } from '../../types';
11
14
  import RealtimeLayerRenderer from '../renderers/RealtimeLayerRenderer';
12
- export type RealtimeLayerOptions = RealtimeLayerMixinOptions & {
15
+ export type RealtimeLayerOptions = {
13
16
  allowRenderWhenAnimating?: boolean;
14
17
  fullTrajectoryStyle?: (feature: FeatureLike, resolution: number, options: any) => void;
15
- };
18
+ maxNbFeaturesRequested?: number;
19
+ } & RealtimeEngineOptions;
16
20
  declare const RealtimeLayer_base: {
17
- new (options: RealtimeLayerMixinOptions): {
18
- [x: string]: any;
19
- [x: symbol]: any;
20
- api: import("..").RealtimeAPI;
21
- bboxParameters?: Record<string, boolean | boolean[] | number | number[] | string | string[]>;
22
- canvas?: import("../../types").AnyCanvas;
23
- debounceRenderTrajectories: (viewState: ViewState, noInterpolate?: boolean) => void;
24
- debug: boolean;
25
- filter?: import("../../common/typedefs").FilterFunction;
26
- format: GeoJSON;
27
- generalizationLevel?: import("../../types").RealtimeGeneralizationLevel;
28
- generalizationLevelByZoom: import("../../types").RealtimeGeneralizationLevel[];
29
- getGeneralizationLevelByZoom: (zoom: number) => import("../../types").RealtimeGeneralizationLevel;
30
- getMotsByZoom: (zoom: number) => import("../../types").RealtimeMot[];
31
- getRenderTimeIntervalByZoom: (zoom: number) => number;
32
- hoverVehicleId?: RealtimeTrainId;
33
- isUpdateBboxOnMoveEnd: boolean;
34
- live?: boolean;
35
- minZoomInterpolation: number;
36
- mode: import("../../types").RealtimeMode;
37
- mots?: import("../../types").RealtimeMot[];
38
- motsByZoom: import("../../types").RealtimeMot[][];
39
- onStart?: ((realtimeLayer: import("../../types").AnyLayer) => void) | undefined;
40
- onStop?: ((realtimeLayer: import("../../types").AnyLayer) => void) | undefined;
41
- pixelRatio?: number;
42
- renderState?: import("../../types").RealtimeRenderState;
43
- renderTimeIntervalByZoom: number[];
44
- requestId?: number;
45
- selectedVehicle: RealtimeTrajectory;
46
- selectedVehicleId?: RealtimeTrainId;
47
- sort?: import("../../common/typedefs").SortFunction;
48
- speed?: number;
49
- style?: import("../../types").RealtimeStyleFunction;
50
- styleOptions?: import("../../types").RealtimeStyleOptions;
51
- tenant: import("../../types").RealtimeTenant;
52
- throttleRenderTrajectories: (viewState: ViewState, noInterpolate?: boolean) => void;
53
- time?: Date;
54
- trajectories?: Record<RealtimeTrainId, RealtimeTrajectory>;
55
- updateTimeDelay?: number;
56
- updateTimeInterval?: number;
57
- useDebounce?: boolean;
58
- useRequestAnimationFrame?: boolean;
59
- useThrottle?: boolean;
60
- visibilityRef: import("ol/events").EventsKey;
61
- addTrajectory(trajectory: RealtimeTrajectory): void;
62
- attachToMap(map: import("../../types").AnyMap): void;
63
- defineProperties(options: RealtimeLayerMixinOptions): void;
64
- detachFromMap(): void;
65
- getFeatureInfoAtCoordinate(coordinate: import("ol/coordinate").Coordinate, options: import("../../types").LayerGetFeatureInfoOptions): Promise<import("../../types").LayerGetFeatureInfoResponse>;
66
- getRefreshTimeInMs(zoom?: number | undefined): number;
67
- getTrajectoryInfos(id: RealtimeTrainId): Promise<{
68
- fullTrajectory: WebSocketAPIMessageEventData<import("../../types").RealtimeStopSequence[]> | WebSocketAPIMessageEventData<RealtimeFullTrajectory>;
69
- stopSequence: WebSocketAPIMessageEventData<import("../../types").RealtimeStopSequence[]> | WebSocketAPIMessageEventData<RealtimeFullTrajectory>;
70
- }>;
71
- getVehicle(filterFc: import("../../common/typedefs").FilterFunction): RealtimeTrajectory[];
72
- highlightVehicle(id: RealtimeTrainId): void;
73
- onDeleteTrajectoryMessage(data: WebSocketAPIMessageEventData<RealtimeTrainId>): void;
74
- onDocumentVisibilityChange(): void;
75
- onTrajectoryMessage(data: WebSocketAPIMessageEventData<RealtimeTrajectory>): void;
76
- onZoomEnd(): void;
77
- purgeOutOfDateTrajectories(): void;
78
- purgeTrajectory(trajectory: RealtimeTrajectory, extent: [number, number, number, number], zoom: number): boolean;
79
- removeTrajectory(trajectoryOrId: RealtimeTrainId | RealtimeTrajectory): void;
80
- renderTrajectories(viewState: undefined | ViewState, noInterpolate: boolean | undefined): void;
81
- renderTrajectoriesInternal(viewState: ViewState, noInterpolate?: boolean): boolean;
82
- selectVehicle(id: RealtimeTrainId): void;
83
- setBbox(extent: [number, number, number, number], zoom: number): void;
84
- start(): void;
85
- startUpdateTime(): void;
86
- stop(): void;
87
- stopUpdateTime(): void;
88
- };
89
- } & {
90
21
  new (...args: any[]): {
91
22
  olEventsKeys: import("ol/events").EventsKey[];
92
23
  options?: import("../mixins/PropertiesLayerMixin").PropertiesLayerMixinOptions;
@@ -190,94 +121,114 @@ declare const RealtimeLayer_base: {
190
121
  *
191
122
  *
192
123
  * @see <a href="/api/class/src/api/RealtimeAPI%20js~RealtimeAPI%20html">RealtimeAPI</a>
124
+ * @see <a href="/example/ol-realtime">OpenLayers Realtime layer example</a>
125
+ *
193
126
  *
194
127
  * @extends {ol/layer/Layer~Layer}
195
128
  *
129
+ *
196
130
  * @classproperty {boolean} allowRenderWhenAnimating - Allow rendering of the layer when the map is animating.
197
131
  * @public
198
132
  */
199
133
  declare class RealtimeLayer extends RealtimeLayer_base {
200
- /** @private */
201
134
  allowRenderWhenAnimating?: boolean;
202
- vectorLayer: VectorLayer<Feature>;
135
+ currentZoom?: number;
136
+ engine: RealtimeEngine;
137
+ maxNbFeaturesRequested: number;
138
+ onMoveEndDebounced: DebouncedFunc<(evt: MapEvent | ObjectEvent) => void>;
139
+ onZoomEndDebounced: DebouncedFunc<(evt: MapEvent | ObjectEvent) => void>;
140
+ renderedViewState: State | undefined;
141
+ vectorLayer: VectorLayer<VectorSource>;
203
142
  /**
204
143
  * Constructor.
205
144
  *
206
145
  * @param {RealtimeLayerOptions} options
207
146
  * @param {boolean} [options.allowRenderWhenAnimating=false] Allow rendering of the layer when the map is animating.
208
- * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
209
- * @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The geOps Realtime API url.
210
- *
147
+ * @param {string} options.apiKey Access key for [geOps APIs](https://developer.geops.io/).
148
+ * @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The [geOps Realtime API](https://developer.geops.io/apis/realtime/) url.
149
+ * @public
211
150
  */
212
151
  constructor(options: RealtimeLayerOptions);
213
- /** @private */
214
152
  attachToMap(map: Map): void;
215
153
  /**
216
154
  * Create a copy of the RealtimeLayer.
217
- * @param {Object} newOptions Options to override
155
+ *
156
+ * @param {Object} newOptions Options to override. See constructor.
218
157
  * @return {RealtimeLayer} A RealtimeLayer
158
+ * @public
219
159
  */
220
160
  clone(newOptions: RealtimeLayerOptions): RealtimeLayer;
221
- /**
222
- * @private
223
- */
224
161
  createRenderer(): RealtimeLayerRenderer;
225
- /**
226
- * Render the trajectories using current map's size, resolution and rotation.
227
- * @param {boolean} noInterpolate if true, renders the vehicles without interpolating theirs positions.
228
- * @overrides
229
- * @private
230
- */
231
162
  /**
232
163
  * Destroy the container of the tracker.
233
- * @private
234
164
  */
235
165
  detachFromMap(): void;
236
166
  /**
237
- * Return the delay in ms before the next rendering.
238
- * @private
239
- */
240
- getRefreshTimeInMs(): number;
241
- highlight(feature: Feature): void;
242
- /**
243
- * On move end we update the websocket with the new bbox.
167
+ * Get some informations about a trajectory.
244
168
  *
245
- * @private
246
- * @override
169
+ * @param {RealtimeTrainId} id A vehicle's id.
170
+ * @returns
247
171
  */
172
+ getTrajectoryInfos(id: RealtimeTrainId): Promise<{
173
+ fullTrajectory: WebSocketAPIMessageEventData<RealtimeFullTrajectory> | WebSocketAPIMessageEventData<import("../../types").RealtimeStopSequence[]>;
174
+ stopSequence: WebSocketAPIMessageEventData<RealtimeFullTrajectory> | WebSocketAPIMessageEventData<import("../../types").RealtimeStopSequence[]>;
175
+ }>;
176
+ getViewState(): {
177
+ center?: undefined;
178
+ extent?: undefined;
179
+ pixelRatio?: undefined;
180
+ resolution?: undefined;
181
+ rotation?: undefined;
182
+ size?: undefined;
183
+ visible?: undefined;
184
+ zoom?: undefined;
185
+ } | {
186
+ center: import("ol/coordinate").Coordinate | undefined;
187
+ extent: import("ol/extent").Extent;
188
+ pixelRatio: number | undefined;
189
+ resolution: number | undefined;
190
+ rotation: number;
191
+ size: import("ol/size").Size | undefined;
192
+ visible: boolean;
193
+ zoom: number | undefined;
194
+ };
195
+ highlight(feature: Feature): void;
248
196
  /**
249
197
  * Highlight the trajectory of journey.
250
- * @private
251
198
  */
252
199
  highlightTrajectory(id: RealtimeTrainId): Promise<Feature[] | undefined>;
200
+ onMoveEnd(): void;
253
201
  /**
254
- * Function called on moveend event only when the zoom has changed.
255
- *
256
- * @param {ol/MapEvent~MapEvent} evt Moveend event.
257
- * @private
258
- * @override
202
+ * Callback when the RealtimeEngine has rendered successfully.
259
203
  */
260
- onMoveEnd(evt: MapEvent | ObjectEvent): void;
204
+ onRealtimeEngineRender(renderState: RealtimeRenderState, viewState: ViewState): void;
261
205
  onZoomEnd(): void;
206
+ select(feature: Feature): void;
207
+ shouldRender(): boolean;
262
208
  /**
263
- * Remove the trajectory form the list if necessary.
209
+ * Start the rendering.
264
210
  *
265
- * @private
211
+ * @public
266
212
  */
267
- purgeTrajectory(trajectory: RealtimeTrajectory, extent: [number, number, number, number], zoom: number): boolean;
268
- renderTrajectories(noInterpolate: boolean): void;
269
- /**
270
- * Launch renderTrajectories. it avoids duplicating code in renderTrajectories methhod.
271
- * @private
272
- * @override
273
- */
274
- renderTrajectoriesInternal(viewState: ViewState, noInterpolate: boolean): boolean;
275
- select(feature: Feature): void;
213
+ start(): void;
276
214
  /**
277
- * Send the current bbox to the websocket
215
+ * Stop the rendering.
278
216
  *
279
- * @private
217
+ * @public
280
218
  */
281
- setBbox(extent?: [number, number, number, number], zoom?: number): void;
219
+ stop(): void;
220
+ get api(): RealtimeAPI;
221
+ set api(api: RealtimeAPI);
222
+ get canvas(): import("../../types").AnyCanvas | undefined;
223
+ get filter(): Function | undefined;
224
+ get hoverVehicleId(): RealtimeTrainId | undefined;
225
+ set hoverVehicleId(id: RealtimeTrainId);
226
+ get mode(): RealtimeMode;
227
+ set mode(mode: RealtimeMode);
228
+ get pixelRatio(): number | undefined;
229
+ get selectedVehicleId(): RealtimeTrainId | undefined;
230
+ set selectedVehicleId(id: RealtimeTrainId);
231
+ get sort(): Function | undefined;
232
+ get trajectories(): Record<string, import("../../types").RealtimeTrajectory> | undefined;
282
233
  }
283
234
  export default RealtimeLayer;