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
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getRadius,
|
|
3
|
-
getBgColor,
|
|
4
|
-
getDelayColor,
|
|
5
|
-
getDelayText,
|
|
6
|
-
getTextColor,
|
|
7
|
-
getTextSize,
|
|
8
|
-
} from '../trackerConfig';
|
|
9
|
-
|
|
10
|
-
const createCanvas = (width, height) => {
|
|
11
|
-
const canvas = document.createElement('canvas');
|
|
12
|
-
canvas.width = width;
|
|
13
|
-
canvas.height = height;
|
|
14
|
-
return canvas;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// Draw circle delay background
|
|
18
|
-
const cacheDelayBg = {};
|
|
19
|
-
export const getDelayBgCanvas = (origin, radius, color) => {
|
|
20
|
-
const key = `${origin}, ${radius}, ${color}`;
|
|
21
|
-
if (!cacheDelayBg[key]) {
|
|
22
|
-
const canvas = createCanvas(origin * 2, origin * 2);
|
|
23
|
-
const ctx = canvas.getContext('2d');
|
|
24
|
-
ctx.beginPath();
|
|
25
|
-
ctx.arc(origin, origin, radius, 0, 2 * Math.PI, false);
|
|
26
|
-
ctx.fillStyle = color;
|
|
27
|
-
ctx.filter = 'blur(1px)';
|
|
28
|
-
ctx.fill();
|
|
29
|
-
cacheDelayBg[key] = canvas;
|
|
30
|
-
}
|
|
31
|
-
return cacheDelayBg[key];
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Draw delay text
|
|
35
|
-
const cacheDelayText = {};
|
|
36
|
-
export const getDelayTextCanvas = (
|
|
37
|
-
width,
|
|
38
|
-
text,
|
|
39
|
-
fontSize,
|
|
40
|
-
font,
|
|
41
|
-
delayColor,
|
|
42
|
-
delayOutlineColor,
|
|
43
|
-
pixelRatio,
|
|
44
|
-
) => {
|
|
45
|
-
const key = `${width}, ${text}, ${font}, ${delayColor}, ${delayOutlineColor}, ${pixelRatio}`;
|
|
46
|
-
if (!cacheDelayText[key]) {
|
|
47
|
-
const canvas = createCanvas(width, fontSize + 8 * pixelRatio);
|
|
48
|
-
const ctx = canvas.getContext('2d');
|
|
49
|
-
ctx.textAlign = 'left';
|
|
50
|
-
ctx.textBaseline = 'middle';
|
|
51
|
-
ctx.font = font;
|
|
52
|
-
ctx.fillStyle = delayColor;
|
|
53
|
-
ctx.strokeStyle = delayOutlineColor;
|
|
54
|
-
ctx.lineWidth = 1.5 * pixelRatio;
|
|
55
|
-
const delayText = text;
|
|
56
|
-
ctx.strokeText(delayText, 0, fontSize);
|
|
57
|
-
ctx.fillText(delayText, 0, fontSize);
|
|
58
|
-
cacheDelayText[key] = canvas;
|
|
59
|
-
}
|
|
60
|
-
return cacheDelayText[key];
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// Draw colored circle with black border
|
|
64
|
-
const cacheCircle = {};
|
|
65
|
-
export const getCircleCanvas = (
|
|
66
|
-
origin,
|
|
67
|
-
radius,
|
|
68
|
-
color,
|
|
69
|
-
hasStroke,
|
|
70
|
-
hasDash,
|
|
71
|
-
pixelRatio,
|
|
72
|
-
) => {
|
|
73
|
-
const key = `${origin}, ${radius}, ${color}, ${hasStroke}, ${hasDash}, ${pixelRatio}`;
|
|
74
|
-
if (!cacheCircle[key]) {
|
|
75
|
-
const canvas = createCanvas(origin * 2, origin * 2);
|
|
76
|
-
const ctx = canvas.getContext('2d');
|
|
77
|
-
ctx.fillStyle = color;
|
|
78
|
-
|
|
79
|
-
if (hasStroke) {
|
|
80
|
-
ctx.lineWidth = 1 * pixelRatio;
|
|
81
|
-
ctx.strokeStyle = '#000000';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
ctx.beginPath();
|
|
85
|
-
ctx.arc(origin, origin, radius, 0, 2 * Math.PI, false);
|
|
86
|
-
ctx.fill();
|
|
87
|
-
|
|
88
|
-
if (hasDash) {
|
|
89
|
-
ctx.setLineDash([5, 3]);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (hasStroke) {
|
|
93
|
-
ctx.stroke();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
cacheCircle[key] = canvas;
|
|
97
|
-
}
|
|
98
|
-
return cacheCircle[key];
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// Draw text in the circle
|
|
102
|
-
const cacheText = {};
|
|
103
|
-
export const getTextCanvas = (
|
|
104
|
-
text,
|
|
105
|
-
origin,
|
|
106
|
-
textSize,
|
|
107
|
-
fillColor,
|
|
108
|
-
strokeColor,
|
|
109
|
-
hasStroke,
|
|
110
|
-
pixelRatio,
|
|
111
|
-
) => {
|
|
112
|
-
const key = `${text}, ${origin}, ${textSize}, ${fillColor},${strokeColor}, ${hasStroke}, ${pixelRatio}`;
|
|
113
|
-
if (!cacheText[key]) {
|
|
114
|
-
const canvas = createCanvas(origin * 2, origin * 2);
|
|
115
|
-
const ctx = canvas.getContext('2d');
|
|
116
|
-
|
|
117
|
-
// Draw a stroke to the text only if a provider provides realtime but we don't use it.
|
|
118
|
-
if (hasStroke) {
|
|
119
|
-
ctx.save();
|
|
120
|
-
ctx.textBaseline = 'middle';
|
|
121
|
-
ctx.textAlign = 'center';
|
|
122
|
-
ctx.font = `bold ${textSize + 2}px Arial`;
|
|
123
|
-
ctx.strokeStyle = strokeColor;
|
|
124
|
-
ctx.strokeText(text, origin, origin);
|
|
125
|
-
ctx.restore();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Draw a text
|
|
129
|
-
ctx.textBaseline = 'middle';
|
|
130
|
-
ctx.textAlign = 'center';
|
|
131
|
-
ctx.fillStyle = fillColor;
|
|
132
|
-
ctx.font = `bold ${textSize}px Arial`;
|
|
133
|
-
ctx.strokeStyle = strokeColor;
|
|
134
|
-
ctx.strokeText(text, origin, origin);
|
|
135
|
-
ctx.fillText(text, origin, origin);
|
|
136
|
-
|
|
137
|
-
cacheText[key] = canvas;
|
|
138
|
-
}
|
|
139
|
-
return cacheText[key];
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* A tracker style that take in account the delay.
|
|
144
|
-
*
|
|
145
|
-
* @param {*} trajectory The trajectory to render.
|
|
146
|
-
* @param {*} viewState The view state of the map.
|
|
147
|
-
* @param {*} options Some options to change the rendering
|
|
148
|
-
* @return a canvas
|
|
149
|
-
*/
|
|
150
|
-
const styleCache = {};
|
|
151
|
-
const style = (trajectory, viewState, options) => {
|
|
152
|
-
const {
|
|
153
|
-
hoverVehicleId,
|
|
154
|
-
selectedVehicleId,
|
|
155
|
-
useDelayStyle,
|
|
156
|
-
delayOutlineColor,
|
|
157
|
-
delayDisplay,
|
|
158
|
-
} = options;
|
|
159
|
-
|
|
160
|
-
const { zoom, pixelRatio } = viewState;
|
|
161
|
-
let { type, cancelled } = trajectory.properties;
|
|
162
|
-
const {
|
|
163
|
-
train_id: id,
|
|
164
|
-
line,
|
|
165
|
-
delay,
|
|
166
|
-
state,
|
|
167
|
-
operator_provides_realtime_journey: operatorProvidesRealtime,
|
|
168
|
-
} = trajectory.properties;
|
|
169
|
-
let { name, text_color: textColor, color } = line || {};
|
|
170
|
-
|
|
171
|
-
// In the future, the cancelled property will be removed we still managed it
|
|
172
|
-
// until the backend change is on prod.
|
|
173
|
-
cancelled = cancelled === true || state === 'JOURNEY_CANCELLED';
|
|
174
|
-
|
|
175
|
-
if (!type) {
|
|
176
|
-
type = 'Rail';
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (!name) {
|
|
180
|
-
name = 'I';
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
if (!textColor) {
|
|
184
|
-
textColor = '#000000';
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (color && color[0] !== '#') {
|
|
188
|
-
color = `#${color}`;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if (textColor[0] !== '#') {
|
|
192
|
-
textColor = `#${textColor}`;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const z = Math.min(Math.floor(zoom || 1), 16);
|
|
196
|
-
const hover = hoverVehicleId && hoverVehicleId === id;
|
|
197
|
-
const selected = selectedVehicleId && selectedVehicleId === id;
|
|
198
|
-
|
|
199
|
-
// Calcul the radius of the circle
|
|
200
|
-
let radius = getRadius(type, z) * pixelRatio;
|
|
201
|
-
const isDisplayStrokeAndDelay = radius >= 7 * pixelRatio;
|
|
202
|
-
if (hover || selected) {
|
|
203
|
-
radius = isDisplayStrokeAndDelay
|
|
204
|
-
? radius + 5 * pixelRatio
|
|
205
|
-
: 14 * pixelRatio;
|
|
206
|
-
}
|
|
207
|
-
const mustDrawText = radius > 10 * pixelRatio;
|
|
208
|
-
|
|
209
|
-
// Optimize the cache key, very important in high zoom level
|
|
210
|
-
let key = `${radius}${type}${color}${hover}${selected}${cancelled}${delay}`;
|
|
211
|
-
|
|
212
|
-
if (useDelayStyle) {
|
|
213
|
-
key += `${operatorProvidesRealtime}`;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (mustDrawText) {
|
|
217
|
-
key += `${name}${textColor}`;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (!styleCache[key]) {
|
|
221
|
-
if (radius === 0) {
|
|
222
|
-
styleCache[key] = null;
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const margin = 1 * pixelRatio;
|
|
227
|
-
const radiusDelay = radius + 2;
|
|
228
|
-
const markerSize = radius * 2;
|
|
229
|
-
const size = radiusDelay * 2 + margin * 2 + 100 * pixelRatio; // add space for delay information
|
|
230
|
-
const origin = size / 2;
|
|
231
|
-
|
|
232
|
-
// Create the canvas
|
|
233
|
-
const canvas = createCanvas(size, size);
|
|
234
|
-
const ctx = canvas.getContext('2d');
|
|
235
|
-
|
|
236
|
-
if (isDisplayStrokeAndDelay && delay !== null) {
|
|
237
|
-
// Draw circle delay background
|
|
238
|
-
const delayBg = getDelayBgCanvas(
|
|
239
|
-
origin,
|
|
240
|
-
radiusDelay,
|
|
241
|
-
getDelayColor(delay, cancelled),
|
|
242
|
-
);
|
|
243
|
-
ctx.drawImage(delayBg, 0, 0);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Show delay if feature is hovered or if delay is above 5mins.
|
|
247
|
-
if (
|
|
248
|
-
isDisplayStrokeAndDelay &&
|
|
249
|
-
(hover || delay >= delayDisplay || cancelled)
|
|
250
|
-
) {
|
|
251
|
-
// Draw delay text
|
|
252
|
-
const fontSize =
|
|
253
|
-
Math.max(
|
|
254
|
-
cancelled ? 19 : 14,
|
|
255
|
-
Math.min(cancelled ? 19 : 17, radius * 1.2),
|
|
256
|
-
) * pixelRatio;
|
|
257
|
-
const text = getDelayText(delay, cancelled);
|
|
258
|
-
|
|
259
|
-
if (text) {
|
|
260
|
-
const textWidth = text.length * fontSize;
|
|
261
|
-
const delayText = getDelayTextCanvas(
|
|
262
|
-
textWidth,
|
|
263
|
-
text,
|
|
264
|
-
fontSize,
|
|
265
|
-
`bold ${fontSize}px arial, sans-serif`,
|
|
266
|
-
getDelayColor(delay, cancelled, true),
|
|
267
|
-
delayOutlineColor,
|
|
268
|
-
pixelRatio,
|
|
269
|
-
);
|
|
270
|
-
ctx.drawImage(
|
|
271
|
-
delayText,
|
|
272
|
-
origin + radiusDelay + margin,
|
|
273
|
-
origin - fontSize,
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// Draw colored circle with black border
|
|
279
|
-
let circleFillColor;
|
|
280
|
-
if (useDelayStyle) {
|
|
281
|
-
circleFillColor = getDelayColor(delay, cancelled);
|
|
282
|
-
} else {
|
|
283
|
-
circleFillColor = color || getBgColor(type);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const hasStroke = isDisplayStrokeAndDelay || hover || selected;
|
|
287
|
-
|
|
288
|
-
const hasDash =
|
|
289
|
-
isDisplayStrokeAndDelay &&
|
|
290
|
-
useDelayStyle &&
|
|
291
|
-
delay === null &&
|
|
292
|
-
operatorProvidesRealtime === 'yes';
|
|
293
|
-
|
|
294
|
-
const circle = getCircleCanvas(
|
|
295
|
-
origin,
|
|
296
|
-
radius,
|
|
297
|
-
circleFillColor,
|
|
298
|
-
hasStroke,
|
|
299
|
-
hasDash,
|
|
300
|
-
pixelRatio,
|
|
301
|
-
);
|
|
302
|
-
|
|
303
|
-
ctx.drawImage(circle, 0, 0);
|
|
304
|
-
|
|
305
|
-
// Draw text in the circle
|
|
306
|
-
if (mustDrawText) {
|
|
307
|
-
const fontSize = Math.max(radius, 10);
|
|
308
|
-
const textSize = getTextSize(ctx, markerSize, name, fontSize);
|
|
309
|
-
const textColor2 = !useDelayStyle
|
|
310
|
-
? textColor || getTextColor(type)
|
|
311
|
-
: '#000000';
|
|
312
|
-
const hasStroke2 =
|
|
313
|
-
useDelayStyle && delay === null && operatorProvidesRealtime === 'yes';
|
|
314
|
-
|
|
315
|
-
const text = getTextCanvas(
|
|
316
|
-
name,
|
|
317
|
-
origin,
|
|
318
|
-
textSize,
|
|
319
|
-
textColor2,
|
|
320
|
-
circleFillColor,
|
|
321
|
-
hasStroke2,
|
|
322
|
-
pixelRatio,
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
ctx.drawImage(text, 0, 0);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
styleCache[key] = canvas;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
return styleCache[key];
|
|
332
|
-
};
|
|
333
|
-
export default style;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A very simple tracker style.
|
|
3
|
-
* Display blue point for each train.
|
|
4
|
-
*/
|
|
5
|
-
let canvas;
|
|
6
|
-
const style = () => {
|
|
7
|
-
if (!canvas) {
|
|
8
|
-
document.createElement('canvas');
|
|
9
|
-
canvas.width = 15;
|
|
10
|
-
canvas.height = 15;
|
|
11
|
-
const ctx = canvas.getContext('2d');
|
|
12
|
-
ctx.arc(8, 8, 5, 0, 2 * Math.PI, false);
|
|
13
|
-
ctx.fillStyle = '#8ED6FF';
|
|
14
|
-
ctx.fill();
|
|
15
|
-
ctx.lineWidth = 3;
|
|
16
|
-
ctx.strokeStyle = 'black';
|
|
17
|
-
ctx.stroke();
|
|
18
|
-
ctx.lineWidth = 3;
|
|
19
|
-
}
|
|
20
|
-
return canvas;
|
|
21
|
-
};
|
|
22
|
-
export default style;
|
package/common/trackerConfig.js
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
const trackerRadiusMapping = {
|
|
2
|
-
0: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
3
|
-
1: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
4
|
-
2: [0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 12, 15, 15, 15, 15, 15],
|
|
5
|
-
3: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
6
|
-
4: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
7
|
-
5: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
8
|
-
6: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
9
|
-
7: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
10
|
-
8: [0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
|
|
11
|
-
9: [0, 0, 0, 0, 0, 2, 2, 3, 7, 7, 7, 12, 15, 15, 15, 15, 15],
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Trajserv value: 'Tram', 'Subway / Metro / S-Bahn', 'Train', 'Bus', 'Ferry', 'Cable Car', 'Gondola', 'Funicular', 'Long distance bus', 'Rail',
|
|
16
|
-
* New endpoint use Rail instead of Train.
|
|
17
|
-
* New tracker values: null, "tram", "subway", "rail", "bus", "ferry", "cablecar", "gondola", "funicular", "coach".
|
|
18
|
-
*
|
|
19
|
-
* @ignore
|
|
20
|
-
*/
|
|
21
|
-
export const types = [
|
|
22
|
-
/^Tram/i,
|
|
23
|
-
/^Subway( \/ Metro \/ S-Bahn)?/i,
|
|
24
|
-
/^Train/i,
|
|
25
|
-
/^Bus/i,
|
|
26
|
-
/^Ferry/i,
|
|
27
|
-
/^Cable ?Car/i,
|
|
28
|
-
/^Gondola/i,
|
|
29
|
-
/^Funicular/i,
|
|
30
|
-
/^(Long distance bus|coach)/i,
|
|
31
|
-
/^Rail/i, // New endpoint use Rail instead of Train.
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @ignore
|
|
36
|
-
*/
|
|
37
|
-
export const bgColors = [
|
|
38
|
-
'#ffb400',
|
|
39
|
-
'#ff5400',
|
|
40
|
-
'#ff8080',
|
|
41
|
-
'#ea0000',
|
|
42
|
-
'#3000ff',
|
|
43
|
-
'#ffb400',
|
|
44
|
-
'#41a27b',
|
|
45
|
-
'#00d237',
|
|
46
|
-
'#b5b5b5',
|
|
47
|
-
'#ff8080',
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @ignore
|
|
52
|
-
*/
|
|
53
|
-
export const textColors = [
|
|
54
|
-
'#000000',
|
|
55
|
-
'#ffffff',
|
|
56
|
-
'#000000',
|
|
57
|
-
'#ffffff',
|
|
58
|
-
'#ffffff',
|
|
59
|
-
'#000000',
|
|
60
|
-
'#ffffff',
|
|
61
|
-
'#000000',
|
|
62
|
-
'#000000',
|
|
63
|
-
'#000000',
|
|
64
|
-
];
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @ignore
|
|
68
|
-
*/
|
|
69
|
-
export const timeSteps = [
|
|
70
|
-
100000, 50000, 40000, 30000, 20000, 15000, 10000, 5000, 2000, 1000, 400, 300,
|
|
71
|
-
250, 180, 90, 60, 50, 50, 50, 50, 50,
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @ignore
|
|
76
|
-
*/
|
|
77
|
-
export const getTypeIndex = (type) => {
|
|
78
|
-
if (typeof type === 'string') {
|
|
79
|
-
return types.findIndex((t) => t.test(type));
|
|
80
|
-
}
|
|
81
|
-
return type;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @ignore
|
|
86
|
-
*/
|
|
87
|
-
export const getRadius = (type, zoom) => {
|
|
88
|
-
try {
|
|
89
|
-
const typeIdx = getTypeIndex(type || 0);
|
|
90
|
-
return trackerRadiusMapping[typeIdx][zoom];
|
|
91
|
-
} catch (e) {
|
|
92
|
-
return 1;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* @ignore
|
|
98
|
-
*/
|
|
99
|
-
export const getBgColor = (type = 0) => {
|
|
100
|
-
try {
|
|
101
|
-
const typeIdx = getTypeIndex(type);
|
|
102
|
-
return bgColors[typeIdx];
|
|
103
|
-
} catch (e) {
|
|
104
|
-
return 1;
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* @ignore
|
|
110
|
-
*/
|
|
111
|
-
export const getTextColor = (type = 0) => {
|
|
112
|
-
try {
|
|
113
|
-
const typeIdx = getTypeIndex(type);
|
|
114
|
-
return textColors[typeIdx];
|
|
115
|
-
} catch (e) {
|
|
116
|
-
return 1;
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* @ignore
|
|
122
|
-
*/
|
|
123
|
-
export const getTextSize = (ctx, markerSize, text, fontSize) => {
|
|
124
|
-
ctx.font = `bold ${fontSize}px Arial`;
|
|
125
|
-
let newText = ctx.measureText(text);
|
|
126
|
-
|
|
127
|
-
const maxiter = 25;
|
|
128
|
-
let i = 0;
|
|
129
|
-
|
|
130
|
-
while (newText.width > markerSize - 6 && i < maxiter) {
|
|
131
|
-
// eslint-disable-next-line no-param-reassign
|
|
132
|
-
fontSize -= 0.5;
|
|
133
|
-
ctx.font = `bold ${fontSize}px arial, sans-serif`;
|
|
134
|
-
newText = ctx.measureText(text);
|
|
135
|
-
i += 1;
|
|
136
|
-
}
|
|
137
|
-
return fontSize;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @ignore
|
|
142
|
-
* @param {number} delayInMs Delay in milliseconds.
|
|
143
|
-
* @param {boolean} cancelled true if the journey is cancelled.
|
|
144
|
-
* @param {boolean} isDelayText true if the color is used for delay text of the symbol.
|
|
145
|
-
*/
|
|
146
|
-
export const getDelayColor = (delayInMs, cancelled, isDelayText) => {
|
|
147
|
-
if (cancelled) {
|
|
148
|
-
return isDelayText ? '#ff0000' : '#a0a0a0'; // red or gray
|
|
149
|
-
}
|
|
150
|
-
if (delayInMs >= 3600000) {
|
|
151
|
-
return '#ed004c'; // pink { r: 237, g: 0, b: 76, s: '237,0,76' };
|
|
152
|
-
}
|
|
153
|
-
if (delayInMs >= 500000) {
|
|
154
|
-
return '#e80000'; // red { r: 232, g: 0, b: 0, s: '232,0,0' };
|
|
155
|
-
}
|
|
156
|
-
if (delayInMs >= 300000) {
|
|
157
|
-
return '#ff4a00'; // orange { r: 255, g: 74, b: 0, s: '255,74,0' };
|
|
158
|
-
}
|
|
159
|
-
if (delayInMs >= 180000) {
|
|
160
|
-
return '#f7bf00'; // yellow { r: 247, g: 191, b: 0, s: '247,191,0' };
|
|
161
|
-
}
|
|
162
|
-
if (delayInMs === null) {
|
|
163
|
-
return '#a0a0a0'; // grey { r: 160, g: 160, b: 160, s: '160,160,160' };
|
|
164
|
-
}
|
|
165
|
-
return '#00a00c'; // green { r: 0, g: 160, b: 12, s: '0,160,12' };
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* @ignore
|
|
170
|
-
*/
|
|
171
|
-
export const getDelayText = (delayInMs, cancelled) => {
|
|
172
|
-
if (cancelled) {
|
|
173
|
-
return String.fromCodePoint(0x00d7);
|
|
174
|
-
}
|
|
175
|
-
if (delayInMs > 3600000) {
|
|
176
|
-
const rounded = Math.round(delayInMs / 3600000);
|
|
177
|
-
return `+${rounded}h`;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (delayInMs > 59000) {
|
|
181
|
-
const rounded = Math.round(delayInMs / 60000);
|
|
182
|
-
return `+${rounded}m`;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (delayInMs > 0) {
|
|
186
|
-
return `+${delayInMs}s`;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return '';
|
|
190
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getTypeIndex } from './trackerConfig';
|
|
2
|
-
|
|
3
|
-
describe('trackerConfig', () => {
|
|
4
|
-
describe('#getTypeIndex()', () => {
|
|
5
|
-
test("retrurn the type is it's not a string", () => {
|
|
6
|
-
const obj = { foo: 'foo' };
|
|
7
|
-
expect(getTypeIndex(obj)).toBe(obj);
|
|
8
|
-
expect(getTypeIndex(0)).toBe(0);
|
|
9
|
-
expect(getTypeIndex(null)).toBe(null);
|
|
10
|
-
expect(getTypeIndex(undefined)).toBe(undefined);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('find good index for new tracker values', () => {
|
|
14
|
-
expect(getTypeIndex('tram')).toBe(0);
|
|
15
|
-
expect(getTypeIndex('subway')).toBe(1);
|
|
16
|
-
expect(getTypeIndex('bus')).toBe(3);
|
|
17
|
-
expect(getTypeIndex('ferry')).toBe(4);
|
|
18
|
-
expect(getTypeIndex('cablecar')).toBe(5);
|
|
19
|
-
expect(getTypeIndex('gondola')).toBe(6);
|
|
20
|
-
expect(getTypeIndex('funicular')).toBe(7);
|
|
21
|
-
expect(getTypeIndex('coach')).toBe(8);
|
|
22
|
-
expect(getTypeIndex('rail')).toBe(9);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Return a filter functions based on some parameters of a vehicle.
|
|
3
|
-
*
|
|
4
|
-
* @param {string|Array<string>} line - A list of vehicle's name to filter. Names can be separated by a comma. Ex: 'S1,S2,S3'
|
|
5
|
-
* @param {string|Array<string} route - A list of vehicle's route (contained in routeIdentifier property) to filter. Indentifiers can be separated by a comma. Ex: 'id1,id2,id3'
|
|
6
|
-
* @param {string|Array<string} operator A list of vehicle's operator to filter. Operators can be separated by a comma. Ex: 'SBB,DB'
|
|
7
|
-
* @param {Regexp} regexLine - A regex aplly of vehcile's name.
|
|
8
|
-
* @private
|
|
9
|
-
*/
|
|
10
|
-
const createFilters = (line, route, operator, regexLine) => {
|
|
11
|
-
const filterList = [];
|
|
12
|
-
|
|
13
|
-
if (!line && !route && !operator && !regexLine) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (regexLine) {
|
|
18
|
-
const regexLineList =
|
|
19
|
-
typeof regexLine === 'string' ? [regexLine] : regexLine;
|
|
20
|
-
const lineFilter = (item) => {
|
|
21
|
-
const name =
|
|
22
|
-
item.properties.name ||
|
|
23
|
-
(item.properties.line && item.properties.line.name) ||
|
|
24
|
-
'';
|
|
25
|
-
if (!name) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
return regexLineList.some((regexStr) =>
|
|
29
|
-
new RegExp(regexStr, 'i').test(name),
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
filterList.push(lineFilter);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (line) {
|
|
36
|
-
const lineFiltersList = typeof line === 'string' ? line.split(',') : line;
|
|
37
|
-
const lineList = lineFiltersList.map((l) =>
|
|
38
|
-
l.replace(/\s+/g, '').toUpperCase(),
|
|
39
|
-
);
|
|
40
|
-
const lineFilter = (item) => {
|
|
41
|
-
const { line: linee, name } = item.properties;
|
|
42
|
-
const lineName = (name || (linee && linee.name) || '').toUpperCase();
|
|
43
|
-
if (!lineName) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
return lineList.includes(lineName);
|
|
47
|
-
};
|
|
48
|
-
filterList.push(lineFilter);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (route) {
|
|
52
|
-
const routes = typeof route === 'string' ? route.split(',') : route;
|
|
53
|
-
const routeList = routes.map((item) => parseInt(item, 10));
|
|
54
|
-
const routeFilter = (item) => {
|
|
55
|
-
const routeId = parseInt(
|
|
56
|
-
item.properties.routeIdentifier.split('.')[0],
|
|
57
|
-
10,
|
|
58
|
-
);
|
|
59
|
-
return routeList.includes(routeId);
|
|
60
|
-
};
|
|
61
|
-
filterList.push(routeFilter);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (operator) {
|
|
65
|
-
const operatorList = typeof operator === 'string' ? [operator] : operator;
|
|
66
|
-
const operatorFilter = (item) =>
|
|
67
|
-
operatorList.some((op) =>
|
|
68
|
-
new RegExp(op, 'i').test(item.properties.operator),
|
|
69
|
-
);
|
|
70
|
-
filterList.push(operatorFilter);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (!filterList.length) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return (t) => {
|
|
78
|
-
for (let i = 0; i < filterList.length; i += 1) {
|
|
79
|
-
if (!filterList[i](t)) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export default createFilters;
|