mobility-toolbox-js 2.0.0-beta.30 → 2.0.0-beta.34
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 +268 -0
- package/api/RealtimeAPI.d.ts.map +1 -0
- package/api/RealtimeAPI.js +626 -343
- package/api/RoutingAPI.d.ts +33 -0
- package/api/RoutingAPI.d.ts.map +1 -0
- package/api/RoutingAPI.js +65 -15
- package/api/StopsAPI.d.ts +36 -0
- package/api/StopsAPI.d.ts.map +1 -0
- package/api/StopsAPI.js +70 -12
- package/api/index.d.ts +5 -0
- package/api/index.d.ts.map +1 -0
- package/api/index.js +10 -3
- package/api/typedefs.d.ts +105 -0
- package/api/typedefs.d.ts.map +1 -0
- package/api/typedefs.js +72 -0
- package/common/api/HttpAPI.d.ts +31 -0
- package/common/api/HttpAPI.d.ts.map +1 -0
- package/common/api/HttpAPI.js +82 -30
- package/common/api/WebSocketAPI.d.ts +95 -0
- package/common/api/WebSocketAPI.d.ts.map +1 -0
- package/common/api/WebSocketAPI.js +313 -168
- package/common/controls/Control.d.ts +74 -0
- package/common/controls/Control.d.ts.map +1 -0
- package/common/controls/Control.js +167 -78
- package/common/index.d.ts +3 -0
- package/common/index.d.ts.map +1 -0
- package/common/index.js +18 -2
- package/common/layers/Layer.d.ts +80 -0
- package/common/layers/Layer.d.ts.map +1 -0
- package/common/layers/Layer.js +251 -134
- package/common/mixins/CopyrightMixin.d.ts +22 -0
- package/common/mixins/CopyrightMixin.d.ts.map +1 -0
- package/common/mixins/CopyrightMixin.js +70 -22
- package/common/mixins/MapboxLayerMixin.d.ts +27 -0
- package/common/mixins/MapboxLayerMixin.d.ts.map +1 -0
- package/common/mixins/MapboxLayerMixin.js +240 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +58 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
- package/common/mixins/RealtimeLayerMixin.js +698 -429
- package/common/mixins/StopFinderMixin.d.ts +40 -0
- package/common/mixins/StopFinderMixin.d.ts.map +1 -0
- package/common/mixins/StopFinderMixin.js +195 -107
- package/common/mixins/UserInteractionsLayerMixin.d.ts +42 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
- package/common/mixins/UserInteractionsLayerMixin.js +222 -121
- package/common/styles/index.d.ts +5 -0
- package/common/styles/index.d.ts.map +1 -0
- package/common/styles/index.js +24 -4
- package/common/styles/realtimeDefaultStyle.d.ts +15 -0
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.js +236 -190
- package/common/styles/realtimeDelayStyle.d.ts +11 -0
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
- package/common/styles/realtimeDelayStyle.js +25 -7
- package/common/styles/realtimeSimpleStyle.d.ts +3 -0
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
- package/common/styles/realtimeSimpleStyle.js +23 -17
- package/common/typedefs.d.ts +50 -0
- package/common/typedefs.d.ts.map +1 -0
- package/common/typedefs.js +21 -0
- package/common/utils/cleanStopTime.d.ts +7 -0
- package/common/utils/cleanStopTime.d.ts.map +1 -0
- package/common/utils/cleanStopTime.js +28 -17
- package/common/utils/compareDepartures.d.ts +9 -0
- package/common/utils/compareDepartures.d.ts.map +1 -0
- package/common/utils/compareDepartures.js +34 -22
- package/common/utils/createCanvas.d.ts +9 -0
- package/common/utils/createCanvas.d.ts.map +1 -0
- package/common/utils/createCanvas.js +28 -16
- package/common/utils/createTrackerFilters.d.ts +12 -0
- package/common/utils/createTrackerFilters.d.ts.map +1 -0
- package/common/utils/createTrackerFilters.js +75 -54
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
- package/common/utils/getLayersAsFlatArray.js +15 -13
- package/common/utils/getMapboxMapCopyrights.d.ts +8 -0
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
- package/common/utils/getMapboxMapCopyrights.js +24 -17
- package/common/utils/getMapboxRender.d.ts +5 -0
- package/common/utils/getMapboxRender.d.ts.map +1 -0
- package/common/utils/getMapboxRender.js +77 -0
- package/common/utils/getMaplibreRender.d.ts +5 -0
- package/common/utils/getMaplibreRender.d.ts.map +1 -0
- package/common/utils/getMaplibreRender.js +38 -0
- package/common/utils/getRealtimeModeSuffix.d.ts +8 -0
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
- package/common/utils/getRealtimeModeSuffix.js +11 -2
- package/common/utils/getUrlWithParams.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts.map +1 -0
- package/common/utils/getUrlWithParams.js +20 -10
- package/common/utils/getVehiclePosition.d.ts +14 -0
- package/common/utils/getVehiclePosition.d.ts.map +1 -0
- package/common/utils/getVehiclePosition.js +63 -39
- package/common/utils/index.d.ts +12 -0
- package/common/utils/index.d.ts.map +1 -0
- package/common/utils/index.js +37 -9
- package/common/utils/removeDuplicate.d.ts +10 -0
- package/common/utils/removeDuplicate.d.ts.map +1 -0
- package/common/utils/removeDuplicate.js +29 -7
- package/common/utils/renderTrajectories.d.ts +20 -0
- package/common/utils/renderTrajectories.d.ts.map +1 -0
- package/common/utils/renderTrajectories.js +111 -78
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.d.ts.map +1 -0
- package/common/utils/sortByDelay.js +21 -17
- package/common/utils/timeUtils.d.ts +5 -0
- package/common/utils/timeUtils.d.ts.map +1 -0
- package/common/utils/timeUtils.js +47 -18
- package/common/utils/trackerConfig.d.ts +24 -0
- package/common/utils/trackerConfig.d.ts.map +1 -0
- package/common/utils/trackerConfig.js +171 -118
- package/iife.d.ts +3 -0
- package/iife.d.ts.map +1 -0
- package/iife.js +7 -0
- package/index.d.ts +6 -0
- package/index.d.ts.map +1 -0
- package/index.js +10 -7
- package/mapbox/controls/CopyrightControl.d.ts +32 -0
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
- package/mapbox/controls/CopyrightControl.js +72 -28
- package/mapbox/controls/index.d.ts +2 -0
- package/mapbox/controls/index.d.ts.map +1 -0
- package/mapbox/controls/index.js +6 -1
- package/mapbox/index.d.ts +5 -0
- package/mapbox/index.d.ts.map +1 -0
- package/mapbox/index.js +20 -4
- package/mapbox/layers/Layer.d.ts +47 -0
- package/mapbox/layers/Layer.d.ts.map +1 -0
- package/mapbox/layers/Layer.js +137 -54
- package/mapbox/layers/RealtimeLayer.d.ts +118 -0
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
- package/mapbox/layers/RealtimeLayer.js +310 -183
- package/mapbox/layers/index.d.ts +3 -0
- package/mapbox/layers/index.d.ts.map +1 -0
- package/mapbox/layers/index.js +7 -2
- package/mapbox/utils.d.ts +8 -0
- package/mapbox/utils.d.ts.map +1 -0
- package/mapbox/utils.js +54 -29
- package/mbt.js +2052 -2109
- package/mbt.js.map +3 -3
- package/mbt.min.js +18 -18
- package/mbt.min.js.map +3 -3
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.d.ts.map +1 -0
- package/ol/controls/CopyrightControl.js +89 -41
- package/ol/controls/RoutingControl.d.ts +180 -0
- package/ol/controls/RoutingControl.d.ts.map +1 -0
- package/ol/controls/RoutingControl.js +666 -371
- package/ol/controls/StopFinderControl.d.ts +32 -0
- package/ol/controls/StopFinderControl.d.ts.map +1 -0
- package/ol/controls/StopFinderControl.js +59 -10
- package/ol/controls/index.d.ts +4 -0
- package/ol/controls/index.d.ts.map +1 -0
- package/ol/controls/index.js +9 -3
- package/ol/index.d.ts +6 -0
- package/ol/index.d.ts.map +1 -0
- package/ol/index.js +21 -5
- package/ol/layers/Layer.d.ts +49 -0
- package/ol/layers/Layer.d.ts.map +1 -0
- package/ol/layers/Layer.js +178 -81
- package/ol/layers/MapboxLayer.d.ts +42 -0
- package/ol/layers/MapboxLayer.d.ts.map +1 -0
- package/ol/layers/MapboxLayer.js +131 -198
- package/ol/layers/MapboxStyleLayer.d.ts +146 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +382 -186
- package/ol/layers/MaplibreLayer.d.ts +27 -0
- package/ol/layers/MaplibreLayer.d.ts.map +1 -0
- package/ol/layers/MaplibreLayer.js +67 -138
- package/ol/layers/RealtimeLayer.d.ts +119 -0
- package/ol/layers/RealtimeLayer.d.ts.map +1 -0
- package/ol/layers/RealtimeLayer.js +327 -184
- package/ol/layers/RoutingLayer.d.ts +24 -0
- package/ol/layers/RoutingLayer.d.ts.map +1 -0
- package/ol/layers/RoutingLayer.js +111 -56
- package/ol/layers/VectorLayer.d.ts +23 -0
- package/ol/layers/VectorLayer.d.ts.map +1 -0
- package/ol/layers/VectorLayer.js +71 -21
- package/ol/layers/WMSLayer.d.ts +38 -0
- package/ol/layers/WMSLayer.d.ts.map +1 -0
- package/ol/layers/WMSLayer.js +105 -37
- package/ol/layers/index.d.ts +9 -0
- package/ol/layers/index.d.ts.map +1 -0
- package/ol/layers/index.js +19 -8
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.js +32 -28
- package/ol/styles/fullTrajectoryStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryStyle.js +44 -40
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/index.d.ts.map +1 -0
- package/ol/styles/index.js +7 -2
- package/package.json +14 -36
- package/setupTests.d.ts +2 -0
- package/setupTests.d.ts.map +1 -0
- package/setupTests.js +15 -0
- package/types/index.d.ts +7 -6
- package/types/routing.d.ts +25 -25
- package/types/stops.d.ts +19 -19
- package/api/RealtimeAPI.test.js +0 -67
- package/api/RoutingAPI.test.js +0 -25
- package/api/StopsAPI.test.js +0 -22
- package/common/api/HttpAPI.test.js +0 -50
- package/common/api/WebSocketAPI.test.js +0 -311
- package/common/controls/Control.test.js +0 -87
- package/common/layers/Layer.test.js +0 -134
- package/common/mixins/UserInteractionsLayerMixin.test.js +0 -199
- package/common/utils/createTrackerFilters.test.js +0 -79
- package/common/utils/getMapboxMapCopyrights.test.js +0 -40
- package/common/utils/removeDuplicate.test.js +0 -19
- package/common/utils/timeUtils.test.js +0 -10
- package/common/utils/trackerConfig.test.js +0 -23
- package/mapbox/layers/Layer.test.js +0 -182
- package/mapbox/layers/RealtimeLayer.test.js +0 -10
- package/ol/controls/CopyrightControl.test.js +0 -165
- package/ol/controls/RoutingControl.test.js +0 -146
- package/ol/controls/StopFinderControl.test.js +0 -48
- package/ol/layers/Layer.test.js +0 -175
- package/ol/layers/MapboxLayer.test.js +0 -160
- package/ol/layers/MapboxStyleLayer.test.js +0 -226
- package/ol/layers/RealtimeLayer.test.js +0 -67
- package/ol/layers/RoutingLayer.test.js +0 -39
- package/ol/layers/VectorLayer.test.js +0 -76
- package/ol/layers/WMSLayer.test.js +0 -57
|
@@ -1,202 +1,248 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTextCanvas = exports.getCircleCanvas = exports.getDelayTextCanvas = exports.getDelayBgCanvas = void 0;
|
|
4
|
+
var createCanvas_1 = require("../utils/createCanvas");
|
|
5
|
+
/** @private */
|
|
6
|
+
var cacheDelayBg = {};
|
|
7
|
+
/**
|
|
8
|
+
* Draw circle delay background
|
|
9
|
+
*
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
var getDelayBgCanvas = function (origin, radius, color) {
|
|
13
|
+
var key = "".concat(origin, ", ").concat(radius, ", ").concat(color);
|
|
14
|
+
if (!cacheDelayBg[key]) {
|
|
15
|
+
var canvas = (0, createCanvas_1.default)(origin * 2, origin * 2);
|
|
16
|
+
if (canvas) {
|
|
17
|
+
var ctx = canvas.getContext('2d');
|
|
18
|
+
ctx.beginPath();
|
|
19
|
+
ctx.arc(origin, origin, radius, 0, 2 * Math.PI, false);
|
|
20
|
+
ctx.fillStyle = color;
|
|
21
|
+
ctx.filter = 'blur(1px)';
|
|
22
|
+
ctx.fill();
|
|
23
|
+
cacheDelayBg[key] = canvas;
|
|
24
|
+
}
|
|
15
25
|
}
|
|
16
|
-
|
|
17
|
-
return cacheDelayBg[key];
|
|
26
|
+
return cacheDelayBg[key];
|
|
18
27
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
exports.getDelayBgCanvas = getDelayBgCanvas;
|
|
29
|
+
/** @private */
|
|
30
|
+
var cacheDelayText = {};
|
|
31
|
+
/**
|
|
32
|
+
* Draw delay text
|
|
33
|
+
*
|
|
34
|
+
* @private
|
|
35
|
+
*/
|
|
36
|
+
var getDelayTextCanvas = function (width, text, fontSize, font, delayColor, delayOutlineColor, pixelRatio) {
|
|
37
|
+
if (delayOutlineColor === void 0) { delayOutlineColor = '#000'; }
|
|
38
|
+
if (pixelRatio === void 0) { pixelRatio = 1; }
|
|
39
|
+
var key = "".concat(width, ", ").concat(text, ", ").concat(font, ", ").concat(delayColor, ", ").concat(delayOutlineColor, ", ").concat(pixelRatio);
|
|
40
|
+
if (!cacheDelayText[key]) {
|
|
41
|
+
var canvas = (0, createCanvas_1.default)(width, fontSize + 8 * pixelRatio);
|
|
42
|
+
if (canvas) {
|
|
43
|
+
var ctx = canvas.getContext('2d');
|
|
44
|
+
ctx.textAlign = 'left';
|
|
45
|
+
ctx.textBaseline = 'middle';
|
|
46
|
+
ctx.font = font;
|
|
47
|
+
ctx.fillStyle = delayColor;
|
|
48
|
+
ctx.strokeStyle = delayOutlineColor;
|
|
49
|
+
ctx.lineWidth = 1.5 * pixelRatio;
|
|
50
|
+
var delayText = text;
|
|
51
|
+
ctx.strokeText(delayText, 0, fontSize);
|
|
52
|
+
ctx.fillText(delayText, 0, fontSize);
|
|
53
|
+
cacheDelayText[key] = canvas;
|
|
54
|
+
}
|
|
36
55
|
}
|
|
37
|
-
|
|
38
|
-
return cacheDelayText[key];
|
|
56
|
+
return cacheDelayText[key];
|
|
39
57
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
exports.getDelayTextCanvas = getDelayTextCanvas;
|
|
59
|
+
/** @private */
|
|
60
|
+
var cacheCircle = {};
|
|
61
|
+
/**
|
|
62
|
+
* Draw colored circle with black border
|
|
63
|
+
*
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
var getCircleCanvas = function (origin, radius, color, hasStroke, hasDash, pixelRatio) {
|
|
67
|
+
var key = "".concat(origin, ", ").concat(radius, ", ").concat(color, ", ").concat(hasStroke, ", ").concat(hasDash, ", ").concat(pixelRatio);
|
|
68
|
+
if (!cacheCircle[key]) {
|
|
69
|
+
var canvas = (0, createCanvas_1.default)(origin * 2, origin * 2);
|
|
70
|
+
if (canvas) {
|
|
71
|
+
var ctx = canvas.getContext('2d');
|
|
72
|
+
ctx.fillStyle = color;
|
|
73
|
+
if (hasStroke) {
|
|
74
|
+
ctx.lineWidth = 1 * pixelRatio;
|
|
75
|
+
ctx.strokeStyle = '#000000';
|
|
76
|
+
}
|
|
77
|
+
ctx.beginPath();
|
|
78
|
+
ctx.arc(origin, origin, radius, 0, 2 * Math.PI, false);
|
|
79
|
+
ctx.fill();
|
|
80
|
+
if (hasDash) {
|
|
81
|
+
ctx.setLineDash([5, 3]);
|
|
82
|
+
}
|
|
83
|
+
if (hasStroke) {
|
|
84
|
+
ctx.stroke();
|
|
85
|
+
}
|
|
86
|
+
cacheCircle[key] = canvas;
|
|
87
|
+
}
|
|
62
88
|
}
|
|
63
|
-
|
|
64
|
-
return cacheCircle[key];
|
|
89
|
+
return cacheCircle[key];
|
|
65
90
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
exports.getCircleCanvas = getCircleCanvas;
|
|
92
|
+
/** @private */
|
|
93
|
+
var cacheText = {};
|
|
94
|
+
/**
|
|
95
|
+
* Draw text in the circle
|
|
96
|
+
*
|
|
97
|
+
* @private
|
|
98
|
+
*/
|
|
99
|
+
var getTextCanvas = function (text, origin, textSize, fillColor, strokeColor, hasStroke, pixelRatio) {
|
|
100
|
+
var key = "".concat(text, ", ").concat(origin, ", ").concat(textSize, ", ").concat(fillColor, ",").concat(strokeColor, ", ").concat(hasStroke, ", ").concat(pixelRatio);
|
|
101
|
+
if (!cacheText[key]) {
|
|
102
|
+
var canvas = (0, createCanvas_1.default)(origin * 2, origin * 2);
|
|
103
|
+
if (canvas) {
|
|
104
|
+
var ctx = canvas.getContext('2d');
|
|
105
|
+
// Draw a stroke to the text only if a provider provides realtime but we don't use it.
|
|
106
|
+
if (hasStroke) {
|
|
107
|
+
ctx.save();
|
|
108
|
+
ctx.textBaseline = 'middle';
|
|
109
|
+
ctx.textAlign = 'center';
|
|
110
|
+
ctx.font = "bold ".concat(textSize + 2, "px Arial");
|
|
111
|
+
ctx.strokeStyle = strokeColor;
|
|
112
|
+
ctx.strokeText(text, origin, origin);
|
|
113
|
+
ctx.restore();
|
|
114
|
+
}
|
|
115
|
+
// Draw a text
|
|
116
|
+
ctx.textBaseline = 'middle';
|
|
117
|
+
ctx.textAlign = 'center';
|
|
118
|
+
ctx.fillStyle = fillColor;
|
|
119
|
+
ctx.font = "bold ".concat(textSize, "px Arial");
|
|
120
|
+
ctx.strokeStyle = strokeColor;
|
|
121
|
+
ctx.strokeText(text, origin, origin);
|
|
122
|
+
ctx.fillText(text, origin, origin);
|
|
123
|
+
cacheText[key] = canvas;
|
|
124
|
+
}
|
|
90
125
|
}
|
|
91
|
-
|
|
92
|
-
return cacheText[key];
|
|
126
|
+
return cacheText[key];
|
|
93
127
|
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
getTextColor,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
if (!textColor) {
|
|
127
|
-
textColor = "#000000";
|
|
128
|
-
}
|
|
129
|
-
if (color && color[0] !== "#") {
|
|
130
|
-
color = `#${color}`;
|
|
131
|
-
}
|
|
132
|
-
if (textColor[0] !== "#") {
|
|
133
|
-
textColor = `#${textColor}`;
|
|
134
|
-
}
|
|
135
|
-
const z = Math.min(Math.floor(zoom || 1), 16);
|
|
136
|
-
const hover = hoverVehicleId && hoverVehicleId === id;
|
|
137
|
-
const selected = selectedVehicleId && selectedVehicleId === id;
|
|
138
|
-
let radius = getRadius(type, z) * pixelRatio;
|
|
139
|
-
const isDisplayStrokeAndDelay = radius >= 7 * pixelRatio;
|
|
140
|
-
if (hover || selected) {
|
|
141
|
-
radius = isDisplayStrokeAndDelay ? radius + 5 * pixelRatio : 14 * pixelRatio;
|
|
142
|
-
}
|
|
143
|
-
const mustDrawText = radius > 10 * pixelRatio;
|
|
144
|
-
let key = `${radius}${hover}${selected}${cancelled}${delay}`;
|
|
145
|
-
if (useDelayStyle) {
|
|
146
|
-
key += `${operatorProvidesRealtime}`;
|
|
147
|
-
} else {
|
|
148
|
-
key += `${type}${color}`;
|
|
149
|
-
}
|
|
150
|
-
if (mustDrawText) {
|
|
151
|
-
key += `${name}${textColor}`;
|
|
152
|
-
}
|
|
153
|
-
if (!cache[key]) {
|
|
154
|
-
if (radius === 0) {
|
|
155
|
-
cache[key] = null;
|
|
156
|
-
return null;
|
|
128
|
+
exports.getTextCanvas = getTextCanvas;
|
|
129
|
+
/** @private */
|
|
130
|
+
var cache = {};
|
|
131
|
+
/**
|
|
132
|
+
* A tracker style that take in account the delay.
|
|
133
|
+
*
|
|
134
|
+
* @param {*} trajectory The trajectory to render.
|
|
135
|
+
* @param {*} viewState The view state of the map.
|
|
136
|
+
* @param {*} options Some options to change the rendering
|
|
137
|
+
* @return a canvas
|
|
138
|
+
*/
|
|
139
|
+
var realtimeDefaultStyle = function (trajectory, viewState, options) {
|
|
140
|
+
var hoverVehicleId = options.hoverVehicleId, selectedVehicleId = options.selectedVehicleId, useDelayStyle = options.useDelayStyle, _a = options.delayOutlineColor, delayOutlineColor = _a === void 0 ? '#000' : _a, _b = options.delayDisplay, delayDisplay = _b === void 0 ? 300000 : _b, getRadius = options.getRadius, getBgColor = options.getBgColor, getDelayColor = options.getDelayColor, getDelayText = options.getDelayText, getTextColor = options.getTextColor, getTextSize = options.getTextSize;
|
|
141
|
+
var zoom = viewState.zoom, pixelRatio = viewState.pixelRatio;
|
|
142
|
+
var _c = trajectory.properties, type = _c.type, cancelled = _c.cancelled;
|
|
143
|
+
var _d = trajectory.properties, id = _d.train_id, line = _d.line, delay = _d.delay, state = _d.state, operatorProvidesRealtime = _d.operator_provides_realtime_journey;
|
|
144
|
+
var _e = line || {}, name = _e.name, textColor = _e.text_color, color = _e.color;
|
|
145
|
+
// In the future, the cancelled property will be removed we still managed it
|
|
146
|
+
// until the backend change is on prod.
|
|
147
|
+
cancelled = cancelled === true || state === 'JOURNEY_CANCELLED';
|
|
148
|
+
if (!type) {
|
|
149
|
+
type = 'Rail';
|
|
150
|
+
}
|
|
151
|
+
if (!name) {
|
|
152
|
+
name = 'I';
|
|
153
|
+
}
|
|
154
|
+
if (!textColor) {
|
|
155
|
+
textColor = '#000000';
|
|
156
|
+
}
|
|
157
|
+
if (color && color[0] !== '#') {
|
|
158
|
+
color = "#".concat(color);
|
|
157
159
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
160
|
+
if (textColor[0] !== '#') {
|
|
161
|
+
textColor = "#".concat(textColor);
|
|
162
|
+
}
|
|
163
|
+
var z = Math.min(Math.floor(zoom || 1), 16);
|
|
164
|
+
var hover = hoverVehicleId && hoverVehicleId === id;
|
|
165
|
+
var selected = selectedVehicleId && selectedVehicleId === id;
|
|
166
|
+
// Calcul the radius of the circle
|
|
167
|
+
var radius = getRadius(type, z) * pixelRatio;
|
|
168
|
+
var isDisplayStrokeAndDelay = radius >= 7 * pixelRatio;
|
|
169
|
+
if (hover || selected) {
|
|
170
|
+
radius = isDisplayStrokeAndDelay
|
|
171
|
+
? radius + 5 * pixelRatio
|
|
172
|
+
: 14 * pixelRatio;
|
|
173
|
+
}
|
|
174
|
+
var mustDrawText = radius > 10 * pixelRatio;
|
|
175
|
+
// Optimize the cache key, very important in high zoom level
|
|
176
|
+
var key = "".concat(radius).concat(hover).concat(selected).concat(cancelled).concat(delay);
|
|
177
|
+
if (useDelayStyle) {
|
|
178
|
+
key += "".concat(operatorProvidesRealtime);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
key += "".concat(type).concat(color);
|
|
182
|
+
}
|
|
183
|
+
if (mustDrawText) {
|
|
184
|
+
key += "".concat(name).concat(textColor);
|
|
185
|
+
}
|
|
186
|
+
if (!cache[key]) {
|
|
187
|
+
if (radius === 0) {
|
|
188
|
+
cache[key] = null;
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
var margin = 1 * pixelRatio;
|
|
192
|
+
var radiusDelay = radius + 2;
|
|
193
|
+
var markerSize = radius * 2;
|
|
194
|
+
var size = radiusDelay * 2 + margin * 2 + 100 * pixelRatio; // add space for delay information
|
|
195
|
+
var origin_1 = size / 2;
|
|
196
|
+
// Create the canvas
|
|
197
|
+
var canvas = (0, createCanvas_1.default)(size, size);
|
|
198
|
+
if (canvas) {
|
|
199
|
+
var ctx = canvas.getContext('2d');
|
|
200
|
+
if (isDisplayStrokeAndDelay && delay !== null) {
|
|
201
|
+
// Draw circle delay background
|
|
202
|
+
var delayBg = (0, exports.getDelayBgCanvas)(origin_1, radiusDelay, getDelayColor(delay, cancelled));
|
|
203
|
+
ctx.drawImage(delayBg, 0, 0);
|
|
204
|
+
}
|
|
205
|
+
// Show delay if feature is hovered or if delay is above 5mins.
|
|
206
|
+
if (isDisplayStrokeAndDelay &&
|
|
207
|
+
(hover || delay >= delayDisplay || cancelled)) {
|
|
208
|
+
// Draw delay text
|
|
209
|
+
var fontSize = Math.max(cancelled ? 19 : 14, Math.min(cancelled ? 19 : 17, radius * 1.2)) * pixelRatio;
|
|
210
|
+
var text = getDelayText(delay, cancelled);
|
|
211
|
+
if (text) {
|
|
212
|
+
var textWidth = text.length * fontSize;
|
|
213
|
+
var delayText = (0, exports.getDelayTextCanvas)(textWidth, text, fontSize, "bold ".concat(fontSize, "px arial, sans-serif"), getDelayColor(delay, cancelled, true), delayOutlineColor, pixelRatio);
|
|
214
|
+
ctx.drawImage(delayText, origin_1 + radiusDelay + margin, origin_1 - fontSize);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// Draw colored circle with black border
|
|
218
|
+
var circleFillColor = void 0;
|
|
219
|
+
if (useDelayStyle) {
|
|
220
|
+
circleFillColor = getDelayColor(delay, cancelled);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
circleFillColor = color || getBgColor(type);
|
|
224
|
+
}
|
|
225
|
+
var hasStroke = isDisplayStrokeAndDelay || hover || selected;
|
|
226
|
+
var hasDash = isDisplayStrokeAndDelay &&
|
|
227
|
+
useDelayStyle &&
|
|
228
|
+
delay === null &&
|
|
229
|
+
operatorProvidesRealtime === 'yes';
|
|
230
|
+
var circle = (0, exports.getCircleCanvas)(origin_1, radius, circleFillColor, hasStroke, hasDash, pixelRatio);
|
|
231
|
+
ctx.drawImage(circle, 0, 0);
|
|
232
|
+
// Draw text in the circle
|
|
233
|
+
if (mustDrawText) {
|
|
234
|
+
var fontSize = Math.max(radius, 10);
|
|
235
|
+
var textSize = getTextSize(ctx, markerSize, name, fontSize);
|
|
236
|
+
var textColor2 = !useDelayStyle
|
|
237
|
+
? textColor || getTextColor(type)
|
|
238
|
+
: '#000000';
|
|
239
|
+
var hasStroke2 = useDelayStyle && delay === null && operatorProvidesRealtime === 'yes';
|
|
240
|
+
var text = (0, exports.getTextCanvas)(name, origin_1, textSize, textColor2, circleFillColor, hasStroke2, pixelRatio);
|
|
241
|
+
ctx.drawImage(text, 0, 0);
|
|
242
|
+
}
|
|
243
|
+
cache[key] = canvas;
|
|
177
244
|
}
|
|
178
|
-
}
|
|
179
|
-
let circleFillColor;
|
|
180
|
-
if (useDelayStyle) {
|
|
181
|
-
circleFillColor = getDelayColor(delay, cancelled);
|
|
182
|
-
} else {
|
|
183
|
-
circleFillColor = color || getBgColor(type);
|
|
184
|
-
}
|
|
185
|
-
const hasStroke = isDisplayStrokeAndDelay || hover || selected;
|
|
186
|
-
const hasDash = isDisplayStrokeAndDelay && useDelayStyle && delay === null && operatorProvidesRealtime === "yes";
|
|
187
|
-
const circle = getCircleCanvas(origin, radius, circleFillColor, hasStroke, hasDash, pixelRatio);
|
|
188
|
-
ctx.drawImage(circle, 0, 0);
|
|
189
|
-
if (mustDrawText) {
|
|
190
|
-
const fontSize = Math.max(radius, 10);
|
|
191
|
-
const textSize = getTextSize(ctx, markerSize, name, fontSize);
|
|
192
|
-
const textColor2 = !useDelayStyle ? textColor || getTextColor(type) : "#000000";
|
|
193
|
-
const hasStroke2 = useDelayStyle && delay === null && operatorProvidesRealtime === "yes";
|
|
194
|
-
const text = getTextCanvas(name, origin, textSize, textColor2, circleFillColor, hasStroke2, pixelRatio);
|
|
195
|
-
ctx.drawImage(text, 0, 0);
|
|
196
|
-
}
|
|
197
|
-
cache[key] = canvas;
|
|
198
245
|
}
|
|
199
|
-
|
|
200
|
-
return cache[key];
|
|
246
|
+
return cache[key];
|
|
201
247
|
};
|
|
202
|
-
|
|
248
|
+
exports.default = realtimeDefaultStyle;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default realtimeDelayStyle;
|
|
2
|
+
/**
|
|
3
|
+
* A tracker style that display the delay as backgroundColor.
|
|
4
|
+
*
|
|
5
|
+
* @param {*} trajectory The trajectory to render.
|
|
6
|
+
* @param {*} viewState The view state of the map.
|
|
7
|
+
* @param {*} options Some options to change the rendering
|
|
8
|
+
* @return a canvas
|
|
9
|
+
*/
|
|
10
|
+
declare function realtimeDelayStyle(trajectory: any, viewState: any, options: any): any;
|
|
11
|
+
//# sourceMappingURL=realtimeDelayStyle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtimeDelayStyle.d.ts","sourceRoot":"","sources":["../../../src/common/styles/realtimeDelayStyle.js"],"names":[],"mappings":";AAEA;;;;;;;GAOG;AACH,wFAKC"}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
7
12
|
};
|
|
8
|
-
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var realtimeDefaultStyle_1 = require("./realtimeDefaultStyle");
|
|
15
|
+
/**
|
|
16
|
+
* A tracker style that display the delay as backgroundColor.
|
|
17
|
+
*
|
|
18
|
+
* @param {*} trajectory The trajectory to render.
|
|
19
|
+
* @param {*} viewState The view state of the map.
|
|
20
|
+
* @param {*} options Some options to change the rendering
|
|
21
|
+
* @return a canvas
|
|
22
|
+
*/
|
|
23
|
+
var realtimeDelayStyle = function (trajectory, viewState, options) {
|
|
24
|
+
return (0, realtimeDefaultStyle_1.default)(trajectory, viewState, __assign(__assign({}, options), { useDelayStyle: true }));
|
|
25
|
+
};
|
|
26
|
+
exports.default = realtimeDelayStyle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtimeSimpleStyle.d.ts","sourceRoot":"","sources":["../../../src/common/styles/realtimeSimpleStyle.js"],"names":[],"mappings":";AAKA,4CAeC"}
|
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* A very simple tracker style.
|
|
5
|
+
* Display blue point for each train.
|
|
6
|
+
*/
|
|
7
|
+
var canvas;
|
|
8
|
+
var realtimeSimpleStyle = function () {
|
|
9
|
+
if (!canvas) {
|
|
10
|
+
document.createElement('canvas');
|
|
11
|
+
canvas.width = 15;
|
|
12
|
+
canvas.height = 15;
|
|
13
|
+
var ctx = canvas.getContext('2d');
|
|
14
|
+
ctx.arc(8, 8, 5, 0, 2 * Math.PI, false);
|
|
15
|
+
ctx.fillStyle = '#8ED6FF';
|
|
16
|
+
ctx.fill();
|
|
17
|
+
ctx.lineWidth = 3;
|
|
18
|
+
ctx.strokeStyle = 'black';
|
|
19
|
+
ctx.stroke();
|
|
20
|
+
ctx.lineWidth = 3;
|
|
21
|
+
}
|
|
22
|
+
return canvas;
|
|
17
23
|
};
|
|
18
|
-
|
|
24
|
+
exports.default = realtimeSimpleStyle;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
type FilterFunction = Function;
|
|
2
|
+
type ViewState = {
|
|
3
|
+
/**
|
|
4
|
+
* A time in ms.
|
|
5
|
+
*/
|
|
6
|
+
time: number;
|
|
7
|
+
/**
|
|
8
|
+
* A center in mercator coordinate.
|
|
9
|
+
*/
|
|
10
|
+
center: any;
|
|
11
|
+
/**
|
|
12
|
+
* An Extent in mercator coordinates.
|
|
13
|
+
*/
|
|
14
|
+
extent: any;
|
|
15
|
+
/**
|
|
16
|
+
* A size ([width, height]).
|
|
17
|
+
*/
|
|
18
|
+
size: any;
|
|
19
|
+
/**
|
|
20
|
+
* A rotation in radians.
|
|
21
|
+
*/
|
|
22
|
+
rotation: number;
|
|
23
|
+
/**
|
|
24
|
+
* A resolution.
|
|
25
|
+
*/
|
|
26
|
+
resolution: number;
|
|
27
|
+
/**
|
|
28
|
+
* A zoom level.
|
|
29
|
+
*/
|
|
30
|
+
zoom: number;
|
|
31
|
+
/**
|
|
32
|
+
* A pixel ratio.
|
|
33
|
+
*/
|
|
34
|
+
pixelRatio: number;
|
|
35
|
+
};
|
|
36
|
+
type FeatureInfo = {
|
|
37
|
+
/**
|
|
38
|
+
* A layer.
|
|
39
|
+
*/
|
|
40
|
+
layer: Layer;
|
|
41
|
+
/**
|
|
42
|
+
* /Feature~Feature[]} features An array of features.
|
|
43
|
+
*/
|
|
44
|
+
"": ol;
|
|
45
|
+
/**
|
|
46
|
+
* The coordinate where to find the featue.
|
|
47
|
+
*/
|
|
48
|
+
coordinate: any;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=typedefs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedefs.d.ts","sourceRoot":"","sources":["../../src/common/typedefs.js"],"names":[],"mappings":";;;;;UAOc,MAAM;;;;;;;;;;;;;;;;cAIN,MAAM;;;;gBACN,MAAM;;;;UACN,MAAM;;;;gBACN,MAAM"}
|
package/common/typedefs.js
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {function} FilterFunction
|
|
3
|
+
* @param {Object} vehicle Vehicle to filter.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {Object} ViewState
|
|
7
|
+
* @property {number} time A time in ms.
|
|
8
|
+
* @property {number[2]} center A center in mercator coordinate.
|
|
9
|
+
* @property {number[4]} extent An Extent in mercator coordinates.
|
|
10
|
+
* @property {number[2]} size A size ([width, height]).
|
|
11
|
+
* @property {number} rotation A rotation in radians.
|
|
12
|
+
* @property {number} resolution A resolution.
|
|
13
|
+
* @property {number} zoom A zoom level.
|
|
14
|
+
* @property {number} pixelRatio A pixel ratio.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {Object} FeatureInfo
|
|
18
|
+
* @property {Layer} layer A layer.
|
|
19
|
+
* @property {ol/Feature~Feature[]} features An array of features.
|
|
20
|
+
* @property {number[2]} coordinate The coordinate where to find the featue.
|
|
21
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanStopTime.d.ts","sourceRoot":"","sources":["../../../src/common/utils/cleanStopTime.js"],"names":[],"mappings":";AAAA;;;GAGG;AACH,kDAsBC"}
|