mobility-toolbox-js 2.0.0-beta.52 → 2.0.0-beta.54
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/README.md +26 -3
- package/api/RealtimeAPI.d.ts +79 -84
- package/api/RealtimeAPI.d.ts.map +1 -1
- package/api/RealtimeAPI.js +102 -266
- package/common/api/WebSocketAPI.d.ts +13 -15
- package/common/api/WebSocketAPI.d.ts.map +1 -1
- package/common/controls/ControlCommon.d.ts +1 -1
- package/common/controls/ControlCommon.d.ts.map +1 -1
- package/common/layers/LayerCommon.d.ts +1 -0
- package/common/layers/LayerCommon.d.ts.map +1 -1
- package/common/layers/LayerCommon.js +3 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +5 -5
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -1
- package/common/mixins/RealtimeLayerMixin.js +6 -6
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -1
- package/common/mixins/UserInteractionsLayerMixin.js +7 -10
- package/common/styles/realtimeDefaultStyle.d.ts +2 -2
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -1
- package/common/styles/realtimeDelayStyle.d.ts +2 -2
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -1
- package/common/styles/realtimeSimpleStyle.d.ts +2 -1
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -1
- package/common/typedefs.js +3 -3
- package/common/utils/{createTrackerFilters.d.ts → createRealtimeFilters.d.ts} +3 -3
- package/common/utils/createRealtimeFilters.d.ts.map +1 -0
- package/common/utils/{createTrackerFilters.js → createRealtimeFilters.js} +2 -2
- 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/getMapboxRender.d.ts +3 -3
- package/common/utils/getMapboxRender.d.ts.map +1 -1
- package/common/utils/getMapboxRender.js +2 -1
- package/common/utils/getMaplibreRender.d.ts +3 -1
- package/common/utils/getMaplibreRender.d.ts.map +1 -1
- package/common/utils/getMaplibreRender.js +4 -4
- package/common/utils/getRealtimeModeSuffix.d.ts +4 -2
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -1
- package/common/utils/getUrlWithParams.d.ts +2 -2
- package/common/utils/getUrlWithParams.d.ts.map +1 -1
- package/common/utils/getVehiclePosition.d.ts +7 -5
- package/common/utils/getVehiclePosition.d.ts.map +1 -1
- package/common/utils/index.d.ts +5 -2
- package/common/utils/index.js +6 -3
- package/common/utils/realtimeConfig.d.ts +49 -0
- package/common/utils/realtimeConfig.d.ts.map +1 -0
- package/common/utils/{trackerConfig.js → realtimeConfig.js} +17 -17
- 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 +1 -1
- package/common/utils/sortByDelay.d.ts.map +1 -1
- package/common/utils/timeUtils.d.ts +23 -4
- package/common/utils/timeUtils.d.ts.map +1 -1
- package/common/utils/timeUtils.js +1 -1
- package/mapbox/layers/RealtimeLayer.d.ts +4 -4
- package/mbt.js +349 -410
- package/mbt.js.map +3 -3
- package/mbt.min.js +62 -62
- package/mbt.min.js.map +3 -3
- package/ol/controls/RoutingControl.d.ts +95 -91
- package/ol/controls/RoutingControl.d.ts.map +1 -1
- package/ol/controls/RoutingControl.js +100 -90
- package/ol/layers/Layer.d.ts +3 -2
- package/ol/layers/Layer.d.ts.map +1 -1
- package/ol/layers/Layer.js +2 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -1
- package/ol/layers/MapGlLayer.js +3 -5
- package/ol/layers/MapboxLayer.d.ts +1 -1
- package/ol/layers/MapboxLayer.d.ts.map +1 -1
- package/ol/layers/MapboxLayer.js +1 -0
- package/ol/layers/MapboxStyleLayer.js +4 -2
- package/ol/layers/MaplibreLayer.d.ts +2 -1
- package/ol/layers/MaplibreLayer.d.ts.map +1 -1
- package/ol/layers/RealtimeLayer.d.ts +8 -6
- package/ol/layers/RealtimeLayer.d.ts.map +1 -1
- package/ol/layers/RealtimeLayer.js +3 -3
- package/ol/layers/RoutingLayer.d.ts +15 -5
- package/ol/layers/RoutingLayer.d.ts.map +1 -1
- package/ol/layers/RoutingLayer.js +3 -2
- package/ol/styles/fullTrajectoryStyle.d.ts +2 -2
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -1
- package/package.json +1 -1
- package/types/common.d.ts +6 -1
- package/types/realtime.d.ts +0 -2
- package/common/utils/cleanStopTime.d.ts +0 -8
- package/common/utils/cleanStopTime.d.ts.map +0 -1
- package/common/utils/cleanStopTime.js +0 -25
- package/common/utils/createTrackerFilters.d.ts.map +0 -1
- package/common/utils/trackerConfig.d.ts +0 -24
- package/common/utils/trackerConfig.d.ts.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
13
|
/**
|
|
14
14
|
* Trajserv value: 'Tram', 'Subway / Metro / S-Bahn', 'Train', 'Bus', 'Ferry', 'Cable Car', 'Gondola', 'Funicular', 'Long distance bus', 'Rail',
|
|
15
15
|
* New endpoint use Rail instead of Train.
|
|
@@ -74,7 +74,7 @@ export const getTypeIndex = (type) => {
|
|
|
74
74
|
export const getRadius = (type, zoom) => {
|
|
75
75
|
try {
|
|
76
76
|
const typeIdx = getTypeIndex(type || 0);
|
|
77
|
-
return
|
|
77
|
+
return radiusMapping[typeIdx][zoom];
|
|
78
78
|
}
|
|
79
79
|
catch (e) {
|
|
80
80
|
return 1;
|
|
@@ -83,25 +83,25 @@ export const getRadius = (type, zoom) => {
|
|
|
83
83
|
/**
|
|
84
84
|
* @ignore
|
|
85
85
|
*/
|
|
86
|
-
export const getBgColor = (type
|
|
86
|
+
export const getBgColor = (type) => {
|
|
87
87
|
try {
|
|
88
88
|
const typeIdx = getTypeIndex(type);
|
|
89
89
|
return bgColors[typeIdx];
|
|
90
90
|
}
|
|
91
91
|
catch (e) {
|
|
92
|
-
return
|
|
92
|
+
return '#ffffff';
|
|
93
93
|
}
|
|
94
94
|
};
|
|
95
95
|
/**
|
|
96
96
|
* @ignore
|
|
97
97
|
*/
|
|
98
|
-
export const getTextColor = (type
|
|
98
|
+
export const getTextColor = (type) => {
|
|
99
99
|
try {
|
|
100
100
|
const typeIdx = getTypeIndex(type);
|
|
101
101
|
return textColors[typeIdx];
|
|
102
102
|
}
|
|
103
103
|
catch (e) {
|
|
104
|
-
return
|
|
104
|
+
return '#ffffff';
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
/**
|
|
@@ -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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortByDelay.d.ts","sourceRoot":"","sources":["../../../src/common/utils/sortByDelay.
|
|
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,5 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
5
24
|
//# sourceMappingURL=timeUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeUtils.d.ts","sourceRoot":"","sources":["../../../src/common/utils/timeUtils.
|
|
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"}
|
|
@@ -24,7 +24,7 @@ export const getUTCTimeString = (date) => [
|
|
|
24
24
|
* Returns a string representation of a number, with a zero if the number is lower than 10.
|
|
25
25
|
* @ignore
|
|
26
26
|
*/
|
|
27
|
-
export const pad = (integer) =>
|
|
27
|
+
export const pad = (integer) => integer < 10 ? `0${integer}` : `${integer}`;
|
|
28
28
|
/**
|
|
29
29
|
* Returns a 'hh:mm' string from a time in ms.
|
|
30
30
|
* @param {Number} timeInMs Time in milliseconds.
|
|
@@ -64,16 +64,16 @@ declare const RealtimeLayer_base: {
|
|
|
64
64
|
coordinate: Coordinate;
|
|
65
65
|
}>;
|
|
66
66
|
getTrajectoryInfos(id: string): Promise<{
|
|
67
|
-
stopSequence:
|
|
68
|
-
fullTrajectory:
|
|
67
|
+
stopSequence: import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory> | import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData<GeoJSONFeature[]>;
|
|
68
|
+
fullTrajectory: import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory> | import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData<GeoJSONFeature[]>;
|
|
69
69
|
}>;
|
|
70
70
|
purgeTrajectory(trajectory: GeoJSONFeature, extent: [number, number, number, number], zoom: number): boolean;
|
|
71
71
|
addTrajectory(trajectory: GeoJSONFeature): void;
|
|
72
72
|
removeTrajectory(trajectoryOrId: any): void;
|
|
73
73
|
onZoomEnd(): void;
|
|
74
74
|
onDocumentVisibilityChange(): void;
|
|
75
|
-
onTrajectoryMessage(data: import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData): void;
|
|
76
|
-
onDeleteTrajectoryMessage(data: import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData): void;
|
|
75
|
+
onTrajectoryMessage(data: import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData<GeoJSONFeature>): void;
|
|
76
|
+
onDeleteTrajectoryMessage(data: import("../../common/api/WebSocketAPI").WebSocketAPIMessageEventData<string>): void;
|
|
77
77
|
onFeatureHover(features: Feature<import("ol/geom/Geometry").default>[], layer: import("../../types").AnyRealtimeLayer, coordinate: Coordinate): void;
|
|
78
78
|
onFeatureClick(features: Feature<import("ol/geom/Geometry").default>[], layer: import("../../types").AnyRealtimeLayer, coordinate: Coordinate): void;
|
|
79
79
|
};
|