mobility-toolbox-js 2.0.0-beta.71 → 2.0.0-beta.74
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/RealtimeAPI.d.ts +5 -5
- package/api/RealtimeAPI.d.ts.map +1 -1
- package/api/RealtimeAPI.js +20 -16
- package/common/mixins/RealtimeLayerMixin.d.ts +0 -1
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -1
- package/common/mixins/RealtimeLayerMixin.js +4 -1
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts.map +1 -0
- package/common/styles/realtimeHeadingStyle.js +85 -0
- package/common/utils/getMapboxRender.d.ts +1 -1
- package/common/utils/getMapboxRender.d.ts.map +1 -1
- package/common/utils/getRealtimeModeSuffix.d.ts +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -1
- package/common/utils/getRealtimeModeSuffix.js +8 -2
- package/common/utils/getVehiclePosition.d.ts.map +1 -1
- package/common/utils/getVehiclePosition.js +5 -1
- package/mbt.js +51 -19
- package/mbt.js.map +2 -2
- package/mbt.min.js +2 -2
- package/mbt.min.js.map +3 -3
- package/ol/layers/RealtimeLayer.d.ts +1 -1
- package/ol/layers/RealtimeLayer.d.ts.map +1 -1
- package/ol/layers/RealtimeLayer.js +3 -2
- package/package.json +1 -1
package/api/RealtimeAPI.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import WebSocketAPI, { WebSocketAPIMessageCallback, WebSocketAPIMessageEventData } from '../common/api/WebSocketAPI';
|
|
2
|
-
import
|
|
2
|
+
import { RealtimeMode, RealtimeDeparture, RealtimeNews, RealtimeStation, RealtimeExtraGeom, RealtimeTrainId, RealtimeGeneralizationLevel, RealtimeFullTrajectory, RealtimeTrajectoryResponse, RealtimeStationId, RealtimeTenant } from '../types';
|
|
3
3
|
import { StopSequence } from './typedefs';
|
|
4
4
|
export declare type RealtimeAPIOptions = {
|
|
5
5
|
url?: string;
|
|
6
6
|
apiKey?: string;
|
|
7
|
-
|
|
7
|
+
tenant?: RealtimeTenant;
|
|
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
|
+
tenant?: RealtimeTenant;
|
|
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.tenant=''] Tenant of the provider. Use to limitate some subscriptions to a specfic provider (it is used by schematic channels and newsticker).
|
|
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 stations 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,
|
|
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,EACjB,cAAc,EACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,oBAAY,kBAAkB,GAAG;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,CAAC,OAAO,MAAM,yBAAyB,GAAG;IAC9C,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAAC;CACpC,CAAC;AAEF,oBAAY,yBAAyB,GAAG;IACtC,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAAC;CACpC,CAAC;AAEF,oBAAY,iBAAiB,GAAG;IAC9B,GAAG,EAAE,YAAY,CAAC;IAClB,WAAW,EAAE,YAAY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GvE;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 getRealtimeModeSuffix 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.tenant=''] Tenant of the provider. Use to limitate some subscriptions to a specfic provider (it is used by schematic channels and newsticker).
|
|
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.tenant = options.tenant;
|
|
49
49
|
/** @ignore */
|
|
50
50
|
this.onOpen = this.onOpen.bind(this);
|
|
51
51
|
}
|
|
@@ -218,9 +218,9 @@ class RealtimeAPI {
|
|
|
218
218
|
* @private
|
|
219
219
|
*/
|
|
220
220
|
unsubscribe(channel, suffix = '', onMessage) {
|
|
221
|
-
const
|
|
222
|
-
const suffixTopographic =
|
|
223
|
-
this.wsApi.unsubscribe(`${channel}${
|
|
221
|
+
const suffixSchematic = getRealtimeModeSuffix(RealtimeModes.SCHEMATIC, RealtimeModes, this.tenant);
|
|
222
|
+
const suffixTopographic = getRealtimeModeSuffix(RealtimeModes.TOPOGRAPHIC, RealtimeModes, this.tenant);
|
|
223
|
+
this.wsApi.unsubscribe(`${channel}${suffixSchematic}${suffix || ''}`, onMessage);
|
|
224
224
|
this.wsApi.unsubscribe(`${channel}${suffixTopographic}${suffix || ''}`, onMessage);
|
|
225
225
|
}
|
|
226
226
|
/**
|
|
@@ -251,7 +251,8 @@ class RealtimeAPI {
|
|
|
251
251
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
252
252
|
*/
|
|
253
253
|
subscribeDisruptions(onMessage, onError = () => { }, quiet = false) {
|
|
254
|
-
this.
|
|
254
|
+
const channel = [this.tenant, 'newsticker'];
|
|
255
|
+
this.subscribe(channel.join('_'), onMessage, onError, quiet);
|
|
255
256
|
}
|
|
256
257
|
/**
|
|
257
258
|
* Unsubscribe disruptions.
|
|
@@ -259,7 +260,8 @@ class RealtimeAPI {
|
|
|
259
260
|
* @param {function(data: { content: RealtimeNews[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
|
260
261
|
*/
|
|
261
262
|
unsubscribeDisruptions(onMessage) {
|
|
262
|
-
this.
|
|
263
|
+
const channel = [this.tenant, 'newsticker'];
|
|
264
|
+
this.unsubscribe(channel.join('_'), '', onMessage);
|
|
263
265
|
}
|
|
264
266
|
/**
|
|
265
267
|
* Return a station with a given uic number and a mode.
|
|
@@ -270,7 +272,7 @@ class RealtimeAPI {
|
|
|
270
272
|
*/
|
|
271
273
|
getStation(uic, mode) {
|
|
272
274
|
const params = {
|
|
273
|
-
channel: `station${
|
|
275
|
+
channel: `station${getRealtimeModeSuffix(mode, RealtimeModes, this.tenant)}`,
|
|
274
276
|
args: uic,
|
|
275
277
|
};
|
|
276
278
|
return new Promise((resolve, reject) => {
|
|
@@ -278,7 +280,7 @@ class RealtimeAPI {
|
|
|
278
280
|
});
|
|
279
281
|
}
|
|
280
282
|
/**
|
|
281
|
-
* Get the list of
|
|
283
|
+
* Get the list of stations available for a specifc mode. The promise is resolved every 100ms
|
|
282
284
|
* @param {RealtimeMode} mode Realtime mode.
|
|
283
285
|
* @param {number} timeout = 100 Duration in ms between each promise resolve calls.
|
|
284
286
|
* @return {Promise<RealtimeStation[]>} An array of stations.
|
|
@@ -286,7 +288,7 @@ class RealtimeAPI {
|
|
|
286
288
|
getStations(mode, timeout = 100) {
|
|
287
289
|
return new Promise((resolve) => {
|
|
288
290
|
this.wsApi.get({
|
|
289
|
-
channel: `station${
|
|
291
|
+
channel: `station${getRealtimeModeSuffix(mode, RealtimeModes, this.tenant)}`,
|
|
290
292
|
}, debounceWebsocketMessages(resolve, undefined, timeout));
|
|
291
293
|
});
|
|
292
294
|
}
|
|
@@ -300,7 +302,7 @@ class RealtimeAPI {
|
|
|
300
302
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
301
303
|
*/
|
|
302
304
|
subscribeStations(mode, onMessage, onError = () => { }, quiet = false) {
|
|
303
|
-
this.subscribe(`station${
|
|
305
|
+
this.subscribe(`station${getRealtimeModeSuffix(mode, RealtimeModes, this.tenant)}`, onMessage, onError, quiet);
|
|
304
306
|
}
|
|
305
307
|
/**
|
|
306
308
|
* Unsubscribe to stations channel.
|
|
@@ -336,7 +338,7 @@ class RealtimeAPI {
|
|
|
336
338
|
*/
|
|
337
339
|
subscribeTrajectory(mode, onMessage, onError = () => { }, quiet = false) {
|
|
338
340
|
this.unsubscribeTrajectory(onMessage);
|
|
339
|
-
this.subscribe(`trajectory${
|
|
341
|
+
this.subscribe(`trajectory${getRealtimeModeSuffix(mode, RealtimeModes, this.tenant)}`, onMessage, onError, quiet);
|
|
340
342
|
}
|
|
341
343
|
/**
|
|
342
344
|
* Unsubscribe to trajectory channels.
|
|
@@ -355,7 +357,7 @@ class RealtimeAPI {
|
|
|
355
357
|
*/
|
|
356
358
|
subscribeDeletedVehicles(mode, onMessage, onError = () => { }, quiet = false) {
|
|
357
359
|
this.unsubscribeDeletedVehicles(onMessage);
|
|
358
|
-
this.subscribe(`deleted_vehicles${
|
|
360
|
+
this.subscribe(`deleted_vehicles${getRealtimeModeSuffix(mode, RealtimeModes, this.tenant)}`, onMessage, onError, quiet);
|
|
359
361
|
}
|
|
360
362
|
/**
|
|
361
363
|
* Unsubscribe to deleted_vhicles channels.
|
|
@@ -373,7 +375,9 @@ class RealtimeAPI {
|
|
|
373
375
|
* @return {Promise<{ data: { content: FullTrajectory } }>} Return a full trajectory.
|
|
374
376
|
*/
|
|
375
377
|
getFullTrajectory(id, mode, generalizationLevel) {
|
|
376
|
-
const channel = [
|
|
378
|
+
const channel = [
|
|
379
|
+
`full_trajectory${getRealtimeModeSuffix(mode, RealtimeModes)}`,
|
|
380
|
+
];
|
|
377
381
|
if (id) {
|
|
378
382
|
channel.push(id);
|
|
379
383
|
}
|
|
@@ -397,7 +401,7 @@ class RealtimeAPI {
|
|
|
397
401
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
398
402
|
*/
|
|
399
403
|
subscribeFullTrajectory(id, mode, onMessage, onError = () => { }, quiet = false) {
|
|
400
|
-
this.subscribe(`full_trajectory${
|
|
404
|
+
this.subscribe(`full_trajectory${getRealtimeModeSuffix(mode, RealtimeModes)}_${id}`, onMessage, onError, quiet);
|
|
401
405
|
}
|
|
402
406
|
/**
|
|
403
407
|
* Unsubscribe from full_trajectory channel
|
|
@@ -36,7 +36,6 @@ export declare type RealtimeLayerMixinOptions = OlLayerOptions & {
|
|
|
36
36
|
getRenderTimeIntervalByZoom?: (zoom: number, renderTimeIntervalByZoom: number[]) => number;
|
|
37
37
|
url?: string;
|
|
38
38
|
apiKey?: string;
|
|
39
|
-
prefix?: string;
|
|
40
39
|
projection?: string;
|
|
41
40
|
bbox?: (number | string)[];
|
|
42
41
|
buffer?: number[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealtimeLayerMixin.d.ts","sourceRoot":"","sources":["../../../src/common/mixins/RealtimeLay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DAGI,SAAS,kBACJ,OAAO,KACpB,IAAI;QA0HT;;;;WAIG;kCACuB,yBAAyB;yBAqMlC,MAAM;;;QA4EvB;;;WAGG;;;QAsBH;;;WAGG;;QAQH;;;;;;;;;;;;;WAaG;8CAEU,SAAS,kBACL,OAAO;QA8CxB;;;;;;;;;;;;;;WAcG;sCAEU,SAAS,GAAG,SAAS,iBACjB,OAAO,GAAG,SAAS;yBAwBnB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,SAAS,MAAM;QAyChE;;;;;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;QAcd;;;;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"}
|
|
@@ -57,11 +57,14 @@ function RealtimeLayerMixin(Base) {
|
|
|
57
57
|
return class Mixin extends Base {
|
|
58
58
|
constructor(options) {
|
|
59
59
|
super(Object.assign({ hitTolerance: 10 }, options));
|
|
60
|
+
this.minZoomInterpolation = 8;
|
|
60
61
|
this.debug = options.debug || false;
|
|
61
62
|
this.mode = options.mode || RealtimeModes.TOPOGRAPHIC;
|
|
62
63
|
this.api = options.api || new RealtimeAPI(options);
|
|
63
64
|
this.tenant = options.tenant || ''; // sbb,sbh or sbm
|
|
64
|
-
|
|
65
|
+
if (!Number.isNaN(options.minZoomInterpolation)) {
|
|
66
|
+
this.minZoomInterpolation = options.minZoomInterpolation || 0; // Min zoom level from which trains positions are not interpolated.
|
|
67
|
+
}
|
|
65
68
|
this.format = new GeoJSON();
|
|
66
69
|
// MOTs by zoom
|
|
67
70
|
const allMots = [
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RealtimeStyleFunction } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* A tracker style that take in account the delay.
|
|
4
|
+
*
|
|
5
|
+
* @param {RealtimeTrajectory} trajectory The trajectory to render.
|
|
6
|
+
* @param {ViewState} viewState The view state of the map.
|
|
7
|
+
* @param {RealtimeStyleOptions} options Some options to change the rendering
|
|
8
|
+
* @return a canvas
|
|
9
|
+
*/
|
|
10
|
+
declare const realtimeHeadingStyle: RealtimeStyleFunction;
|
|
11
|
+
export default realtimeHeadingStyle;
|
|
12
|
+
//# sourceMappingURL=realtimeHeadingStyle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtimeHeadingStyle.d.ts","sourceRoot":"","sources":["../../../src/common/styles/realtimeHeadingStyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,qBAAqB,EAEtB,MAAM,aAAa,CAAC;AAoFrB;;;;;;;GAOG;AACH,QAAA,MAAM,oBAAoB,EAAE,qBAoC3B,CAAC;AACF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import createCanvas from '../utils/createCanvas';
|
|
2
|
+
import { getBgColor } from '../utils/realtimeConfig';
|
|
3
|
+
import realtimeDefaultStyle from './realtimeDefaultStyle';
|
|
4
|
+
/** @private */
|
|
5
|
+
const rotateCanvas = (canvas, rotation) => {
|
|
6
|
+
const ctx = canvas.getContext('2d');
|
|
7
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.translate(canvas.width / 2, canvas.height / 2);
|
|
8
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.rotate(rotation);
|
|
9
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.translate(-canvas.width / 2, -canvas.height / 2);
|
|
10
|
+
};
|
|
11
|
+
const arrowCache = {};
|
|
12
|
+
/** @private */
|
|
13
|
+
const getArrowCanvas = (fillColor) => {
|
|
14
|
+
const key = `${fillColor}`;
|
|
15
|
+
if (!arrowCache[key]) {
|
|
16
|
+
// Create the arrow canvas
|
|
17
|
+
const arrowCanvas = createCanvas(20, 20);
|
|
18
|
+
const ctx = arrowCanvas === null || arrowCanvas === void 0 ? void 0 : arrowCanvas.getContext('2d');
|
|
19
|
+
if (ctx) {
|
|
20
|
+
ctx.fillStyle = fillColor;
|
|
21
|
+
ctx.beginPath();
|
|
22
|
+
ctx.moveTo(5, 5);
|
|
23
|
+
ctx.lineTo(10, 10);
|
|
24
|
+
ctx.lineTo(5, 15);
|
|
25
|
+
ctx.fill();
|
|
26
|
+
ctx.beginPath();
|
|
27
|
+
ctx.moveTo(5, 5);
|
|
28
|
+
ctx.lineTo(10, 10);
|
|
29
|
+
ctx.lineTo(5, 15);
|
|
30
|
+
ctx.lineTo(5, 5);
|
|
31
|
+
ctx.stroke();
|
|
32
|
+
}
|
|
33
|
+
arrowCache[key] = arrowCanvas;
|
|
34
|
+
}
|
|
35
|
+
return arrowCache[key];
|
|
36
|
+
};
|
|
37
|
+
const bufferArrowCache = {};
|
|
38
|
+
/** @private */
|
|
39
|
+
const getBufferArrowCanvas = (canvas, fillColor, rotation) => {
|
|
40
|
+
const margin = 20;
|
|
41
|
+
const bufferKey = `${fillColor},${canvas.width},${canvas.height},${rotation}`;
|
|
42
|
+
if (!bufferArrowCache[bufferKey]) {
|
|
43
|
+
// Create a buffer canvas around the current vehicle to display properly the arrow
|
|
44
|
+
const buffer = createCanvas(canvas.width + margin * 2, canvas.height + margin * 2);
|
|
45
|
+
const arrowCanvas = getArrowCanvas(fillColor);
|
|
46
|
+
if (arrowCanvas && buffer) {
|
|
47
|
+
const bufferCtx = buffer.getContext('2d');
|
|
48
|
+
bufferCtx === null || bufferCtx === void 0 ? void 0 : bufferCtx.drawImage(arrowCanvas, buffer.width - margin, buffer.height / 2 - arrowCanvas.height / 2, arrowCanvas.width, arrowCanvas.height);
|
|
49
|
+
bufferCtx === null || bufferCtx === void 0 ? void 0 : bufferCtx.save();
|
|
50
|
+
const rot = rotation + (90 * Math.PI) / 180;
|
|
51
|
+
rotateCanvas(buffer, -rot);
|
|
52
|
+
bufferCtx === null || bufferCtx === void 0 ? void 0 : bufferCtx.restore();
|
|
53
|
+
}
|
|
54
|
+
bufferArrowCache[bufferKey] = buffer;
|
|
55
|
+
}
|
|
56
|
+
return bufferArrowCache[bufferKey];
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* A tracker style that take in account the delay.
|
|
60
|
+
*
|
|
61
|
+
* @param {RealtimeTrajectory} trajectory The trajectory to render.
|
|
62
|
+
* @param {ViewState} viewState The view state of the map.
|
|
63
|
+
* @param {RealtimeStyleOptions} options Some options to change the rendering
|
|
64
|
+
* @return a canvas
|
|
65
|
+
*/
|
|
66
|
+
const realtimeHeadingStyle = (trajectory, viewState, options) => {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
const { rotation, type, line } = trajectory.properties;
|
|
70
|
+
const { color } = line || {};
|
|
71
|
+
const canvas = realtimeDefaultStyle(trajectory, viewState, options);
|
|
72
|
+
if (canvas && rotation !== null) {
|
|
73
|
+
const circleFillColor = color || getBgColor(type);
|
|
74
|
+
const bufferArrow = getBufferArrowCanvas(canvas, circleFillColor, rotation);
|
|
75
|
+
if (bufferArrow) {
|
|
76
|
+
const bufferSize = (bufferArrow.width - canvas.width) / 2;
|
|
77
|
+
const vehicleWithArrow = createCanvas(bufferArrow.width, bufferArrow.height);
|
|
78
|
+
(_a = vehicleWithArrow === null || vehicleWithArrow === void 0 ? void 0 : vehicleWithArrow.getContext('2d')) === null || _a === void 0 ? void 0 : _a.drawImage(bufferArrow, 0, 0, bufferArrow.width, bufferArrow.height);
|
|
79
|
+
(_b = vehicleWithArrow === null || vehicleWithArrow === void 0 ? void 0 : vehicleWithArrow.getContext('2d')) === null || _b === void 0 ? void 0 : _b.drawImage(canvas, bufferSize, bufferSize, canvas.width, canvas.height);
|
|
80
|
+
return vehicleWithArrow;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return canvas;
|
|
84
|
+
};
|
|
85
|
+
export default realtimeHeadingStyle;
|
|
@@ -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,
|
|
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,6BAA6B,CAAC;AAC3D;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,UAAU,EAAE,WAAW,GACtB,cAAc,CA4FhB"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { RealtimeMode } from '../../types';
|
|
1
|
+
import type { RealtimeMode, RealtimeTenant } 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 getRealtimeModeSuffix: (mode: RealtimeMode, modes: RealtimeModesType, tenant?: RealtimeTenant) => string;
|
|
9
|
+
export default getRealtimeModeSuffix;
|
|
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,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"getRealtimeModeSuffix.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getRealtimeModeSuffix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D;;;;GAIG;AACH,QAAA,MAAM,qBAAqB,SACnB,YAAY,SACX,iBAAiB,WACf,cAAc,KACtB,MAQF,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
|
@@ -3,5 +3,11 @@
|
|
|
3
3
|
* @param {String} mode Mode 'topographic' ou 'schematic'.
|
|
4
4
|
* @private
|
|
5
5
|
*/
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const getRealtimeModeSuffix = (mode, modes, tenant) => {
|
|
7
|
+
const schematicSuffix = ['', 'schematic'];
|
|
8
|
+
if (tenant) {
|
|
9
|
+
schematicSuffix.push(tenant);
|
|
10
|
+
}
|
|
11
|
+
return mode === modes.SCHEMATIC ? schematicSuffix.join('_') : '';
|
|
12
|
+
};
|
|
13
|
+
export default getRealtimeModeSuffix;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getVehiclePosition.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getVehiclePosition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,oBAAY,eAAe,GAAG;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,kBAAkB,QACjB,MAAM,6CAEI,OAAO,KACrB,
|
|
1
|
+
{"version":3,"file":"getVehiclePosition.d.ts","sourceRoot":"","sources":["../../../src/common/utils/getVehiclePosition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,oBAAY,eAAe,GAAG;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,kBAAkB,QACjB,MAAM,6CAEI,OAAO,KACrB,eAoEF,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -9,10 +9,14 @@ import { LineString } from 'ol/geom';
|
|
|
9
9
|
*/
|
|
10
10
|
const getVehiclePosition = (now, trajectory, noInterpolate) => {
|
|
11
11
|
const { time_intervals: timeIntervals, olGeometry, coordinate, } = trajectory.properties;
|
|
12
|
-
const {
|
|
12
|
+
const { coordinates } = trajectory.geometry;
|
|
13
|
+
let { type } = trajectory.geometry;
|
|
13
14
|
let geometry = olGeometry;
|
|
14
15
|
let coord;
|
|
15
16
|
let rotation;
|
|
17
|
+
if (olGeometry) {
|
|
18
|
+
type = geometry.getType();
|
|
19
|
+
}
|
|
16
20
|
if (noInterpolate && coordinate) {
|
|
17
21
|
coord = coordinate;
|
|
18
22
|
}
|
package/mbt.js
CHANGED
|
@@ -34191,8 +34191,14 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34191
34191
|
var debounceWebsocketMessages_default = debounceWebsocketMessages;
|
|
34192
34192
|
|
|
34193
34193
|
// src/common/utils/getRealtimeModeSuffix.ts
|
|
34194
|
-
var
|
|
34195
|
-
|
|
34194
|
+
var getRealtimeModeSuffix = (mode, modes, tenant) => {
|
|
34195
|
+
const schematicSuffix = ["", "schematic"];
|
|
34196
|
+
if (tenant) {
|
|
34197
|
+
schematicSuffix.push(tenant);
|
|
34198
|
+
}
|
|
34199
|
+
return mode === modes.SCHEMATIC ? schematicSuffix.join("_") : "";
|
|
34200
|
+
};
|
|
34201
|
+
var getRealtimeModeSuffix_default = getRealtimeModeSuffix;
|
|
34196
34202
|
|
|
34197
34203
|
// src/api/RealtimeAPI.ts
|
|
34198
34204
|
var RealtimeModes = {
|
|
@@ -34203,7 +34209,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34203
34209
|
var RealtimeAPI = class {
|
|
34204
34210
|
constructor(options = {}) {
|
|
34205
34211
|
this.defineProperties(options);
|
|
34206
|
-
this.
|
|
34212
|
+
this.tenant = options.tenant;
|
|
34207
34213
|
this.onOpen = this.onOpen.bind(this);
|
|
34208
34214
|
}
|
|
34209
34215
|
defineProperties(options) {
|
|
@@ -34324,16 +34330,18 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34324
34330
|
this.wsApi.subscribe({ channel }, onSuccess, onError, quiet);
|
|
34325
34331
|
}
|
|
34326
34332
|
unsubscribe(channel, suffix = "", onMessage) {
|
|
34327
|
-
const
|
|
34333
|
+
const suffixSchematic = getRealtimeModeSuffix_default(
|
|
34328
34334
|
RealtimeModes.SCHEMATIC,
|
|
34329
|
-
RealtimeModes
|
|
34335
|
+
RealtimeModes,
|
|
34336
|
+
this.tenant
|
|
34330
34337
|
);
|
|
34331
34338
|
const suffixTopographic = getRealtimeModeSuffix_default(
|
|
34332
34339
|
RealtimeModes.TOPOGRAPHIC,
|
|
34333
|
-
RealtimeModes
|
|
34340
|
+
RealtimeModes,
|
|
34341
|
+
this.tenant
|
|
34334
34342
|
);
|
|
34335
34343
|
this.wsApi.unsubscribe(
|
|
34336
|
-
`${channel}${
|
|
34344
|
+
`${channel}${suffixSchematic}${suffix || ""}`,
|
|
34337
34345
|
onMessage
|
|
34338
34346
|
);
|
|
34339
34347
|
this.wsApi.unsubscribe(
|
|
@@ -34350,14 +34358,20 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34350
34358
|
}
|
|
34351
34359
|
subscribeDisruptions(onMessage, onError = () => {
|
|
34352
34360
|
}, quiet = false) {
|
|
34353
|
-
this.
|
|
34361
|
+
const channel = [this.tenant, "newsticker"];
|
|
34362
|
+
this.subscribe(channel.join("_"), onMessage, onError, quiet);
|
|
34354
34363
|
}
|
|
34355
34364
|
unsubscribeDisruptions(onMessage) {
|
|
34356
|
-
this.
|
|
34365
|
+
const channel = [this.tenant, "newsticker"];
|
|
34366
|
+
this.unsubscribe(channel.join("_"), "", onMessage);
|
|
34357
34367
|
}
|
|
34358
34368
|
getStation(uic, mode) {
|
|
34359
34369
|
const params = {
|
|
34360
|
-
channel: `station${getRealtimeModeSuffix_default(
|
|
34370
|
+
channel: `station${getRealtimeModeSuffix_default(
|
|
34371
|
+
mode,
|
|
34372
|
+
RealtimeModes,
|
|
34373
|
+
this.tenant
|
|
34374
|
+
)}`,
|
|
34361
34375
|
args: uic
|
|
34362
34376
|
};
|
|
34363
34377
|
return new Promise((resolve, reject) => {
|
|
@@ -34368,7 +34382,11 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34368
34382
|
return new Promise((resolve) => {
|
|
34369
34383
|
this.wsApi.get(
|
|
34370
34384
|
{
|
|
34371
|
-
channel: `station${getRealtimeModeSuffix_default(
|
|
34385
|
+
channel: `station${getRealtimeModeSuffix_default(
|
|
34386
|
+
mode,
|
|
34387
|
+
RealtimeModes,
|
|
34388
|
+
this.tenant
|
|
34389
|
+
)}`
|
|
34372
34390
|
},
|
|
34373
34391
|
debounceWebsocketMessages_default(resolve, void 0, timeout)
|
|
34374
34392
|
);
|
|
@@ -34377,7 +34395,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34377
34395
|
subscribeStations(mode, onMessage, onError = () => {
|
|
34378
34396
|
}, quiet = false) {
|
|
34379
34397
|
this.subscribe(
|
|
34380
|
-
`station${getRealtimeModeSuffix_default(mode, RealtimeModes)}`,
|
|
34398
|
+
`station${getRealtimeModeSuffix_default(mode, RealtimeModes, this.tenant)}`,
|
|
34381
34399
|
onMessage,
|
|
34382
34400
|
onError,
|
|
34383
34401
|
quiet
|
|
@@ -34397,7 +34415,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34397
34415
|
}, quiet = false) {
|
|
34398
34416
|
this.unsubscribeTrajectory(onMessage);
|
|
34399
34417
|
this.subscribe(
|
|
34400
|
-
`trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes)}`,
|
|
34418
|
+
`trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes, this.tenant)}`,
|
|
34401
34419
|
onMessage,
|
|
34402
34420
|
onError,
|
|
34403
34421
|
quiet
|
|
@@ -34410,7 +34428,11 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34410
34428
|
}, quiet = false) {
|
|
34411
34429
|
this.unsubscribeDeletedVehicles(onMessage);
|
|
34412
34430
|
this.subscribe(
|
|
34413
|
-
`deleted_vehicles${getRealtimeModeSuffix_default(
|
|
34431
|
+
`deleted_vehicles${getRealtimeModeSuffix_default(
|
|
34432
|
+
mode,
|
|
34433
|
+
RealtimeModes,
|
|
34434
|
+
this.tenant
|
|
34435
|
+
)}`,
|
|
34414
34436
|
onMessage,
|
|
34415
34437
|
onError,
|
|
34416
34438
|
quiet
|
|
@@ -34420,7 +34442,9 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34420
34442
|
this.unsubscribe("deleted_vehicles", "", onMessage);
|
|
34421
34443
|
}
|
|
34422
34444
|
getFullTrajectory(id, mode, generalizationLevel) {
|
|
34423
|
-
const channel = [
|
|
34445
|
+
const channel = [
|
|
34446
|
+
`full_trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes)}`
|
|
34447
|
+
];
|
|
34424
34448
|
if (id) {
|
|
34425
34449
|
channel.push(id);
|
|
34426
34450
|
}
|
|
@@ -37985,10 +38009,14 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
37985
38009
|
olGeometry,
|
|
37986
38010
|
coordinate
|
|
37987
38011
|
} = trajectory.properties;
|
|
37988
|
-
const {
|
|
38012
|
+
const { coordinates: coordinates2 } = trajectory.geometry;
|
|
38013
|
+
let { type } = trajectory.geometry;
|
|
37989
38014
|
let geometry = olGeometry;
|
|
37990
38015
|
let coord;
|
|
37991
38016
|
let rotation;
|
|
38017
|
+
if (olGeometry) {
|
|
38018
|
+
type = geometry.getType();
|
|
38019
|
+
}
|
|
37992
38020
|
if (noInterpolate && coordinate) {
|
|
37993
38021
|
coord = coordinate;
|
|
37994
38022
|
} else if (type === "Point") {
|
|
@@ -49641,11 +49669,14 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
49641
49669
|
hitTolerance: 10,
|
|
49642
49670
|
...options
|
|
49643
49671
|
});
|
|
49672
|
+
this.minZoomInterpolation = 8;
|
|
49644
49673
|
this.debug = options.debug || false;
|
|
49645
49674
|
this.mode = options.mode || RealtimeModes.TOPOGRAPHIC;
|
|
49646
49675
|
this.api = options.api || new RealtimeAPI_default(options);
|
|
49647
49676
|
this.tenant = options.tenant || "";
|
|
49648
|
-
|
|
49677
|
+
if (!Number.isNaN(options.minZoomInterpolation)) {
|
|
49678
|
+
this.minZoomInterpolation = options.minZoomInterpolation || 0;
|
|
49679
|
+
}
|
|
49649
49680
|
this.format = new GeoJSON_default();
|
|
49650
49681
|
const allMots = [
|
|
49651
49682
|
"tram",
|
|
@@ -50506,14 +50537,15 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50506
50537
|
super.setBbox(newExtent, newZoom);
|
|
50507
50538
|
}
|
|
50508
50539
|
highlightTrajectory(id) {
|
|
50509
|
-
this.api.getFullTrajectory(id, this.mode, this.generalizationLevel).then((data) => {
|
|
50540
|
+
return this.api.getFullTrajectory(id, this.mode, this.generalizationLevel).then((data) => {
|
|
50510
50541
|
const fullTrajectory = data.content;
|
|
50511
50542
|
this.vectorLayer.getSource().clear();
|
|
50512
50543
|
if (!fullTrajectory || !fullTrajectory.features || !fullTrajectory.features.length) {
|
|
50513
|
-
return;
|
|
50544
|
+
return void 0;
|
|
50514
50545
|
}
|
|
50515
50546
|
const features = format.readFeatures(fullTrajectory);
|
|
50516
50547
|
this.vectorLayer.getSource().addFeatures(features);
|
|
50548
|
+
return features;
|
|
50517
50549
|
});
|
|
50518
50550
|
}
|
|
50519
50551
|
clone(newOptions) {
|