mobility-toolbox-js 2.0.0-beta.73 → 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/index.d.ts +0 -1
- package/common/styles/index.js +0 -1
- 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/index.d.ts +0 -1
- package/common/utils/index.js +0 -1
- package/common/utils/renderTrajectories.js +2 -3
- package/mbt.js +66 -130
- package/mbt.js.map +4 -4
- package/mbt.min.js +28 -28
- package/mbt.min.js.map +4 -4
- package/package.json +1 -1
package/mbt.js
CHANGED
|
@@ -33297,7 +33297,6 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
33297
33297
|
VectorLayer: () => VectorLayer_default2,
|
|
33298
33298
|
WMSLayer: () => WMSLayer_default,
|
|
33299
33299
|
compareDepartures: () => compareDepartures_default,
|
|
33300
|
-
createCanvas: () => createCanvas_default,
|
|
33301
33300
|
createRealtimeFilters: () => createRealtimeFilters_default,
|
|
33302
33301
|
debounceDeparturesMessages: () => debounceDeparturesMessages_default,
|
|
33303
33302
|
debounceWebsocketMessages: () => debounceWebsocketMessages_default,
|
|
@@ -33319,7 +33318,6 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
33319
33318
|
realtimeConfig: () => realtimeConfig_exports,
|
|
33320
33319
|
realtimeDefaultStyle: () => realtimeDefaultStyle_default,
|
|
33321
33320
|
realtimeDelayStyle: () => realtimeDelayStyle_default,
|
|
33322
|
-
realtimeHeadingStyle: () => realtimeHeadingStyle_default,
|
|
33323
33321
|
realtimeSimpleStyle: () => realtimeSimpleStyle_default,
|
|
33324
33322
|
removeDuplicate: () => removeDuplicate_default,
|
|
33325
33323
|
renderTrajectories: () => renderTrajectories_default,
|
|
@@ -34193,8 +34191,14 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34193
34191
|
var debounceWebsocketMessages_default = debounceWebsocketMessages;
|
|
34194
34192
|
|
|
34195
34193
|
// src/common/utils/getRealtimeModeSuffix.ts
|
|
34196
|
-
var
|
|
34197
|
-
|
|
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;
|
|
34198
34202
|
|
|
34199
34203
|
// src/api/RealtimeAPI.ts
|
|
34200
34204
|
var RealtimeModes = {
|
|
@@ -34205,7 +34209,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34205
34209
|
var RealtimeAPI = class {
|
|
34206
34210
|
constructor(options = {}) {
|
|
34207
34211
|
this.defineProperties(options);
|
|
34208
|
-
this.
|
|
34212
|
+
this.tenant = options.tenant;
|
|
34209
34213
|
this.onOpen = this.onOpen.bind(this);
|
|
34210
34214
|
}
|
|
34211
34215
|
defineProperties(options) {
|
|
@@ -34326,16 +34330,18 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34326
34330
|
this.wsApi.subscribe({ channel }, onSuccess, onError, quiet);
|
|
34327
34331
|
}
|
|
34328
34332
|
unsubscribe(channel, suffix = "", onMessage) {
|
|
34329
|
-
const
|
|
34333
|
+
const suffixSchematic = getRealtimeModeSuffix_default(
|
|
34330
34334
|
RealtimeModes.SCHEMATIC,
|
|
34331
|
-
RealtimeModes
|
|
34335
|
+
RealtimeModes,
|
|
34336
|
+
this.tenant
|
|
34332
34337
|
);
|
|
34333
34338
|
const suffixTopographic = getRealtimeModeSuffix_default(
|
|
34334
34339
|
RealtimeModes.TOPOGRAPHIC,
|
|
34335
|
-
RealtimeModes
|
|
34340
|
+
RealtimeModes,
|
|
34341
|
+
this.tenant
|
|
34336
34342
|
);
|
|
34337
34343
|
this.wsApi.unsubscribe(
|
|
34338
|
-
`${channel}${
|
|
34344
|
+
`${channel}${suffixSchematic}${suffix || ""}`,
|
|
34339
34345
|
onMessage
|
|
34340
34346
|
);
|
|
34341
34347
|
this.wsApi.unsubscribe(
|
|
@@ -34352,14 +34358,20 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34352
34358
|
}
|
|
34353
34359
|
subscribeDisruptions(onMessage, onError = () => {
|
|
34354
34360
|
}, quiet = false) {
|
|
34355
|
-
this.
|
|
34361
|
+
const channel = [this.tenant, "newsticker"];
|
|
34362
|
+
this.subscribe(channel.join("_"), onMessage, onError, quiet);
|
|
34356
34363
|
}
|
|
34357
34364
|
unsubscribeDisruptions(onMessage) {
|
|
34358
|
-
this.
|
|
34365
|
+
const channel = [this.tenant, "newsticker"];
|
|
34366
|
+
this.unsubscribe(channel.join("_"), "", onMessage);
|
|
34359
34367
|
}
|
|
34360
34368
|
getStation(uic, mode) {
|
|
34361
34369
|
const params = {
|
|
34362
|
-
channel: `station${getRealtimeModeSuffix_default(
|
|
34370
|
+
channel: `station${getRealtimeModeSuffix_default(
|
|
34371
|
+
mode,
|
|
34372
|
+
RealtimeModes,
|
|
34373
|
+
this.tenant
|
|
34374
|
+
)}`,
|
|
34363
34375
|
args: uic
|
|
34364
34376
|
};
|
|
34365
34377
|
return new Promise((resolve, reject) => {
|
|
@@ -34370,7 +34382,11 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34370
34382
|
return new Promise((resolve) => {
|
|
34371
34383
|
this.wsApi.get(
|
|
34372
34384
|
{
|
|
34373
|
-
channel: `station${getRealtimeModeSuffix_default(
|
|
34385
|
+
channel: `station${getRealtimeModeSuffix_default(
|
|
34386
|
+
mode,
|
|
34387
|
+
RealtimeModes,
|
|
34388
|
+
this.tenant
|
|
34389
|
+
)}`
|
|
34374
34390
|
},
|
|
34375
34391
|
debounceWebsocketMessages_default(resolve, void 0, timeout)
|
|
34376
34392
|
);
|
|
@@ -34379,7 +34395,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34379
34395
|
subscribeStations(mode, onMessage, onError = () => {
|
|
34380
34396
|
}, quiet = false) {
|
|
34381
34397
|
this.subscribe(
|
|
34382
|
-
`station${getRealtimeModeSuffix_default(mode, RealtimeModes)}`,
|
|
34398
|
+
`station${getRealtimeModeSuffix_default(mode, RealtimeModes, this.tenant)}`,
|
|
34383
34399
|
onMessage,
|
|
34384
34400
|
onError,
|
|
34385
34401
|
quiet
|
|
@@ -34399,7 +34415,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34399
34415
|
}, quiet = false) {
|
|
34400
34416
|
this.unsubscribeTrajectory(onMessage);
|
|
34401
34417
|
this.subscribe(
|
|
34402
|
-
`trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes)}`,
|
|
34418
|
+
`trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes, this.tenant)}`,
|
|
34403
34419
|
onMessage,
|
|
34404
34420
|
onError,
|
|
34405
34421
|
quiet
|
|
@@ -34412,7 +34428,11 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34412
34428
|
}, quiet = false) {
|
|
34413
34429
|
this.unsubscribeDeletedVehicles(onMessage);
|
|
34414
34430
|
this.subscribe(
|
|
34415
|
-
`deleted_vehicles${getRealtimeModeSuffix_default(
|
|
34431
|
+
`deleted_vehicles${getRealtimeModeSuffix_default(
|
|
34432
|
+
mode,
|
|
34433
|
+
RealtimeModes,
|
|
34434
|
+
this.tenant
|
|
34435
|
+
)}`,
|
|
34416
34436
|
onMessage,
|
|
34417
34437
|
onError,
|
|
34418
34438
|
quiet
|
|
@@ -34422,7 +34442,9 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
34422
34442
|
this.unsubscribe("deleted_vehicles", "", onMessage);
|
|
34423
34443
|
}
|
|
34424
34444
|
getFullTrajectory(id, mode, generalizationLevel) {
|
|
34425
|
-
const channel = [
|
|
34445
|
+
const channel = [
|
|
34446
|
+
`full_trajectory${getRealtimeModeSuffix_default(mode, RealtimeModes)}`
|
|
34447
|
+
];
|
|
34426
34448
|
if (id) {
|
|
34427
34449
|
channel.push(id);
|
|
34428
34450
|
}
|
|
@@ -38089,13 +38111,13 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
38089
38111
|
continue;
|
|
38090
38112
|
}
|
|
38091
38113
|
const { train_id: id, timeOffset } = trajectory.properties;
|
|
38092
|
-
const { coord, rotation:
|
|
38114
|
+
const { coord, rotation: rotationIcon } = getVehiclePosition_default(
|
|
38093
38115
|
time - (timeOffset || 0),
|
|
38094
38116
|
trajectory,
|
|
38095
38117
|
noInterpolate
|
|
38096
38118
|
);
|
|
38097
38119
|
trajectories[i].properties.coordinate = coord;
|
|
38098
|
-
trajectories[i].properties.rotation =
|
|
38120
|
+
trajectories[i].properties.rotation = rotationIcon;
|
|
38099
38121
|
if (!coord) {
|
|
38100
38122
|
continue;
|
|
38101
38123
|
}
|
|
@@ -38330,27 +38352,6 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
38330
38352
|
};
|
|
38331
38353
|
var debounceDeparturesMessages_default = debounceDeparturesMessages;
|
|
38332
38354
|
|
|
38333
|
-
// src/common/utils/createCanvas.ts
|
|
38334
|
-
var createCanvas = (width, height) => {
|
|
38335
|
-
let canvas2 = null;
|
|
38336
|
-
if (typeof window === "undefined") {
|
|
38337
|
-
return null;
|
|
38338
|
-
}
|
|
38339
|
-
if (typeof document !== "undefined" && document?.createElement) {
|
|
38340
|
-
canvas2 = document.createElement("canvas");
|
|
38341
|
-
canvas2.width = width;
|
|
38342
|
-
canvas2.height = height;
|
|
38343
|
-
} else if (OffscreenCanvas) {
|
|
38344
|
-
canvas2 = new OffscreenCanvas(width, height);
|
|
38345
|
-
} else {
|
|
38346
|
-
console.error(
|
|
38347
|
-
"We didn't find a way to create a canvas element, document.createElement('canvas') and new OffscrenCanvas() are not supported"
|
|
38348
|
-
);
|
|
38349
|
-
}
|
|
38350
|
-
return canvas2;
|
|
38351
|
-
};
|
|
38352
|
-
var createCanvas_default = createCanvas;
|
|
38353
|
-
|
|
38354
38355
|
// src/common/utils/realtimeConfig.ts
|
|
38355
38356
|
var realtimeConfig_exports = {};
|
|
38356
38357
|
__export(realtimeConfig_exports, {
|
|
@@ -38498,6 +38499,27 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
38498
38499
|
return "";
|
|
38499
38500
|
};
|
|
38500
38501
|
|
|
38502
|
+
// src/common/utils/createCanvas.ts
|
|
38503
|
+
var createCanvas = (width, height) => {
|
|
38504
|
+
let canvas2 = null;
|
|
38505
|
+
if (typeof window === "undefined") {
|
|
38506
|
+
return null;
|
|
38507
|
+
}
|
|
38508
|
+
if (typeof document !== "undefined" && document?.createElement) {
|
|
38509
|
+
canvas2 = document.createElement("canvas");
|
|
38510
|
+
canvas2.width = width;
|
|
38511
|
+
canvas2.height = height;
|
|
38512
|
+
} else if (OffscreenCanvas) {
|
|
38513
|
+
canvas2 = new OffscreenCanvas(width, height);
|
|
38514
|
+
} else {
|
|
38515
|
+
console.error(
|
|
38516
|
+
"We didn't find a way to create a canvas element, document.createElement('canvas') and new OffscrenCanvas() are not supported"
|
|
38517
|
+
);
|
|
38518
|
+
}
|
|
38519
|
+
return canvas2;
|
|
38520
|
+
};
|
|
38521
|
+
var createCanvas_default = createCanvas;
|
|
38522
|
+
|
|
38501
38523
|
// src/common/styles/realtimeDefaultStyle.ts
|
|
38502
38524
|
var cacheDelayBg = {};
|
|
38503
38525
|
var getDelayBgCanvas = (origin, radius, color) => {
|
|
@@ -38802,93 +38824,6 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
38802
38824
|
};
|
|
38803
38825
|
var realtimeSimpleStyle_default = realtimeSimpleStyle;
|
|
38804
38826
|
|
|
38805
|
-
// src/common/styles/realtimeHeadingStyle.ts
|
|
38806
|
-
var rotateCanvas = (canvas2, rotation) => {
|
|
38807
|
-
const ctx = canvas2.getContext("2d");
|
|
38808
|
-
ctx?.translate(canvas2.width / 2, canvas2.height / 2);
|
|
38809
|
-
ctx?.rotate(rotation);
|
|
38810
|
-
ctx?.translate(-canvas2.width / 2, -canvas2.height / 2);
|
|
38811
|
-
};
|
|
38812
|
-
var arrowCache = {};
|
|
38813
|
-
var getArrowCanvas = (fillColor) => {
|
|
38814
|
-
const key = `${fillColor}`;
|
|
38815
|
-
if (!arrowCache[key]) {
|
|
38816
|
-
const arrowCanvas = createCanvas_default(20, 20);
|
|
38817
|
-
const ctx = arrowCanvas?.getContext("2d");
|
|
38818
|
-
if (ctx) {
|
|
38819
|
-
ctx.fillStyle = fillColor;
|
|
38820
|
-
ctx.beginPath();
|
|
38821
|
-
ctx.moveTo(5, 5);
|
|
38822
|
-
ctx.lineTo(10, 10);
|
|
38823
|
-
ctx.lineTo(5, 15);
|
|
38824
|
-
ctx.fill();
|
|
38825
|
-
ctx.beginPath();
|
|
38826
|
-
ctx.moveTo(5, 5);
|
|
38827
|
-
ctx.lineTo(10, 10);
|
|
38828
|
-
ctx.lineTo(5, 15);
|
|
38829
|
-
ctx.lineTo(5, 5);
|
|
38830
|
-
ctx.stroke();
|
|
38831
|
-
}
|
|
38832
|
-
arrowCache[key] = arrowCanvas;
|
|
38833
|
-
}
|
|
38834
|
-
return arrowCache[key];
|
|
38835
|
-
};
|
|
38836
|
-
var bufferArrowCache = {};
|
|
38837
|
-
var getBufferArrowCanvas = (canvas2, fillColor, rotation) => {
|
|
38838
|
-
const margin = 20;
|
|
38839
|
-
const bufferKey = `${fillColor},${canvas2.width},${canvas2.height},${rotation}`;
|
|
38840
|
-
if (!bufferArrowCache[bufferKey]) {
|
|
38841
|
-
const buffer2 = createCanvas_default(
|
|
38842
|
-
canvas2.width + margin * 2,
|
|
38843
|
-
canvas2.height + margin * 2
|
|
38844
|
-
);
|
|
38845
|
-
const arrowCanvas = getArrowCanvas(fillColor);
|
|
38846
|
-
if (arrowCanvas && buffer2) {
|
|
38847
|
-
const bufferCtx = buffer2.getContext("2d");
|
|
38848
|
-
bufferCtx?.drawImage(
|
|
38849
|
-
arrowCanvas,
|
|
38850
|
-
buffer2.width - margin,
|
|
38851
|
-
buffer2.height / 2 - arrowCanvas.height / 2,
|
|
38852
|
-
arrowCanvas.width,
|
|
38853
|
-
arrowCanvas.height
|
|
38854
|
-
);
|
|
38855
|
-
bufferCtx?.save();
|
|
38856
|
-
const rot = rotation + 90 * Math.PI / 180;
|
|
38857
|
-
rotateCanvas(buffer2, -rot);
|
|
38858
|
-
bufferCtx?.restore();
|
|
38859
|
-
}
|
|
38860
|
-
bufferArrowCache[bufferKey] = buffer2;
|
|
38861
|
-
}
|
|
38862
|
-
return bufferArrowCache[bufferKey];
|
|
38863
|
-
};
|
|
38864
|
-
var realtimeHeadingStyle = (trajectory, viewState, options) => {
|
|
38865
|
-
const { rotation, type, line } = trajectory.properties;
|
|
38866
|
-
const { color } = line || {};
|
|
38867
|
-
const canvas2 = realtimeDefaultStyle_default(trajectory, viewState, options);
|
|
38868
|
-
if (canvas2 && rotation !== null) {
|
|
38869
|
-
const circleFillColor = color || getBgColor(type);
|
|
38870
|
-
const bufferArrow = getBufferArrowCanvas(canvas2, circleFillColor, rotation);
|
|
38871
|
-
if (bufferArrow) {
|
|
38872
|
-
const bufferSize = (bufferArrow.width - canvas2.width) / 2;
|
|
38873
|
-
const vehicleWithArrow = createCanvas_default(
|
|
38874
|
-
bufferArrow.width,
|
|
38875
|
-
bufferArrow.height
|
|
38876
|
-
);
|
|
38877
|
-
vehicleWithArrow?.getContext("2d")?.drawImage(bufferArrow, 0, 0, bufferArrow.width, bufferArrow.height);
|
|
38878
|
-
vehicleWithArrow?.getContext("2d")?.drawImage(
|
|
38879
|
-
canvas2,
|
|
38880
|
-
bufferSize,
|
|
38881
|
-
bufferSize,
|
|
38882
|
-
canvas2.width,
|
|
38883
|
-
canvas2.height
|
|
38884
|
-
);
|
|
38885
|
-
return vehicleWithArrow;
|
|
38886
|
-
}
|
|
38887
|
-
}
|
|
38888
|
-
return canvas2;
|
|
38889
|
-
};
|
|
38890
|
-
var realtimeHeadingStyle_default = realtimeHeadingStyle;
|
|
38891
|
-
|
|
38892
38827
|
// node_modules/ol/layer/Property.js
|
|
38893
38828
|
var Property_default = {
|
|
38894
38829
|
OPACITY: "opacity",
|
|
@@ -49734,11 +49669,14 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
49734
49669
|
hitTolerance: 10,
|
|
49735
49670
|
...options
|
|
49736
49671
|
});
|
|
49672
|
+
this.minZoomInterpolation = 8;
|
|
49737
49673
|
this.debug = options.debug || false;
|
|
49738
49674
|
this.mode = options.mode || RealtimeModes.TOPOGRAPHIC;
|
|
49739
49675
|
this.api = options.api || new RealtimeAPI_default(options);
|
|
49740
49676
|
this.tenant = options.tenant || "";
|
|
49741
|
-
|
|
49677
|
+
if (!Number.isNaN(options.minZoomInterpolation)) {
|
|
49678
|
+
this.minZoomInterpolation = options.minZoomInterpolation || 0;
|
|
49679
|
+
}
|
|
49742
49680
|
this.format = new GeoJSON_default();
|
|
49743
49681
|
const allMots = [
|
|
49744
49682
|
"tram",
|
|
@@ -50701,7 +50639,6 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50701
50639
|
RoutingAPI: () => RoutingAPI_default,
|
|
50702
50640
|
StopsAPI: () => StopsAPI_default,
|
|
50703
50641
|
compareDepartures: () => compareDepartures_default,
|
|
50704
|
-
createCanvas: () => createCanvas_default,
|
|
50705
50642
|
createRealtimeFilters: () => createRealtimeFilters_default,
|
|
50706
50643
|
debounceDeparturesMessages: () => debounceDeparturesMessages_default,
|
|
50707
50644
|
debounceWebsocketMessages: () => debounceWebsocketMessages_default,
|
|
@@ -50723,7 +50660,6 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50723
50660
|
realtimeConfig: () => realtimeConfig_exports,
|
|
50724
50661
|
realtimeDefaultStyle: () => realtimeDefaultStyle_default,
|
|
50725
50662
|
realtimeDelayStyle: () => realtimeDelayStyle_default,
|
|
50726
|
-
realtimeHeadingStyle: () => realtimeHeadingStyle_default,
|
|
50727
50663
|
realtimeSimpleStyle: () => realtimeSimpleStyle_default,
|
|
50728
50664
|
removeDuplicate: () => removeDuplicate_default,
|
|
50729
50665
|
renderTrajectories: () => renderTrajectories_default,
|