mobility-toolbox-js 2.0.0 → 2.1.0
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 +279 -0
- package/api/RealtimeAPI.d.ts.map +1 -0
- package/api/RealtimeAPI.js +466 -0
- package/api/RoutingAPI.d.ts +37 -0
- package/api/RoutingAPI.d.ts.map +1 -0
- package/api/RoutingAPI.js +35 -0
- package/api/StopsAPI.d.ts +38 -0
- package/api/StopsAPI.d.ts.map +1 -0
- package/api/StopsAPI.js +36 -0
- package/api/index.d.ts +4 -0
- package/api/index.d.ts.map +1 -0
- package/api/index.js +3 -3
- package/api/typedefs.d.ts +179 -0
- package/api/typedefs.d.ts.map +1 -0
- package/api/{tralis/typedefs.js → typedefs.js} +4 -10
- package/common/api/HttpAPI.d.ts +31 -0
- package/common/api/HttpAPI.d.ts.map +1 -0
- package/common/api/HttpAPI.js +57 -0
- package/common/api/WebSocketAPI.d.ts +153 -0
- package/common/api/WebSocketAPI.d.ts.map +1 -0
- package/common/api/WebSocketAPI.js +341 -0
- package/common/controls/ControlCommon.d.ts +76 -0
- package/common/controls/ControlCommon.d.ts.map +1 -0
- package/common/controls/ControlCommon.js +150 -0
- package/common/controls/CopyrightControlCommon.d.ts +13 -0
- package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
- package/common/controls/CopyrightControlCommon.js +34 -0
- package/common/controls/StopFinderControlCommon.d.ts +55 -0
- package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
- package/common/controls/StopFinderControlCommon.js +144 -0
- package/common/index.d.ts +3 -0
- package/common/index.d.ts.map +1 -0
- package/common/index.js +2 -0
- package/common/layers/LayerCommon.d.ts +94 -0
- package/common/layers/LayerCommon.d.ts.map +1 -0
- package/common/layers/LayerCommon.js +244 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +286 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
- package/common/mixins/RealtimeLayerMixin.js +776 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
- package/common/mixins/UserInteractionsLayerMixin.js +241 -0
- package/common/styles/index.d.ts +5 -0
- package/common/styles/index.d.ts.map +1 -0
- package/common/styles/index.js +4 -4
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.js +275 -0
- package/common/styles/{trackerDelayStyle.js → realtimeDelayStyle.d.ts} +4 -9
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
- package/common/styles/realtimeDelayStyle.js +13 -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/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
- package/common/styles/realtimeSimpleStyle.js +23 -0
- package/common/typedefs.d.ts +111 -0
- package/common/typedefs.d.ts.map +1 -0
- package/common/typedefs.js +35 -6
- package/common/utils/compareDepartures.d.ts +11 -0
- package/common/utils/compareDepartures.d.ts.map +1 -0
- package/common/utils/compareDepartures.js +35 -0
- package/common/utils/createCanvas.d.ts +10 -0
- package/common/utils/createCanvas.d.ts.map +1 -0
- package/common/utils/createCanvas.js +27 -0
- package/common/utils/createRealtimeFilters.d.ts +13 -0
- package/common/utils/createRealtimeFilters.d.ts.map +1 -0
- package/common/utils/createRealtimeFilters.js +74 -0
- package/common/utils/debounceDeparturesMessages.d.ts +12 -0
- package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
- package/common/utils/debounceDeparturesMessages.js +24 -0
- package/common/utils/debounceWebsocketMessages.d.ts +11 -0
- package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
- package/common/utils/debounceWebsocketMessages.js +29 -0
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
- package/common/utils/getLayersAsFlatArray.js +15 -0
- package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
- package/common/utils/getMapboxMapCopyrights.js +21 -23
- package/common/utils/getMapboxRender.d.ts +7 -0
- package/common/utils/getMapboxRender.d.ts.map +1 -0
- package/common/utils/getMapboxRender.js +87 -0
- package/common/utils/getMaplibreRender.d.ts +7 -0
- package/common/utils/getMaplibreRender.d.ts.map +1 -0
- package/common/utils/getMaplibreRender.js +38 -0
- package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
- package/common/utils/getRealtimeModeSuffix.js +7 -0
- package/common/utils/getUrlWithParams.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts.map +1 -0
- package/common/utils/getUrlWithParams.js +18 -0
- package/common/utils/getVehiclePosition.d.ts +16 -0
- package/common/utils/getVehiclePosition.d.ts.map +1 -0
- package/common/utils/getVehiclePosition.js +60 -60
- package/common/utils/index.d.ts +17 -0
- package/common/utils/index.d.ts.map +1 -0
- package/common/utils/index.js +13 -2
- package/common/utils/realtimeConfig.d.ts +49 -0
- package/common/utils/realtimeConfig.d.ts.map +1 -0
- package/common/utils/realtimeConfig.js +173 -0
- package/common/utils/removeDuplicate.d.ts +10 -0
- package/common/utils/removeDuplicate.d.ts.map +1 -0
- package/common/utils/removeDuplicate.js +5 -12
- package/common/utils/renderTrajectories.d.ts +17 -0
- package/common/utils/renderTrajectories.d.ts.map +1 -0
- package/common/utils/renderTrajectories.js +110 -0
- package/common/utils/sortAndFilterDepartures.d.ts +16 -0
- package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
- package/common/utils/sortAndFilterDepartures.js +58 -0
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.d.ts.map +1 -0
- package/common/utils/sortByDelay.js +17 -20
- package/common/utils/timeUtils.d.ts +24 -0
- package/common/utils/timeUtils.d.ts.map +1 -0
- package/common/utils/timeUtils.js +13 -18
- package/iife.d.ts +3 -0
- package/iife.d.ts.map +1 -0
- package/iife.js +5 -0
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.js +10 -2
- package/mapbox/controls/CopyrightControl.d.ts +29 -0
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
- package/mapbox/controls/CopyrightControl.js +25 -35
- package/mapbox/controls/index.d.ts +2 -0
- package/mapbox/controls/index.d.ts.map +1 -0
- package/mapbox/controls/index.js +2 -0
- package/mapbox/index.d.ts +6 -0
- package/mapbox/index.d.ts.map +1 -0
- package/mapbox/index.js +5 -3
- package/mapbox/layers/Layer.d.ts +59 -0
- package/mapbox/layers/Layer.d.ts.map +1 -0
- package/mapbox/layers/Layer.js +78 -95
- package/mapbox/layers/RealtimeLayer.d.ts +181 -0
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
- package/mapbox/layers/RealtimeLayer.js +276 -0
- package/mapbox/layers/index.d.ts +3 -0
- package/mapbox/layers/index.d.ts.map +1 -0
- package/mapbox/layers/index.js +2 -0
- package/mapbox/utils/getMercatorResolution.d.ts +9 -0
- package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
- package/mapbox/utils/getMercatorResolution.js +18 -0
- package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
- package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
- package/mapbox/utils/getSourceCoordinates.js +27 -0
- package/mapbox/utils/index.d.ts +3 -0
- package/mapbox/utils/index.d.ts.map +1 -0
- package/mapbox/utils/index.js +2 -0
- package/mbt.js +60005 -0
- package/mbt.js.map +7 -0
- package/mbt.min.js +1084 -0
- package/mbt.min.js.map +7 -0
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.d.ts.map +1 -0
- package/ol/controls/CopyrightControl.js +44 -56
- package/ol/controls/RoutingControl.d.ts +193 -0
- package/ol/controls/RoutingControl.d.ts.map +1 -0
- package/ol/controls/RoutingControl.js +546 -667
- package/ol/controls/StopFinderControl.d.ts +30 -0
- package/ol/controls/StopFinderControl.d.ts.map +1 -0
- package/ol/controls/StopFinderControl.js +10 -16
- package/ol/controls/index.d.ts +4 -0
- package/ol/controls/index.d.ts.map +1 -0
- package/ol/controls/index.js +3 -0
- package/ol/index.d.ts +6 -0
- package/ol/index.d.ts.map +1 -0
- package/ol/index.js +4 -12
- package/ol/layers/Layer.d.ts +86 -0
- package/ol/layers/Layer.d.ts.map +1 -0
- package/ol/layers/Layer.js +147 -166
- package/ol/layers/MapGlLayer.d.ts +67 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -0
- package/ol/layers/MapGlLayer.js +218 -0
- package/ol/layers/MapboxLayer.d.ts +50 -0
- package/ol/layers/MapboxLayer.d.ts.map +1 -0
- package/ol/layers/MapboxLayer.js +79 -348
- package/ol/layers/MapboxStyleLayer.d.ts +129 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +329 -368
- package/ol/layers/MaplibreLayer.d.ts +28 -0
- package/ol/layers/MaplibreLayer.d.ts.map +1 -0
- package/ol/layers/MaplibreLayer.js +13 -259
- package/ol/layers/RealtimeLayer.d.ts +202 -0
- package/ol/layers/RealtimeLayer.d.ts.map +1 -0
- package/ol/layers/RealtimeLayer.js +340 -0
- package/ol/layers/RoutingLayer.d.ts +34 -0
- package/ol/layers/RoutingLayer.d.ts.map +1 -0
- package/ol/layers/RoutingLayer.js +62 -68
- package/ol/layers/VectorLayer.d.ts +25 -0
- package/ol/layers/VectorLayer.d.ts.map +1 -0
- package/ol/layers/VectorLayer.js +27 -32
- package/ol/layers/WMSLayer.d.ts +42 -0
- package/ol/layers/WMSLayer.d.ts.map +1 -0
- package/ol/layers/WMSLayer.js +74 -66
- package/ol/layers/index.d.ts +9 -0
- package/ol/layers/index.d.ts.map +1 -0
- package/ol/layers/index.js +8 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.js +23 -25
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryStyle.js +37 -44
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/index.d.ts.map +1 -0
- package/package.json +98 -177
- package/setupTests.d.ts +2 -0
- package/setupTests.d.ts.map +1 -0
- package/setupTests.js +26 -0
- package/types/common.d.ts +122 -0
- package/types/index.d.ts +11 -0
- package/types/realtime.d.ts +320 -0
- package/types/routing.d.ts +206 -0
- package/types/stops.d.ts +143 -0
- package/README.md +0 -23
- package/api/routing/RoutingAPI.js +0 -44
- package/api/routing/RoutingAPI.test.js +0 -41
- package/api/stops/StopsAPI.js +0 -41
- package/api/stops/StopsAPI.test.js +0 -34
- package/api/tralis/TralisAPI.js +0 -731
- package/api/tralis/TralisAPI.test.js +0 -75
- package/api/tralis/TralisAPIUtils.js +0 -73
- package/api/tralis/WebSocketConnector.js +0 -338
- package/api/tralis/WebSocketConnector.test.js +0 -356
- package/common/Tracker.js +0 -197
- package/common/api/api.js +0 -64
- package/common/api/api.test.js +0 -68
- package/common/controls/Control.js +0 -146
- package/common/controls/Control.test.js +0 -98
- package/common/layers/Layer.js +0 -404
- package/common/layers/Layer.test.js +0 -585
- package/common/mixins/CopyrightMixin.js +0 -48
- package/common/mixins/SearchMixin.js +0 -176
- package/common/mixins/TralisLayerMixin.js +0 -930
- package/common/styles/trackerDefaultStyle.js +0 -333
- package/common/styles/trackerSimpleStyle.js +0 -22
- package/common/trackerConfig.js +0 -190
- package/common/trackerConfig.test.js +0 -25
- package/common/utils/createTrackerFilters.js +0 -87
- package/common/utils/createTrackerFilters.test.js +0 -95
- package/common/utils/getMapboxMapCopyrights.test.js +0 -47
- package/common/utils/getMapboxStyleUrl.js +0 -32
- package/common/utils/removeDuplicate.test.js +0 -22
- package/common/utils/timeUtils.test.js +0 -16
- package/index.js.map +0 -1
- package/mapbox/layers/Layer.test.js +0 -202
- package/mapbox/layers/TralisLayer.js +0 -329
- package/mapbox/layers/TralisLayer.test.js +0 -40
- package/mapbox/utils.js +0 -46
- package/module.js +0 -23
- package/ol/README.md +0 -0
- package/ol/controls/CopyrightControl.test.js +0 -211
- package/ol/controls/RoutingControl.test.js +0 -216
- package/ol/controls/StopFinderControl.test.js +0 -59
- package/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
- package/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
- package/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
- package/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
- package/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
- package/ol/controls/snapshots/RoutingControlStation1.json +0 -60
- package/ol/controls/snapshots/RoutingControlStation2.json +0 -49
- package/ol/layers/Layer.test.js +0 -197
- package/ol/layers/MapboxLayer.test.js +0 -186
- package/ol/layers/MapboxStyleLayer.test.js +0 -262
- package/ol/layers/RoutingLayer.test.js +0 -49
- package/ol/layers/TralisLayer.js +0 -359
- package/ol/layers/TralisLayer.test.js +0 -97
- package/ol/layers/VectorLayer.test.js +0 -98
- package/ol/layers/WMSLayer.test.js +0 -84
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
const radiusMapping = [
|
|
2
|
+
[0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
3
|
+
[0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
4
|
+
[0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 12, 15, 15, 15, 15, 15],
|
|
5
|
+
[0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
6
|
+
[0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
7
|
+
[0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
8
|
+
[0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
9
|
+
[0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
10
|
+
[0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
11
|
+
[0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 12, 15, 15, 15, 15, 15],
|
|
12
|
+
];
|
|
13
|
+
/**
|
|
14
|
+
* Trajserv value: 'Tram', 'Subway / Metro / S-Bahn', 'Train', 'Bus', 'Ferry', 'Cable Car', 'Gondola', 'Funicular', 'Long distance bus', 'Rail',
|
|
15
|
+
* New endpoint use Rail instead of Train.
|
|
16
|
+
* New tracker values: null, "tram", "subway", "rail", "bus", "ferry", "cablecar", "gondola", "funicular", "coach".
|
|
17
|
+
*
|
|
18
|
+
* @ignore
|
|
19
|
+
*/
|
|
20
|
+
export const types = [
|
|
21
|
+
/^Tram/i,
|
|
22
|
+
/^Subway( \/ Metro \/ S-Bahn)?/i,
|
|
23
|
+
/^Train/i,
|
|
24
|
+
/^Bus/i,
|
|
25
|
+
/^Ferry/i,
|
|
26
|
+
/^Cable ?Car/i,
|
|
27
|
+
/^Gondola/i,
|
|
28
|
+
/^Funicular/i,
|
|
29
|
+
/^(Long distance bus|coach)/i,
|
|
30
|
+
/^Rail/i, // New endpoint use Rail instead of Train.
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* @ignore
|
|
34
|
+
*/
|
|
35
|
+
export const bgColors = [
|
|
36
|
+
'#ffb400',
|
|
37
|
+
'#ff5400',
|
|
38
|
+
'#ff8080',
|
|
39
|
+
'#ea0000',
|
|
40
|
+
'#3000ff',
|
|
41
|
+
'#ffb400',
|
|
42
|
+
'#41a27b',
|
|
43
|
+
'#00d237',
|
|
44
|
+
'#b5b5b5',
|
|
45
|
+
'#ff8080',
|
|
46
|
+
];
|
|
47
|
+
/**
|
|
48
|
+
* @ignore
|
|
49
|
+
*/
|
|
50
|
+
export const textColors = [
|
|
51
|
+
'#000000',
|
|
52
|
+
'#ffffff',
|
|
53
|
+
'#000000',
|
|
54
|
+
'#ffffff',
|
|
55
|
+
'#ffffff',
|
|
56
|
+
'#000000',
|
|
57
|
+
'#ffffff',
|
|
58
|
+
'#000000',
|
|
59
|
+
'#000000',
|
|
60
|
+
'#000000',
|
|
61
|
+
];
|
|
62
|
+
/**
|
|
63
|
+
* @ignore
|
|
64
|
+
*/
|
|
65
|
+
export const getTypeIndex = (type) => {
|
|
66
|
+
if (typeof type === 'string') {
|
|
67
|
+
return types.findIndex((t) => t.test(type));
|
|
68
|
+
}
|
|
69
|
+
return type;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* @ignore
|
|
73
|
+
*/
|
|
74
|
+
export const getRadius = (type, zoom) => {
|
|
75
|
+
try {
|
|
76
|
+
const typeIdx = getTypeIndex(type || 0);
|
|
77
|
+
return radiusMapping[typeIdx][zoom];
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
return 1;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* @ignore
|
|
85
|
+
*/
|
|
86
|
+
export const getBgColor = (type) => {
|
|
87
|
+
try {
|
|
88
|
+
const typeIdx = getTypeIndex(type);
|
|
89
|
+
return bgColors[typeIdx];
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
return '#ffffff';
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* @ignore
|
|
97
|
+
*/
|
|
98
|
+
export const getTextColor = (type) => {
|
|
99
|
+
try {
|
|
100
|
+
const typeIdx = getTypeIndex(type);
|
|
101
|
+
return textColors[typeIdx];
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
return '#ffffff';
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* @ignore
|
|
109
|
+
*/
|
|
110
|
+
export const getTextSize = (ctx, markerSize, text, fontSize) => {
|
|
111
|
+
if (!ctx) {
|
|
112
|
+
return 0;
|
|
113
|
+
}
|
|
114
|
+
ctx.font = `bold ${fontSize}px Arial`;
|
|
115
|
+
let newText = ctx.measureText(text);
|
|
116
|
+
const maxiter = 25;
|
|
117
|
+
let i = 0;
|
|
118
|
+
while (newText.width > markerSize - 6 && i < maxiter) {
|
|
119
|
+
// eslint-disable-next-line no-param-reassign
|
|
120
|
+
fontSize -= 0.5;
|
|
121
|
+
ctx.font = `bold ${fontSize}px arial, sans-serif`;
|
|
122
|
+
newText = ctx.measureText(text);
|
|
123
|
+
i += 1;
|
|
124
|
+
}
|
|
125
|
+
return fontSize;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* @ignore
|
|
129
|
+
* @param {number} delayInMs Delay in milliseconds.
|
|
130
|
+
* @param {boolean} cancelled true if the journey is cancelled.
|
|
131
|
+
* @param {boolean} isDelayText true if the color is used for delay text of the symbol.
|
|
132
|
+
*/
|
|
133
|
+
export const getDelayColor = (delayInMs, cancelled, isDelayText) => {
|
|
134
|
+
if (cancelled) {
|
|
135
|
+
return isDelayText ? '#ff0000' : '#a0a0a0'; // red or gray
|
|
136
|
+
}
|
|
137
|
+
if (delayInMs === null) {
|
|
138
|
+
return '#a0a0a0'; // grey { r: 160, g: 160, b: 160, s: '160,160,160' };
|
|
139
|
+
}
|
|
140
|
+
if (delayInMs >= 3600000) {
|
|
141
|
+
return '#ed004c'; // pink { r: 237, g: 0, b: 76, s: '237,0,76' };
|
|
142
|
+
}
|
|
143
|
+
if (delayInMs >= 500000) {
|
|
144
|
+
return '#e80000'; // red { r: 232, g: 0, b: 0, s: '232,0,0' };
|
|
145
|
+
}
|
|
146
|
+
if (delayInMs >= 300000) {
|
|
147
|
+
return '#ff4a00'; // orange { r: 255, g: 74, b: 0, s: '255,74,0' };
|
|
148
|
+
}
|
|
149
|
+
if (delayInMs >= 180000) {
|
|
150
|
+
return '#f7bf00'; // yellow { r: 247, g: 191, b: 0, s: '247,191,0' };
|
|
151
|
+
}
|
|
152
|
+
return '#00a00c'; // green { r: 0, g: 160, b: 12, s: '0,160,12' };
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* @ignore
|
|
156
|
+
*/
|
|
157
|
+
export const getDelayText = (delayInMs, cancelled) => {
|
|
158
|
+
if (cancelled) {
|
|
159
|
+
return String.fromCodePoint(0x00d7);
|
|
160
|
+
}
|
|
161
|
+
if (delayInMs > 3600000) {
|
|
162
|
+
const rounded = Math.round(delayInMs / 3600000);
|
|
163
|
+
return `+${rounded}h`;
|
|
164
|
+
}
|
|
165
|
+
if (delayInMs > 59000) {
|
|
166
|
+
const rounded = Math.round(delayInMs / 60000);
|
|
167
|
+
return `+${rounded}m`;
|
|
168
|
+
}
|
|
169
|
+
if (delayInMs > 0) {
|
|
170
|
+
return `+${delayInMs}s`;
|
|
171
|
+
}
|
|
172
|
+
return '';
|
|
173
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function remove duplicates lower case string value of an array.
|
|
3
|
+
* It removes also null, undefined or non string values.
|
|
4
|
+
*
|
|
5
|
+
* @param {array} array Array of values.
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
declare const removeDuplicate: (array: any[]) => any[];
|
|
9
|
+
export default removeDuplicate;
|
|
10
|
+
//# sourceMappingURL=removeDuplicate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeDuplicate.d.ts","sourceRoot":"","sources":["../../../src/common/utils/removeDuplicate.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,QAAA,MAAM,eAAe,UAAW,GAAG,EAAE,UAYpC,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -6,17 +6,10 @@
|
|
|
6
6
|
* @ignore
|
|
7
7
|
*/
|
|
8
8
|
const removeDuplicate = (array) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
15
|
-
const uniqueLowerCaseValues = [...new Set(lowerCasesValues)];
|
|
16
|
-
const uniqueValues = uniqueLowerCaseValues.map((uniqueStr) =>
|
|
17
|
-
arrWithoutEmptyValues.find((str) => str.toLowerCase() === uniqueStr),
|
|
18
|
-
);
|
|
19
|
-
return uniqueValues;
|
|
9
|
+
const arrWithoutEmptyValues = array.filter((val) => val !== undefined && val !== null && val.trim && val.trim());
|
|
10
|
+
const lowerCasesValues = arrWithoutEmptyValues.map((str) => str.toLowerCase());
|
|
11
|
+
const uniqueLowerCaseValues = [...new Set(lowerCasesValues)];
|
|
12
|
+
const uniqueValues = uniqueLowerCaseValues.map((uniqueStr) => arrWithoutEmptyValues.find((str) => str.toLowerCase() === uniqueStr));
|
|
13
|
+
return uniqueValues;
|
|
20
14
|
};
|
|
21
|
-
|
|
22
15
|
export default removeDuplicate;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AnyCanvas, RealtimeRenderState, RealtimeStyleFunction, RealtimeStyleOptions, RealtimeTrajectories, ViewState } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Draw all the trajectories available in a canvas.
|
|
4
|
+
* @param {HTMLCanvas|HTMLOffscreenCanvas} The canvas where to draw the trajectories.
|
|
5
|
+
* @param {ViewState} trajectories An array of trajectories.
|
|
6
|
+
* @param {Function} style A function that returns a canvas representing a vehicle of a specific trajectory.
|
|
7
|
+
* @param {ViewState} viewState The view state of the map.
|
|
8
|
+
* @param {boolean} options.hoverVehicleId The id of the vehicle to highlight.
|
|
9
|
+
* @param {boolean} options.selectedVehicleId The id of the vehicle to select.
|
|
10
|
+
* @param {boolean} options.noInterpolate If true trajectories are not interpolated but
|
|
11
|
+
* drawn at the last known coordinate. Use this for performance optimization
|
|
12
|
+
* during map navigation.
|
|
13
|
+
* @private
|
|
14
|
+
*/
|
|
15
|
+
declare const renderTrajectories: (canvas: AnyCanvas, trajectories: RealtimeTrajectories, style: RealtimeStyleFunction, viewState: ViewState, options: RealtimeStyleOptions) => RealtimeRenderState;
|
|
16
|
+
export default renderTrajectories;
|
|
17
|
+
//# sourceMappingURL=renderTrajectories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderTrajectories.d.ts","sourceRoot":"","sources":["../../../src/common/utils/renderTrajectories.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,SAAS,EACV,MAAM,aAAa,CAAC;AAGrB;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,kBAAkB,WACd,SAAS,gBACH,oBAAoB,SAC3B,qBAAqB,aACjB,SAAS,WACX,oBAAoB,KAC5B,mBA+JF,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { compose, apply, create } from 'ol/transform';
|
|
2
|
+
import getVehiclePosition from './getVehiclePosition';
|
|
3
|
+
/**
|
|
4
|
+
* Draw all the trajectories available in a canvas.
|
|
5
|
+
* @param {HTMLCanvas|HTMLOffscreenCanvas} The canvas where to draw the trajectories.
|
|
6
|
+
* @param {ViewState} trajectories An array of trajectories.
|
|
7
|
+
* @param {Function} style A function that returns a canvas representing a vehicle of a specific trajectory.
|
|
8
|
+
* @param {ViewState} viewState The view state of the map.
|
|
9
|
+
* @param {boolean} options.hoverVehicleId The id of the vehicle to highlight.
|
|
10
|
+
* @param {boolean} options.selectedVehicleId The id of the vehicle to select.
|
|
11
|
+
* @param {boolean} options.noInterpolate If true trajectories are not interpolated but
|
|
12
|
+
* drawn at the last known coordinate. Use this for performance optimization
|
|
13
|
+
* during map navigation.
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
const renderTrajectories = (canvas, trajectories, style, viewState, options) => {
|
|
17
|
+
if (!canvas) {
|
|
18
|
+
return { renderedTrajectories: [] };
|
|
19
|
+
}
|
|
20
|
+
const { time = Date.now(), size = [], center, resolution, rotation = 0, pixelRatio = 1, } = viewState;
|
|
21
|
+
if (!resolution || !center) {
|
|
22
|
+
return { renderedTrajectories: [] };
|
|
23
|
+
}
|
|
24
|
+
const { noInterpolate = false, hoverVehicleId, selectedVehicleId, filter, getScreenPixel = (pixel, viewStat) => (viewStat.zoom || 0) < 12
|
|
25
|
+
? pixel.map((coord) => Math.floor(coord))
|
|
26
|
+
: pixel, } = options;
|
|
27
|
+
const context = canvas.getContext('2d');
|
|
28
|
+
context === null || context === void 0 ? void 0 : context.clearRect(0, 0, canvas.width, canvas.height);
|
|
29
|
+
const [width, height] = size;
|
|
30
|
+
if (width && height && (canvas.width !== width || canvas.height !== height)) {
|
|
31
|
+
[canvas.width, canvas.height] = [width * pixelRatio, height * pixelRatio];
|
|
32
|
+
}
|
|
33
|
+
const coordinateToPixelTransform = compose(create(), size[0] / 2, size[1] / 2, 1 / resolution, -1 / resolution, -rotation, -center[0], -center[1]);
|
|
34
|
+
// Offscreen canvas has not style attribute
|
|
35
|
+
if (canvas.style) {
|
|
36
|
+
canvas.style.width = `${canvas.width / pixelRatio}px`;
|
|
37
|
+
canvas.style.height = `${canvas.height / pixelRatio}px`;
|
|
38
|
+
}
|
|
39
|
+
let hoverVehicleImg;
|
|
40
|
+
let hoverVehiclePx;
|
|
41
|
+
let selectedVehicleImg;
|
|
42
|
+
let selectedVehiclePx;
|
|
43
|
+
const renderedTrajectories = [];
|
|
44
|
+
for (let i = trajectories.length - 1; i >= 0; i -= 1) {
|
|
45
|
+
const trajectory = trajectories[i];
|
|
46
|
+
// Filter out trajectories
|
|
47
|
+
if (filter && !filter(trajectory)) {
|
|
48
|
+
// eslint-disable-next-line no-continue
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
// We simplify the trajectory object
|
|
52
|
+
const { train_id: id, timeOffset } = trajectory.properties;
|
|
53
|
+
// We set the rotation and the timeFraction of the trajectory (used by tralis).
|
|
54
|
+
// if rotation === null that seems there is no rotation available.
|
|
55
|
+
const { coord, rotation: rotationIcon } = getVehiclePosition(time - (timeOffset || 0), trajectory, noInterpolate);
|
|
56
|
+
// We store the current vehicle position to the trajectory.
|
|
57
|
+
trajectories[i].properties.coordinate = coord;
|
|
58
|
+
trajectories[i].properties.rotation = rotationIcon;
|
|
59
|
+
if (!coord) {
|
|
60
|
+
// eslint-disable-next-line no-continue
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
let px = apply(coordinateToPixelTransform, [...coord]);
|
|
64
|
+
if (!px) {
|
|
65
|
+
// eslint-disable-next-line no-continue
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
px = px.map((p) => p * pixelRatio);
|
|
69
|
+
if (px[0] < 0 ||
|
|
70
|
+
px[0] > canvas.width ||
|
|
71
|
+
px[1] < 0 ||
|
|
72
|
+
px[1] > canvas.height) {
|
|
73
|
+
// eslint-disable-next-line no-continue
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
const vehicleImg = style(trajectory, viewState, options);
|
|
77
|
+
if (!vehicleImg) {
|
|
78
|
+
// eslint-disable-next-line no-continue
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (hoverVehicleId !== id && selectedVehicleId !== id) {
|
|
82
|
+
// To optimize the performance we use integer as pixel coordinate
|
|
83
|
+
// to avoid an additional work by the browser on zoom level < 12.
|
|
84
|
+
// See https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Optimizing_canvas?retiredLocale=de#avoid_floating-point_coordinates_and_use_integers_instead
|
|
85
|
+
const [x, y] = getScreenPixel([px[0] - vehicleImg.width / 2, px[1] - vehicleImg.height / 2], viewState);
|
|
86
|
+
context === null || context === void 0 ? void 0 : context.drawImage(vehicleImg, x, y);
|
|
87
|
+
}
|
|
88
|
+
if (hoverVehicleId && hoverVehicleId === id) {
|
|
89
|
+
// Store the canvas to draw it at the end
|
|
90
|
+
hoverVehicleImg = vehicleImg;
|
|
91
|
+
hoverVehiclePx = px;
|
|
92
|
+
}
|
|
93
|
+
if (selectedVehicleId && selectedVehicleId === id) {
|
|
94
|
+
// Store the canvas to draw it at the end
|
|
95
|
+
selectedVehicleImg = vehicleImg;
|
|
96
|
+
selectedVehiclePx = px;
|
|
97
|
+
}
|
|
98
|
+
renderedTrajectories.push(trajectory);
|
|
99
|
+
}
|
|
100
|
+
if (selectedVehicleImg && selectedVehiclePx) {
|
|
101
|
+
context === null || context === void 0 ? void 0 : context.drawImage(selectedVehicleImg, Math.floor(selectedVehiclePx[0] - selectedVehicleImg.width / 2), Math.floor(selectedVehiclePx[1] - selectedVehicleImg.height / 2));
|
|
102
|
+
}
|
|
103
|
+
if (hoverVehicleImg && hoverVehiclePx) {
|
|
104
|
+
context === null || context === void 0 ? void 0 : context.drawImage(hoverVehicleImg, Math.floor(hoverVehiclePx[0] - hoverVehicleImg.width / 2), Math.floor(hoverVehiclePx[1] - hoverVehicleImg.height / 2));
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
renderedTrajectories,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
export default renderTrajectories;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RealtimeAPIDeparturesById } from '../../api/RealtimeAPI';
|
|
2
|
+
import type { RealtimeDepartureExtended } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* This function sort Departures by arrival time and filter out unwanted departures:
|
|
5
|
+
* - when dparture time is in the past
|
|
6
|
+
* - when departure are duplicated
|
|
7
|
+
* - when departure is not in the next 30 min
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} depObject The object containing departures by id.
|
|
10
|
+
* @param {boolean} [sortByMinArrivalTime=false] If true sort departures by arrival time.
|
|
11
|
+
* @return {Array<Departure>} Return departures array.
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
declare const sortAndfilterDepartures: (depObject: RealtimeAPIDeparturesById, sortByMinArrivalTime?: boolean, maxDepartureAge?: number) => RealtimeDepartureExtended[];
|
|
15
|
+
export default sortAndfilterDepartures;
|
|
16
|
+
//# sourceMappingURL=sortAndFilterDepartures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortAndFilterDepartures.d.ts","sourceRoot":"","sources":["../../../src/common/utils/sortAndFilterDepartures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAG7D;;;;;;;;;;GAUG;AACH,QAAA,MAAM,uBAAuB,cAChB,yBAAyB,yBACd,OAAO,oBACZ,MAAM,KACtB,yBAAyB,EAwD3B,CAAC;AAEF,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import compareDepartures from './compareDepartures';
|
|
2
|
+
/**
|
|
3
|
+
* This function sort Departures by arrival time and filter out unwanted departures:
|
|
4
|
+
* - when dparture time is in the past
|
|
5
|
+
* - when departure are duplicated
|
|
6
|
+
* - when departure is not in the next 30 min
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} depObject The object containing departures by id.
|
|
9
|
+
* @param {boolean} [sortByMinArrivalTime=false] If true sort departures by arrival time.
|
|
10
|
+
* @return {Array<Departure>} Return departures array.
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
const sortAndfilterDepartures = (depObject, sortByMinArrivalTime = false, maxDepartureAge = 30) => {
|
|
14
|
+
const departures = Object.keys(depObject).map((k) => depObject[k]);
|
|
15
|
+
departures.sort((a, b) => compareDepartures(a, b, sortByMinArrivalTime));
|
|
16
|
+
const futureDate = new Date();
|
|
17
|
+
futureDate.setMinutes(futureDate.getMinutes() + maxDepartureAge);
|
|
18
|
+
const future = futureDate.getTime();
|
|
19
|
+
const pastDate = new Date();
|
|
20
|
+
pastDate.setMinutes(pastDate.getMinutes() - maxDepartureAge);
|
|
21
|
+
const past = pastDate.getTime();
|
|
22
|
+
const departureArray = [];
|
|
23
|
+
const platformsBoarding = [];
|
|
24
|
+
let previousDeparture = null;
|
|
25
|
+
for (let i = departures.length - 1; i >= 0; i -= 1) {
|
|
26
|
+
const departure = Object.assign({}, departures[i]);
|
|
27
|
+
const time = new Date(departure.time).getTime();
|
|
28
|
+
// Only show departures within the next 30 minutes
|
|
29
|
+
if (time > past && time < future) {
|
|
30
|
+
// If 2 trains are boarding at the same platform,
|
|
31
|
+
// remove the older one.
|
|
32
|
+
if (departure.state === 'BOARDING') {
|
|
33
|
+
if (!platformsBoarding.includes(departure.platform)) {
|
|
34
|
+
platformsBoarding.push(departure.platform);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
departure.state = 'HIDDEN';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// If two trains with the same line number and destinatin
|
|
41
|
+
// and a departure difference < 1 minute, hide the second one.
|
|
42
|
+
if (previousDeparture &&
|
|
43
|
+
departure.to[0] === previousDeparture.to[0] &&
|
|
44
|
+
Math.abs(time - previousDeparture.time) < 1000 &&
|
|
45
|
+
departure.line.name === previousDeparture.line.name) {
|
|
46
|
+
departure.state = 'HIDDEN';
|
|
47
|
+
}
|
|
48
|
+
if (/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(departure.state)) {
|
|
49
|
+
departure.cancelled = true;
|
|
50
|
+
}
|
|
51
|
+
previousDeparture = departure;
|
|
52
|
+
previousDeparture.time = time;
|
|
53
|
+
departureArray.unshift(departure);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return departureArray;
|
|
57
|
+
};
|
|
58
|
+
export default sortAndfilterDepartures;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortByDelay.d.ts","sourceRoot":"","sources":["../../../src/common/utils/sortByDelay.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW,oDAGd,MAoBF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
const sortByDelay = (traj1, traj2) => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
return props2.delay - props1.delay;
|
|
2
|
+
const props1 = traj1.properties;
|
|
3
|
+
const props2 = traj2.properties;
|
|
4
|
+
if (props1.delay === null && props2.delay !== null) {
|
|
5
|
+
return 1;
|
|
6
|
+
}
|
|
7
|
+
if (props2.delay === null && props1.delay !== null) {
|
|
8
|
+
return -1;
|
|
9
|
+
}
|
|
10
|
+
// We put cancelled train inbetween green and yellow trains
|
|
11
|
+
// >=180000ms corresponds to yellow train
|
|
12
|
+
if (props1.cancelled && !props2.cancelled) {
|
|
13
|
+
return props2.delay < 180000 ? -1 : 1;
|
|
14
|
+
}
|
|
15
|
+
if (props2.cancelled && !props1.cancelled) {
|
|
16
|
+
return props1.delay < 180000 ? 1 : -1;
|
|
17
|
+
}
|
|
18
|
+
return props2.delay - props1.delay;
|
|
21
19
|
};
|
|
22
|
-
|
|
23
20
|
export default sortByDelay;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a Date object as UTC date string .
|
|
3
|
+
* ex: 2019 09 01
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
export declare const getUTCDateString: (now?: Date) => string;
|
|
7
|
+
/**
|
|
8
|
+
* Get the UTC time string of Date object.
|
|
9
|
+
* ex: 09:05:01.123
|
|
10
|
+
* @ignore
|
|
11
|
+
*/
|
|
12
|
+
export declare const getUTCTimeString: (date: Date) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Returns a string representation of a number, with a zero if the number is lower than 10.
|
|
15
|
+
* @ignore
|
|
16
|
+
*/
|
|
17
|
+
export declare const pad: (integer: number) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Returns a 'hh:mm' string from a time in ms.
|
|
20
|
+
* @param {Number} timeInMs Time in milliseconds.
|
|
21
|
+
* @ignore
|
|
22
|
+
*/
|
|
23
|
+
export declare const getHoursAndMinutes: (timeInMs: number) => string;
|
|
24
|
+
//# sourceMappingURL=timeUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeUtils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/timeUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,kBAAuB,MAOnD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,SAAU,IAAI,KAAG,MAKjC,CAAC;AAEd;;;GAGG;AACH,eAAO,MAAM,GAAG,YAAa,MAAM,KAAG,MACO,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,aAAc,MAAM,KAAG,MAMrD,CAAC"}
|
|
@@ -4,41 +4,36 @@
|
|
|
4
4
|
* @ignore
|
|
5
5
|
*/
|
|
6
6
|
export const getUTCDateString = (now = new Date()) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return [now.getUTCFullYear(), month, day].join('');
|
|
7
|
+
let month = (now.getUTCMonth() + 1).toString();
|
|
8
|
+
month = month.length === 1 ? `0${month}` : month;
|
|
9
|
+
let day = now.getUTCDate().toString();
|
|
10
|
+
day = day.length === 1 ? `0${day}` : day;
|
|
11
|
+
return [now.getUTCFullYear(), month, day].join('');
|
|
13
12
|
};
|
|
14
|
-
|
|
15
13
|
/**
|
|
16
14
|
* Get the UTC time string of Date object.
|
|
17
15
|
* ex: 09:05:01.123
|
|
18
16
|
* @ignore
|
|
19
17
|
*/
|
|
20
|
-
export const getUTCTimeString = (date) =>
|
|
21
|
-
[
|
|
18
|
+
export const getUTCTimeString = (date) => [
|
|
22
19
|
date.getUTCHours(),
|
|
23
20
|
date.getUTCMinutes(),
|
|
24
21
|
`${date.getUTCSeconds()}.${date.getUTCMilliseconds()}`,
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
].join(':');
|
|
27
23
|
/**
|
|
28
24
|
* Returns a string representation of a number, with a zero if the number is lower than 10.
|
|
29
25
|
* @ignore
|
|
30
26
|
*/
|
|
31
|
-
export const pad = (integer) =>
|
|
32
|
-
|
|
27
|
+
export const pad = (integer) => integer < 10 ? `0${integer}` : `${integer}`;
|
|
33
28
|
/**
|
|
34
29
|
* Returns a 'hh:mm' string from a time in ms.
|
|
35
30
|
* @param {Number} timeInMs Time in milliseconds.
|
|
36
31
|
* @ignore
|
|
37
32
|
*/
|
|
38
33
|
export const getHoursAndMinutes = (timeInMs) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
34
|
+
if (!timeInMs || timeInMs <= 0) {
|
|
35
|
+
return '';
|
|
36
|
+
}
|
|
37
|
+
const date = new Date(timeInMs);
|
|
38
|
+
return `${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
44
39
|
};
|
package/iife.d.ts
ADDED
package/iife.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iife.d.ts","sourceRoot":"","sources":["../src/iife.js"],"names":[],"mappings":";gBAAgB,SAAS"}
|
package/iife.js
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * as ol from "./ol";
|
|
2
|
+
export * as mapbox from "./mapbox";
|
|
3
|
+
declare namespace _default {
|
|
4
|
+
export { ol };
|
|
5
|
+
export { mapbox };
|
|
6
|
+
}
|
|
7
|
+
export default _default;
|
|
8
|
+
import * as ol from './ol';
|
|
9
|
+
import * as mapbox from './mapbox';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;;;;;oBAAoB,MAAM;wBACF,UAAU"}
|