mobility-toolbox-js 3.0.0-beta.34 → 3.0.0-beta.36
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/common/utils/RealtimeEngine.d.ts +1 -1
- package/common/utils/RealtimeEngine.js +1 -1
- package/mbt.js +23 -5
- package/mbt.js.map +2 -2
- package/mbt.min.js +27 -27
- package/mbt.min.js.map +3 -3
- package/ol/controls/RoutingControl.js +9 -6
- package/ol/layers/MaplibreLayer.d.ts +8 -9
- package/ol/layers/MaplibreLayer.js +5 -0
- package/ol/layers/RealtimeLayer.d.ts +6 -2
- package/ol/layers/RealtimeLayer.js +9 -0
- package/ol/mixins/PropertiesLayerMixin.d.ts +1 -1
- package/ol/mixins/PropertiesLayerMixin.js +1 -2
- package/package.json +1 -1
|
@@ -367,8 +367,7 @@ class RoutingControl extends Control {
|
|
|
367
367
|
this.loading = false;
|
|
368
368
|
})
|
|
369
369
|
.catch((error) => {
|
|
370
|
-
|
|
371
|
-
if (/AbortError/.test(error.message)) {
|
|
370
|
+
if (/AbortError/.test(error.name)) {
|
|
372
371
|
// Ignore abort error
|
|
373
372
|
return;
|
|
374
373
|
}
|
|
@@ -376,7 +375,6 @@ class RoutingControl extends Control {
|
|
|
376
375
|
// Dispatch error event and execute error function
|
|
377
376
|
this.dispatchEvent(new BaseEvent('error'));
|
|
378
377
|
this.onRouteError(error, this);
|
|
379
|
-
(_b = (_a = this.routingLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear();
|
|
380
378
|
this.loading = false;
|
|
381
379
|
});
|
|
382
380
|
}));
|
|
@@ -413,15 +411,19 @@ class RoutingControl extends Control {
|
|
|
413
411
|
return fetch(`${this.stopsApiUrl}lookup/${stationId}?key=${this.stopsApiKey}`, { signal: abortController.signal })
|
|
414
412
|
.then((res) => res.json())
|
|
415
413
|
.then((stationData) => {
|
|
416
|
-
var _a, _b;
|
|
417
|
-
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
|
+
}
|
|
418
419
|
this.cacheStationData[viaPoint] = fromLonLat(coordinates);
|
|
419
420
|
pointFeature.set('viaPointTrack', track);
|
|
420
421
|
pointFeature.setGeometry(new Point(fromLonLat(coordinates)));
|
|
421
|
-
(
|
|
422
|
+
(_d = (_c = this.routingLayer) === null || _c === void 0 ? void 0 : _c.getSource()) === null || _d === void 0 ? void 0 : _d.addFeature(pointFeature);
|
|
422
423
|
return pointFeature;
|
|
423
424
|
})
|
|
424
425
|
.catch((error) => {
|
|
426
|
+
var _a, _b;
|
|
425
427
|
if (/AbortError/.test(error.message)) {
|
|
426
428
|
// Ignore abort error
|
|
427
429
|
return;
|
|
@@ -429,6 +431,7 @@ class RoutingControl extends Control {
|
|
|
429
431
|
// Dispatch error event and execute error function
|
|
430
432
|
this.dispatchEvent(new BaseEvent('error'));
|
|
431
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();
|
|
432
435
|
this.loading = false;
|
|
433
436
|
});
|
|
434
437
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { MapLibreLayer } from '@geoblocks/ol-maplibre-layer';
|
|
2
2
|
import OlMap from 'ol/Map';
|
|
3
3
|
import { MobilityLayerOptions } from '../mixins/MobilityLayerMixin';
|
|
4
|
-
import type { MapLibreOptions } from '@geoblocks/ol-maplibre-layer/lib/types/MapLibreLayer';
|
|
4
|
+
import type { MapLibreLayerOptions, MapLibreOptions } from '@geoblocks/ol-maplibre-layer/lib/types/MapLibreLayer';
|
|
5
5
|
import type { QueryRenderedFeaturesOptions } from 'maplibre-gl';
|
|
6
|
-
import type { Options as LayerOptions } from 'ol/layer/Layer';
|
|
7
6
|
export type MaplibreLayerOptions = {
|
|
8
7
|
apiKey?: string;
|
|
9
8
|
apiKeyName?: string;
|
|
@@ -11,7 +10,7 @@ export type MaplibreLayerOptions = {
|
|
|
11
10
|
queryRenderedFeaturesOptions?: QueryRenderedFeaturesOptions | undefined;
|
|
12
11
|
style?: maplibregl.StyleSpecification | null | string;
|
|
13
12
|
url?: string;
|
|
14
|
-
} &
|
|
13
|
+
} & MapLibreLayerOptions & MobilityLayerOptions;
|
|
15
14
|
declare const MaplibreLayer_base: {
|
|
16
15
|
new (...args: any[]): {
|
|
17
16
|
olEventsKeys: import("ol/events").EventsKey[];
|
|
@@ -19,9 +18,9 @@ declare const MaplibreLayer_base: {
|
|
|
19
18
|
attachToMap(map: OlMap): void;
|
|
20
19
|
detachFromMap(): void;
|
|
21
20
|
flat(): any[];
|
|
22
|
-
onChildrenChange(oldValue: import("ol/layer
|
|
21
|
+
onChildrenChange(oldValue: import("ol/layer").Layer[]): void;
|
|
23
22
|
setMapInternal: ((map: OlMap) => void) & ((map: import("ol/Map").default | null) => void);
|
|
24
|
-
children: import("ol/layer
|
|
23
|
+
children: import("ol/layer").Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
25
24
|
get copyrights(): string;
|
|
26
25
|
set copyrights(newCopyrights: string | string[]);
|
|
27
26
|
disabled: boolean;
|
|
@@ -30,8 +29,8 @@ declare const MaplibreLayer_base: {
|
|
|
30
29
|
readonly key: string;
|
|
31
30
|
readonly map: OlMap;
|
|
32
31
|
readonly name: string;
|
|
33
|
-
olLayer: import("ol/layer
|
|
34
|
-
parent: import("ol/layer
|
|
32
|
+
olLayer: import("ol/layer").Layer;
|
|
33
|
+
parent: import("ol/layer").Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
35
34
|
visible: boolean;
|
|
36
35
|
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
37
36
|
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
@@ -55,7 +54,7 @@ declare const MaplibreLayer_base: {
|
|
|
55
54
|
getBackground: () => import("ol/layer/Base").BackgroundColor | false;
|
|
56
55
|
getClassName: () => string;
|
|
57
56
|
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
58
|
-
getLayersArray: (array?: import("ol/layer
|
|
57
|
+
getLayersArray: (array?: import("ol/layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer").default>;
|
|
59
58
|
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
|
|
60
59
|
getExtent: () => import("ol/extent").Extent | undefined;
|
|
61
60
|
getMaxResolution: () => number;
|
|
@@ -158,7 +157,7 @@ declare class MaplibreLayer extends MaplibreLayer_base {
|
|
|
158
157
|
* @public
|
|
159
158
|
*/
|
|
160
159
|
clone(newOptions: MaplibreLayerOptions): MaplibreLayer;
|
|
161
|
-
getStyle():
|
|
160
|
+
getStyle(): any;
|
|
162
161
|
updateMaplibreMap(): void;
|
|
163
162
|
set apiKey(newValue: string);
|
|
164
163
|
get apiKey(): string;
|
|
@@ -105,6 +105,7 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
105
105
|
return new MaplibreLayer(Object.assign(Object.assign({}, (this.options || {})), (newOptions || {})));
|
|
106
106
|
}
|
|
107
107
|
getStyle() {
|
|
108
|
+
var _a;
|
|
108
109
|
// If the style is a complete style object, use it directly.
|
|
109
110
|
if (this.style &&
|
|
110
111
|
typeof this.style === 'object' &&
|
|
@@ -116,6 +117,10 @@ class MaplibreLayer extends MobilityLayerMixin(MapLibreLayer) {
|
|
|
116
117
|
if (this.url.includes('style.json')) {
|
|
117
118
|
return this.url;
|
|
118
119
|
}
|
|
120
|
+
// If the style is defined by the maplibreOptions, we use it directly
|
|
121
|
+
if ((_a = this.get('mapLibreOptions')) === null || _a === void 0 ? void 0 : _a.style) {
|
|
122
|
+
return this.get('mapLibreOptions').style;
|
|
123
|
+
}
|
|
119
124
|
/// Otherwise build the complete style url.
|
|
120
125
|
return buildStyleUrl(this.url, this.style, this.apiKey, this.apiKeyName);
|
|
121
126
|
}
|
|
@@ -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';
|
|
@@ -173,6 +174,7 @@ declare class RealtimeLayer extends RealtimeLayer_base {
|
|
|
173
174
|
fullTrajectory: WebSocketAPIMessageEventData<RealtimeFullTrajectory> | WebSocketAPIMessageEventData<import("../../types").RealtimeStopSequence[]>;
|
|
174
175
|
stopSequence: WebSocketAPIMessageEventData<RealtimeFullTrajectory> | WebSocketAPIMessageEventData<import("../../types").RealtimeStopSequence[]>;
|
|
175
176
|
}>;
|
|
177
|
+
getVehicles(filterFunc: FilterFunction): import("../../types").RealtimeTrajectory[];
|
|
176
178
|
getViewState(): {
|
|
177
179
|
center?: undefined;
|
|
178
180
|
extent?: undefined;
|
|
@@ -220,7 +222,8 @@ declare class RealtimeLayer extends RealtimeLayer_base {
|
|
|
220
222
|
get api(): RealtimeAPI;
|
|
221
223
|
set api(api: RealtimeAPI);
|
|
222
224
|
get canvas(): import("../../types").AnyCanvas | undefined;
|
|
223
|
-
get filter():
|
|
225
|
+
get filter(): FilterFunction | undefined;
|
|
226
|
+
set filter(filter: FilterFunction);
|
|
224
227
|
get hoverVehicleId(): RealtimeTrainId | undefined;
|
|
225
228
|
set hoverVehicleId(id: RealtimeTrainId);
|
|
226
229
|
get mode(): RealtimeMode;
|
|
@@ -228,7 +231,8 @@ declare class RealtimeLayer extends RealtimeLayer_base {
|
|
|
228
231
|
get pixelRatio(): number | undefined;
|
|
229
232
|
get selectedVehicleId(): RealtimeTrainId | undefined;
|
|
230
233
|
set selectedVehicleId(id: RealtimeTrainId);
|
|
231
|
-
get sort():
|
|
234
|
+
get sort(): SortFunction | undefined;
|
|
235
|
+
set sort(sort: SortFunction);
|
|
232
236
|
get trajectories(): Record<string, import("../../types").RealtimeTrajectory> | undefined;
|
|
233
237
|
}
|
|
234
238
|
export default RealtimeLayer;
|
|
@@ -145,6 +145,9 @@ class RealtimeLayer extends MobilityLayerMixin(Layer) {
|
|
|
145
145
|
return response;
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
+
getVehicles(filterFunc) {
|
|
149
|
+
return this.engine.getVehicles(filterFunc);
|
|
150
|
+
}
|
|
148
151
|
getViewState() {
|
|
149
152
|
var _a;
|
|
150
153
|
if (!((_a = this.map) === null || _a === void 0 ? void 0 : _a.getView())) {
|
|
@@ -267,6 +270,9 @@ class RealtimeLayer extends MobilityLayerMixin(Layer) {
|
|
|
267
270
|
get filter() {
|
|
268
271
|
return this.engine.filter;
|
|
269
272
|
}
|
|
273
|
+
set filter(filter) {
|
|
274
|
+
this.engine.filter = filter;
|
|
275
|
+
}
|
|
270
276
|
get hoverVehicleId() {
|
|
271
277
|
return this.engine.hoverVehicleId;
|
|
272
278
|
}
|
|
@@ -291,6 +297,9 @@ class RealtimeLayer extends MobilityLayerMixin(Layer) {
|
|
|
291
297
|
get sort() {
|
|
292
298
|
return this.engine.sort;
|
|
293
299
|
}
|
|
300
|
+
set sort(sort) {
|
|
301
|
+
this.engine.sort = sort;
|
|
302
|
+
}
|
|
294
303
|
get trajectories() {
|
|
295
304
|
return this.engine.trajectories;
|
|
296
305
|
}
|
|
@@ -84,7 +84,7 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
84
84
|
getBackground: () => import("ol/layer/Base").BackgroundColor | false;
|
|
85
85
|
getClassName: () => string;
|
|
86
86
|
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
87
|
-
getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer"
|
|
87
|
+
getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
|
|
88
88
|
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
|
|
89
89
|
getExtent: () => import("ol/extent").Extent | undefined;
|
|
90
90
|
getMaxResolution: () => number;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// eslint-disable-next-line max-classes-per-file
|
|
2
2
|
import debounce from 'lodash.debounce';
|
|
3
|
-
import { getUid } from 'ol';
|
|
4
3
|
import { unByKey } from 'ol/Observable';
|
|
5
4
|
import getLayersAsFlatArray from '../../common/utils/getLayersAsFlatArray';
|
|
6
5
|
let deprecated = () => { };
|
|
@@ -134,7 +133,7 @@ function PropertiesLayerMixin(Base) {
|
|
|
134
133
|
this.set('hitTolerance', newValue);
|
|
135
134
|
}
|
|
136
135
|
get key() {
|
|
137
|
-
return this.get('key') || this.get('name')
|
|
136
|
+
return this.get('key') || this.get('name');
|
|
138
137
|
}
|
|
139
138
|
get map() {
|
|
140
139
|
return this.getMapInternal();
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "mobility-toolbox-js",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"description": "Toolbox for JavaScript applications in the domains of mobility and logistics.",
|
|
5
|
-
"version": "3.0.0-beta.
|
|
5
|
+
"version": "3.0.0-beta.36",
|
|
6
6
|
"homepage": "https://mobility-toolbox-js.geops.io/",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./index.js",
|