mobility-toolbox-js 3.0.0-beta.33 → 3.0.0-beta.35
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 +2 -2
- package/api/RealtimeAPI.js +3 -3
- package/common/controls/StopFinderControlCommon.d.ts +1 -1
- package/common/controls/StopFinderControlCommon.js +1 -1
- package/common/utils/RealtimeEngine.d.ts +1 -11
- package/common/utils/RealtimeEngine.js +1 -11
- package/common/utils/renderTrajectories.d.ts +1 -0
- package/common/utils/renderTrajectories.js +1 -0
- package/common/utils/sortAndFilterDepartures.d.ts +1 -0
- package/common/utils/sortAndFilterDepartures.js +1 -0
- package/maplibre/controls/CopyrightControl.d.ts +9 -6
- package/maplibre/controls/CopyrightControl.js +11 -8
- package/maplibre/layers/Layer.d.ts +7 -6
- package/maplibre/layers/Layer.js +1 -2
- package/maplibre/layers/RealtimeLayer.d.ts +4 -2
- package/maplibre/layers/RealtimeLayer.js +26 -11
- package/maplibre/utils/getSourceCoordinates.d.ts +1 -0
- package/maplibre/utils/getSourceCoordinates.js +5 -4
- package/mbt.js +258 -204
- package/mbt.js.map +3 -3
- package/mbt.min.js +13 -13
- 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 +25 -15
- package/ol/controls/RoutingControl.js +40 -25
- package/ol/controls/StopFinderControl.d.ts +22 -0
- package/ol/controls/StopFinderControl.js +22 -0
- package/ol/layers/MaplibreLayer.d.ts +6 -1
- package/ol/layers/MaplibreLayer.js +6 -1
- package/ol/layers/MaplibreStyleLayer.d.ts +5 -9
- package/ol/layers/MaplibreStyleLayer.js +5 -3
- package/ol/layers/RealtimeLayer.d.ts +10 -3
- package/ol/layers/RealtimeLayer.js +13 -1
- package/package.json +21 -20
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MapEvent } from 'ol';
|
|
2
2
|
import Control, { Options } from 'ol/control/Control';
|
|
3
|
-
export type CopyrightControlOptions =
|
|
3
|
+
export type CopyrightControlOptions = {
|
|
4
4
|
className?: 'string';
|
|
5
5
|
format?: (copyrights: string[]) => string;
|
|
6
|
-
};
|
|
6
|
+
} & Options;
|
|
7
7
|
/**
|
|
8
|
-
* Display layer's copyrights.
|
|
8
|
+
* Display layer's copyrights. Adding the possibility to format them as you wish.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* import { Map } from 'ol';
|
|
@@ -19,12 +19,20 @@ export type CopyrightControlOptions = Options & {
|
|
|
19
19
|
* map.addControl(control);
|
|
20
20
|
*
|
|
21
21
|
*
|
|
22
|
-
* @see <a href="/example/ol-
|
|
22
|
+
* @see <a href="/example/ol-realtime>OpenLayers Realtime layer example</a>
|
|
23
|
+
*
|
|
24
|
+
* @extends {ol/control/Control~Control}
|
|
23
25
|
*
|
|
24
|
-
* @extends {ol/control/Control}
|
|
25
26
|
*/
|
|
26
27
|
declare class CopyrightControl extends Control {
|
|
27
28
|
format: (copyrights: string[]) => string;
|
|
29
|
+
/**
|
|
30
|
+
* Constructor.
|
|
31
|
+
*
|
|
32
|
+
* @param {Object} options
|
|
33
|
+
* @param {Function} format Function used to format the list of copyrights available to a single string. By default join all the copyrights with a |.
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
28
36
|
constructor(options?: CopyrightControlOptions);
|
|
29
37
|
render({ frameState }: MapEvent): void;
|
|
30
38
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { inView } from 'ol/layer/Layer';
|
|
2
1
|
import Control from 'ol/control/Control';
|
|
3
|
-
import
|
|
2
|
+
import { inView } from 'ol/layer/Layer';
|
|
4
3
|
import createDefaultCopyrightElement from '../../common/utils/createDefaultCopyrightElt';
|
|
4
|
+
import removeDuplicate from '../../common/utils/removeDuplicate';
|
|
5
5
|
/**
|
|
6
|
-
* Display layer's copyrights.
|
|
6
|
+
* Display layer's copyrights. Adding the possibility to format them as you wish.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* import { Map } from 'ol';
|
|
@@ -17,11 +17,19 @@ import createDefaultCopyrightElement from '../../common/utils/createDefaultCopyr
|
|
|
17
17
|
* map.addControl(control);
|
|
18
18
|
*
|
|
19
19
|
*
|
|
20
|
-
* @see <a href="/example/ol-
|
|
20
|
+
* @see <a href="/example/ol-realtime>OpenLayers Realtime layer example</a>
|
|
21
|
+
*
|
|
22
|
+
* @extends {ol/control/Control~Control}
|
|
21
23
|
*
|
|
22
|
-
* @extends {ol/control/Control}
|
|
23
24
|
*/
|
|
24
25
|
class CopyrightControl extends Control {
|
|
26
|
+
/**
|
|
27
|
+
* Constructor.
|
|
28
|
+
*
|
|
29
|
+
* @param {Object} options
|
|
30
|
+
* @param {Function} format Function used to format the list of copyrights available to a single string. By default join all the copyrights with a |.
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
25
33
|
constructor(options = {}) {
|
|
26
34
|
const element = createDefaultCopyrightElement();
|
|
27
35
|
element.className = options.className || 'mbt-copyright';
|
|
@@ -15,11 +15,11 @@ import type { RoutingGraph, RoutingMot, RoutingParameters, RoutingViaPoint } fro
|
|
|
15
15
|
export type RoutingControlOptions = {
|
|
16
16
|
active?: boolean;
|
|
17
17
|
apiKey?: string;
|
|
18
|
+
apiParams?: RoutingParameters;
|
|
18
19
|
graphs?: RoutingGraph[];
|
|
19
20
|
modify?: boolean;
|
|
20
21
|
mot?: string;
|
|
21
22
|
onRouteError?: () => void;
|
|
22
|
-
routingApiParams?: RoutingParameters;
|
|
23
23
|
routingLayer?: VectorLayer<VectorSource>;
|
|
24
24
|
snapToClosestStation?: boolean;
|
|
25
25
|
stopsApiKey?: string;
|
|
@@ -29,7 +29,8 @@ export type RoutingControlOptions = {
|
|
|
29
29
|
} & Options;
|
|
30
30
|
export type AbotControllersByGraph = Record<string, AbortController>;
|
|
31
31
|
/**
|
|
32
|
-
* This OpenLayers control allows the user to add and modifiy via points to
|
|
32
|
+
* This OpenLayers control allows the user to add and modifiy via points to
|
|
33
|
+
* a map and request a route from the [geOps Routing API](https://developer.geops.io/apis/routing/).
|
|
33
34
|
*
|
|
34
35
|
* @example
|
|
35
36
|
* import { Map } from 'ol';
|
|
@@ -41,29 +42,23 @@ export type AbotControllersByGraph = Record<string, AbortController>;
|
|
|
41
42
|
*
|
|
42
43
|
* const control = new RoutingControl();
|
|
43
44
|
*
|
|
44
|
-
*
|
|
45
|
+
* map.addControl(control);
|
|
45
46
|
*
|
|
46
|
-
* @classproperty {string} apiKey - Key used for RoutingApi requests.
|
|
47
|
-
* @classproperty {string} stopsApiKey - Key used for Stop lookup requests (defaults to apiKey).
|
|
48
|
-
* @classproperty {string} stopsApiUrl - Url used for Stop lookup requests (defaults to https://api.geops.io/stops/v1/lookup/).
|
|
49
|
-
* @classproperty {Array.<Array<graph="osm", minZoom=0, maxZoom=99>>} graphs - Array of routing graphs and min/max zoom levels. If you use the control in combination with the [geOps Maps API](https://developer.geops.io/apis/maps/), you may want to use the optimal level of generalizations: "[['gen4', 0, 8], ['gen3', 8, 9], ['gen2', 9, 11], ['gen1', 11, 13], ['osm', 13, 99]]"
|
|
50
47
|
* @classproperty {string} mot - Mean of transport to be used for routing.
|
|
51
|
-
* @classproperty {object} routingApiParams - object of additional parameters to pass to the routing api request.
|
|
52
|
-
* @classproperty {object} snapToClosestStation - If true, the routing will snap the coordinate to the closest station. Default to false.
|
|
53
|
-
* @classproperty {boolean} useRawViaPoints - Experimental property. Wen true, it allows the user to add via points using different kind of string. See "via" parameter defined by the [geOps Routing API](https://developer.geops.io/apis/routing/). Default to false, only array of coordinates and station's id are supported as via points.
|
|
54
48
|
* @classproperty {VectorLayer} routingLayer - Layer for adding route features.
|
|
55
|
-
* @classproperty {function} onRouteError - Callback on error.
|
|
56
49
|
* @classproperty {boolean} loading - True if the control is requesting the backend.
|
|
50
|
+
*
|
|
57
51
|
* @see <a href="/example/ol-routing">Openlayers routing example</a>
|
|
58
52
|
*
|
|
59
|
-
* @extends {Control}
|
|
60
|
-
*
|
|
53
|
+
* @extends {ol/control/Control~Control}
|
|
54
|
+
*
|
|
61
55
|
* @public
|
|
62
56
|
*/
|
|
63
57
|
declare class RoutingControl extends Control {
|
|
64
58
|
abortControllers: Record<string, AbortController>;
|
|
65
59
|
api?: RoutingAPI;
|
|
66
60
|
apiKey?: string;
|
|
61
|
+
apiParams?: RoutingParameters;
|
|
67
62
|
cacheStationData: Record<string, Coordinate>;
|
|
68
63
|
format: GeoJSON;
|
|
69
64
|
graphs: RoutingGraph[];
|
|
@@ -77,7 +72,6 @@ declare class RoutingControl extends Control {
|
|
|
77
72
|
modifyInteraction?: Modify;
|
|
78
73
|
onMapClickKey?: EventsKey;
|
|
79
74
|
onRouteError: (error?: Error, control?: RoutingControl) => void;
|
|
80
|
-
routingApiParams?: RoutingParameters;
|
|
81
75
|
routingLayer?: VectorLayer<VectorSource>;
|
|
82
76
|
segments: Feature<LineString>[];
|
|
83
77
|
snapToClosestStation: boolean;
|
|
@@ -85,6 +79,22 @@ declare class RoutingControl extends Control {
|
|
|
85
79
|
stopsApiUrl?: string;
|
|
86
80
|
useRawViaPoints: boolean;
|
|
87
81
|
viaPoints: RoutingViaPoint[];
|
|
82
|
+
/**
|
|
83
|
+
* Constructor.
|
|
84
|
+
*
|
|
85
|
+
* @param {Object} options
|
|
86
|
+
* @param {string} options.apiKey Access key for [geOps APIs](https://developer.geops.io/).
|
|
87
|
+
* @param {Object} options.apiParams Request parameters. See [geOps Routing API documentation](https://developer.geops.io/apis/routing/).
|
|
88
|
+
* @param {Array.<Array<graph="osm", minZoom=0, maxZoom=99>>} [options.graphs=[['osm', 0, 99]]] - Array of routing graphs and min/max zoom levels. If you use the control in combination with the [geOps Maps API](https://developer.geops.io/apis/maps/), you may want to use the optimal level of generalizations: "[['gen4', 0, 8], ['gen3', 8, 9], ['gen2', 9, 11], ['gen1', 11, 13], ['osm', 13, 99]]".
|
|
89
|
+
* @param {string} [options.mot="bus"] Mean of transport to be used for routing.
|
|
90
|
+
* @param {function} options.onRouteError Callback on request errors.
|
|
91
|
+
* @param {VectorLayer} [options.routingLayer=new VectorLayer()] Vector layer for adding route features.
|
|
92
|
+
* @param {boolean} [options.snapToClosestStation=false] If true, the routing will snap the coordinate to the closest station. Default to false.
|
|
93
|
+
* @param {StyleLike} options.style Style of the default vector layer.
|
|
94
|
+
* @param {boolean} [options.useRawViaPoints=fale] Experimental property. If true, it allows the user to add via points using different kind of string. See "via" parameter defined by the [geOps Routing API](https://developer.geops.io/apis/routing/). Default to false, only array of coordinates and station's id are supported as via points.
|
|
95
|
+
* @param {string} [options.url='https://api.geops.io/routing/v1/'] [geOps Realtime API](https://developer.geops.io/apis/realtime/) url.
|
|
96
|
+
* @public
|
|
97
|
+
*/
|
|
88
98
|
constructor(options?: RoutingControlOptions);
|
|
89
99
|
/**
|
|
90
100
|
* Calculate at which resolutions corresponds each generalizations.
|
|
@@ -109,7 +119,7 @@ declare class RoutingControl extends Control {
|
|
|
109
119
|
* If an index is passed a viaPoint is added at the specified index.
|
|
110
120
|
* If an index is passed and overwrite x is > 0, x viaPoints at the specified
|
|
111
121
|
* index are replaced with a single new viaPoint.
|
|
112
|
-
* @param {
|
|
122
|
+
* @param {string | Coordinate} coordinatesOrString Array of coordinates or a string representing a station
|
|
113
123
|
* @param {number} [index=-1] Integer representing the index of the added viaPoint. If not specified, the viaPoint is added at the end of the array.
|
|
114
124
|
* @param {number} [overwrite=0] Marks the number of viaPoints that are removed at the specified index on add.
|
|
115
125
|
* @public
|
|
@@ -33,7 +33,7 @@ const getFlatCoordinatesFromSegments = (segmentArray) => {
|
|
|
33
33
|
const coords = [];
|
|
34
34
|
segmentArray.forEach((seg) => {
|
|
35
35
|
var _a;
|
|
36
|
-
// @ts-expect-error
|
|
36
|
+
// @ts-expect-error missing type
|
|
37
37
|
const coordArr = (_a = seg.getGeometry()) === null || _a === void 0 ? void 0 : _a.getCoordinates();
|
|
38
38
|
if (coordArr === null || coordArr === void 0 ? void 0 : coordArr.length) {
|
|
39
39
|
coords.push(...coordArr);
|
|
@@ -42,7 +42,8 @@ const getFlatCoordinatesFromSegments = (segmentArray) => {
|
|
|
42
42
|
return coords;
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
|
-
* This OpenLayers control allows the user to add and modifiy via points to
|
|
45
|
+
* This OpenLayers control allows the user to add and modifiy via points to
|
|
46
|
+
* a map and request a route from the [geOps Routing API](https://developer.geops.io/apis/routing/).
|
|
46
47
|
*
|
|
47
48
|
* @example
|
|
48
49
|
* import { Map } from 'ol';
|
|
@@ -54,26 +55,35 @@ const getFlatCoordinatesFromSegments = (segmentArray) => {
|
|
|
54
55
|
*
|
|
55
56
|
* const control = new RoutingControl();
|
|
56
57
|
*
|
|
57
|
-
*
|
|
58
|
+
* map.addControl(control);
|
|
58
59
|
*
|
|
59
|
-
* @classproperty {string} apiKey - Key used for RoutingApi requests.
|
|
60
|
-
* @classproperty {string} stopsApiKey - Key used for Stop lookup requests (defaults to apiKey).
|
|
61
|
-
* @classproperty {string} stopsApiUrl - Url used for Stop lookup requests (defaults to https://api.geops.io/stops/v1/lookup/).
|
|
62
|
-
* @classproperty {Array.<Array<graph="osm", minZoom=0, maxZoom=99>>} graphs - Array of routing graphs and min/max zoom levels. If you use the control in combination with the [geOps Maps API](https://developer.geops.io/apis/maps/), you may want to use the optimal level of generalizations: "[['gen4', 0, 8], ['gen3', 8, 9], ['gen2', 9, 11], ['gen1', 11, 13], ['osm', 13, 99]]"
|
|
63
60
|
* @classproperty {string} mot - Mean of transport to be used for routing.
|
|
64
|
-
* @classproperty {object} routingApiParams - object of additional parameters to pass to the routing api request.
|
|
65
|
-
* @classproperty {object} snapToClosestStation - If true, the routing will snap the coordinate to the closest station. Default to false.
|
|
66
|
-
* @classproperty {boolean} useRawViaPoints - Experimental property. Wen true, it allows the user to add via points using different kind of string. See "via" parameter defined by the [geOps Routing API](https://developer.geops.io/apis/routing/). Default to false, only array of coordinates and station's id are supported as via points.
|
|
67
61
|
* @classproperty {VectorLayer} routingLayer - Layer for adding route features.
|
|
68
|
-
* @classproperty {function} onRouteError - Callback on error.
|
|
69
62
|
* @classproperty {boolean} loading - True if the control is requesting the backend.
|
|
63
|
+
*
|
|
70
64
|
* @see <a href="/example/ol-routing">Openlayers routing example</a>
|
|
71
65
|
*
|
|
72
|
-
* @extends {Control}
|
|
73
|
-
*
|
|
66
|
+
* @extends {ol/control/Control~Control}
|
|
67
|
+
*
|
|
74
68
|
* @public
|
|
75
69
|
*/
|
|
76
70
|
class RoutingControl extends Control {
|
|
71
|
+
/**
|
|
72
|
+
* Constructor.
|
|
73
|
+
*
|
|
74
|
+
* @param {Object} options
|
|
75
|
+
* @param {string} options.apiKey Access key for [geOps APIs](https://developer.geops.io/).
|
|
76
|
+
* @param {Object} options.apiParams Request parameters. See [geOps Routing API documentation](https://developer.geops.io/apis/routing/).
|
|
77
|
+
* @param {Array.<Array<graph="osm", minZoom=0, maxZoom=99>>} [options.graphs=[['osm', 0, 99]]] - Array of routing graphs and min/max zoom levels. If you use the control in combination with the [geOps Maps API](https://developer.geops.io/apis/maps/), you may want to use the optimal level of generalizations: "[['gen4', 0, 8], ['gen3', 8, 9], ['gen2', 9, 11], ['gen1', 11, 13], ['osm', 13, 99]]".
|
|
78
|
+
* @param {string} [options.mot="bus"] Mean of transport to be used for routing.
|
|
79
|
+
* @param {function} options.onRouteError Callback on request errors.
|
|
80
|
+
* @param {VectorLayer} [options.routingLayer=new VectorLayer()] Vector layer for adding route features.
|
|
81
|
+
* @param {boolean} [options.snapToClosestStation=false] If true, the routing will snap the coordinate to the closest station. Default to false.
|
|
82
|
+
* @param {StyleLike} options.style Style of the default vector layer.
|
|
83
|
+
* @param {boolean} [options.useRawViaPoints=fale] Experimental property. If true, it allows the user to add via points using different kind of string. See "via" parameter defined by the [geOps Routing API](https://developer.geops.io/apis/routing/). Default to false, only array of coordinates and station's id are supported as via points.
|
|
84
|
+
* @param {string} [options.url='https://api.geops.io/routing/v1/'] [geOps Realtime API](https://developer.geops.io/apis/realtime/) url.
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
77
87
|
constructor(options = {}) {
|
|
78
88
|
super(options);
|
|
79
89
|
this.abortControllers = {};
|
|
@@ -94,7 +104,7 @@ class RoutingControl extends Control {
|
|
|
94
104
|
this.graphs = options.graphs || [['osm', 0, 99]];
|
|
95
105
|
this.mot = options.mot || 'bus';
|
|
96
106
|
this.modify = options.modify !== false;
|
|
97
|
-
this.
|
|
107
|
+
this.apiParams = options.apiParams;
|
|
98
108
|
this.useRawViaPoints = options.useRawViaPoints || false;
|
|
99
109
|
this.snapToClosestStation = options.snapToClosestStation || false;
|
|
100
110
|
this.apiKey = options.apiKey;
|
|
@@ -201,7 +211,7 @@ class RoutingControl extends Control {
|
|
|
201
211
|
* If an index is passed a viaPoint is added at the specified index.
|
|
202
212
|
* If an index is passed and overwrite x is > 0, x viaPoints at the specified
|
|
203
213
|
* index are replaced with a single new viaPoint.
|
|
204
|
-
* @param {
|
|
214
|
+
* @param {string | Coordinate} coordinatesOrString Array of coordinates or a string representing a station
|
|
205
215
|
* @param {number} [index=-1] Integer representing the index of the added viaPoint. If not specified, the viaPoint is added at the end of the array.
|
|
206
216
|
* @param {number} [overwrite=0] Marks the number of viaPoints that are removed at the specified index on add.
|
|
207
217
|
* @public
|
|
@@ -306,7 +316,9 @@ class RoutingControl extends Control {
|
|
|
306
316
|
});
|
|
307
317
|
this.loading = true;
|
|
308
318
|
// Create point features for the viaPoints
|
|
309
|
-
this.viaPoints.forEach((viaPoint, idx) =>
|
|
319
|
+
this.viaPoints.forEach((viaPoint, idx) => {
|
|
320
|
+
this.drawViaPoint(viaPoint, idx, this.abortControllers[STOP_FETCH_ABORT_CONTROLLER_KEY]);
|
|
321
|
+
});
|
|
310
322
|
return Promise.all(this.graphs.map(([graph], index) => {
|
|
311
323
|
const { signal } = this.abortControllers[graph];
|
|
312
324
|
if (!this.api) {
|
|
@@ -315,7 +327,7 @@ class RoutingControl extends Control {
|
|
|
315
327
|
return this.api
|
|
316
328
|
.route(Object.assign({ 'coord-punish': 1000.0, 'coord-radius': 100.0,
|
|
317
329
|
// @ts-expect-error missing property in swagger
|
|
318
|
-
elevation: false, graph, mot: this.mot, 'resolve-hops': false, via: `${formattedViaPoints.join('|')}` }, (this.
|
|
330
|
+
elevation: false, graph, mot: this.mot, 'resolve-hops': false, via: `${formattedViaPoints.join('|')}` }, (this.apiParams || {})), { signal })
|
|
319
331
|
.then((featureCollection) => {
|
|
320
332
|
var _a, _b, _c;
|
|
321
333
|
this.segments = this.format.readFeatures(featureCollection);
|
|
@@ -355,8 +367,7 @@ class RoutingControl extends Control {
|
|
|
355
367
|
this.loading = false;
|
|
356
368
|
})
|
|
357
369
|
.catch((error) => {
|
|
358
|
-
|
|
359
|
-
if (/AbortError/.test(error.message)) {
|
|
370
|
+
if (/AbortError/.test(error.name)) {
|
|
360
371
|
// Ignore abort error
|
|
361
372
|
return;
|
|
362
373
|
}
|
|
@@ -364,7 +375,6 @@ class RoutingControl extends Control {
|
|
|
364
375
|
// Dispatch error event and execute error function
|
|
365
376
|
this.dispatchEvent(new BaseEvent('error'));
|
|
366
377
|
this.onRouteError(error, this);
|
|
367
|
-
(_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear();
|
|
368
378
|
this.loading = false;
|
|
369
379
|
});
|
|
370
380
|
}));
|
|
@@ -401,15 +411,19 @@ class RoutingControl extends Control {
|
|
|
401
411
|
return fetch(`${this.stopsApiUrl}lookup/${stationId}?key=${this.stopsApiKey}`, { signal: abortController.signal })
|
|
402
412
|
.then((res) => res.json())
|
|
403
413
|
.then((stationData) => {
|
|
404
|
-
var _a, _b;
|
|
405
|
-
const { coordinates } = stationData.features[0].geometry;
|
|
414
|
+
var _a, _b, _c, _d;
|
|
415
|
+
const { coordinates } = ((_b = (_a = stationData === null || stationData === void 0 ? void 0 : stationData.features) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.geometry) || {};
|
|
416
|
+
if (!coordinates) {
|
|
417
|
+
console.log('No coordinates found for station ' + stationId, stationData);
|
|
418
|
+
}
|
|
406
419
|
this.cacheStationData[viaPoint] = fromLonLat(coordinates);
|
|
407
420
|
pointFeature.set('viaPointTrack', track);
|
|
408
421
|
pointFeature.setGeometry(new Point(fromLonLat(coordinates)));
|
|
409
|
-
(
|
|
422
|
+
(_d = (_c = this.routingLayer) === null || _c === void 0 ? void 0 : _c.getSource()) === null || _d === void 0 ? void 0 : _d.addFeature(pointFeature);
|
|
410
423
|
return pointFeature;
|
|
411
424
|
})
|
|
412
425
|
.catch((error) => {
|
|
426
|
+
var _a, _b;
|
|
413
427
|
if (/AbortError/.test(error.message)) {
|
|
414
428
|
// Ignore abort error
|
|
415
429
|
return;
|
|
@@ -417,6 +431,7 @@ class RoutingControl extends Control {
|
|
|
417
431
|
// Dispatch error event and execute error function
|
|
418
432
|
this.dispatchEvent(new BaseEvent('error'));
|
|
419
433
|
this.onRouteError(error, this);
|
|
434
|
+
(_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear();
|
|
420
435
|
this.loading = false;
|
|
421
436
|
});
|
|
422
437
|
}
|
|
@@ -549,7 +564,7 @@ class RoutingControl extends Control {
|
|
|
549
564
|
if ((route === null || route === void 0 ? void 0 : route.getGeometry()) && evt.mapBrowserEvent.coordinate) {
|
|
550
565
|
// We use a buff extent to fix floating issues , see https://github.com/openlayers/openlayers/issues/7130#issuecomment-535856422
|
|
551
566
|
const closestExtent = buffer(new Point(
|
|
552
|
-
// @ts-expect-error
|
|
567
|
+
// @ts-expect-error bad def
|
|
553
568
|
(_a = route.getGeometry()) === null || _a === void 0 ? void 0 : _a.getClosestPoint(evt.mapBrowserEvent.coordinate)).getExtent(), 0.001);
|
|
554
569
|
segmentIndex = this.segments.findIndex((segment) => { var _a; return (_a = segment.getGeometry()) === null || _a === void 0 ? void 0 : _a.intersectsExtent(closestExtent); });
|
|
555
570
|
}
|
|
@@ -560,7 +575,7 @@ class RoutingControl extends Control {
|
|
|
560
575
|
[])[0];
|
|
561
576
|
// Write object with modify info
|
|
562
577
|
this.initialRouteDrag = {
|
|
563
|
-
oldRoute: route
|
|
578
|
+
oldRoute: route === null || route === void 0 ? void 0 : route.clone(),
|
|
564
579
|
segmentIndex,
|
|
565
580
|
viaPoint,
|
|
566
581
|
};
|
|
@@ -23,12 +23,34 @@ export type StopFinderControlOptions = {
|
|
|
23
23
|
*
|
|
24
24
|
*
|
|
25
25
|
* @see <a href="/example/ol-search">Openlayers search example</a>
|
|
26
|
+
*
|
|
27
|
+
* @extends {ol/control/Control~Control}
|
|
28
|
+
*
|
|
26
29
|
* @public
|
|
27
30
|
*/
|
|
28
31
|
declare class StopFinderControl extends Control {
|
|
29
32
|
controller: StopFinderControlCommon;
|
|
33
|
+
/**
|
|
34
|
+
* Constructor.
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} options
|
|
37
|
+
* @param {HTMLElement} options.element HTML element where to attach input and suggestions.
|
|
38
|
+
* @param {string} options.apiKey Access key for [geOps APIs](https://developer.geops.io/).
|
|
39
|
+
* @param {StopsSearchParams} [options.apiParams={ limit: 20 }] Request parameters. See [geOps Stops API documentation](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
|
|
40
|
+
* @param {string} [options.placeholder='Search for a stop...'] Input field placeholder.
|
|
41
|
+
* @param {string} [options.url='https://api.geops.io/stops/v1/'] [geOps Stops API](https://developer.geops.io/apis/stops/) url.
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
30
44
|
constructor(options: StopFinderControlOptions);
|
|
31
45
|
onSuggestionClick(suggestion: Feature): void;
|
|
46
|
+
/**
|
|
47
|
+
* Search for stations using a query.
|
|
48
|
+
*
|
|
49
|
+
* @param {string} q Query used to search stops.
|
|
50
|
+
* @param {AbortController} abortController Abort controller used to abort requests.
|
|
51
|
+
* @returns {Promise<Array<GeoJSONFeature>>}
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
32
54
|
search(q: string, abortController: AbortController): Promise<void>;
|
|
33
55
|
}
|
|
34
56
|
export default StopFinderControl;
|
|
@@ -21,9 +21,23 @@ import createDefaultStopFinderElement from '../../common/utils/createDefaultStop
|
|
|
21
21
|
*
|
|
22
22
|
*
|
|
23
23
|
* @see <a href="/example/ol-search">Openlayers search example</a>
|
|
24
|
+
*
|
|
25
|
+
* @extends {ol/control/Control~Control}
|
|
26
|
+
*
|
|
24
27
|
* @public
|
|
25
28
|
*/
|
|
26
29
|
class StopFinderControl extends Control {
|
|
30
|
+
/**
|
|
31
|
+
* Constructor.
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} options
|
|
34
|
+
* @param {HTMLElement} options.element HTML element where to attach input and suggestions.
|
|
35
|
+
* @param {string} options.apiKey Access key for [geOps APIs](https://developer.geops.io/).
|
|
36
|
+
* @param {StopsSearchParams} [options.apiParams={ limit: 20 }] Request parameters. See [geOps Stops API documentation](https://developer.geops.io/apis/5dcbd702a256d90001cf1361/).
|
|
37
|
+
* @param {string} [options.placeholder='Search for a stop...'] Input field placeholder.
|
|
38
|
+
* @param {string} [options.url='https://api.geops.io/stops/v1/'] [geOps Stops API](https://developer.geops.io/apis/stops/) url.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
27
41
|
constructor(options) {
|
|
28
42
|
const element = createDefaultStopFinderElement();
|
|
29
43
|
element.className = (options === null || options === void 0 ? void 0 : options.className) || 'mbt-stop-finder';
|
|
@@ -36,6 +50,14 @@ class StopFinderControl extends Control {
|
|
|
36
50
|
const coord = fromLonLat(suggestion.geometry.coordinates);
|
|
37
51
|
(_a = this.getMap()) === null || _a === void 0 ? void 0 : _a.getView().setCenter(coord);
|
|
38
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Search for stations using a query.
|
|
55
|
+
*
|
|
56
|
+
* @param {string} q Query used to search stops.
|
|
57
|
+
* @param {AbortController} abortController Abort controller used to abort requests.
|
|
58
|
+
* @returns {Promise<Array<GeoJSONFeature>>}
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
39
61
|
search(q, abortController) {
|
|
40
62
|
return this.controller.search(q, abortController);
|
|
41
63
|
}
|
|
@@ -125,7 +125,12 @@ declare const MaplibreLayer_base: {
|
|
|
125
125
|
*
|
|
126
126
|
* @classproperty {maplibregl.Map} mapLibreMap - The Maplibre map object. Readonly.
|
|
127
127
|
* @classproperty {string} style - The [geOps Maps API](https://developer.geops.io/apis/maps) style.
|
|
128
|
-
*
|
|
128
|
+
*
|
|
129
|
+
*
|
|
130
|
+
* @see <a href="/example/ol-maplibre-layer">OpenLayers Maplibre layer example</a>
|
|
131
|
+
*
|
|
132
|
+
* @extends {ol/layer/Layer~Layer}
|
|
133
|
+
* @extends {geoblocks/ol-maplibre-layer/MapLibreLayer}
|
|
129
134
|
* @public
|
|
130
135
|
*/
|
|
131
136
|
declare class MaplibreLayer extends MaplibreLayer_base {
|
|
@@ -38,7 +38,12 @@ if (typeof window !== 'undefined' &&
|
|
|
38
38
|
*
|
|
39
39
|
* @classproperty {maplibregl.Map} mapLibreMap - The Maplibre map object. Readonly.
|
|
40
40
|
* @classproperty {string} style - The [geOps Maps API](https://developer.geops.io/apis/maps) style.
|
|
41
|
-
*
|
|
41
|
+
*
|
|
42
|
+
*
|
|
43
|
+
* @see <a href="/example/ol-maplibre-layer">OpenLayers Maplibre layer example</a>
|
|
44
|
+
*
|
|
45
|
+
* @extends {ol/layer/Layer~Layer}
|
|
46
|
+
* @extends {geoblocks/ol-maplibre-layer/MapLibreLayer}
|
|
42
47
|
* @public
|
|
43
48
|
*/
|
|
44
49
|
class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
@@ -36,12 +36,7 @@ declare const MaplibreStyleLayer_base: {
|
|
|
36
36
|
olLayer: Layer;
|
|
37
37
|
parent: Layer<Source, import("ol/renderer/Layer").default<any>>;
|
|
38
38
|
visible: boolean;
|
|
39
|
-
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events"
|
|
40
|
-
* Request feature information for a given coordinate.
|
|
41
|
-
* @param {ol/coordinate~Coordinate} coordinate Coordinate to request the information at.
|
|
42
|
-
* @return {Promise<FeatureInfo>} Promise with features, layer and coordinate.
|
|
43
|
-
* @deprecated Use getFeatureInfoAtCoordinate([layer], coordinate) from mobility-toolbox-ol package instead.
|
|
44
|
-
*/).EventsKey>;
|
|
39
|
+
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
45
40
|
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
46
41
|
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
47
42
|
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
@@ -128,6 +123,7 @@ declare const MaplibreStyleLayer_base: {
|
|
|
128
123
|
* },
|
|
129
124
|
* });
|
|
130
125
|
*
|
|
126
|
+
* @see <a href="/example/ol-maplibre-style-layer">OpenLayers MaplibreStyle layer example</a>
|
|
131
127
|
* @extends {ol/layer/Layer~Layer}
|
|
132
128
|
* @public
|
|
133
129
|
*/
|
|
@@ -143,7 +139,7 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
143
139
|
* @param {FilterFunction} [options.layersFilter] Filter function to decide which style layer to apply visiblity on. If not provided, the 'layers' property is used.
|
|
144
140
|
* @param {MaplibreLayer} [options.maplibreLayer] The MaplibreLayer to use.
|
|
145
141
|
* @param {FilterFunction} [options.queryRenderedLayersFilter] Filter function to decide which style layer are available for query.
|
|
146
|
-
* @param {maplibregl.SourceSpecification
|
|
142
|
+
* @param {{[id: string]:maplibregl.SourceSpecification}} [options.sources] The sources to add to the style on load.
|
|
147
143
|
* @public
|
|
148
144
|
*/
|
|
149
145
|
constructor(options?: MaplibreStyleLayerOptions);
|
|
@@ -196,10 +192,10 @@ declare class MaplibreStyleLayer extends MaplibreStyleLayer_base {
|
|
|
196
192
|
*/
|
|
197
193
|
select(features?: Feature[]): void;
|
|
198
194
|
/**
|
|
199
|
-
* Set the feature state of the features.
|
|
195
|
+
* Set the [feature state](https://maplibre.org/maplibre-style-spec/expressions/#feature-state) of the features.
|
|
200
196
|
*
|
|
201
197
|
* @param {ol/Feature~Feature[]} features
|
|
202
|
-
* @param {
|
|
198
|
+
* @param {{[key: string]: any}} state The feature state
|
|
203
199
|
* @public
|
|
204
200
|
*/
|
|
205
201
|
setFeatureState(features: Feature[], state: FeatureState): void;
|
|
@@ -30,6 +30,7 @@ if (typeof window !== 'undefined' &&
|
|
|
30
30
|
* },
|
|
31
31
|
* });
|
|
32
32
|
*
|
|
33
|
+
* @see <a href="/example/ol-maplibre-style-layer">OpenLayers MaplibreStyle layer example</a>
|
|
33
34
|
* @extends {ol/layer/Layer~Layer}
|
|
34
35
|
* @public
|
|
35
36
|
*/
|
|
@@ -43,7 +44,7 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
|
|
|
43
44
|
* @param {FilterFunction} [options.layersFilter] Filter function to decide which style layer to apply visiblity on. If not provided, the 'layers' property is used.
|
|
44
45
|
* @param {MaplibreLayer} [options.maplibreLayer] The MaplibreLayer to use.
|
|
45
46
|
* @param {FilterFunction} [options.queryRenderedLayersFilter] Filter function to decide which style layer are available for query.
|
|
46
|
-
* @param {maplibregl.SourceSpecification
|
|
47
|
+
* @param {{[id: string]:maplibregl.SourceSpecification}} [options.sources] The sources to add to the style on load.
|
|
47
48
|
* @public
|
|
48
49
|
*/
|
|
49
50
|
constructor(options = {
|
|
@@ -245,6 +246,7 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
|
|
|
245
246
|
let layers = this.layers || [];
|
|
246
247
|
if (this.layersFilter) {
|
|
247
248
|
layers = mapLibreMap.getStyle().layers.filter(this.layersFilter);
|
|
249
|
+
console.log(layers);
|
|
248
250
|
}
|
|
249
251
|
if (this.queryRenderedLayersFilter) {
|
|
250
252
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -353,10 +355,10 @@ class MaplibreStyleLayer extends MobilityLayerMixin(Layer) {
|
|
|
353
355
|
this.setHoverState(this.selectedFeatures || [], true);
|
|
354
356
|
}
|
|
355
357
|
/**
|
|
356
|
-
* Set the feature state of the features.
|
|
358
|
+
* Set the [feature state](https://maplibre.org/maplibre-style-spec/expressions/#feature-state) of the features.
|
|
357
359
|
*
|
|
358
360
|
* @param {ol/Feature~Feature[]} features
|
|
359
|
-
* @param {
|
|
361
|
+
* @param {{[key: string]: any}} state The feature state
|
|
360
362
|
* @public
|
|
361
363
|
*/
|
|
362
364
|
setFeatureState(features, state) {
|
|
@@ -8,6 +8,7 @@ import { Vector as VectorSource } from 'ol/source';
|
|
|
8
8
|
import Source from 'ol/source/Source';
|
|
9
9
|
import { State } from 'ol/View';
|
|
10
10
|
import { WebSocketAPIMessageEventData } from '../../api/WebSocketAPI';
|
|
11
|
+
import { FilterFunction, SortFunction } from '../../common/typedefs';
|
|
11
12
|
import RealtimeEngine, { RealtimeEngineOptions } from '../../common/utils/RealtimeEngine';
|
|
12
13
|
import { RealtimeAPI } from '../../maplibre';
|
|
13
14
|
import { RealtimeFullTrajectory, RealtimeMode, RealtimeRenderState, RealtimeTrainId, ViewState } from '../../types';
|
|
@@ -121,9 +122,12 @@ declare const RealtimeLayer_base: {
|
|
|
121
122
|
*
|
|
122
123
|
*
|
|
123
124
|
* @see <a href="/api/class/src/api/RealtimeAPI%20js~RealtimeAPI%20html">RealtimeAPI</a>
|
|
125
|
+
* @see <a href="/example/ol-realtime">OpenLayers Realtime layer example</a>
|
|
126
|
+
*
|
|
124
127
|
*
|
|
125
128
|
* @extends {ol/layer/Layer~Layer}
|
|
126
129
|
*
|
|
130
|
+
*
|
|
127
131
|
* @classproperty {boolean} allowRenderWhenAnimating - Allow rendering of the layer when the map is animating.
|
|
128
132
|
* @public
|
|
129
133
|
*/
|
|
@@ -143,7 +147,7 @@ declare class RealtimeLayer extends RealtimeLayer_base {
|
|
|
143
147
|
* @param {boolean} [options.allowRenderWhenAnimating=false] Allow rendering of the layer when the map is animating.
|
|
144
148
|
* @param {string} options.apiKey Access key for [geOps APIs](https://developer.geops.io/).
|
|
145
149
|
* @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The [geOps Realtime API](https://developer.geops.io/apis/realtime/) url.
|
|
146
|
-
*
|
|
150
|
+
* @public
|
|
147
151
|
*/
|
|
148
152
|
constructor(options: RealtimeLayerOptions);
|
|
149
153
|
attachToMap(map: Map): void;
|
|
@@ -170,6 +174,7 @@ declare class RealtimeLayer extends RealtimeLayer_base {
|
|
|
170
174
|
fullTrajectory: WebSocketAPIMessageEventData<RealtimeFullTrajectory> | WebSocketAPIMessageEventData<import("../../types").RealtimeStopSequence[]>;
|
|
171
175
|
stopSequence: WebSocketAPIMessageEventData<RealtimeFullTrajectory> | WebSocketAPIMessageEventData<import("../../types").RealtimeStopSequence[]>;
|
|
172
176
|
}>;
|
|
177
|
+
getVehicles(filterFunc: FilterFunction): import("../../types").RealtimeTrajectory[];
|
|
173
178
|
getViewState(): {
|
|
174
179
|
center?: undefined;
|
|
175
180
|
extent?: undefined;
|
|
@@ -217,7 +222,8 @@ declare class RealtimeLayer extends RealtimeLayer_base {
|
|
|
217
222
|
get api(): RealtimeAPI;
|
|
218
223
|
set api(api: RealtimeAPI);
|
|
219
224
|
get canvas(): import("../../types").AnyCanvas | undefined;
|
|
220
|
-
get filter():
|
|
225
|
+
get filter(): FilterFunction | undefined;
|
|
226
|
+
set filter(filter: FilterFunction);
|
|
221
227
|
get hoverVehicleId(): RealtimeTrainId | undefined;
|
|
222
228
|
set hoverVehicleId(id: RealtimeTrainId);
|
|
223
229
|
get mode(): RealtimeMode;
|
|
@@ -225,7 +231,8 @@ declare class RealtimeLayer extends RealtimeLayer_base {
|
|
|
225
231
|
get pixelRatio(): number | undefined;
|
|
226
232
|
get selectedVehicleId(): RealtimeTrainId | undefined;
|
|
227
233
|
set selectedVehicleId(id: RealtimeTrainId);
|
|
228
|
-
get sort():
|
|
234
|
+
get sort(): SortFunction | undefined;
|
|
235
|
+
set sort(sort: SortFunction);
|
|
229
236
|
get trajectories(): Record<string, import("../../types").RealtimeTrajectory> | undefined;
|
|
230
237
|
}
|
|
231
238
|
export default RealtimeLayer;
|
|
@@ -23,9 +23,12 @@ const format = new GeoJSON();
|
|
|
23
23
|
*
|
|
24
24
|
*
|
|
25
25
|
* @see <a href="/api/class/src/api/RealtimeAPI%20js~RealtimeAPI%20html">RealtimeAPI</a>
|
|
26
|
+
* @see <a href="/example/ol-realtime">OpenLayers Realtime layer example</a>
|
|
27
|
+
*
|
|
26
28
|
*
|
|
27
29
|
* @extends {ol/layer/Layer~Layer}
|
|
28
30
|
*
|
|
31
|
+
*
|
|
29
32
|
* @classproperty {boolean} allowRenderWhenAnimating - Allow rendering of the layer when the map is animating.
|
|
30
33
|
* @public
|
|
31
34
|
*/
|
|
@@ -37,7 +40,7 @@ class RealtimeLayer extends MobilityLayerMixin(Layer) {
|
|
|
37
40
|
* @param {boolean} [options.allowRenderWhenAnimating=false] Allow rendering of the layer when the map is animating.
|
|
38
41
|
* @param {string} options.apiKey Access key for [geOps APIs](https://developer.geops.io/).
|
|
39
42
|
* @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The [geOps Realtime API](https://developer.geops.io/apis/realtime/) url.
|
|
40
|
-
*
|
|
43
|
+
* @public
|
|
41
44
|
*/
|
|
42
45
|
constructor(options) {
|
|
43
46
|
// We use a group to be able to add custom vector layer in extended class.
|
|
@@ -142,6 +145,9 @@ class RealtimeLayer extends MobilityLayerMixin(Layer) {
|
|
|
142
145
|
return response;
|
|
143
146
|
});
|
|
144
147
|
}
|
|
148
|
+
getVehicles(filterFunc) {
|
|
149
|
+
return this.engine.getVehicles(filterFunc);
|
|
150
|
+
}
|
|
145
151
|
getViewState() {
|
|
146
152
|
var _a;
|
|
147
153
|
if (!((_a = this.map) === null || _a === void 0 ? void 0 : _a.getView())) {
|
|
@@ -264,6 +270,9 @@ class RealtimeLayer extends MobilityLayerMixin(Layer) {
|
|
|
264
270
|
get filter() {
|
|
265
271
|
return this.engine.filter;
|
|
266
272
|
}
|
|
273
|
+
set filter(filter) {
|
|
274
|
+
this.engine.filter = filter;
|
|
275
|
+
}
|
|
267
276
|
get hoverVehicleId() {
|
|
268
277
|
return this.engine.hoverVehicleId;
|
|
269
278
|
}
|
|
@@ -288,6 +297,9 @@ class RealtimeLayer extends MobilityLayerMixin(Layer) {
|
|
|
288
297
|
get sort() {
|
|
289
298
|
return this.engine.sort;
|
|
290
299
|
}
|
|
300
|
+
set sort(sort) {
|
|
301
|
+
this.engine.sort = sort;
|
|
302
|
+
}
|
|
291
303
|
get trajectories() {
|
|
292
304
|
return this.engine.trajectories;
|
|
293
305
|
}
|