mobility-toolbox-js 2.0.0-beta.70 → 2.0.0-beta.73
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 +1 -1
- package/api/RealtimeAPI.d.ts.map +1 -1
- package/common/styles/index.d.ts +1 -0
- package/common/styles/index.js +1 -0
- 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/getVehiclePosition.d.ts.map +1 -1
- package/common/utils/getVehiclePosition.js +5 -1
- package/common/utils/index.d.ts +1 -0
- package/common/utils/index.js +1 -0
- package/common/utils/renderTrajectories.js +3 -2
- package/mbt.js +130 -27
- package/mbt.js.map +4 -4
- package/mbt.min.js +28 -28
- package/mbt.min.js.map +4 -4
- package/ol/layers/RealtimeLayer.d.ts +1 -1
- package/ol/layers/RealtimeLayer.d.ts.map +1 -1
- package/ol/layers/RealtimeLayer.js +15 -3
- package/package.json +1 -1
package/api/RealtimeAPI.d.ts
CHANGED
|
@@ -193,7 +193,7 @@ declare class RealtimeAPI {
|
|
|
193
193
|
* @param {function} onError Callback when the subscription fails.
|
|
194
194
|
* @param {boolean} [quiet=false] If true avoid to store the subscription in the subscriptions list.
|
|
195
195
|
*/
|
|
196
|
-
subscribeTrajectory(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrajectoryResponse[]>, onError?: EventListener, quiet?: boolean): void;
|
|
196
|
+
subscribeTrajectory(mode: RealtimeMode, onMessage: WebSocketAPIMessageCallback<RealtimeTrajectoryResponse[] | RealtimeTrajectoryResponse>, onError?: EventListener, quiet?: boolean): void;
|
|
197
197
|
/**
|
|
198
198
|
* Unsubscribe to trajectory channels.
|
|
199
199
|
* @param {function(data: { content: RealtimeTrajectoryResponse[] })} onMessage Callback function to unsubscribe. If null all subscriptions for the channel will be unsubscribed.
|
package/api/RealtimeAPI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AAC,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/common/styles/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as realtimeDefaultStyle } from "./realtimeDefaultStyle";
|
|
2
2
|
export { default as realtimeDelayStyle } from "./realtimeDelayStyle";
|
|
3
3
|
export { default as realtimeSimpleStyle } from "./realtimeSimpleStyle";
|
|
4
|
+
export { default as realtimeHeadingStyle } from "./realtimeHeadingStyle";
|
|
4
5
|
export * from "./realtimeDefaultStyle";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/common/styles/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as realtimeDefaultStyle } from './realtimeDefaultStyle';
|
|
2
2
|
export { default as realtimeDelayStyle } from './realtimeDelayStyle';
|
|
3
3
|
export { default as realtimeSimpleStyle } from './realtimeSimpleStyle';
|
|
4
|
+
export { default as realtimeHeadingStyle } from './realtimeHeadingStyle';
|
|
4
5
|
export * from './realtimeDefaultStyle';
|
|
@@ -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":"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/common/utils/index.d.ts
CHANGED
|
@@ -12,5 +12,6 @@ export { default as debounceDeparturesMessages } from "./debounceDeparturesMessa
|
|
|
12
12
|
export { default as debounceWebsocketMessages } from "./debounceWebsocketMessages";
|
|
13
13
|
export { default as sortAndFilterDepartures } from "./sortAndFilterDepartures";
|
|
14
14
|
export { default as compareDepartures } from "./compareDepartures";
|
|
15
|
+
export { default as createCanvas } from "./createCanvas";
|
|
15
16
|
export * as realtimeConfig from "./realtimeConfig";
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
package/common/utils/index.js
CHANGED
|
@@ -12,5 +12,6 @@ export { default as debounceDeparturesMessages } from './debounceDeparturesMessa
|
|
|
12
12
|
export { default as debounceWebsocketMessages } from './debounceWebsocketMessages';
|
|
13
13
|
export { default as sortAndFilterDepartures } from './sortAndFilterDepartures';
|
|
14
14
|
export { default as compareDepartures } from './compareDepartures';
|
|
15
|
+
export { default as createCanvas } from './createCanvas';
|
|
15
16
|
import * as realtimeConfig_1 from './realtimeConfig';
|
|
16
17
|
export { realtimeConfig_1 as realtimeConfig };
|
|
@@ -52,10 +52,11 @@ const renderTrajectories = (canvas, trajectories, style, viewState, options) =>
|
|
|
52
52
|
const { train_id: id, timeOffset } = trajectory.properties;
|
|
53
53
|
// We set the rotation and the timeFraction of the trajectory (used by tralis).
|
|
54
54
|
// if rotation === null that seems there is no rotation available.
|
|
55
|
-
const { coord, rotation:
|
|
55
|
+
const { coord, rotation: heading } = getVehiclePosition(time - (timeOffset || 0), trajectory, noInterpolate);
|
|
56
|
+
// console.log(heading);
|
|
56
57
|
// We store the current vehicle position to the trajectory.
|
|
57
58
|
trajectories[i].properties.coordinate = coord;
|
|
58
|
-
trajectories[i].properties.rotation =
|
|
59
|
+
trajectories[i].properties.rotation = heading;
|
|
59
60
|
if (!coord) {
|
|
60
61
|
// eslint-disable-next-line no-continue
|
|
61
62
|
continue;
|
package/mbt.js
CHANGED
|
@@ -33297,6 +33297,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
33297
33297
|
VectorLayer: () => VectorLayer_default2,
|
|
33298
33298
|
WMSLayer: () => WMSLayer_default,
|
|
33299
33299
|
compareDepartures: () => compareDepartures_default,
|
|
33300
|
+
createCanvas: () => createCanvas_default,
|
|
33300
33301
|
createRealtimeFilters: () => createRealtimeFilters_default,
|
|
33301
33302
|
debounceDeparturesMessages: () => debounceDeparturesMessages_default,
|
|
33302
33303
|
debounceWebsocketMessages: () => debounceWebsocketMessages_default,
|
|
@@ -33318,6 +33319,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
33318
33319
|
realtimeConfig: () => realtimeConfig_exports,
|
|
33319
33320
|
realtimeDefaultStyle: () => realtimeDefaultStyle_default,
|
|
33320
33321
|
realtimeDelayStyle: () => realtimeDelayStyle_default,
|
|
33322
|
+
realtimeHeadingStyle: () => realtimeHeadingStyle_default,
|
|
33321
33323
|
realtimeSimpleStyle: () => realtimeSimpleStyle_default,
|
|
33322
33324
|
removeDuplicate: () => removeDuplicate_default,
|
|
33323
33325
|
renderTrajectories: () => renderTrajectories_default,
|
|
@@ -37985,10 +37987,14 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
37985
37987
|
olGeometry,
|
|
37986
37988
|
coordinate
|
|
37987
37989
|
} = trajectory.properties;
|
|
37988
|
-
const {
|
|
37990
|
+
const { coordinates: coordinates2 } = trajectory.geometry;
|
|
37991
|
+
let { type } = trajectory.geometry;
|
|
37989
37992
|
let geometry = olGeometry;
|
|
37990
37993
|
let coord;
|
|
37991
37994
|
let rotation;
|
|
37995
|
+
if (olGeometry) {
|
|
37996
|
+
type = geometry.getType();
|
|
37997
|
+
}
|
|
37992
37998
|
if (noInterpolate && coordinate) {
|
|
37993
37999
|
coord = coordinate;
|
|
37994
38000
|
} else if (type === "Point") {
|
|
@@ -38083,13 +38089,13 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
38083
38089
|
continue;
|
|
38084
38090
|
}
|
|
38085
38091
|
const { train_id: id, timeOffset } = trajectory.properties;
|
|
38086
|
-
const { coord, rotation:
|
|
38092
|
+
const { coord, rotation: heading } = getVehiclePosition_default(
|
|
38087
38093
|
time - (timeOffset || 0),
|
|
38088
38094
|
trajectory,
|
|
38089
38095
|
noInterpolate
|
|
38090
38096
|
);
|
|
38091
38097
|
trajectories[i].properties.coordinate = coord;
|
|
38092
|
-
trajectories[i].properties.rotation =
|
|
38098
|
+
trajectories[i].properties.rotation = heading;
|
|
38093
38099
|
if (!coord) {
|
|
38094
38100
|
continue;
|
|
38095
38101
|
}
|
|
@@ -38324,6 +38330,27 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
38324
38330
|
};
|
|
38325
38331
|
var debounceDeparturesMessages_default = debounceDeparturesMessages;
|
|
38326
38332
|
|
|
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
|
+
|
|
38327
38354
|
// src/common/utils/realtimeConfig.ts
|
|
38328
38355
|
var realtimeConfig_exports = {};
|
|
38329
38356
|
__export(realtimeConfig_exports, {
|
|
@@ -38471,27 +38498,6 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
38471
38498
|
return "";
|
|
38472
38499
|
};
|
|
38473
38500
|
|
|
38474
|
-
// src/common/utils/createCanvas.ts
|
|
38475
|
-
var createCanvas = (width, height) => {
|
|
38476
|
-
let canvas2 = null;
|
|
38477
|
-
if (typeof window === "undefined") {
|
|
38478
|
-
return null;
|
|
38479
|
-
}
|
|
38480
|
-
if (typeof document !== "undefined" && document?.createElement) {
|
|
38481
|
-
canvas2 = document.createElement("canvas");
|
|
38482
|
-
canvas2.width = width;
|
|
38483
|
-
canvas2.height = height;
|
|
38484
|
-
} else if (OffscreenCanvas) {
|
|
38485
|
-
canvas2 = new OffscreenCanvas(width, height);
|
|
38486
|
-
} else {
|
|
38487
|
-
console.error(
|
|
38488
|
-
"We didn't find a way to create a canvas element, document.createElement('canvas') and new OffscrenCanvas() are not supported"
|
|
38489
|
-
);
|
|
38490
|
-
}
|
|
38491
|
-
return canvas2;
|
|
38492
|
-
};
|
|
38493
|
-
var createCanvas_default = createCanvas;
|
|
38494
|
-
|
|
38495
38501
|
// src/common/styles/realtimeDefaultStyle.ts
|
|
38496
38502
|
var cacheDelayBg = {};
|
|
38497
38503
|
var getDelayBgCanvas = (origin, radius, color) => {
|
|
@@ -38796,6 +38802,93 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
38796
38802
|
};
|
|
38797
38803
|
var realtimeSimpleStyle_default = realtimeSimpleStyle;
|
|
38798
38804
|
|
|
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
|
+
|
|
38799
38892
|
// node_modules/ol/layer/Property.js
|
|
38800
38893
|
var Property_default = {
|
|
38801
38894
|
OPACITY: "opacity",
|
|
@@ -50407,10 +50500,13 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50407
50500
|
return;
|
|
50408
50501
|
}
|
|
50409
50502
|
const view = this.map.getView();
|
|
50503
|
+
if (!view.getCenter()) {
|
|
50504
|
+
return;
|
|
50505
|
+
}
|
|
50410
50506
|
super.renderTrajectories(
|
|
50411
50507
|
{
|
|
50412
50508
|
size: this.map.getSize(),
|
|
50413
|
-
center:
|
|
50509
|
+
center: view.getCenter(),
|
|
50414
50510
|
extent: view.calculateExtent(),
|
|
50415
50511
|
resolution: view.getResolution(),
|
|
50416
50512
|
rotation: view.getRotation(),
|
|
@@ -50483,6 +50579,10 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50483
50579
|
}
|
|
50484
50580
|
}
|
|
50485
50581
|
purgeTrajectory(trajectory, extent, zoom) {
|
|
50582
|
+
const center = this.map.getView().getCenter();
|
|
50583
|
+
if (!extent && !center) {
|
|
50584
|
+
return false;
|
|
50585
|
+
}
|
|
50486
50586
|
return super.purgeTrajectory(
|
|
50487
50587
|
trajectory,
|
|
50488
50588
|
extent || this.map.getView().calculateExtent(),
|
|
@@ -50499,14 +50599,15 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50499
50599
|
super.setBbox(newExtent, newZoom);
|
|
50500
50600
|
}
|
|
50501
50601
|
highlightTrajectory(id) {
|
|
50502
|
-
this.api.getFullTrajectory(id, this.mode, this.generalizationLevel).then((data) => {
|
|
50602
|
+
return this.api.getFullTrajectory(id, this.mode, this.generalizationLevel).then((data) => {
|
|
50503
50603
|
const fullTrajectory = data.content;
|
|
50504
50604
|
this.vectorLayer.getSource().clear();
|
|
50505
50605
|
if (!fullTrajectory || !fullTrajectory.features || !fullTrajectory.features.length) {
|
|
50506
|
-
return;
|
|
50606
|
+
return void 0;
|
|
50507
50607
|
}
|
|
50508
50608
|
const features = format.readFeatures(fullTrajectory);
|
|
50509
50609
|
this.vectorLayer.getSource().addFeatures(features);
|
|
50610
|
+
return features;
|
|
50510
50611
|
});
|
|
50511
50612
|
}
|
|
50512
50613
|
clone(newOptions) {
|
|
@@ -50600,6 +50701,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50600
50701
|
RoutingAPI: () => RoutingAPI_default,
|
|
50601
50702
|
StopsAPI: () => StopsAPI_default,
|
|
50602
50703
|
compareDepartures: () => compareDepartures_default,
|
|
50704
|
+
createCanvas: () => createCanvas_default,
|
|
50603
50705
|
createRealtimeFilters: () => createRealtimeFilters_default,
|
|
50604
50706
|
debounceDeparturesMessages: () => debounceDeparturesMessages_default,
|
|
50605
50707
|
debounceWebsocketMessages: () => debounceWebsocketMessages_default,
|
|
@@ -50621,6 +50723,7 @@ uniform ${i3} ${o3} u_${a3};
|
|
|
50621
50723
|
realtimeConfig: () => realtimeConfig_exports,
|
|
50622
50724
|
realtimeDefaultStyle: () => realtimeDefaultStyle_default,
|
|
50623
50725
|
realtimeDelayStyle: () => realtimeDelayStyle_default,
|
|
50726
|
+
realtimeHeadingStyle: () => realtimeHeadingStyle_default,
|
|
50624
50727
|
realtimeSimpleStyle: () => realtimeSimpleStyle_default,
|
|
50625
50728
|
removeDuplicate: () => removeDuplicate_default,
|
|
50626
50729
|
renderTrajectories: () => renderTrajectories_default,
|