mobility-toolbox-js 3.0.0-beta.9 → 3.0.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/README.md +11 -3
- package/api/HttpAPI.d.ts +5 -16
- package/api/HttpAPI.js +1 -14
- package/api/RealtimeAPI.d.ts +188 -143
- package/api/RealtimeAPI.js +265 -206
- package/api/RoutingAPI.d.ts +21 -11
- package/api/RoutingAPI.js +17 -7
- package/api/StopsAPI.d.ts +20 -14
- package/api/StopsAPI.js +17 -11
- package/api/WebSocketAPI.d.ts +60 -66
- package/api/WebSocketAPI.js +164 -165
- package/api/index.js +1 -1
- package/api/typedefs.d.ts +0 -102
- package/api/typedefs.js +27 -42
- package/common/controls/StopFinderControlCommon.d.ts +13 -13
- package/common/controls/StopFinderControlCommon.js +32 -32
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/common/styles/realtimeDefaultStyle.js +6 -11
- package/common/styles/realtimeHeadingStyle.js +5 -10
- package/common/styles/realtimeSimpleStyle.d.ts +0 -1
- package/common/styles/realtimeSimpleStyle.js +0 -1
- package/common/typedefs.d.ts +11 -121
- package/common/typedefs.js +6 -31
- package/common/utils/RealtimeEngine.d.ts +214 -0
- package/common/utils/RealtimeEngine.js +554 -0
- package/common/utils/compareDepartures.d.ts +2 -2
- package/common/utils/compareDepartures.js +2 -2
- package/common/utils/debounceWebsocketMessages.d.ts +1 -1
- package/common/utils/getLayersAsFlatArray.d.ts +0 -1
- package/common/utils/getLayersAsFlatArray.js +0 -1
- package/common/utils/getMapGlCopyrights.d.ts +1 -1
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getRealtimeModeSuffix.d.ts +1 -0
- package/common/utils/getRealtimeModeSuffix.js +1 -0
- package/common/utils/getVehiclePosition.d.ts +5 -4
- package/common/utils/getVehiclePosition.js +6 -3
- package/common/utils/realtimeConfig.d.ts +1 -1
- package/common/utils/realtimeConfig.js +0 -1
- package/common/utils/renderTrajectories.d.ts +2 -1
- package/common/utils/renderTrajectories.js +7 -6
- package/common/utils/sortAndFilterDepartures.d.ts +2 -1
- package/common/utils/sortAndFilterDepartures.js +2 -1
- package/common/utils/sortByDelay.d.ts +2 -2
- package/common/utils/sortByDelay.js +5 -1
- package/maplibre/controls/CopyrightControl.d.ts +9 -6
- package/maplibre/controls/CopyrightControl.js +11 -8
- package/maplibre/layers/Layer.d.ts +8 -7
- package/maplibre/layers/Layer.js +2 -3
- package/maplibre/layers/RealtimeLayer.d.ts +82 -118
- package/maplibre/layers/RealtimeLayer.js +154 -118
- package/maplibre/utils/getSourceCoordinates.d.ts +1 -0
- package/maplibre/utils/getSourceCoordinates.js +6 -5
- package/mbt.js +14611 -14591
- package/mbt.js.map +4 -4
- package/mbt.min.js +75 -75
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +13 -5
- package/ol/controls/CopyrightControl.js +13 -5
- package/ol/controls/RoutingControl.d.ts +105 -101
- package/ol/controls/RoutingControl.js +250 -264
- package/ol/controls/StopFinderControl.d.ts +24 -5
- package/ol/controls/StopFinderControl.js +24 -5
- package/ol/layers/Layer.d.ts +26 -0
- package/ol/layers/Layer.js +39 -0
- package/ol/layers/MaplibreLayer.d.ts +56 -28
- package/ol/layers/MaplibreLayer.js +154 -31
- package/ol/layers/MaplibreStyleLayer.d.ts +71 -149
- package/ol/layers/MaplibreStyleLayer.js +281 -210
- package/ol/layers/RealtimeLayer.d.ts +95 -230
- package/ol/layers/RealtimeLayer.js +209 -211
- package/ol/layers/VectorLayer.d.ts +17 -0
- package/ol/layers/VectorLayer.js +33 -0
- package/ol/layers/index.d.ts +2 -0
- package/ol/layers/index.js +3 -0
- package/ol/renderers/MaplibreLayerRenderer.d.ts +0 -20
- package/ol/renderers/MaplibreLayerRenderer.js +142 -114
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
- package/ol/renderers/MaplibreStyleLayerRenderer.js +20 -23
- package/ol/renderers/RealtimeLayerRenderer.d.ts +7 -7
- package/ol/renderers/RealtimeLayerRenderer.js +46 -66
- package/ol/styles/fullTrajectoryDelayStyle.js +5 -7
- package/ol/styles/fullTrajectoryStyle.d.ts +1 -2
- package/ol/styles/fullTrajectoryStyle.js +5 -7
- package/ol/styles/routingStyle.d.ts +0 -1
- package/ol/styles/routingStyle.js +13 -10
- package/ol/utils/defineDeprecatedProperties.d.ts +10 -0
- package/ol/utils/defineDeprecatedProperties.js +180 -0
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
- package/ol/utils/getFeatureInfoAtCoordinate.js +11 -17
- package/package.json +44 -44
- package/setupTests.js +17 -4
- package/types/common.d.ts +53 -69
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +98 -95
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
- package/common/mixins/RealtimeLayerMixin.d.ts +0 -273
- package/common/mixins/RealtimeLayerMixin.js +0 -743
- package/ol/layers/MapGlLayer.d.ts +0 -144
- package/ol/layers/MapGlLayer.js +0 -144
- package/ol/mixins/MobilityLayerMixin.d.ts +0 -98
- package/ol/mixins/MobilityLayerMixin.js +0 -6
- package/ol/mixins/PropertiesLayerMixin.d.ts +0 -127
- package/ol/mixins/PropertiesLayerMixin.js +0 -143
|
@@ -9,14 +9,17 @@ import { LineString } from 'ol/geom';
|
|
|
9
9
|
* @private
|
|
10
10
|
*/
|
|
11
11
|
const getVehiclePosition = (now, trajectory, noInterpolate) => {
|
|
12
|
-
const {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const { coordinate,
|
|
13
|
+
// @ts-expect-error olGeometry is added by the RealtimeLayer
|
|
14
|
+
olGeometry, time_intervals: timeIntervals, } = trajectory.properties;
|
|
15
|
+
let { coordinates, type } = trajectory.geometry;
|
|
15
16
|
let geometry = olGeometry;
|
|
16
17
|
let coord;
|
|
17
18
|
let rotation;
|
|
19
|
+
// If an olGeometry exists we use it. It avoids to create one each time.
|
|
18
20
|
if (olGeometry) {
|
|
19
21
|
type = geometry.getType();
|
|
22
|
+
coordinates = geometry.getCoordinates();
|
|
20
23
|
}
|
|
21
24
|
if (noInterpolate && coordinate) {
|
|
22
25
|
coord = coordinate;
|
|
@@ -57,7 +57,7 @@ export declare const getTextSize: (ctx: AnyCanvasContext, markerSize: number, te
|
|
|
57
57
|
* @param {boolean} cancelled true if the journey is cancelled.
|
|
58
58
|
* @param {boolean} isDelayText true if the color is used for delay text of the symbol.
|
|
59
59
|
*/
|
|
60
|
-
export declare const getDelayColor: (delayInMs:
|
|
60
|
+
export declare const getDelayColor: (delayInMs: null | number, cancelled?: boolean, isDelayText?: boolean) => string;
|
|
61
61
|
/**
|
|
62
62
|
* @private
|
|
63
63
|
*/
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { AnyCanvas, RealtimeRenderState, RealtimeStyleFunction, RealtimeStyleOptions, RealtimeTrajectories, ViewState } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Draw all the trajectories available in a canvas.
|
|
4
|
-
* @param {HTMLCanvas|HTMLOffscreenCanvas} The canvas where to draw the trajectories.
|
|
4
|
+
* @param {HTMLCanvas|HTMLOffscreenCanvas} canvas The canvas where to draw the trajectories.
|
|
5
5
|
* @param {ViewState} trajectories An array of trajectories.
|
|
6
6
|
* @param {Function} style A function that returns a canvas representing a vehicle of a specific trajectory.
|
|
7
7
|
* @param {ViewState} viewState The view state of the map.
|
|
8
|
+
* @param {Object} options The options.
|
|
8
9
|
* @param {boolean} options.hoverVehicleId The id of the vehicle to highlight.
|
|
9
10
|
* @param {boolean} options.selectedVehicleId The id of the vehicle to select.
|
|
10
11
|
* @param {boolean} options.noInterpolate If true trajectories are not interpolated but
|
|
@@ -1,11 +1,12 @@
|
|
|
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.
|
|
5
|
-
* @param {HTMLCanvas|HTMLOffscreenCanvas} The canvas where to draw the trajectories.
|
|
5
|
+
* @param {HTMLCanvas|HTMLOffscreenCanvas} canvas The canvas where to draw the trajectories.
|
|
6
6
|
* @param {ViewState} trajectories An array of trajectories.
|
|
7
7
|
* @param {Function} style A function that returns a canvas representing a vehicle of a specific trajectory.
|
|
8
8
|
* @param {ViewState} viewState The view state of the map.
|
|
9
|
+
* @param {Object} options The options.
|
|
9
10
|
* @param {boolean} options.hoverVehicleId The id of the vehicle to highlight.
|
|
10
11
|
* @param {boolean} options.selectedVehicleId The id of the vehicle to select.
|
|
11
12
|
* @param {boolean} options.noInterpolate If true trajectories are not interpolated but
|
|
@@ -17,13 +18,13 @@ const renderTrajectories = (canvas, trajectories, style, viewState, options) =>
|
|
|
17
18
|
if (!canvas) {
|
|
18
19
|
return { renderedTrajectories: [] };
|
|
19
20
|
}
|
|
20
|
-
const {
|
|
21
|
+
const { center, pixelRatio = 1, resolution, rotation = 0, size = [], time = Date.now(), } = viewState;
|
|
21
22
|
if (!resolution || !center) {
|
|
22
23
|
return { renderedTrajectories: [] };
|
|
23
24
|
}
|
|
24
|
-
const {
|
|
25
|
+
const { filter, getScreenPixel = (pixel, viewStat) => (viewStat.zoom || 0) < 12
|
|
25
26
|
? pixel.map((coord) => Math.floor(coord))
|
|
26
|
-
: pixel, } = options;
|
|
27
|
+
: pixel, hoverVehicleId, noInterpolate = false, selectedVehicleId, } = options;
|
|
27
28
|
const context = canvas.getContext('2d');
|
|
28
29
|
context === null || context === void 0 ? void 0 : context.clearRect(0, 0, canvas.width, canvas.height);
|
|
29
30
|
const [width, height] = size;
|
|
@@ -49,7 +50,7 @@ const renderTrajectories = (canvas, trajectories, style, viewState, options) =>
|
|
|
49
50
|
continue;
|
|
50
51
|
}
|
|
51
52
|
// We simplify the trajectory object
|
|
52
|
-
const { train_id: id
|
|
53
|
+
const { timeOffset, train_id: id } = trajectory.properties;
|
|
53
54
|
// We set the rotation and the timeFraction of the trajectory (used by tralis).
|
|
54
55
|
// if rotation === null that seems there is no rotation available.
|
|
55
56
|
const { coord, rotation: rotationIcon } = getVehiclePosition(time - (timeOffset || 0), trajectory, noInterpolate);
|
|
@@ -8,7 +8,8 @@ import type { RealtimeDepartureExtended } from '../../types';
|
|
|
8
8
|
*
|
|
9
9
|
* @param {Object} depObject The object containing departures by id.
|
|
10
10
|
* @param {boolean} [sortByMinArrivalTime=false] If true sort departures by arrival time.
|
|
11
|
-
* @
|
|
11
|
+
* @param {number} [maxDepartureAge=30] The maximum departure age in minutes.
|
|
12
|
+
* @return {RealtimeDeparture[]} Return departures array.
|
|
12
13
|
* @private
|
|
13
14
|
*/
|
|
14
15
|
declare const sortAndfilterDepartures: (depObject: RealtimeAPIDeparturesById, sortByMinArrivalTime?: boolean, maxDepartureAge?: number) => RealtimeDepartureExtended[];
|
|
@@ -7,7 +7,8 @@ import compareDepartures from './compareDepartures';
|
|
|
7
7
|
*
|
|
8
8
|
* @param {Object} depObject The object containing departures by id.
|
|
9
9
|
* @param {boolean} [sortByMinArrivalTime=false] If true sort departures by arrival time.
|
|
10
|
-
* @
|
|
10
|
+
* @param {number} [maxDepartureAge=30] The maximum departure age in minutes.
|
|
11
|
+
* @return {RealtimeDeparture[]} Return departures array.
|
|
11
12
|
* @private
|
|
12
13
|
*/
|
|
13
14
|
const sortAndfilterDepartures = (depObject, sortByMinArrivalTime = false, maxDepartureAge = 30) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
declare const sortByDelay: (traj1:
|
|
1
|
+
import { RealtimeTrajectory } from '../../types';
|
|
2
|
+
declare const sortByDelay: (traj1: RealtimeTrajectory, traj2: RealtimeTrajectory) => number;
|
|
3
3
|
export default sortByDelay;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** @private */
|
|
2
1
|
const sortByDelay = (traj1, traj2) => {
|
|
3
2
|
const props1 = traj1.properties;
|
|
4
3
|
const props2 = traj2.properties;
|
|
@@ -10,12 +9,17 @@ const sortByDelay = (traj1, traj2) => {
|
|
|
10
9
|
}
|
|
11
10
|
// We put cancelled train inbetween green and yellow trains
|
|
12
11
|
// >=180000ms corresponds to yellow train
|
|
12
|
+
// @ts-expect-error
|
|
13
13
|
if (props1.cancelled && !props2.cancelled) {
|
|
14
|
+
// @ts-expect-error
|
|
14
15
|
return props2.delay < 180000 ? -1 : 1;
|
|
15
16
|
}
|
|
17
|
+
// @ts-expect-error
|
|
16
18
|
if (props2.cancelled && !props1.cancelled) {
|
|
19
|
+
// @ts-expect-error
|
|
17
20
|
return props1.delay < 180000 ? 1 : -1;
|
|
18
21
|
}
|
|
22
|
+
// @ts-expect-error
|
|
19
23
|
return props2.delay - props1.delay;
|
|
20
24
|
};
|
|
21
25
|
export default sortByDelay;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ControlPosition, IControl } from 'maplibre-gl';
|
|
2
2
|
/**
|
|
3
|
-
* Display layer's
|
|
3
|
+
* Display layer's attributions trying to remove duplicated ones.
|
|
4
4
|
*
|
|
5
5
|
* @example
|
|
6
|
-
* import { Map } from '
|
|
7
|
-
* import { CopyrightControl } from 'mobility-toolbox-js/
|
|
6
|
+
* import { Map } from 'maplibre-gl';
|
|
7
|
+
* import { CopyrightControl } from 'mobility-toolbox-js/maplibre';
|
|
8
8
|
*
|
|
9
9
|
* const map = new Map({
|
|
10
10
|
* container: 'map',
|
|
@@ -15,21 +15,24 @@ import { ControlPosition, IControl } from 'maplibre-gl';
|
|
|
15
15
|
* map.addControl(control);
|
|
16
16
|
*
|
|
17
17
|
*
|
|
18
|
-
* @see <a href="/example/mb-
|
|
18
|
+
* @see <a href="/example/mb-realtime>MapLibre Realtime layer example</a>
|
|
19
19
|
*
|
|
20
|
+
* @implements {maplibregl.IControl}
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
20
23
|
*/
|
|
21
24
|
declare class CopyrightControl implements IControl {
|
|
22
|
-
map?: maplibregl.Map;
|
|
23
25
|
container?: HTMLElement;
|
|
24
26
|
content?: string;
|
|
27
|
+
map?: maplibregl.Map;
|
|
25
28
|
options?: {
|
|
26
29
|
customAttribution?: string | string[];
|
|
27
30
|
separator?: string;
|
|
28
31
|
};
|
|
29
32
|
constructor(options?: {});
|
|
33
|
+
getDefaultPosition(): ControlPosition;
|
|
30
34
|
onAdd(map: maplibregl.Map): HTMLElement;
|
|
31
35
|
onRemove(): HTMLElement | undefined;
|
|
32
|
-
getDefaultPosition(): ControlPosition;
|
|
33
36
|
render(): void;
|
|
34
37
|
}
|
|
35
38
|
export default CopyrightControl;
|
|
@@ -4,11 +4,11 @@ import { getMapGlCopyrights } from '../../common/utils';
|
|
|
4
4
|
*/
|
|
5
5
|
const DEFAULT_SEPARATOR = ' | ';
|
|
6
6
|
/**
|
|
7
|
-
* Display layer's
|
|
7
|
+
* Display layer's attributions trying to remove duplicated ones.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
|
-
* import { Map } from '
|
|
11
|
-
* import { CopyrightControl } from 'mobility-toolbox-js/
|
|
10
|
+
* import { Map } from 'maplibre-gl';
|
|
11
|
+
* import { CopyrightControl } from 'mobility-toolbox-js/maplibre';
|
|
12
12
|
*
|
|
13
13
|
* const map = new Map({
|
|
14
14
|
* container: 'map',
|
|
@@ -19,13 +19,20 @@ const DEFAULT_SEPARATOR = ' | ';
|
|
|
19
19
|
* map.addControl(control);
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
|
-
* @see <a href="/example/mb-
|
|
22
|
+
* @see <a href="/example/mb-realtime>MapLibre Realtime layer example</a>
|
|
23
23
|
*
|
|
24
|
+
* @implements {maplibregl.IControl}
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
24
27
|
*/
|
|
25
28
|
class CopyrightControl {
|
|
26
29
|
constructor(options = {}) {
|
|
27
30
|
this.options = options;
|
|
28
31
|
}
|
|
32
|
+
// eslint-disable-next-line class-methods-use-this
|
|
33
|
+
getDefaultPosition() {
|
|
34
|
+
return 'bottom-right';
|
|
35
|
+
}
|
|
29
36
|
onAdd(map) {
|
|
30
37
|
this.map = map;
|
|
31
38
|
if (!this.container) {
|
|
@@ -51,10 +58,6 @@ class CopyrightControl {
|
|
|
51
58
|
this.map = undefined;
|
|
52
59
|
return this.container;
|
|
53
60
|
}
|
|
54
|
-
// eslint-disable-next-line class-methods-use-this
|
|
55
|
-
getDefaultPosition() {
|
|
56
|
-
return 'bottom-right';
|
|
57
|
-
}
|
|
58
61
|
render() {
|
|
59
62
|
var _a, _b;
|
|
60
63
|
if (this.map && this.container) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CustomLayerInterface, Evented } from 'maplibre-gl';
|
|
2
2
|
import type { AnyMapGlMap } from '../../types';
|
|
3
|
-
export
|
|
3
|
+
export interface LayerOptions {
|
|
4
4
|
id?: string;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
|
+
export type CUSTOM = 'custom';
|
|
6
7
|
/**
|
|
7
8
|
* A class representing a layer to display on an Maplibre map.
|
|
8
9
|
*
|
|
@@ -11,7 +12,7 @@ export type LayerOptions = {
|
|
|
11
12
|
*
|
|
12
13
|
* const layer = new Layer({ id:'MyLayer' });
|
|
13
14
|
*
|
|
14
|
-
* @implements {maplibregl.
|
|
15
|
+
* @implements {maplibregl.CustomLayerInterface}
|
|
15
16
|
* @extends {maplibregl.Evented}
|
|
16
17
|
* @private
|
|
17
18
|
*/
|
|
@@ -19,10 +20,10 @@ declare class Layer extends Evented implements CustomLayerInterface {
|
|
|
19
20
|
id: string;
|
|
20
21
|
map: AnyMapGlMap | undefined;
|
|
21
22
|
options: LayerOptions;
|
|
22
|
-
type:
|
|
23
|
+
type: CUSTOM;
|
|
23
24
|
constructor(options?: LayerOptions);
|
|
24
|
-
onAdd(map: AnyMapGlMap, gl:
|
|
25
|
-
onRemove(map: AnyMapGlMap, gl:
|
|
26
|
-
render(gl:
|
|
25
|
+
onAdd(map: AnyMapGlMap, gl: WebGL2RenderingContext | WebGLRenderingContext): void;
|
|
26
|
+
onRemove(map: AnyMapGlMap, gl: WebGL2RenderingContext | WebGLRenderingContext): void;
|
|
27
|
+
render(gl: WebGL2RenderingContext | WebGLRenderingContext): void;
|
|
27
28
|
}
|
|
28
29
|
export default Layer;
|
package/maplibre/layers/Layer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { v4 as uuid } from 'uuid';
|
|
2
1
|
import { Evented } from 'maplibre-gl';
|
|
2
|
+
import { v4 as uuid } from 'uuid';
|
|
3
3
|
/**
|
|
4
4
|
* A class representing a layer to display on an Maplibre map.
|
|
5
5
|
*
|
|
@@ -8,7 +8,7 @@ import { Evented } from 'maplibre-gl';
|
|
|
8
8
|
*
|
|
9
9
|
* const layer = new Layer({ id:'MyLayer' });
|
|
10
10
|
*
|
|
11
|
-
* @implements {maplibregl.
|
|
11
|
+
* @implements {maplibregl.CustomLayerInterface}
|
|
12
12
|
* @extends {maplibregl.Evented}
|
|
13
13
|
* @private
|
|
14
14
|
*/
|
|
@@ -19,7 +19,6 @@ class Layer extends Evented {
|
|
|
19
19
|
this.type = 'custom';
|
|
20
20
|
this.options = options;
|
|
21
21
|
this.id = options.id || uuid();
|
|
22
|
-
this.type = 'custom';
|
|
23
22
|
}
|
|
24
23
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
24
|
onAdd(map, gl) {
|
|
@@ -1,122 +1,110 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CanvasSourceSpecification, LayerSpecification } from 'maplibre-gl';
|
|
2
|
+
import RealtimeEngine, { RealtimeEngineOptions } from '../../common/utils/RealtimeEngine';
|
|
2
3
|
import Layer, { LayerOptions } from './Layer';
|
|
3
|
-
import type {
|
|
4
|
-
|
|
5
|
-
export type RealtimeLayerOptions = LayerOptions & RealtimeLayerMixinOptions;
|
|
6
|
-
declare const RealtimeLayer_base: {
|
|
7
|
-
new (options: RealtimeLayerMixinOptions): {
|
|
8
|
-
[x: string]: any;
|
|
9
|
-
debug: boolean;
|
|
10
|
-
trajectories?: {
|
|
11
|
-
[key: string]: GeoJSONFeature;
|
|
12
|
-
} | undefined;
|
|
13
|
-
canvas?: import("../../types").AnyCanvas | undefined;
|
|
14
|
-
mode: import("../../types").RealtimeMode;
|
|
15
|
-
api: import("../../api/RealtimeAPI").default;
|
|
16
|
-
tenant: string;
|
|
17
|
-
bboxParameters?: {
|
|
18
|
-
[index: string]: string | number | boolean | string[] | number[] | boolean[];
|
|
19
|
-
} | undefined;
|
|
20
|
-
time?: Date | undefined;
|
|
21
|
-
live?: boolean | undefined;
|
|
22
|
-
speed?: number | undefined;
|
|
23
|
-
filter?: Function | undefined;
|
|
24
|
-
sort?: Function | undefined;
|
|
25
|
-
style?: import("../../types").RealtimeStyleFunction | undefined;
|
|
26
|
-
styleOptions?: import("../../types").RealtimeStyleOptions | undefined;
|
|
27
|
-
pixelRatio?: number | undefined;
|
|
28
|
-
minZoomInterpolation: number;
|
|
29
|
-
isUpdateBboxOnMoveEnd: boolean;
|
|
30
|
-
hoverVehicleId?: string | undefined;
|
|
31
|
-
selectedVehicleId?: string | undefined;
|
|
32
|
-
renderState?: import("../../types").RealtimeRenderState | undefined;
|
|
33
|
-
useRequestAnimationFrame?: boolean | undefined;
|
|
34
|
-
useDebounce?: boolean | undefined;
|
|
35
|
-
useThrottle?: boolean | undefined;
|
|
36
|
-
mots?: import("../../types").RealtimeMot[] | undefined;
|
|
37
|
-
motsByZoom: import("../../types").RealtimeMot[][];
|
|
38
|
-
generalizationLevel?: import("../../types").RealtimeGeneralizationLevel | undefined;
|
|
39
|
-
generalizationLevelByZoom: import("../../types").RealtimeGeneralizationLevel[];
|
|
40
|
-
renderTimeIntervalByZoom: number[];
|
|
41
|
-
format: import("ol/format/GeoJSON").default<typeof import("ol/Feature").default>;
|
|
42
|
-
requestId?: number | undefined;
|
|
43
|
-
updateTimeInterval?: number | undefined;
|
|
44
|
-
updateTimeDelay?: number | undefined;
|
|
45
|
-
visibilityRef: import("ol/events").EventsKey;
|
|
46
|
-
selectedVehicle: GeoJSONFeature;
|
|
47
|
-
getMotsByZoom: (zoom: number) => import("../../types").RealtimeMot[];
|
|
48
|
-
getGeneralizationLevelByZoom: (zoom: number) => import("../../types").RealtimeGeneralizationLevel;
|
|
49
|
-
getRenderTimeIntervalByZoom: (zoom: number) => number;
|
|
50
|
-
throttleRenderTrajectories: (viewState: ViewState, noInterpolate?: boolean | undefined) => void;
|
|
51
|
-
debounceRenderTrajectories: (viewState: ViewState, noInterpolate?: boolean | undefined) => void;
|
|
52
|
-
onStart?: ((realtimeLayer: any) => void) | undefined;
|
|
53
|
-
onStop?: ((realtimeLayer: any) => void) | undefined;
|
|
54
|
-
defineProperties(options: RealtimeLayerMixinOptions): void;
|
|
55
|
-
attachToMap(map: any): void;
|
|
56
|
-
detachFromMap(): void;
|
|
57
|
-
start(): void;
|
|
58
|
-
startUpdateTime(): void;
|
|
59
|
-
stop(): void;
|
|
60
|
-
stopUpdateTime(): void;
|
|
61
|
-
renderTrajectoriesInternal(viewState: ViewState, noInterpolate?: boolean): boolean;
|
|
62
|
-
renderTrajectories(viewState: ViewState | undefined, noInterpolate: boolean | undefined): void;
|
|
63
|
-
setBbox(extent: [number, number, number, number], zoom: number): void;
|
|
64
|
-
getRefreshTimeInMs(zoom?: number | undefined): number;
|
|
65
|
-
getVehicle(filterFc: Function): GeoJSONFeature[];
|
|
66
|
-
getFeatureInfoAtCoordinate(coordinate: import("ol/coordinate").Coordinate, options: import("../../types").LayerGetFeatureInfoOptions): Promise<import("../../types").LayerGetFeatureInfoResponse>;
|
|
67
|
-
getTrajectoryInfos(id: string): Promise<{
|
|
68
|
-
stopSequence: import("../../api/WebSocketAPI").WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory> | import("../../api/WebSocketAPI").WebSocketAPIMessageEventData<GeoJSONFeature[]>;
|
|
69
|
-
fullTrajectory: import("../../api/WebSocketAPI").WebSocketAPIMessageEventData<import("../../types").RealtimeFullTrajectory> | import("../../api/WebSocketAPI").WebSocketAPIMessageEventData<GeoJSONFeature[]>;
|
|
70
|
-
}>;
|
|
71
|
-
purgeOutOfDateTrajectories(): void;
|
|
72
|
-
purgeTrajectory(trajectory: GeoJSONFeature, extent: [number, number, number, number], zoom: number): boolean;
|
|
73
|
-
addTrajectory(trajectory: GeoJSONFeature): void;
|
|
74
|
-
removeTrajectory(trajectoryOrId: any): void;
|
|
75
|
-
onZoomEnd(): void;
|
|
76
|
-
onDocumentVisibilityChange(): void;
|
|
77
|
-
onTrajectoryMessage(data: import("../../api/WebSocketAPI").WebSocketAPIMessageEventData<GeoJSONFeature>): void;
|
|
78
|
-
onDeleteTrajectoryMessage(data: import("../../api/WebSocketAPI").WebSocketAPIMessageEventData<string>): void;
|
|
79
|
-
highlightVehicle(id: string): void;
|
|
80
|
-
selectVehicle(id: string): void;
|
|
81
|
-
};
|
|
82
|
-
} & typeof Layer;
|
|
4
|
+
import type { AnyCanvas, AnyMapGlMap } from '../../types';
|
|
5
|
+
export type RealtimeLayerOptions = LayerOptions & RealtimeEngineOptions;
|
|
83
6
|
/**
|
|
84
|
-
*
|
|
7
|
+
* A Maplibre layer able to display data from the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
|
|
85
8
|
*
|
|
86
9
|
* @example
|
|
87
|
-
* import {
|
|
10
|
+
* import { Map } from 'maplibre-gl';
|
|
11
|
+
* import { RealtimeLayer } from 'mobility-toolbox-js/maplibre';
|
|
12
|
+
*
|
|
13
|
+
* // Define the map
|
|
14
|
+
* const map = new Map({ ... });
|
|
88
15
|
*
|
|
16
|
+
* // Define your layer map
|
|
89
17
|
* const layer = new RealtimeLayer({
|
|
90
18
|
* apiKey: "yourApiKey"
|
|
91
19
|
* // url: "wss://api.geops.io/tracker-ws/v1/",
|
|
92
20
|
* });
|
|
93
21
|
*
|
|
22
|
+
* // Add the layer to your map *
|
|
23
|
+
* map.on('load', () => {
|
|
24
|
+
* map.addLayer(layer);
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
94
27
|
*
|
|
95
28
|
* @see <a href="/api/class/src/api/RealtimeAPI%20js~RealtimeAPI%20html">RealtimeAPI</a>
|
|
29
|
+
* @see <a href="/example/mb-realtime>MapLibre Realtime layer example</a>
|
|
96
30
|
*
|
|
97
|
-
* @implements {maplibregl.
|
|
31
|
+
* @implements {maplibregl.CustomLayerInterface}
|
|
98
32
|
* @extends {maplibregl.Evented}
|
|
33
|
+
* @classproperty {function} filter - Filter out a train. This function must be fast, it is executed for every trajectory on every render frame.
|
|
34
|
+
* @classproperty {RealtimeMode} mode - The realtime mode to use.
|
|
35
|
+
* @classproperty {RealtimeMot[]} mots - Filter trains by its mode of transportation. It filters trains on backend side.
|
|
36
|
+
* @classproperty {RealtimeTenant} tenant - Filter trains by its tenant. It filters trains on backend side.
|
|
37
|
+
* @classproperty {function} sort - Sort trains. This function must be fast, it is executed on every render frame.
|
|
38
|
+
* @classproperty {function} style - Function to style the vehicles.
|
|
39
|
+
s
|
|
99
40
|
* @public
|
|
100
41
|
*/
|
|
101
|
-
declare class RealtimeLayer extends
|
|
42
|
+
declare class RealtimeLayer extends Layer {
|
|
43
|
+
#private;
|
|
44
|
+
engine: RealtimeEngine;
|
|
45
|
+
layer: LayerSpecification;
|
|
46
|
+
source: CanvasSourceSpecification;
|
|
47
|
+
sourceId: string;
|
|
102
48
|
/**
|
|
103
49
|
* Constructor.
|
|
104
50
|
*
|
|
105
51
|
* @param {RealtimeLayerOptions} options
|
|
106
52
|
* @param {string} options.apiKey Access key for [geOps apis](https://developer.geops.io/).
|
|
107
|
-
* @param {
|
|
108
|
-
*
|
|
53
|
+
* @param {FilterFunction} options.filter Filter out a train. This function must be fast, it is executed for every trajectory on every render frame.
|
|
54
|
+
* @param {getMotsByZoomFunction} options.getMotsByZoom Returns for each zoom level the list of MOTs to display. It filters trains on backend side.
|
|
55
|
+
* @param {number} [options.minZoomInterpolation=8] Minimal zoom level where to start to interpolate train positions.
|
|
56
|
+
* @param {RealtimeMode} [options.mode='topographic'] The realtime mode to use.
|
|
57
|
+
* @param {SortFunction} options.sort Sort trains. This function must be fast, it is executed on every render frame.
|
|
58
|
+
* @param {RealtimeStyleFunction} options.style Function to style the vehicles.
|
|
59
|
+
* @param {RealtimeTenant} options.tenant Filter trains by its tenant. It filters trains on backend side.
|
|
60
|
+
* @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The geOps Realtime API url.
|
|
109
61
|
*/
|
|
110
|
-
constructor(options?:
|
|
62
|
+
constructor(options?: RealtimeLayerOptions);
|
|
63
|
+
/**
|
|
64
|
+
* Return the current view state. Used by the RealtimeEngine.
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
getViewState(): {
|
|
68
|
+
center?: undefined;
|
|
69
|
+
extent?: undefined;
|
|
70
|
+
pixelRatio?: undefined;
|
|
71
|
+
resolution?: undefined;
|
|
72
|
+
rotation?: undefined;
|
|
73
|
+
size?: undefined;
|
|
74
|
+
visible?: undefined;
|
|
75
|
+
zoom?: undefined;
|
|
76
|
+
} | {
|
|
77
|
+
center: import("ol/coordinate").Coordinate;
|
|
78
|
+
extent: number[];
|
|
79
|
+
pixelRatio: number;
|
|
80
|
+
resolution: number;
|
|
81
|
+
rotation: number;
|
|
82
|
+
size: number[];
|
|
83
|
+
visible: boolean;
|
|
84
|
+
zoom: number;
|
|
85
|
+
};
|
|
111
86
|
/**
|
|
112
87
|
* Add sources, layers and listeners to the map.
|
|
113
88
|
*/
|
|
114
|
-
onAdd(map: AnyMapGlMap, gl:
|
|
89
|
+
onAdd(map: AnyMapGlMap, gl: WebGL2RenderingContext | WebGLRenderingContext): void;
|
|
90
|
+
onLoad(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Callback on 'move' event.
|
|
93
|
+
*/
|
|
94
|
+
onMove(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Callback on 'moveend' event.
|
|
97
|
+
*/
|
|
98
|
+
onMoveEnd(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Callback when the RealtimeEngine has rendered successfully.
|
|
101
|
+
*/
|
|
102
|
+
onRealtimeEngineRender(): void;
|
|
115
103
|
/**
|
|
116
104
|
* Remove source, layers and listeners from the map.
|
|
117
105
|
*/
|
|
118
|
-
onRemove(map: AnyMapGlMap, gl:
|
|
119
|
-
|
|
106
|
+
onRemove(map: AnyMapGlMap, gl: WebGL2RenderingContext | WebGLRenderingContext): void;
|
|
107
|
+
onZoomEnd(): void;
|
|
120
108
|
/**
|
|
121
109
|
* Start updating vehicles position.
|
|
122
110
|
*
|
|
@@ -129,32 +117,8 @@ declare class RealtimeLayer extends RealtimeLayer_base {
|
|
|
129
117
|
* @public
|
|
130
118
|
*/
|
|
131
119
|
stop(): void;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
* @private
|
|
136
|
-
*/
|
|
137
|
-
renderTrajectories(noInterpolate?: boolean): void;
|
|
138
|
-
/**
|
|
139
|
-
* Return the delay in ms before the next rendering.
|
|
140
|
-
*/
|
|
141
|
-
getRefreshTimeInMs(): number;
|
|
142
|
-
/**
|
|
143
|
-
* Remove the trajectory form the list if necessary.
|
|
144
|
-
*/
|
|
145
|
-
purgeTrajectory(trajectory: RealtimeTrajectory, extent: [number, number, number, number], zoom: number): boolean;
|
|
146
|
-
/**
|
|
147
|
-
* Send the current bbox to the websocket
|
|
148
|
-
*/
|
|
149
|
-
setBbox(extent?: [number, number, number, number], zoom?: number): void;
|
|
150
|
-
renderTrajectoriesInternal(viewState: ViewState, noInterpolate?: boolean): boolean;
|
|
151
|
-
/**
|
|
152
|
-
* Callback on 'move' event.
|
|
153
|
-
*/
|
|
154
|
-
onMove(): void;
|
|
155
|
-
/**
|
|
156
|
-
* Callback on 'moveend' event.
|
|
157
|
-
*/
|
|
158
|
-
onMoveEnd(): void;
|
|
120
|
+
get canvas(): AnyCanvas | undefined;
|
|
121
|
+
get pixelRatio(): number | undefined;
|
|
122
|
+
set pixelRatio(pixelRatio: number | undefined);
|
|
159
123
|
}
|
|
160
124
|
export default RealtimeLayer;
|