mobility-toolbox-js 3.0.0-beta.10 → 3.0.0-beta.12

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 (54) hide show
  1. package/api/RealtimeAPI.d.ts +30 -24
  2. package/api/RealtimeAPI.js +25 -18
  3. package/api/RoutingAPI.d.ts +17 -7
  4. package/api/RoutingAPI.js +17 -7
  5. package/api/StopsAPI.d.ts +4 -4
  6. package/api/StopsAPI.js +4 -4
  7. package/api/WebSocketAPI.d.ts +2 -2
  8. package/api/WebSocketAPI.js +2 -2
  9. package/api/typedefs.d.ts +0 -102
  10. package/api/typedefs.js +27 -42
  11. package/common/controls/StopFinderControlCommon.d.ts +1 -1
  12. package/common/controls/StopFinderControlCommon.js +1 -1
  13. package/common/mixins/RealtimeLayerMixin.d.ts +10 -11
  14. package/common/mixins/RealtimeLayerMixin.js +17 -9
  15. package/common/typedefs.d.ts +7 -0
  16. package/common/typedefs.js +6 -0
  17. package/common/utils/compareDepartures.d.ts +2 -2
  18. package/common/utils/compareDepartures.js +2 -2
  19. package/common/utils/debounceWebsocketMessages.d.ts +1 -1
  20. package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
  21. package/common/utils/getRealtimeModeSuffix.js +1 -0
  22. package/common/utils/getVehiclePosition.d.ts +3 -2
  23. package/common/utils/getVehiclePosition.js +9 -3
  24. package/common/utils/renderTrajectories.d.ts +1 -1
  25. package/common/utils/renderTrajectories.js +1 -1
  26. package/common/utils/sortAndFilterDepartures.d.ts +1 -1
  27. package/common/utils/sortAndFilterDepartures.js +1 -1
  28. package/common/utils/sortByDelay.d.ts +2 -2
  29. package/common/utils/sortByDelay.js +5 -1
  30. package/maplibre/layers/Layer.d.ts +1 -1
  31. package/maplibre/layers/Layer.js +1 -1
  32. package/maplibre/layers/RealtimeLayer.d.ts +43 -14
  33. package/maplibre/layers/RealtimeLayer.js +30 -6
  34. package/mbt.js +5500 -6796
  35. package/mbt.js.map +4 -4
  36. package/mbt.min.js +67 -67
  37. package/mbt.min.js.map +4 -4
  38. package/ol/controls/RoutingControl.d.ts +1 -1
  39. package/ol/controls/RoutingControl.js +1 -1
  40. package/ol/controls/StopFinderControl.d.ts +1 -1
  41. package/ol/controls/StopFinderControl.js +1 -1
  42. package/ol/layers/{MapGlLayer.d.ts → Layer.d.ts} +23 -66
  43. package/ol/layers/Layer.js +17 -0
  44. package/ol/layers/MaplibreLayer.d.ts +133 -13
  45. package/ol/layers/MaplibreLayer.js +136 -13
  46. package/ol/layers/MaplibreStyleLayer.d.ts +8 -2
  47. package/ol/layers/MaplibreStyleLayer.js +37 -22
  48. package/ol/layers/RealtimeLayer.d.ts +17 -14
  49. package/ol/layers/RealtimeLayer.js +2 -2
  50. package/ol/layers/index.d.ts +1 -0
  51. package/ol/layers/index.js +1 -0
  52. package/ol/renderers/RealtimeLayerRenderer.js +4 -1
  53. package/package.json +14 -15
  54. package/ol/layers/MapGlLayer.js +0 -144
@@ -8,21 +8,39 @@ import Layer from './Layer';
8
8
  import { getSourceCoordinates } from '../utils';
9
9
  import toMercatorExtent from '../../common/utils/toMercatorExtent';
10
10
  /**
11
- * Responsible for loading and display data from a geOps realtime API.
11
+ * A Maplibre layer able to display data from the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
12
12
  *
13
13
  * @example
14
- * import { RealtimeLayer } from 'mobility-toolbox-js/Maplibre';
14
+ * import { Map } from 'maplibre-gl';
15
+ * import { RealtimeLayer } from 'mobility-toolbox-js/maplibre';
15
16
  *
17
+ * // Define the map
18
+ * const map = new Map({ ... });
19
+ *
20
+ * // Define your layer map
16
21
  * const layer = new RealtimeLayer({
17
22
  * apiKey: "yourApiKey"
18
23
  * // url: "wss://api.geops.io/tracker-ws/v1/",
19
24
  * });
20
25
  *
26
+ * // Add the layer to your map *
27
+ * map.on('load', () => {
28
+ * map.addLayer(layer);
29
+ * });
30
+ *
21
31
  *
22
32
  * @see <a href="/api/class/src/api/RealtimeAPI%20js~RealtimeAPI%20html">RealtimeAPI</a>
33
+ * @see <a href="/example/mb-realtime>Live example</a>
23
34
  *
24
- * @implements {maplibregl.CustomLayer}
35
+ * @implements {maplibregl.CustomLayerInterface}
25
36
  * @extends {maplibregl.Evented}
37
+ * @classproperty {function} filter
38
+ * @classproperty {RealtimeMode} mode
39
+ * @classproperty {RealtimeMot[]} mots
40
+ * @classproperty {RealtimeTenant} tenant
41
+ * @classproperty {function} sort
42
+ * @classproperty {function} style
43
+
26
44
  * @public
27
45
  */
28
46
  class RealtimeLayer extends RealtimeLayerMixin(Layer) {
@@ -31,13 +49,19 @@ class RealtimeLayer extends RealtimeLayerMixin(Layer) {
31
49
  *
32
50
  * @param {RealtimeLayerOptions} options
33
51
  * @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
34
- * @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The geOps realtime API url.
35
- *
52
+ * @param {FilterFunction} options.filter Filter out a train. This function must be fast, it is executed for every trajectory on every render frame.
53
+ * @param {getMotsByZoomFunction} options.getMotsByZoom Returns for each zoom level the list of MOTs to display. It filters trains on backend side.
54
+ * @param {number} [options.minZoomInterpolation=8] Minimal zoom level where to start to interpolate train positions.
55
+ * @param {RealtimeMode} [options.mode='topographic'] The realtime mode to use.
56
+ * @param {SortFunction} options.sort Sort trains. This function must be fast, it is executed on every render frame.
57
+ * @param {RealtimeStyleFunction} options.style Function to style the trajectories.
58
+ * @param {RealtimeTenant} options.tenant Filter trains by its tenant. It filters trains on backend side.
59
+ * @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The geOps Realtime API url.
36
60
  */
37
61
  constructor(options = {}) {
38
62
  var _a;
39
63
  const canvas = document.createElement('canvas');
40
- super(Object.assign({ canvas }, options));
64
+ super(Object.assign({ canvas, id: 'realtime' }, options));
41
65
  /** @private */
42
66
  this.source = {
43
67
  id: this.id,