mobility-toolbox-js 2.0.0-beta.59 → 2.0.0-beta.60
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/README.md +1 -9
- package/api/RealtimeAPI.d.ts +5 -5
- package/api/RealtimeAPI.d.ts.map +1 -1
- package/api/RealtimeAPI.js +16 -20
- package/common/mixins/RealtimeLayerMixin.d.ts +5 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -1
- package/common/mixins/RealtimeLayerMixin.js +35 -5
- package/common/utils/getMapboxRender.d.ts +1 -1
- package/common/utils/getMapboxRender.d.ts.map +1 -1
- package/common/utils/getMapboxRender.js +5 -1
- package/common/utils/getMaplibreRender.d.ts.map +1 -1
- package/common/utils/getMaplibreRender.js +4 -1
- package/common/utils/getRealtimeModeSuffix.d.ts +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -1
- package/common/utils/getRealtimeModeSuffix.js +2 -8
- package/mapbox/layers/RealtimeLayer.d.ts +2 -5
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -1
- package/mbt.js +49 -33
- package/mbt.js.map +2 -2
- package/mbt.min.js +2 -2
- package/mbt.min.js.map +2 -2
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -1
- package/ol/layers/MapboxStyleLayer.js +3 -2
- package/ol/layers/RealtimeLayer.d.ts +2 -1
- package/ol/layers/RealtimeLayer.d.ts.map +1 -1
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -22,16 +22,8 @@ Visit https://mobility-toolbox-js.vercel.app/
|
|
|
22
22
|
|
|
23
23
|
Install the library and the peer dependencies:
|
|
24
24
|
|
|
25
|
-
### Using mapbox-gl
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
yarn add mobility-toolbox-js ol@6.14.1 mapbox-gl@1 maplibre-gl@npm:empty-npm-package@1.0.0
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Using maplibre-gl
|
|
32
|
-
|
|
33
25
|
```bash
|
|
34
|
-
yarn add mobility-toolbox-js ol@6.14.1
|
|
26
|
+
yarn add mobility-toolbox-js ol@6.14.1 mapbox-gl@1 maplibre-gl@2
|
|
35
27
|
```
|
|
36
28
|
|
|
37
29
|
## Development
|
package/api/RealtimeAPI.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import WebSocketAPI, { WebSocketAPIMessageCallback, WebSocketAPIMessageEventData } from '../common/api/WebSocketAPI';
|
|
2
|
-
import { RealtimeMode, RealtimeDeparture, RealtimeNews, RealtimeStation, RealtimeExtraGeom, RealtimeTrainId, RealtimeGeneralizationLevel, RealtimeFullTrajectory, RealtimeTrajectoryResponse, RealtimeStationId
|
|
2
|
+
import { RealtimeMode, RealtimeDeparture, RealtimeNews, RealtimeStation, RealtimeExtraGeom, RealtimeTrainId, RealtimeGeneralizationLevel, RealtimeFullTrajectory, RealtimeTrajectoryResponse, RealtimeStationId } from '../types';
|
|
3
3
|
import { StopSequence } from './typedefs';
|
|
4
4
|
export declare type RealtimeAPIOptions = {
|
|
5
5
|
url?: string;
|
|
6
6
|
apiKey?: string;
|
|
7
|
-
|
|
7
|
+
prefix?: string;
|
|
8
8
|
projection?: string;
|
|
9
9
|
bbox?: (number | string)[];
|
|
10
10
|
buffer?: number[];
|
|
@@ -57,7 +57,7 @@ declare class RealtimeAPI {
|
|
|
57
57
|
projection?: string;
|
|
58
58
|
bbox?: (number | string)[];
|
|
59
59
|
buffer?: number[];
|
|
60
|
-
|
|
60
|
+
prefix: string;
|
|
61
61
|
pingInterval: number;
|
|
62
62
|
pingIntervalMs: number;
|
|
63
63
|
reconnectTimeout?: number;
|
|
@@ -68,7 +68,7 @@ declare class RealtimeAPI {
|
|
|
68
68
|
* @param {Object|string} options A string representing the url of the service or an object containing the url and the apiKey.
|
|
69
69
|
* @param {string} options.url Url to the [geOps realtime api](https://developer.geops.io/apis/realtime/).
|
|
70
70
|
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
71
|
-
* @param {string} [options.
|
|
71
|
+
* @param {string} [options.prefix=''] Service prefix to specify tenant.
|
|
72
72
|
* @param {string} [options.projection] The epsg code of the projection for features. Default to EPSG:3857.
|
|
73
73
|
* @param {number[4]} [options.bbox=[minX, minY, maxX, maxY, zoom, tenant] The bounding box to receive data from.
|
|
74
74
|
*/
|
|
@@ -151,7 +151,7 @@ declare class RealtimeAPI {
|
|
|
151
151
|
*/
|
|
152
152
|
getStation(uic: RealtimeStationId, mode: RealtimeMode): Promise<WebSocketAPIMessageEventData<RealtimeStation>>;
|
|
153
153
|
/**
|
|
154
|
-
* Get the list of
|
|
154
|
+
* Get the list of ststions available for a specifc mode. The promise is resolved every 100ms
|
|
155
155
|
* @param {RealtimeMode} mode Realtime mode.
|
|
156
156
|
* @param {number} timeout = 100 Duration in ms between each promise resolve calls.
|
|
157
157
|
* @return {Promise<RealtimeStation[]>} An array of stations.
|
package/api/RealtimeAPI.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealtimeAPI.d.ts","sourceRoot":"","sources":["../../src/api/RealtimeAPI.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EACnB,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,2BAA2B,EAC3B,sBAAsB,EACtB,0BAA0B,EAC1B,iBAAiB,
|
|
1
|
+
{"version":3,"file":"RealtimeAPI.d.ts","sourceRoot":"","sources":["../../src/api/RealtimeAPI.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,EAAE,EACnB,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,2BAA2B,EAC3B,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AAE,OAAe;IAUxB;;;;;OAKG;IACH,yBAAyB,CACvB,EAAE,EAAE,eAAe,EACnB,SAAS,CAAC,EAAE,2BAA2B,CAAC,sBAAsB,CAAC;IAKjE;;;;;OAKG;IACH,eAAe,CACb,EAAE,EAAE,eAAe,GAClB,OAAO,CAAC,4BAA4B,CAAC,YAAY,EAAE,CAAC,CAAC;IAYxD;;;;;;;OAOG;IACH,qBAAqB,CACnB,EAAE,EAAE,eAAe,EACnB,SAAS,EAAE,2BAA2B,CAAC,YAAY,EAAE,CAAC,EACtD,OAAO,GAAE,aAAwB,EACjC,KAAK,GAAE,OAAe;IAKxB;;;;;OAKG;IACH,uBAAuB,CACrB,EAAE,EAAE,eAAe,EACnB,SAAS,CAAC,EAAE,2BAA2B,CAAC,YAAY,EAAE,CAAC;IAKzD;;;;;OAKG;IACH,oBAAoB,CAClB,SAAS,EAAE,2BAA2B,CAAC,MAAM,CAAC,EAC9C,OAAO,GAAE,aAAwB,EACjC,KAAK,GAAE,OAAe;IAKxB;;;OAGG;IACH,sBAAsB,CAAC,SAAS,CAAC,EAAE,2BAA2B,CAAC,MAAM,CAAC;CAGvE;AACD,eAAe,WAAW,CAAC"}
|
package/api/RealtimeAPI.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import WebSocketAPI from '../common/api/WebSocketAPI';
|
|
2
2
|
import debounceWebsocketMessages from '../common/utils/debounceWebsocketMessages';
|
|
3
|
-
import
|
|
3
|
+
import getModeSuffix from '../common/utils/getRealtimeModeSuffix';
|
|
4
4
|
/**
|
|
5
5
|
* Enum for Realtime modes.
|
|
6
6
|
* @readonly
|
|
@@ -38,14 +38,14 @@ class RealtimeAPI {
|
|
|
38
38
|
* @param {Object|string} options A string representing the url of the service or an object containing the url and the apiKey.
|
|
39
39
|
* @param {string} options.url Url to the [geOps realtime api](https://developer.geops.io/apis/realtime/).
|
|
40
40
|
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
41
|
-
* @param {string} [options.
|
|
41
|
+
* @param {string} [options.prefix=''] Service prefix to specify tenant.
|
|
42
42
|
* @param {string} [options.projection] The epsg code of the projection for features. Default to EPSG:3857.
|
|
43
43
|
* @param {number[4]} [options.bbox=[minX, minY, maxX, maxY, zoom, tenant] The bounding box to receive data from.
|
|
44
44
|
*/
|
|
45
45
|
constructor(options = {}) {
|
|
46
46
|
this.defineProperties(options);
|
|
47
47
|
/** @ignore */
|
|
48
|
-
this.
|
|
48
|
+
this.prefix = options.prefix || '';
|
|
49
49
|
/** @ignore */
|
|
50
50
|
this.onOpen = this.onOpen.bind(this);
|
|
51
51
|
}
|
|
@@ -219,9 +219,9 @@ class RealtimeAPI {
|
|
|
219
219
|
* @private
|
|
220
220
|
*/
|
|
221
221
|
unsubscribe(channel, suffix = '', onMessage) {
|
|
222
|
-
const
|
|
223
|
-
const suffixTopographic =
|
|
224
|
-
this.wsApi.unsubscribe(`${channel}${
|
|
222
|
+
const suffixSchenatic = getModeSuffix(RealtimeModes.SCHEMATIC, RealtimeModes);
|
|
223
|
+
const suffixTopographic = getModeSuffix(RealtimeModes.TOPOGRAPHIC, RealtimeModes);
|
|
224
|
+
this.wsApi.unsubscribe(`${channel}${suffixSchenatic}${suffix || ''}`, onMessage);
|
|
225
225
|
this.wsApi.unsubscribe(`${channel}${suffixTopographic}${suffix || ''}`, onMessage);
|
|
226
226
|
}
|
|
227
227
|
/**
|
|
@@ -252,8 +252,7 @@ class RealtimeAPI {
|
|
|
252
252
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
253
253
|
*/
|
|
254
254
|
subscribeDisruptions(onMessage, onError = () => { }, quiet = false) {
|
|
255
|
-
|
|
256
|
-
this.subscribe(channel.join('_'), onMessage, onError, quiet);
|
|
255
|
+
this.subscribe(`${this.prefix}newsticker`, onMessage, onError, quiet);
|
|
257
256
|
}
|
|
258
257
|
/**
|
|
259
258
|
* Unsubscribe disruptions.
|
|
@@ -261,8 +260,7 @@ class RealtimeAPI {
|
|
|
261
260
|
* @param {function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
262
261
|
*/
|
|
263
262
|
unsubscribeDisruptions(onMessage) {
|
|
264
|
-
|
|
265
|
-
this.unsubscribe(channel.join('_'), '', onMessage);
|
|
263
|
+
this.unsubscribe(`${this.prefix}newsticker`, '', onMessage);
|
|
266
264
|
}
|
|
267
265
|
/**
|
|
268
266
|
* Return a station with a given uic number and a mode.
|
|
@@ -273,7 +271,7 @@ class RealtimeAPI {
|
|
|
273
271
|
*/
|
|
274
272
|
getStation(uic, mode) {
|
|
275
273
|
const params = {
|
|
276
|
-
channel: `station${
|
|
274
|
+
channel: `station${getModeSuffix(mode, RealtimeModes)}`,
|
|
277
275
|
args: uic,
|
|
278
276
|
};
|
|
279
277
|
return new Promise((resolve, reject) => {
|
|
@@ -281,7 +279,7 @@ class RealtimeAPI {
|
|
|
281
279
|
});
|
|
282
280
|
}
|
|
283
281
|
/**
|
|
284
|
-
* Get the list of
|
|
282
|
+
* Get the list of ststions available for a specifc mode. The promise is resolved every 100ms
|
|
285
283
|
* @param {RealtimeMode} mode Realtime mode.
|
|
286
284
|
* @param {number} timeout = 100 Duration in ms between each promise resolve calls.
|
|
287
285
|
* @return {Promise<RealtimeStation[]>} An array of stations.
|
|
@@ -289,7 +287,7 @@ class RealtimeAPI {
|
|
|
289
287
|
getStations(mode, timeout = 100) {
|
|
290
288
|
return new Promise((resolve) => {
|
|
291
289
|
this.wsApi.get({
|
|
292
|
-
channel: `station${
|
|
290
|
+
channel: `station${getModeSuffix(mode, RealtimeModes)}`,
|
|
293
291
|
}, debounceWebsocketMessages(resolve, undefined, timeout));
|
|
294
292
|
});
|
|
295
293
|
}
|
|
@@ -303,7 +301,7 @@ class RealtimeAPI {
|
|
|
303
301
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
304
302
|
*/
|
|
305
303
|
subscribeStations(mode, onMessage, onError = () => { }, quiet = false) {
|
|
306
|
-
this.subscribe(`station${
|
|
304
|
+
this.subscribe(`station${getModeSuffix(mode, RealtimeModes)}`, onMessage, onError, quiet);
|
|
307
305
|
}
|
|
308
306
|
/**
|
|
309
307
|
* Unsubscribe to stations channel.
|
|
@@ -339,7 +337,7 @@ class RealtimeAPI {
|
|
|
339
337
|
*/
|
|
340
338
|
subscribeTrajectory(mode, onMessage, onError = () => { }, quiet = false) {
|
|
341
339
|
this.unsubscribeTrajectory(onMessage);
|
|
342
|
-
this.subscribe(`trajectory${
|
|
340
|
+
this.subscribe(`trajectory${getModeSuffix(mode, RealtimeModes)}`, onMessage, onError, quiet);
|
|
343
341
|
}
|
|
344
342
|
/**
|
|
345
343
|
* Unsubscribe to trajectory channels.
|
|
@@ -358,7 +356,7 @@ class RealtimeAPI {
|
|
|
358
356
|
*/
|
|
359
357
|
subscribeDeletedVehicles(mode, onMessage, onError = () => { }, quiet = false) {
|
|
360
358
|
this.unsubscribeDeletedVehicles(onMessage);
|
|
361
|
-
this.subscribe(`deleted_vehicles${
|
|
359
|
+
this.subscribe(`deleted_vehicles${getModeSuffix(mode, RealtimeModes)}`, onMessage, onError, quiet);
|
|
362
360
|
}
|
|
363
361
|
/**
|
|
364
362
|
* Unsubscribe to deleted_vhicles channels.
|
|
@@ -376,9 +374,7 @@ class RealtimeAPI {
|
|
|
376
374
|
* @return {Promise<{ data: { content: FullTrajectory } }>} Return a full trajectory.
|
|
377
375
|
*/
|
|
378
376
|
getFullTrajectory(id, mode, generalizationLevel) {
|
|
379
|
-
const channel = [
|
|
380
|
-
`full_trajectory${getRealtimeModeSuffix(mode, RealtimeModes)}`,
|
|
381
|
-
];
|
|
377
|
+
const channel = [`full_trajectory${getModeSuffix(mode, RealtimeModes)}`];
|
|
382
378
|
if (id) {
|
|
383
379
|
channel.push(id);
|
|
384
380
|
}
|
|
@@ -402,7 +398,7 @@ class RealtimeAPI {
|
|
|
402
398
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
403
399
|
*/
|
|
404
400
|
subscribeFullTrajectory(id, mode, onMessage, onError = () => { }, quiet = false) {
|
|
405
|
-
this.subscribe(`full_trajectory${
|
|
401
|
+
this.subscribe(`full_trajectory${getModeSuffix(mode, RealtimeModes)}_${id}`, onMessage, onError, quiet);
|
|
406
402
|
}
|
|
407
403
|
/**
|
|
408
404
|
* Unsubscribe from full_trajectory channel
|
|
@@ -36,6 +36,7 @@ export declare type RealtimeLayerMixinOptions = OlLayerOptions & {
|
|
|
36
36
|
getRenderTimeIntervalByZoom?: (zoom: number, renderTimeIntervalByZoom: number[]) => number;
|
|
37
37
|
url?: string;
|
|
38
38
|
apiKey?: string;
|
|
39
|
+
prefix?: string;
|
|
39
40
|
projection?: string;
|
|
40
41
|
bbox?: (number | string)[];
|
|
41
42
|
buffer?: number[];
|
|
@@ -219,6 +220,10 @@ declare function RealtimeLayerMixin<T extends AnyLayerClass>(Base: T): {
|
|
|
219
220
|
stopSequence: WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory> | WebSocketAPIMessageEventData<GeoJSONFeature[]>;
|
|
220
221
|
fullTrajectory: WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory> | WebSocketAPIMessageEventData<GeoJSONFeature[]>;
|
|
221
222
|
}>;
|
|
223
|
+
/**
|
|
224
|
+
* Remove all trajectories that are in the past.
|
|
225
|
+
*/
|
|
226
|
+
purgeOutOfDateTrajectories(): void;
|
|
222
227
|
/**
|
|
223
228
|
* Determine if the trajectory is useless and should be removed from the list or not.
|
|
224
229
|
* By default, this function exclude vehicles:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealtimeLayerMixin.d.ts","sourceRoot":"","sources":["../../../src/common/mixins/RealtimeLayerMixin.ts"],"names":[],"mappings":"AAOA,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAIxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,UAAU,EA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AS;yBAwBnB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,MAAM;sBAyClD,YAAY;QAmB1B;;;;;WAKG;kCACsB,MAAM,GAAG,SAAS,GAAO,MAAM;QA0BxD;;;;WAIG;6BACkB,cAAc;QASnC;;;;;;;;WAQG;oEAGQ,0BAA0B;;;;;QAkCrC;;;;;WAKG;+BACoB,eAAe;;;;QAiBtC;;WAEG;;QAaH;;;;;;;;;;;WAWG;4DAGO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,QAClC,MAAM;QAed;;;;WAIG;;yCAa8B,kBAAkB,GAAG,eAAe;QAYrE;;;;;WAKG;;;QAqBH;;;;;WAKG;kCAEK,6BAA6B,kBAAkB,CAAC;QAgDxD;;;;;;WAMG;wCAEK,6BAA6B,eAAe,CAAC;QAQrD;;;;;;WAMG;iCAES,OAAO,EAAE,SACZ,gBAAgB;QAgBzB;;;;;;WAMG;iCAES,OAAO,EAAE,SACZ,gBAAgB;;MAkB5B;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -63,14 +63,11 @@ function RealtimeLayerMixin(Base) {
|
|
|
63
63
|
return class Mixin extends Base {
|
|
64
64
|
constructor(options) {
|
|
65
65
|
super(Object.assign({ hitTolerance: 10 }, options));
|
|
66
|
-
this.minZoomInterpolation = 8;
|
|
67
66
|
this.debug = options.debug || false;
|
|
68
67
|
this.mode = options.mode || RealtimeModes.TOPOGRAPHIC;
|
|
69
68
|
this.api = options.api || new RealtimeAPI(options);
|
|
70
69
|
this.tenant = options.tenant || ''; // sbb,sbh or sbm
|
|
71
|
-
|
|
72
|
-
this.minZoomInterpolation = options.minZoomInterpolation || 0; // Min zoom level from which trains positions are not interpolated.
|
|
73
|
-
}
|
|
70
|
+
this.minZoomInterpolation = options.minZoomInterpolation || 8; // Min zoom level from which trains positions are not interpolated.
|
|
74
71
|
this.format = new GeoJSON();
|
|
75
72
|
// MOTs by zoom
|
|
76
73
|
const allMots = [
|
|
@@ -134,6 +131,7 @@ function RealtimeLayerMixin(Base) {
|
|
|
134
131
|
*/
|
|
135
132
|
defineProperties(options) {
|
|
136
133
|
const { style, speed, pixelRatio, hoverVehicleId, selectedVehicleId, filter, sort, time, live, canvas, styleOptions, } = options;
|
|
134
|
+
let currCanvas = canvas;
|
|
137
135
|
let currSpeed = speed || 1;
|
|
138
136
|
let currTime = time || new Date();
|
|
139
137
|
let currStyle = style || realtimeDefaultStyle;
|
|
@@ -141,7 +139,15 @@ function RealtimeLayerMixin(Base) {
|
|
|
141
139
|
Object.defineProperties(this, {
|
|
142
140
|
isTrackerLayer: { value: true },
|
|
143
141
|
canvas: {
|
|
144
|
-
|
|
142
|
+
get: () => {
|
|
143
|
+
if (!currCanvas) {
|
|
144
|
+
currCanvas = document.createElement('canvas');
|
|
145
|
+
}
|
|
146
|
+
return currCanvas;
|
|
147
|
+
},
|
|
148
|
+
set: (cnvas) => {
|
|
149
|
+
currCanvas = cnvas;
|
|
150
|
+
},
|
|
145
151
|
},
|
|
146
152
|
/**
|
|
147
153
|
* Style function used to render a vehicle.
|
|
@@ -299,6 +305,11 @@ function RealtimeLayerMixin(Base) {
|
|
|
299
305
|
}
|
|
300
306
|
start() {
|
|
301
307
|
this.stop();
|
|
308
|
+
// Before starting to update trajectories, we remove trajectories that have
|
|
309
|
+
// a time_intervals in the past, it will
|
|
310
|
+
// avoid phantom train that are at the end of their route because we never
|
|
311
|
+
// received the deleted_vehicle event because we have changed the browser tab.
|
|
312
|
+
this.purgeOutOfDateTrajectories();
|
|
302
313
|
// @ts-ignore function without parameters must be define in subclasses
|
|
303
314
|
this.renderTrajectories();
|
|
304
315
|
this.startUpdateTime();
|
|
@@ -549,6 +560,21 @@ function RealtimeLayerMixin(Base) {
|
|
|
549
560
|
return response;
|
|
550
561
|
});
|
|
551
562
|
}
|
|
563
|
+
/**
|
|
564
|
+
* Remove all trajectories that are in the past.
|
|
565
|
+
*/
|
|
566
|
+
purgeOutOfDateTrajectories() {
|
|
567
|
+
Object.entries(this.trajectories || {}).forEach(([key, trajectory]) => {
|
|
568
|
+
var _a;
|
|
569
|
+
const timeIntervals = (_a = trajectory === null || trajectory === void 0 ? void 0 : trajectory.properties) === null || _a === void 0 ? void 0 : _a.time_intervals;
|
|
570
|
+
if (this.time && timeIntervals.length) {
|
|
571
|
+
const lastTimeInterval = timeIntervals[timeIntervals.length - 1][0];
|
|
572
|
+
if (lastTimeInterval < this.time) {
|
|
573
|
+
this.trackerLayer.removeTrajectory(key);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
}
|
|
552
578
|
/**
|
|
553
579
|
* Determine if the trajectory is useless and should be removed from the list or not.
|
|
554
580
|
* By default, this function exclude vehicles:
|
|
@@ -616,6 +642,10 @@ function RealtimeLayerMixin(Base) {
|
|
|
616
642
|
}
|
|
617
643
|
if (document.hidden) {
|
|
618
644
|
this.stop();
|
|
645
|
+
// Since we don't receive deleted_vehicles event when docuement
|
|
646
|
+
// is hidden. We have to clean all the trajectories for a fresh
|
|
647
|
+
// start when the document is visible again.
|
|
648
|
+
this.trajectories = {};
|
|
619
649
|
}
|
|
620
650
|
else {
|
|
621
651
|
this.start();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMapboxRender.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getMapboxRender.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,KAAK,WAAW,MAAM,
|
|
1
|
+
{"version":3,"file":"getMapboxRender.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getMapboxRender.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAGhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,UAAU,EAAE,WAAW,GACtB,cAAc,CA4FhB"}
|
|
@@ -3,10 +3,14 @@ import { toLonLat } from 'ol/proj';
|
|
|
3
3
|
* Return the render function fo the olLayer of a MaplibreLayer
|
|
4
4
|
*/
|
|
5
5
|
export default function getMapboxRender(mapoxLayer) {
|
|
6
|
-
|
|
6
|
+
// We cretae emptyDiv only in render finction to work with serverside rendering
|
|
7
|
+
let emptyDiv;
|
|
7
8
|
return (frameState) => {
|
|
8
9
|
const { map, mbMap, renderState, olLayer } = mapoxLayer;
|
|
9
10
|
if (!map || !mbMap) {
|
|
11
|
+
if (!emptyDiv) {
|
|
12
|
+
emptyDiv = document.createElement('div');
|
|
13
|
+
}
|
|
10
14
|
return emptyDiv;
|
|
11
15
|
}
|
|
12
16
|
let changed = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMaplibreRender.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getMaplibreRender.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AAEH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,aAAa,EAAE,aAAa,GAC3B,cAAc,
|
|
1
|
+
{"version":3,"file":"getMaplibreRender.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getMaplibreRender.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;GAEG;AAEH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,aAAa,EAAE,aAAa,GAC3B,cAAc,CAuChB"}
|
|
@@ -4,10 +4,13 @@ import { toDegrees } from 'ol/math';
|
|
|
4
4
|
* Return the render function fo the olLayer of a MaplibreLayer
|
|
5
5
|
*/
|
|
6
6
|
export default function getMaplibreRender(maplibreLayer) {
|
|
7
|
-
|
|
7
|
+
let emptyDiv;
|
|
8
8
|
return (frameState) => {
|
|
9
9
|
const { map, mbMap, olLayer } = maplibreLayer;
|
|
10
10
|
if (!map || !mbMap) {
|
|
11
|
+
if (!emptyDiv) {
|
|
12
|
+
emptyDiv = document.createElement('div');
|
|
13
|
+
}
|
|
11
14
|
return emptyDiv;
|
|
12
15
|
}
|
|
13
16
|
const canvas = mbMap.getCanvas();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { RealtimeMode
|
|
1
|
+
import type { RealtimeMode } from '../../types';
|
|
2
2
|
import type { RealtimeModesType } from '../../api/RealtimeAPI';
|
|
3
3
|
/**
|
|
4
4
|
* Get the websocket channel suffix, depending on the current mode.
|
|
5
5
|
* @param {String} mode Mode 'topographic' ou 'schematic'.
|
|
6
6
|
* @private
|
|
7
7
|
*/
|
|
8
|
-
declare const
|
|
9
|
-
export default
|
|
8
|
+
declare const getModeSuffix: (mode: RealtimeMode, modes: RealtimeModesType) => string;
|
|
9
|
+
export default getModeSuffix;
|
|
10
10
|
//# sourceMappingURL=getRealtimeModeSuffix.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRealtimeModeSuffix.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getRealtimeModeSuffix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"getRealtimeModeSuffix.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getRealtimeModeSuffix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;;;GAIG;AACH,QAAA,MAAM,aAAa,SAAU,YAAY,SAAS,iBAAiB,KAAG,MACxB,CAAC;AAE/C,eAAe,aAAa,CAAC"}
|
|
@@ -3,11 +3,5 @@
|
|
|
3
3
|
* @param {String} mode Mode 'topographic' ou 'schematic'.
|
|
4
4
|
* @private
|
|
5
5
|
*/
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
if (tenant) {
|
|
9
|
-
schematicSuffix.push(tenant);
|
|
10
|
-
}
|
|
11
|
-
return mode === modes.SCHEMATIC ? schematicSuffix.join('_') : '';
|
|
12
|
-
};
|
|
13
|
-
export default getRealtimeModeSuffix;
|
|
6
|
+
const getModeSuffix = (mode, modes) => mode === modes.SCHEMATIC ? '_schematic' : '';
|
|
7
|
+
export default getModeSuffix;
|
|
@@ -12,11 +12,7 @@ declare const RealtimeLayer_base: {
|
|
|
12
12
|
[key: string]: GeoJSONFeature;
|
|
13
13
|
} | undefined;
|
|
14
14
|
canvas?: import("../../types").AnyCanvas | undefined;
|
|
15
|
-
mode: import("../../types").RealtimeMode;
|
|
16
|
-
* Render the trajectories using current map's size, resolution and rotation.
|
|
17
|
-
* @param {boolean} noInterpolate if true, renders the vehicles without interpolating theirs positions.
|
|
18
|
-
* @overrides
|
|
19
|
-
*/
|
|
15
|
+
mode: import("../../types").RealtimeMode;
|
|
20
16
|
api: import("../../api/RealtimeAPI").default;
|
|
21
17
|
tenant: string;
|
|
22
18
|
time?: Date | undefined;
|
|
@@ -73,6 +69,7 @@ declare const RealtimeLayer_base: {
|
|
|
73
69
|
stopSequence: import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory> | import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData<GeoJSONFeature[]>;
|
|
74
70
|
fullTrajectory: import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory> | import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData<GeoJSONFeature[]>;
|
|
75
71
|
}>;
|
|
72
|
+
purgeOutOfDateTrajectories(): void;
|
|
76
73
|
purgeTrajectory(trajectory: GeoJSONFeature, extent: [number, number, number, number], zoom: number): boolean;
|
|
77
74
|
addTrajectory(trajectory: GeoJSONFeature): void;
|
|
78
75
|
removeTrajectory(trajectoryOrId: any): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealtimeLayer.d.ts","sourceRoot":"","sources":["../../../src/mapbox/layers/RealtimeLayer.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,OAAO,EACL,YAAY,EACZ,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC
|
|
1
|
+
{"version":3,"file":"RealtimeLayer.d.ts","sourceRoot":"","sources":["../../../src/mapbox/layers/RealtimeLayer.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAE7B,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,OAAO,EACL,YAAY,EACZ,0BAA0B,EAC1B,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExD;;;;;;;;;;;;;;;;GAgBG;AAEH,cAAM,aAAc,SAAQ,kBAAY;gBAC1B,OAAO,KAAK;IAqBxB;;;;;;OAMG;IAEH,WAAW,CAAC,GAAG,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM;IAuC/C;;OAEG;IACH,aAAa;IAkBb;;;;;;OAMG;IACH,KAAK;IAQL;;;;OAIG;IACH,IAAI;IASJ,MAAM;IASN;;;OAGG;IACH,kBAAkB,CAChB,GAAG,EAAE,QAAQ,CAAC,kBA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