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.
- package/api/HttpAPI.d.ts +5 -16
- package/api/HttpAPI.js +0 -11
- package/api/RealtimeAPI.d.ts +221 -176
- package/api/RealtimeAPI.js +317 -258
- package/api/RoutingAPI.d.ts +21 -11
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +20 -14
- package/api/StopsAPI.js +17 -11
- package/api/WebSocketAPI.d.ts +60 -66
- package/api/WebSocketAPI.js +164 -164
- package/api/index.js +1 -1
- package/api/typedefs.d.ts +0 -102
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +12 -12
- package/common/controls/StopFinderControlCommon.js +31 -31
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +157 -163
- package/common/mixins/RealtimeLayerMixin.js +401 -393
- package/common/styles/realtimeDefaultStyle.js +6 -6
- package/common/styles/realtimeHeadingStyle.js +5 -5
- package/common/typedefs.d.ts +13 -6
- package/common/typedefs.js +7 -1
- package/common/utils/compareDepartures.d.ts +2 -2
- package/common/utils/compareDepartures.js +2 -2
- package/common/utils/debounceWebsocketMessages.d.ts +1 -1
- package/common/utils/getMapGlCopyrights.d.ts +1 -1
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getVehiclePosition.d.ts +5 -4
- package/common/utils/getVehiclePosition.js +9 -3
- package/common/utils/renderTrajectories.d.ts +1 -1
- package/common/utils/renderTrajectories.js +6 -6
- package/common/utils/sortAndFilterDepartures.d.ts +1 -1
- package/common/utils/sortAndFilterDepartures.js +1 -1
- package/common/utils/sortByDelay.d.ts +2 -2
- package/common/utils/sortByDelay.js +5 -1
- package/maplibre/layers/Layer.d.ts +1 -1
- package/maplibre/layers/Layer.js +1 -1
- package/maplibre/layers/RealtimeLayer.d.ts +87 -66
- package/maplibre/layers/RealtimeLayer.js +30 -6
- package/maplibre/utils/getSourceCoordinates.js +5 -5
- package/mbt.js +20988 -13287
- package/mbt.js.map +4 -4
- package/mbt.min.js +61 -58
- package/mbt.min.js.map +4 -4
- package/ol/controls/RoutingControl.d.ts +82 -89
- package/ol/controls/RoutingControl.js +217 -219
- package/ol/controls/StopFinderControl.d.ts +3 -3
- package/ol/controls/StopFinderControl.js +2 -2
- package/ol/index.d.ts +1 -0
- package/ol/index.js +1 -0
- package/ol/layers/Layer.d.ts +101 -0
- package/ol/layers/Layer.js +25 -0
- package/ol/layers/MaplibreLayer.d.ts +121 -24
- package/ol/layers/MaplibreLayer.js +98 -27
- package/ol/layers/MaplibreStyleLayer.d.ts +93 -91
- package/ol/layers/MaplibreStyleLayer.js +281 -257
- package/ol/layers/RealtimeLayer.d.ts +119 -121
- package/ol/layers/RealtimeLayer.js +143 -134
- package/ol/layers/VectorLayer.d.ts +18 -0
- package/ol/layers/VectorLayer.js +32 -0
- package/ol/layers/index.d.ts +2 -0
- package/ol/layers/index.js +3 -0
- package/ol/mixins/MobilityLayerMixin.d.ts +32 -34
- package/ol/mixins/PropertiesLayerMixin.d.ts +60 -51
- package/ol/mixins/PropertiesLayerMixin.js +114 -79
- package/ol/mixins/index.d.ts +1 -0
- package/ol/mixins/index.js +2 -0
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -20
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
- package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
- package/ol/renderers/RealtimeLayerRenderer.d.ts +6 -6
- package/ol/renderers/RealtimeLayerRenderer.js +56 -51
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
- package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
- package/package.json +31 -31
- package/setupTests.js +3 -4
- package/types/common.d.ts +55 -48
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +91 -93
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
- package/ol/layers/MapGlLayer.d.ts +0 -144
- 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
|
-
*
|
|
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 {
|
|
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.
|
|
35
|
+
* @implements {maplibregl.CustomLayerInterface}
|
|
25
36
|
* @extends {maplibregl.Evented}
|
|
37
|
+
* @classproperty {function} filter - Filter out a train. This function must be fast, it is executed for every trajectory on every render frame.
|
|
38
|
+
* @classproperty {RealtimeMode} mode - The realtime mode to use.
|
|
39
|
+
* @classproperty {RealtimeMot[]} mots - Filter trains by its mode of transportation. It filters trains on backend side.
|
|
40
|
+
* @classproperty {RealtimeTenant} tenant - Filter trains by its tenant. It filters trains on backend side.
|
|
41
|
+
* @classproperty {function} sort - Sort trains. This function must be fast, it is executed on every render frame.
|
|
42
|
+
* @classproperty {function} style - Function to style the vehicles.
|
|
43
|
+
s
|
|
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 {
|
|
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 vehicles.
|
|
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,
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export const getSourceCoordinates = (map, pixelRatio = 1) => {
|
|
6
6
|
// Requesting getBounds is not enough when we rotate the map, so we request manually each corner.
|
|
7
|
-
const {
|
|
8
|
-
// @ts-
|
|
7
|
+
const { height, width } = map.getCanvas();
|
|
8
|
+
// @ts-expect-error
|
|
9
9
|
const leftTop = map.unproject({ x: 0, y: 0 });
|
|
10
|
-
// @ts-
|
|
10
|
+
// @ts-expect-error
|
|
11
11
|
const leftBottom = map.unproject({ x: 0, y: height / pixelRatio }); // southWest
|
|
12
|
-
// @ts-
|
|
12
|
+
// @ts-expect-error
|
|
13
13
|
const rightBottom = map.unproject({
|
|
14
14
|
x: width / pixelRatio,
|
|
15
15
|
y: height / pixelRatio,
|
|
16
16
|
});
|
|
17
|
-
// @ts-
|
|
17
|
+
// @ts-expect-error
|
|
18
18
|
const rightTop = map.unproject({ x: width / pixelRatio, y: 0 }); // north east
|
|
19
19
|
return [
|
|
20
20
|
[leftTop.lng, leftTop.lat],
|