mobility-toolbox-js 3.0.0-beta.19 → 3.0.0-beta.20
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/HttpAPI.d.ts +5 -5
- package/api/RealtimeAPI.d.ts +204 -171
- package/api/RealtimeAPI.js +306 -258
- package/api/RoutingAPI.d.ts +4 -4
- package/api/StopsAPI.d.ts +4 -4
- package/api/WebSocketAPI.d.ts +60 -66
- package/api/WebSocketAPI.js +164 -164
- package/api/index.js +1 -1
- package/common/controls/StopFinderControlCommon.d.ts +11 -11
- package/common/controls/StopFinderControlCommon.js +30 -30
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +149 -155
- package/common/mixins/RealtimeLayerMixin.js +395 -395
- package/common/styles/realtimeDefaultStyle.js +6 -6
- package/common/styles/realtimeHeadingStyle.js +5 -5
- package/common/utils/getMapGlCopyrights.d.ts +1 -1
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getVehiclePosition.d.ts +2 -2
- package/common/utils/getVehiclePosition.js +7 -7
- package/common/utils/renderTrajectories.js +5 -5
- package/common/utils/sortByDelay.js +5 -5
- package/maplibre/layers/RealtimeLayer.d.ts +59 -64
- package/maplibre/layers/RealtimeLayer.js +8 -8
- package/maplibre/utils/getSourceCoordinates.js +5 -5
- package/mbt.js +7205 -7031
- package/mbt.js.map +4 -4
- package/mbt.min.js +25 -25
- package/mbt.min.js.map +4 -4
- package/ol/controls/RoutingControl.d.ts +81 -87
- package/ol/controls/RoutingControl.js +216 -218
- package/ol/layers/Layer.d.ts +9 -9
- package/ol/layers/MaplibreLayer.d.ts +10 -10
- package/ol/layers/MaplibreLayer.js +9 -3
- package/ol/layers/MaplibreStyleLayer.d.ts +77 -76
- package/ol/layers/MaplibreStyleLayer.js +237 -238
- package/ol/layers/RealtimeLayer.d.ts +92 -96
- package/ol/layers/RealtimeLayer.js +139 -131
- package/ol/mixins/MobilityLayerMixin.d.ts +9 -9
- package/ol/mixins/PropertiesLayerMixin.d.ts +33 -36
- package/ol/mixins/PropertiesLayerMixin.js +73 -72
- package/ol/renderers/MaplibreLayerRenderer.js +3 -3
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
- package/ol/renderers/MaplibreStyleLayerRenderer.js +14 -17
- package/ol/renderers/RealtimeLayerRenderer.d.ts +6 -6
- package/ol/renderers/RealtimeLayerRenderer.js +54 -52
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
- package/ol/utils/getFeatureInfoAtCoordinate.js +10 -16
- package/package.json +6 -5
- package/setupTests.js +3 -4
- package/types/common.d.ts +53 -49
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +91 -93
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
|
@@ -141,11 +141,11 @@ const cache = {};
|
|
|
141
141
|
* @private
|
|
142
142
|
*/
|
|
143
143
|
const realtimeDefaultStyle = (trajectory, viewState, options) => {
|
|
144
|
-
const {
|
|
145
|
-
const {
|
|
144
|
+
const { delayDisplay = 300000, delayOutlineColor = '#000', getBgColor = () => '#000', getDelayColor = () => '#000', getDelayFont = (fontSize) => `bold ${fontSize}px arial, sans-serif`, getDelayText = () => null, getMaxRadiusForStrokeAndDelay = () => 7, getMaxRadiusForText = () => 10, getRadius = () => 0, getText = (text) => text, getTextColor = () => '#000', getTextFont = (fontSize) => `bold ${fontSize}px arial, sans-serif`, getTextSize = () => 14, hoverVehicleId, selectedVehicleId, useDelayStyle, } = options;
|
|
145
|
+
const { pixelRatio = 1, zoom } = viewState;
|
|
146
146
|
let { type } = trajectory.properties;
|
|
147
|
-
const {
|
|
148
|
-
let { name, text_color: textColor
|
|
147
|
+
const { delay, line, operator_provides_realtime_journey: operatorProvidesRealtime, state, train_id: id, } = trajectory.properties;
|
|
148
|
+
let { color, name, text_color: textColor } = line || {};
|
|
149
149
|
name = getText(name);
|
|
150
150
|
const cancelled = state === 'JOURNEY_CANCELLED';
|
|
151
151
|
if (!type) {
|
|
@@ -157,10 +157,10 @@ const realtimeDefaultStyle = (trajectory, viewState, options) => {
|
|
|
157
157
|
if (!textColor) {
|
|
158
158
|
textColor = '#000000';
|
|
159
159
|
}
|
|
160
|
-
if (color && color
|
|
160
|
+
if (color && !color.startsWith('#')) {
|
|
161
161
|
color = `#${color}`;
|
|
162
162
|
}
|
|
163
|
-
if (textColor
|
|
163
|
+
if (!textColor.startsWith('#')) {
|
|
164
164
|
textColor = `#${textColor}`;
|
|
165
165
|
}
|
|
166
166
|
const z = Math.min(Math.floor(zoom || 1), 16);
|
|
@@ -67,9 +67,8 @@ const getBufferArrowCanvas = (canvas, fillColor, rotation) => {
|
|
|
67
67
|
* @private
|
|
68
68
|
*/
|
|
69
69
|
const realtimeHeadingStyle = (trajectory, viewState, options) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const { rotation, type, line } = trajectory.properties;
|
|
70
|
+
// @ts-expect-error improve types
|
|
71
|
+
const { line, rotation, type } = trajectory.properties;
|
|
73
72
|
const { color } = line || {};
|
|
74
73
|
const canvas = realtimeDefaultStyle(trajectory, viewState, options);
|
|
75
74
|
if (canvas && rotation !== null) {
|
|
@@ -78,8 +77,9 @@ const realtimeHeadingStyle = (trajectory, viewState, options) => {
|
|
|
78
77
|
if (bufferArrow) {
|
|
79
78
|
const bufferSize = (bufferArrow.width - canvas.width) / 2;
|
|
80
79
|
const vehicleWithArrow = createCanvas(bufferArrow.width, bufferArrow.height);
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
const context = vehicleWithArrow === null || vehicleWithArrow === void 0 ? void 0 : vehicleWithArrow.getContext('2d');
|
|
81
|
+
context === null || context === void 0 ? void 0 : context.drawImage(bufferArrow, 0, 0, bufferArrow.width, bufferArrow.height);
|
|
82
|
+
context === null || context === void 0 ? void 0 : context.drawImage(canvas, bufferSize, bufferSize, canvas.width, canvas.height);
|
|
83
83
|
return vehicleWithArrow;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -8,7 +8,6 @@ const getMapGlCopyrights = (map) => {
|
|
|
8
8
|
if (!map) {
|
|
9
9
|
return [];
|
|
10
10
|
}
|
|
11
|
-
// @ts-ignore
|
|
12
11
|
const { style } = map;
|
|
13
12
|
if (!style) {
|
|
14
13
|
return [];
|
|
@@ -16,10 +15,11 @@ const getMapGlCopyrights = (map) => {
|
|
|
16
15
|
const { sourceCaches } = style;
|
|
17
16
|
let copyrights = [];
|
|
18
17
|
Object.values(sourceCaches).forEach((value) => {
|
|
18
|
+
var _a;
|
|
19
19
|
if (value.used) {
|
|
20
20
|
const source = value.getSource();
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// @ts-expect-error improve types
|
|
22
|
+
const attribution = source.attribution || ((_a = source.options) === null || _a === void 0 ? void 0 : _a.attribution);
|
|
23
23
|
if (attribution) {
|
|
24
24
|
copyrights = copyrights.concat(attribution.replace(/©/g, '©').split(/(<a.*?<\/a>)/));
|
|
25
25
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Coordinate } from 'ol/coordinate';
|
|
2
2
|
import { RealtimeTrajectory } from '../../types';
|
|
3
|
-
export
|
|
3
|
+
export interface VehiclePosition {
|
|
4
4
|
coord: Coordinate;
|
|
5
5
|
rotation?: number;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
7
|
/**
|
|
8
8
|
* Interpolate or not the vehicle position from a trajectory at a specific date.
|
|
9
9
|
*
|
|
@@ -9,13 +9,13 @@ import { LineString } from 'ol/geom';
|
|
|
9
9
|
* @private
|
|
10
10
|
*/
|
|
11
11
|
const getVehiclePosition = (now, trajectory, noInterpolate) => {
|
|
12
|
-
const {
|
|
13
|
-
// @ts-expect-error
|
|
14
|
-
|
|
15
|
-
// @ts-expect-error
|
|
16
|
-
|
|
17
|
-
// @ts-
|
|
18
|
-
let {
|
|
12
|
+
const {
|
|
13
|
+
// @ts-expect-error coordinate is added by the RealtimeLayer
|
|
14
|
+
coordinate,
|
|
15
|
+
// @ts-expect-error olGeometry is added by the RealtimeLayer
|
|
16
|
+
olGeometry, time_intervals: timeIntervals, } = trajectory.properties;
|
|
17
|
+
// @ts-expect-error
|
|
18
|
+
let { coordinates, type } = trajectory.geometry;
|
|
19
19
|
let geometry = olGeometry;
|
|
20
20
|
let coord;
|
|
21
21
|
let rotation;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { apply, compose, create } from 'ol/transform';
|
|
2
2
|
import getVehiclePosition from './getVehiclePosition';
|
|
3
3
|
/**
|
|
4
4
|
* Draw all the trajectories available in a canvas.
|
|
@@ -17,13 +17,13 @@ const renderTrajectories = (canvas, trajectories, style, viewState, options) =>
|
|
|
17
17
|
if (!canvas) {
|
|
18
18
|
return { renderedTrajectories: [] };
|
|
19
19
|
}
|
|
20
|
-
const {
|
|
20
|
+
const { center, pixelRatio = 1, resolution, rotation = 0, size = [], time = Date.now(), } = viewState;
|
|
21
21
|
if (!resolution || !center) {
|
|
22
22
|
return { renderedTrajectories: [] };
|
|
23
23
|
}
|
|
24
|
-
const {
|
|
24
|
+
const { filter, getScreenPixel = (pixel, viewStat) => (viewStat.zoom || 0) < 12
|
|
25
25
|
? pixel.map((coord) => Math.floor(coord))
|
|
26
|
-
: pixel, } = options;
|
|
26
|
+
: pixel, hoverVehicleId, noInterpolate = false, selectedVehicleId, } = options;
|
|
27
27
|
const context = canvas.getContext('2d');
|
|
28
28
|
context === null || context === void 0 ? void 0 : context.clearRect(0, 0, canvas.width, canvas.height);
|
|
29
29
|
const [width, height] = size;
|
|
@@ -49,7 +49,7 @@ const renderTrajectories = (canvas, trajectories, style, viewState, options) =>
|
|
|
49
49
|
continue;
|
|
50
50
|
}
|
|
51
51
|
// We simplify the trajectory object
|
|
52
|
-
const { train_id: id
|
|
52
|
+
const { timeOffset, train_id: id } = trajectory.properties;
|
|
53
53
|
// We set the rotation and the timeFraction of the trajectory (used by tralis).
|
|
54
54
|
// if rotation === null that seems there is no rotation available.
|
|
55
55
|
const { coord, rotation: rotationIcon } = getVehiclePosition(time - (timeOffset || 0), trajectory, noInterpolate);
|
|
@@ -9,17 +9,17 @@ const sortByDelay = (traj1, traj2) => {
|
|
|
9
9
|
}
|
|
10
10
|
// We put cancelled train inbetween green and yellow trains
|
|
11
11
|
// >=180000ms corresponds to yellow train
|
|
12
|
-
// @ts-
|
|
12
|
+
// @ts-expect-error
|
|
13
13
|
if (props1.cancelled && !props2.cancelled) {
|
|
14
|
-
// @ts-
|
|
14
|
+
// @ts-expect-error
|
|
15
15
|
return props2.delay < 180000 ? -1 : 1;
|
|
16
16
|
}
|
|
17
|
-
// @ts-
|
|
17
|
+
// @ts-expect-error
|
|
18
18
|
if (props2.cancelled && !props1.cancelled) {
|
|
19
|
-
// @ts-
|
|
19
|
+
// @ts-expect-error
|
|
20
20
|
return props1.delay < 180000 ? 1 : -1;
|
|
21
21
|
}
|
|
22
|
-
// @ts-
|
|
22
|
+
// @ts-expect-error
|
|
23
23
|
return props2.delay - props1.delay;
|
|
24
24
|
};
|
|
25
25
|
export default sortByDelay;
|
|
@@ -2,84 +2,79 @@ import { RealtimeLayerMixinOptions } from '../../common/mixins/RealtimeLayerMixi
|
|
|
2
2
|
import Layer, { LayerOptions } from './Layer';
|
|
3
3
|
import type { AnyMapGlMap, ViewState } from '../../types';
|
|
4
4
|
import type { RealtimeTrajectory } from '../../api/typedefs';
|
|
5
|
-
import { FilterFunction, SortFunction } from '../../common/typedefs';
|
|
6
5
|
export type RealtimeLayerOptions = LayerOptions & RealtimeLayerMixinOptions;
|
|
7
6
|
declare const RealtimeLayer_base: {
|
|
8
7
|
new (options: RealtimeLayerMixinOptions): {
|
|
9
8
|
[x: string]: any;
|
|
10
9
|
[x: symbol]: any;
|
|
11
|
-
debug: boolean;
|
|
12
|
-
trajectories?: {
|
|
13
|
-
[key: string]: import("../../types").RealtimeTrajectory;
|
|
14
|
-
} | undefined;
|
|
15
|
-
canvas?: import("../../types").AnyCanvas;
|
|
16
|
-
mode: import("../../types").RealtimeMode;
|
|
17
10
|
api: import("..").RealtimeAPI;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
bboxParameters?: Record<string, boolean | boolean[] | number | number[] | string | string[]>;
|
|
12
|
+
canvas?: import("../../types").AnyCanvas;
|
|
13
|
+
debounceRenderTrajectories: (viewState: ViewState, noInterpolate?: boolean) => void;
|
|
14
|
+
debug: boolean;
|
|
15
|
+
filter?: import("../../common/typedefs").FilterFunction;
|
|
16
|
+
format: import("ol/format").GeoJSON;
|
|
17
|
+
generalizationLevel?: import("../../types").RealtimeGeneralizationLevel;
|
|
18
|
+
generalizationLevelByZoom: import("../../types").RealtimeGeneralizationLevel[];
|
|
19
|
+
getGeneralizationLevelByZoom: (zoom: number) => import("../../types").RealtimeGeneralizationLevel;
|
|
20
|
+
getMotsByZoom: (zoom: number) => import("../../types").RealtimeMot[];
|
|
21
|
+
getRenderTimeIntervalByZoom: (zoom: number) => number;
|
|
22
|
+
hoverVehicleId?: import("../../types").RealtimeTrainId;
|
|
23
|
+
isUpdateBboxOnMoveEnd: boolean;
|
|
23
24
|
live?: boolean;
|
|
24
|
-
speed?: number;
|
|
25
|
-
filter?: FilterFunction;
|
|
26
|
-
sort?: SortFunction;
|
|
27
|
-
style?: import("../../types").RealtimeStyleFunction;
|
|
28
|
-
styleOptions?: import("../../types").RealtimeStyleOptions;
|
|
29
|
-
pixelRatio?: number;
|
|
30
25
|
minZoomInterpolation: number;
|
|
31
|
-
|
|
32
|
-
hoverVehicleId?: import("../../types").RealtimeTrainId;
|
|
33
|
-
selectedVehicleId?: import("../../types").RealtimeTrainId;
|
|
34
|
-
renderState?: import("../../types").RealtimeRenderState;
|
|
35
|
-
useRequestAnimationFrame?: boolean;
|
|
36
|
-
useDebounce?: boolean;
|
|
37
|
-
useThrottle?: boolean;
|
|
26
|
+
mode: import("../../types").RealtimeMode;
|
|
38
27
|
mots?: import("../../types").RealtimeMot[];
|
|
39
28
|
motsByZoom: import("../../types").RealtimeMot[][];
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
onStart?: ((realtimeLayer: import("../../types").AnyLayer) => void) | undefined;
|
|
30
|
+
onStop?: ((realtimeLayer: import("../../types").AnyLayer) => void) | undefined;
|
|
31
|
+
pixelRatio?: number;
|
|
32
|
+
renderState?: import("../../types").RealtimeRenderState;
|
|
42
33
|
renderTimeIntervalByZoom: number[];
|
|
43
|
-
format: import("ol/format").GeoJSON;
|
|
44
34
|
requestId?: number;
|
|
45
|
-
updateTimeInterval?: number;
|
|
46
|
-
updateTimeDelay?: number;
|
|
47
|
-
visibilityRef: import("ol/events").EventsKey;
|
|
48
35
|
selectedVehicle: import("../../types").RealtimeTrajectory;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
selectedVehicleId?: import("../../types").RealtimeTrainId;
|
|
37
|
+
sort?: import("../../common/typedefs").SortFunction;
|
|
38
|
+
speed?: number;
|
|
39
|
+
style?: import("../../types").RealtimeStyleFunction;
|
|
40
|
+
styleOptions?: import("../../types").RealtimeStyleOptions;
|
|
41
|
+
tenant: import("../../types").RealtimeTenant;
|
|
52
42
|
throttleRenderTrajectories: (viewState: ViewState, noInterpolate?: boolean) => void;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
time?: Date;
|
|
44
|
+
trajectories?: Record<import("../../types").RealtimeTrainId, import("../../types").RealtimeTrajectory>;
|
|
45
|
+
updateTimeDelay?: number;
|
|
46
|
+
updateTimeInterval?: number;
|
|
47
|
+
useDebounce?: boolean;
|
|
48
|
+
useRequestAnimationFrame?: boolean;
|
|
49
|
+
useThrottle?: boolean;
|
|
50
|
+
visibilityRef: import("ol/events").EventsKey;
|
|
51
|
+
addTrajectory(trajectory: import("../../types").RealtimeTrajectory): void;
|
|
57
52
|
attachToMap(map: import("../../types").AnyMap): void;
|
|
53
|
+
defineProperties(options: RealtimeLayerMixinOptions): void;
|
|
58
54
|
detachFromMap(): void;
|
|
59
|
-
start(): void;
|
|
60
|
-
startUpdateTime(): void;
|
|
61
|
-
stop(): void;
|
|
62
|
-
stopUpdateTime(): void;
|
|
63
|
-
renderTrajectoriesInternal(viewState: ViewState, noInterpolate?: boolean): boolean;
|
|
64
|
-
renderTrajectories(viewState: ViewState | undefined, noInterpolate: boolean | undefined): void;
|
|
65
|
-
setBbox(extent: [number, number, number, number], zoom: number): void;
|
|
66
|
-
getRefreshTimeInMs(zoom?: number | undefined): number;
|
|
67
|
-
getVehicle(filterFc: FilterFunction): import("../../types").RealtimeTrajectory[];
|
|
68
55
|
getFeatureInfoAtCoordinate(coordinate: import("ol/coordinate").Coordinate, options: import("../../types").LayerGetFeatureInfoOptions): Promise<import("../../types").LayerGetFeatureInfoResponse>;
|
|
56
|
+
getRefreshTimeInMs(zoom?: number | undefined): number;
|
|
69
57
|
getTrajectoryInfos(id: import("../../types").RealtimeTrainId): Promise<{
|
|
70
|
-
|
|
71
|
-
|
|
58
|
+
fullTrajectory: import("../../api/WebSocketAPI").WebSocketAPIMessageEventData<import("../../types").RealtimeStopSequence[]> | import("../../api/WebSocketAPI").WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory>;
|
|
59
|
+
stopSequence: import("../../api/WebSocketAPI").WebSocketAPIMessageEventData<import("../../types").RealtimeStopSequence[]> | import("../../api/WebSocketAPI").WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory>;
|
|
72
60
|
}>;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
removeTrajectory(trajectoryOrId: import("../../types").RealtimeTrajectory | import("../../types").RealtimeTrainId): void;
|
|
77
|
-
onZoomEnd(): void;
|
|
61
|
+
getVehicle(filterFc: import("../../common/typedefs").FilterFunction): import("../../types").RealtimeTrajectory[];
|
|
62
|
+
highlightVehicle(id: import("../../types").RealtimeTrainId): void;
|
|
63
|
+
onDeleteTrajectoryMessage(data: import("../../api/WebSocketAPI").WebSocketAPIMessageEventData<import("../../types").RealtimeTrainId>): void;
|
|
78
64
|
onDocumentVisibilityChange(): void;
|
|
79
65
|
onTrajectoryMessage(data: import("../../api/WebSocketAPI").WebSocketAPIMessageEventData<import("../../types").RealtimeTrajectory>): void;
|
|
80
|
-
|
|
81
|
-
|
|
66
|
+
onZoomEnd(): void;
|
|
67
|
+
purgeOutOfDateTrajectories(): void;
|
|
68
|
+
purgeTrajectory(trajectory: import("../../types").RealtimeTrajectory, extent: [number, number, number, number], zoom: number): boolean;
|
|
69
|
+
removeTrajectory(trajectoryOrId: import("../../types").RealtimeTrainId | import("../../types").RealtimeTrajectory): void;
|
|
70
|
+
renderTrajectories(viewState: undefined | ViewState, noInterpolate: boolean | undefined): void;
|
|
71
|
+
renderTrajectoriesInternal(viewState: ViewState, noInterpolate?: boolean): boolean;
|
|
82
72
|
selectVehicle(id: import("../../types").RealtimeTrainId): void;
|
|
73
|
+
setBbox(extent: [number, number, number, number], zoom: number): void;
|
|
74
|
+
start(): void;
|
|
75
|
+
startUpdateTime(): void;
|
|
76
|
+
stop(): void;
|
|
77
|
+
stopUpdateTime(): void;
|
|
83
78
|
};
|
|
84
79
|
} & typeof Layer;
|
|
85
80
|
/**
|
|
@@ -109,13 +104,13 @@ declare const RealtimeLayer_base: {
|
|
|
109
104
|
*
|
|
110
105
|
* @implements {maplibregl.CustomLayerInterface}
|
|
111
106
|
* @extends {maplibregl.Evented}
|
|
112
|
-
* @classproperty {function} filter
|
|
113
|
-
* @classproperty {RealtimeMode} mode
|
|
114
|
-
* @classproperty {RealtimeMot[]} mots
|
|
115
|
-
* @classproperty {RealtimeTenant} tenant
|
|
116
|
-
* @classproperty {function} sort
|
|
117
|
-
* @classproperty {function} style
|
|
118
|
-
|
|
107
|
+
* @classproperty {function} filter - Filter out a train. This function must be fast, it is executed for every trajectory on every render frame.
|
|
108
|
+
* @classproperty {RealtimeMode} mode - The realtime mode to use.
|
|
109
|
+
* @classproperty {RealtimeMot[]} mots - Filter trains by its mode of transportation. It filters trains on backend side.
|
|
110
|
+
* @classproperty {RealtimeTenant} tenant - Filter trains by its tenant. It filters trains on backend side.
|
|
111
|
+
* @classproperty {function} sort - Sort trains. This function must be fast, it is executed on every render frame.
|
|
112
|
+
* @classproperty {function} style - Function to style the vehicles.
|
|
113
|
+
s
|
|
119
114
|
* @public
|
|
120
115
|
*/
|
|
121
116
|
declare class RealtimeLayer extends RealtimeLayer_base {
|
|
@@ -129,7 +124,7 @@ declare class RealtimeLayer extends RealtimeLayer_base {
|
|
|
129
124
|
* @param {number} [options.minZoomInterpolation=8] Minimal zoom level where to start to interpolate train positions.
|
|
130
125
|
* @param {RealtimeMode} [options.mode='topographic'] The realtime mode to use.
|
|
131
126
|
* @param {SortFunction} options.sort Sort trains. This function must be fast, it is executed on every render frame.
|
|
132
|
-
* @param {RealtimeStyleFunction} options.style Function to style the
|
|
127
|
+
* @param {RealtimeStyleFunction} options.style Function to style the vehicles.
|
|
133
128
|
* @param {RealtimeTenant} options.tenant Filter trains by its tenant. It filters trains on backend side.
|
|
134
129
|
* @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The geOps Realtime API url.
|
|
135
130
|
*/
|
|
@@ -34,13 +34,13 @@ import toMercatorExtent from '../../common/utils/toMercatorExtent';
|
|
|
34
34
|
*
|
|
35
35
|
* @implements {maplibregl.CustomLayerInterface}
|
|
36
36
|
* @extends {maplibregl.Evented}
|
|
37
|
-
* @classproperty {function} filter
|
|
38
|
-
* @classproperty {RealtimeMode} mode
|
|
39
|
-
* @classproperty {RealtimeMot[]} mots
|
|
40
|
-
* @classproperty {RealtimeTenant} tenant
|
|
41
|
-
* @classproperty {function} sort
|
|
42
|
-
* @classproperty {function} style
|
|
43
|
-
|
|
37
|
+
* @classproperty {function} filter - Filter out a train. This function must be fast, it is executed for every trajectory on every render frame.
|
|
38
|
+
* @classproperty {RealtimeMode} mode - The realtime mode to use.
|
|
39
|
+
* @classproperty {RealtimeMot[]} mots - Filter trains by its mode of transportation. It filters trains on backend side.
|
|
40
|
+
* @classproperty {RealtimeTenant} tenant - Filter trains by its tenant. It filters trains on backend side.
|
|
41
|
+
* @classproperty {function} sort - Sort trains. This function must be fast, it is executed on every render frame.
|
|
42
|
+
* @classproperty {function} style - Function to style the vehicles.
|
|
43
|
+
s
|
|
44
44
|
* @public
|
|
45
45
|
*/
|
|
46
46
|
class RealtimeLayer extends RealtimeLayerMixin(Layer) {
|
|
@@ -54,7 +54,7 @@ class RealtimeLayer extends RealtimeLayerMixin(Layer) {
|
|
|
54
54
|
* @param {number} [options.minZoomInterpolation=8] Minimal zoom level where to start to interpolate train positions.
|
|
55
55
|
* @param {RealtimeMode} [options.mode='topographic'] The realtime mode to use.
|
|
56
56
|
* @param {SortFunction} options.sort Sort trains. This function must be fast, it is executed on every render frame.
|
|
57
|
-
* @param {RealtimeStyleFunction} options.style Function to style the
|
|
57
|
+
* @param {RealtimeStyleFunction} options.style Function to style the vehicles.
|
|
58
58
|
* @param {RealtimeTenant} options.tenant Filter trains by its tenant. It filters trains on backend side.
|
|
59
59
|
* @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The geOps Realtime API url.
|
|
60
60
|
*/
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export const getSourceCoordinates = (map, pixelRatio = 1) => {
|
|
6
6
|
// Requesting getBounds is not enough when we rotate the map, so we request manually each corner.
|
|
7
|
-
const {
|
|
8
|
-
// @ts-
|
|
7
|
+
const { height, width } = map.getCanvas();
|
|
8
|
+
// @ts-expect-error
|
|
9
9
|
const leftTop = map.unproject({ x: 0, y: 0 });
|
|
10
|
-
// @ts-
|
|
10
|
+
// @ts-expect-error
|
|
11
11
|
const leftBottom = map.unproject({ x: 0, y: height / pixelRatio }); // southWest
|
|
12
|
-
// @ts-
|
|
12
|
+
// @ts-expect-error
|
|
13
13
|
const rightBottom = map.unproject({
|
|
14
14
|
x: width / pixelRatio,
|
|
15
15
|
y: height / pixelRatio,
|
|
16
16
|
});
|
|
17
|
-
// @ts-
|
|
17
|
+
// @ts-expect-error
|
|
18
18
|
const rightTop = map.unproject({ x: width / pixelRatio, y: 0 }); // north east
|
|
19
19
|
return [
|
|
20
20
|
[leftTop.lng, leftTop.lat],
|