mobility-toolbox-js 2.0.0 → 2.1.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/api/RealtimeAPI.d.ts +279 -0
- package/api/RealtimeAPI.d.ts.map +1 -0
- package/api/RealtimeAPI.js +466 -0
- package/api/RoutingAPI.d.ts +37 -0
- package/api/RoutingAPI.d.ts.map +1 -0
- package/api/RoutingAPI.js +35 -0
- package/api/StopsAPI.d.ts +38 -0
- package/api/StopsAPI.d.ts.map +1 -0
- package/api/StopsAPI.js +36 -0
- package/api/index.d.ts +4 -0
- package/api/index.d.ts.map +1 -0
- package/api/index.js +3 -3
- package/api/typedefs.d.ts +179 -0
- package/api/typedefs.d.ts.map +1 -0
- package/api/{tralis/typedefs.js → typedefs.js} +4 -10
- package/common/api/HttpAPI.d.ts +31 -0
- package/common/api/HttpAPI.d.ts.map +1 -0
- package/common/api/HttpAPI.js +57 -0
- package/common/api/WebSocketAPI.d.ts +153 -0
- package/common/api/WebSocketAPI.d.ts.map +1 -0
- package/common/api/WebSocketAPI.js +341 -0
- package/common/controls/ControlCommon.d.ts +76 -0
- package/common/controls/ControlCommon.d.ts.map +1 -0
- package/common/controls/ControlCommon.js +150 -0
- package/common/controls/CopyrightControlCommon.d.ts +13 -0
- package/common/controls/CopyrightControlCommon.d.ts.map +1 -0
- package/common/controls/CopyrightControlCommon.js +34 -0
- package/common/controls/StopFinderControlCommon.d.ts +55 -0
- package/common/controls/StopFinderControlCommon.d.ts.map +1 -0
- package/common/controls/StopFinderControlCommon.js +144 -0
- package/common/index.d.ts +3 -0
- package/common/index.d.ts.map +1 -0
- package/common/index.js +2 -0
- package/common/layers/LayerCommon.d.ts +94 -0
- package/common/layers/LayerCommon.d.ts.map +1 -0
- package/common/layers/LayerCommon.js +244 -0
- package/common/mixins/RealtimeLayerMixin.d.ts +286 -0
- package/common/mixins/RealtimeLayerMixin.d.ts.map +1 -0
- package/common/mixins/RealtimeLayerMixin.js +776 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts +60 -0
- package/common/mixins/UserInteractionsLayerMixin.d.ts.map +1 -0
- package/common/mixins/UserInteractionsLayerMixin.js +241 -0
- package/common/styles/index.d.ts +5 -0
- package/common/styles/index.d.ts.map +1 -0
- package/common/styles/index.js +4 -4
- package/common/styles/realtimeDefaultStyle.d.ts +36 -0
- package/common/styles/realtimeDefaultStyle.d.ts.map +1 -0
- package/common/styles/realtimeDefaultStyle.js +275 -0
- package/common/styles/{trackerDelayStyle.js → realtimeDelayStyle.d.ts} +4 -9
- package/common/styles/realtimeDelayStyle.d.ts.map +1 -0
- package/common/styles/realtimeDelayStyle.js +13 -0
- package/common/styles/realtimeHeadingStyle.d.ts +12 -0
- package/common/styles/realtimeHeadingStyle.d.ts.map +1 -0
- package/common/styles/realtimeHeadingStyle.js +85 -0
- package/common/styles/realtimeSimpleStyle.d.ts +4 -0
- package/common/styles/realtimeSimpleStyle.d.ts.map +1 -0
- package/common/styles/realtimeSimpleStyle.js +23 -0
- package/common/typedefs.d.ts +111 -0
- package/common/typedefs.d.ts.map +1 -0
- package/common/typedefs.js +35 -6
- package/common/utils/compareDepartures.d.ts +11 -0
- package/common/utils/compareDepartures.d.ts.map +1 -0
- package/common/utils/compareDepartures.js +35 -0
- package/common/utils/createCanvas.d.ts +10 -0
- package/common/utils/createCanvas.d.ts.map +1 -0
- package/common/utils/createCanvas.js +27 -0
- package/common/utils/createRealtimeFilters.d.ts +13 -0
- package/common/utils/createRealtimeFilters.d.ts.map +1 -0
- package/common/utils/createRealtimeFilters.js +74 -0
- package/common/utils/debounceDeparturesMessages.d.ts +12 -0
- package/common/utils/debounceDeparturesMessages.d.ts.map +1 -0
- package/common/utils/debounceDeparturesMessages.js +24 -0
- package/common/utils/debounceWebsocketMessages.d.ts +11 -0
- package/common/utils/debounceWebsocketMessages.d.ts.map +1 -0
- package/common/utils/debounceWebsocketMessages.js +29 -0
- package/common/utils/getLayersAsFlatArray.d.ts +3 -0
- package/common/utils/getLayersAsFlatArray.d.ts.map +1 -0
- package/common/utils/getLayersAsFlatArray.js +15 -0
- package/common/utils/getMapboxMapCopyrights.d.ts +18 -0
- package/common/utils/getMapboxMapCopyrights.d.ts.map +1 -0
- package/common/utils/getMapboxMapCopyrights.js +21 -23
- package/common/utils/getMapboxRender.d.ts +7 -0
- package/common/utils/getMapboxRender.d.ts.map +1 -0
- package/common/utils/getMapboxRender.js +87 -0
- package/common/utils/getMaplibreRender.d.ts +7 -0
- package/common/utils/getMaplibreRender.d.ts.map +1 -0
- package/common/utils/getMaplibreRender.js +38 -0
- package/common/utils/getRealtimeModeSuffix.d.ts +10 -0
- package/common/utils/getRealtimeModeSuffix.d.ts.map +1 -0
- package/common/utils/getRealtimeModeSuffix.js +7 -0
- package/common/utils/getUrlWithParams.d.ts +9 -0
- package/common/utils/getUrlWithParams.d.ts.map +1 -0
- package/common/utils/getUrlWithParams.js +18 -0
- package/common/utils/getVehiclePosition.d.ts +16 -0
- package/common/utils/getVehiclePosition.d.ts.map +1 -0
- package/common/utils/getVehiclePosition.js +60 -60
- package/common/utils/index.d.ts +17 -0
- package/common/utils/index.d.ts.map +1 -0
- package/common/utils/index.js +13 -2
- package/common/utils/realtimeConfig.d.ts +49 -0
- package/common/utils/realtimeConfig.d.ts.map +1 -0
- package/common/utils/realtimeConfig.js +173 -0
- package/common/utils/removeDuplicate.d.ts +10 -0
- package/common/utils/removeDuplicate.d.ts.map +1 -0
- package/common/utils/removeDuplicate.js +5 -12
- package/common/utils/renderTrajectories.d.ts +17 -0
- package/common/utils/renderTrajectories.d.ts.map +1 -0
- package/common/utils/renderTrajectories.js +110 -0
- package/common/utils/sortAndFilterDepartures.d.ts +16 -0
- package/common/utils/sortAndFilterDepartures.d.ts.map +1 -0
- package/common/utils/sortAndFilterDepartures.js +58 -0
- package/common/utils/sortByDelay.d.ts +3 -0
- package/common/utils/sortByDelay.d.ts.map +1 -0
- package/common/utils/sortByDelay.js +17 -20
- package/common/utils/timeUtils.d.ts +24 -0
- package/common/utils/timeUtils.d.ts.map +1 -0
- package/common/utils/timeUtils.js +13 -18
- package/iife.d.ts +3 -0
- package/iife.d.ts.map +1 -0
- package/iife.js +5 -0
- package/index.d.ts +10 -0
- package/index.d.ts.map +1 -0
- package/index.js +10 -2
- package/mapbox/controls/CopyrightControl.d.ts +29 -0
- package/mapbox/controls/CopyrightControl.d.ts.map +1 -0
- package/mapbox/controls/CopyrightControl.js +25 -35
- package/mapbox/controls/index.d.ts +2 -0
- package/mapbox/controls/index.d.ts.map +1 -0
- package/mapbox/controls/index.js +2 -0
- package/mapbox/index.d.ts +6 -0
- package/mapbox/index.d.ts.map +1 -0
- package/mapbox/index.js +5 -3
- package/mapbox/layers/Layer.d.ts +59 -0
- package/mapbox/layers/Layer.d.ts.map +1 -0
- package/mapbox/layers/Layer.js +78 -95
- package/mapbox/layers/RealtimeLayer.d.ts +181 -0
- package/mapbox/layers/RealtimeLayer.d.ts.map +1 -0
- package/mapbox/layers/RealtimeLayer.js +276 -0
- package/mapbox/layers/index.d.ts +3 -0
- package/mapbox/layers/index.d.ts.map +1 -0
- package/mapbox/layers/index.js +2 -0
- package/mapbox/utils/getMercatorResolution.d.ts +9 -0
- package/mapbox/utils/getMercatorResolution.d.ts.map +1 -0
- package/mapbox/utils/getMercatorResolution.js +18 -0
- package/mapbox/utils/getSourceCoordinates.d.ts +9 -0
- package/mapbox/utils/getSourceCoordinates.d.ts.map +1 -0
- package/mapbox/utils/getSourceCoordinates.js +27 -0
- package/mapbox/utils/index.d.ts +3 -0
- package/mapbox/utils/index.d.ts.map +1 -0
- package/mapbox/utils/index.js +2 -0
- package/mbt.js +60005 -0
- package/mbt.js.map +7 -0
- package/mbt.min.js +1084 -0
- package/mbt.min.js.map +7 -0
- package/ol/controls/CopyrightControl.d.ts +31 -0
- package/ol/controls/CopyrightControl.d.ts.map +1 -0
- package/ol/controls/CopyrightControl.js +44 -56
- package/ol/controls/RoutingControl.d.ts +193 -0
- package/ol/controls/RoutingControl.d.ts.map +1 -0
- package/ol/controls/RoutingControl.js +546 -667
- package/ol/controls/StopFinderControl.d.ts +30 -0
- package/ol/controls/StopFinderControl.d.ts.map +1 -0
- package/ol/controls/StopFinderControl.js +10 -16
- package/ol/controls/index.d.ts +4 -0
- package/ol/controls/index.d.ts.map +1 -0
- package/ol/controls/index.js +3 -0
- package/ol/index.d.ts +6 -0
- package/ol/index.d.ts.map +1 -0
- package/ol/index.js +4 -12
- package/ol/layers/Layer.d.ts +86 -0
- package/ol/layers/Layer.d.ts.map +1 -0
- package/ol/layers/Layer.js +147 -166
- package/ol/layers/MapGlLayer.d.ts +67 -0
- package/ol/layers/MapGlLayer.d.ts.map +1 -0
- package/ol/layers/MapGlLayer.js +218 -0
- package/ol/layers/MapboxLayer.d.ts +50 -0
- package/ol/layers/MapboxLayer.d.ts.map +1 -0
- package/ol/layers/MapboxLayer.js +79 -348
- package/ol/layers/MapboxStyleLayer.d.ts +129 -0
- package/ol/layers/MapboxStyleLayer.d.ts.map +1 -0
- package/ol/layers/MapboxStyleLayer.js +329 -368
- package/ol/layers/MaplibreLayer.d.ts +28 -0
- package/ol/layers/MaplibreLayer.d.ts.map +1 -0
- package/ol/layers/MaplibreLayer.js +13 -259
- package/ol/layers/RealtimeLayer.d.ts +202 -0
- package/ol/layers/RealtimeLayer.d.ts.map +1 -0
- package/ol/layers/RealtimeLayer.js +340 -0
- package/ol/layers/RoutingLayer.d.ts +34 -0
- package/ol/layers/RoutingLayer.d.ts.map +1 -0
- package/ol/layers/RoutingLayer.js +62 -68
- package/ol/layers/VectorLayer.d.ts +25 -0
- package/ol/layers/VectorLayer.d.ts.map +1 -0
- package/ol/layers/VectorLayer.js +27 -32
- package/ol/layers/WMSLayer.d.ts +42 -0
- package/ol/layers/WMSLayer.d.ts.map +1 -0
- package/ol/layers/WMSLayer.js +74 -66
- package/ol/layers/index.d.ts +9 -0
- package/ol/layers/index.d.ts.map +1 -0
- package/ol/layers/index.js +8 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts +4 -0
- package/ol/styles/fullTrajectoryDelayStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryDelayStyle.js +23 -25
- package/ol/styles/fullTrajectoryStyle.d.ts +5 -0
- package/ol/styles/fullTrajectoryStyle.d.ts.map +1 -0
- package/ol/styles/fullTrajectoryStyle.js +37 -44
- package/ol/styles/index.d.ts +3 -0
- package/ol/styles/index.d.ts.map +1 -0
- package/package.json +98 -177
- package/setupTests.d.ts +2 -0
- package/setupTests.d.ts.map +1 -0
- package/setupTests.js +26 -0
- package/types/common.d.ts +122 -0
- package/types/index.d.ts +11 -0
- package/types/realtime.d.ts +320 -0
- package/types/routing.d.ts +206 -0
- package/types/stops.d.ts +143 -0
- package/README.md +0 -23
- package/api/routing/RoutingAPI.js +0 -44
- package/api/routing/RoutingAPI.test.js +0 -41
- package/api/stops/StopsAPI.js +0 -41
- package/api/stops/StopsAPI.test.js +0 -34
- package/api/tralis/TralisAPI.js +0 -731
- package/api/tralis/TralisAPI.test.js +0 -75
- package/api/tralis/TralisAPIUtils.js +0 -73
- package/api/tralis/WebSocketConnector.js +0 -338
- package/api/tralis/WebSocketConnector.test.js +0 -356
- package/common/Tracker.js +0 -197
- package/common/api/api.js +0 -64
- package/common/api/api.test.js +0 -68
- package/common/controls/Control.js +0 -146
- package/common/controls/Control.test.js +0 -98
- package/common/layers/Layer.js +0 -404
- package/common/layers/Layer.test.js +0 -585
- package/common/mixins/CopyrightMixin.js +0 -48
- package/common/mixins/SearchMixin.js +0 -176
- package/common/mixins/TralisLayerMixin.js +0 -930
- package/common/styles/trackerDefaultStyle.js +0 -333
- package/common/styles/trackerSimpleStyle.js +0 -22
- package/common/trackerConfig.js +0 -190
- package/common/trackerConfig.test.js +0 -25
- package/common/utils/createTrackerFilters.js +0 -87
- package/common/utils/createTrackerFilters.test.js +0 -95
- package/common/utils/getMapboxMapCopyrights.test.js +0 -47
- package/common/utils/getMapboxStyleUrl.js +0 -32
- package/common/utils/removeDuplicate.test.js +0 -22
- package/common/utils/timeUtils.test.js +0 -16
- package/index.js.map +0 -1
- package/mapbox/layers/Layer.test.js +0 -202
- package/mapbox/layers/TralisLayer.js +0 -329
- package/mapbox/layers/TralisLayer.test.js +0 -40
- package/mapbox/utils.js +0 -46
- package/module.js +0 -23
- package/ol/README.md +0 -0
- package/ol/controls/CopyrightControl.test.js +0 -211
- package/ol/controls/RoutingControl.test.js +0 -216
- package/ol/controls/StopFinderControl.test.js +0 -59
- package/ol/controls/snapshots/RoutingControlRouteGen10.json +0 -58
- package/ol/controls/snapshots/RoutingControlRouteGen100.json +0 -292
- package/ol/controls/snapshots/RoutingControlRouteGen30.json +0 -69
- package/ol/controls/snapshots/RoutingControlRouteGen5.json +0 -58
- package/ol/controls/snapshots/RoutingControlRouteOSM.json +0 -759
- package/ol/controls/snapshots/RoutingControlStation1.json +0 -60
- package/ol/controls/snapshots/RoutingControlStation2.json +0 -49
- package/ol/layers/Layer.test.js +0 -197
- package/ol/layers/MapboxLayer.test.js +0 -186
- package/ol/layers/MapboxStyleLayer.test.js +0 -262
- package/ol/layers/RoutingLayer.test.js +0 -49
- package/ol/layers/TralisLayer.js +0 -359
- package/ol/layers/TralisLayer.test.js +0 -97
- package/ol/layers/VectorLayer.test.js +0 -98
- package/ol/layers/WMSLayer.test.js +0 -84
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import OlMap from 'ol/Map';
|
|
2
|
-
import View from 'ol/View';
|
|
3
|
-
import gllib from 'maplibre-gl';
|
|
4
|
-
import Layer from './Layer';
|
|
5
|
-
import MaplibreLayer from './MaplibreLayer';
|
|
6
|
-
import MapboxStyleLayer from './MapboxStyleLayer';
|
|
7
|
-
|
|
8
|
-
let source;
|
|
9
|
-
let layer;
|
|
10
|
-
let map;
|
|
11
|
-
let onClick;
|
|
12
|
-
|
|
13
|
-
const styleLayer = {
|
|
14
|
-
id: 'layer',
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
describe('MapboxStyleLayer', () => {
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
onClick = jest.fn();
|
|
20
|
-
source = new MaplibreLayer({
|
|
21
|
-
name: 'Layer',
|
|
22
|
-
apiKey: false,
|
|
23
|
-
});
|
|
24
|
-
layer = new MapboxStyleLayer({
|
|
25
|
-
name: 'mapbox layer',
|
|
26
|
-
visible: true,
|
|
27
|
-
mapboxLayer: source,
|
|
28
|
-
styleLayer,
|
|
29
|
-
onClick,
|
|
30
|
-
});
|
|
31
|
-
map = new OlMap({
|
|
32
|
-
target: document.createElement('div'),
|
|
33
|
-
view: new View({ center: [0, 0] }),
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
afterEach(() => {
|
|
38
|
-
if (layer.map) {
|
|
39
|
-
layer.terminate(map);
|
|
40
|
-
}
|
|
41
|
-
if (source.map) {
|
|
42
|
-
source.terminate(map);
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('should be instanced.', () => {
|
|
47
|
-
expect(layer).toBeInstanceOf(MapboxStyleLayer);
|
|
48
|
-
expect(layer.styleLayers[0]).toBe(styleLayer);
|
|
49
|
-
expect(layer.clickCallbacks[0]).toBe(onClick);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('should not initalized mapbox map.', () => {
|
|
53
|
-
layer.init();
|
|
54
|
-
expect(layer.mbMap).toBe();
|
|
55
|
-
layer.terminate();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('should initalized mapbox map.', () => {
|
|
59
|
-
source.init(map);
|
|
60
|
-
layer.init(map);
|
|
61
|
-
expect(layer.mapboxLayer.mbMap).toBeInstanceOf(gllib.Map);
|
|
62
|
-
layer.terminate();
|
|
63
|
-
source.terminate();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('should add onClick callback.', () => {
|
|
67
|
-
const onClick2 = jest.fn();
|
|
68
|
-
layer.onClick(onClick2);
|
|
69
|
-
expect(layer.clickCallbacks[1]).toBe(onClick2);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test('should called terminate on initalization.', () => {
|
|
73
|
-
const spy = jest.spyOn(layer, 'terminate');
|
|
74
|
-
layer.init();
|
|
75
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
76
|
-
layer.terminate(map);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('should return coordinates, features and a layer instance.', async () => {
|
|
80
|
-
source.init(map);
|
|
81
|
-
layer.init(map);
|
|
82
|
-
const data = await layer.getFeatureInfoAtCoordinate([50, 50]);
|
|
83
|
-
expect(data.coordinate).toEqual([50, 50]);
|
|
84
|
-
expect(data.features).toEqual([]);
|
|
85
|
-
expect(data.layer).toBeInstanceOf(MapboxStyleLayer);
|
|
86
|
-
layer.terminate(map);
|
|
87
|
-
source.terminate(map);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test('should call onClick callback', async () => {
|
|
91
|
-
const coordinate = [500, 500];
|
|
92
|
-
const features = [];
|
|
93
|
-
const evt = { type: 'singleclick', map, coordinate };
|
|
94
|
-
layer.init(map);
|
|
95
|
-
expect(onClick).toHaveBeenCalledTimes(0);
|
|
96
|
-
await map.dispatchEvent(evt);
|
|
97
|
-
expect(onClick).toHaveBeenCalledTimes(1);
|
|
98
|
-
expect(onClick).toHaveBeenCalledWith(features, layer, coordinate);
|
|
99
|
-
layer.terminate();
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test('should call super class terminate function.', () => {
|
|
103
|
-
layer.init(map);
|
|
104
|
-
const spy = jest.spyOn(Layer.prototype, 'terminate');
|
|
105
|
-
layer.terminate(map);
|
|
106
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
107
|
-
spy.mockRestore();
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
test('should call super class terminate if the mapboxLayer associated has been terminated before.', () => {
|
|
111
|
-
layer.init(map);
|
|
112
|
-
source.terminate(map);
|
|
113
|
-
const spy = jest.spyOn(Layer.prototype, 'terminate');
|
|
114
|
-
layer.terminate(map);
|
|
115
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
116
|
-
spy.mockRestore();
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test('should clone', () => {
|
|
120
|
-
const clone = layer.clone({ name: 'clone' });
|
|
121
|
-
expect(clone).not.toBe(layer);
|
|
122
|
-
expect(clone.name).toBe('clone');
|
|
123
|
-
expect(clone).toBeInstanceOf(MapboxStyleLayer);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
test('should add layer on load', () => {
|
|
127
|
-
const style = { layers: [] };
|
|
128
|
-
layer.mapboxLayer.mbMap = {
|
|
129
|
-
getStyle: () => style,
|
|
130
|
-
getSource: () => ({}),
|
|
131
|
-
getLayer: () => null,
|
|
132
|
-
setLayoutProperty: () => null,
|
|
133
|
-
addLayer: (styleLayerr) => style.layers.push(styleLayerr),
|
|
134
|
-
};
|
|
135
|
-
layer.onLoad();
|
|
136
|
-
expect(style.layers[0]).toBe(styleLayer);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
describe('should set disabled property to false on load', () => {
|
|
140
|
-
test('when layer uses styleLayer property', () => {
|
|
141
|
-
const styles = { layers: [] };
|
|
142
|
-
layer.mapboxLayer.mbMap = {
|
|
143
|
-
getStyle: () => styles,
|
|
144
|
-
getSource: () => ({}),
|
|
145
|
-
getLayer: () => null,
|
|
146
|
-
setLayoutProperty: () => null,
|
|
147
|
-
addLayer: (styleLayerr) => styles.layers.push(styleLayerr),
|
|
148
|
-
};
|
|
149
|
-
expect(layer).toBeInstanceOf(MapboxStyleLayer);
|
|
150
|
-
layer.onLoad();
|
|
151
|
-
expect(layer.disabled).toBe(false);
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
describe('should set disabled property to true on load', () => {
|
|
156
|
-
test('when layer uses styleLayersFilter property', () => {
|
|
157
|
-
const styles = { layers: [styleLayer] };
|
|
158
|
-
const layer2 = new MapboxStyleLayer({
|
|
159
|
-
name: 'mapbox layer',
|
|
160
|
-
mapboxLayer: source,
|
|
161
|
-
styleLayersFilter: () => false,
|
|
162
|
-
});
|
|
163
|
-
layer2.mapboxLayer.mbMap = {
|
|
164
|
-
getStyle: () => styles,
|
|
165
|
-
getSource: () => ({}),
|
|
166
|
-
getLayer: () => null,
|
|
167
|
-
setLayoutProperty: () => null,
|
|
168
|
-
addLayer: () => ({}),
|
|
169
|
-
};
|
|
170
|
-
layer2.onLoad();
|
|
171
|
-
expect(layer2.disabled).toBe(true);
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
describe('#getFeatureInfoAtCoordinate()', () => {
|
|
176
|
-
beforeEach(() => {
|
|
177
|
-
source.init(map);
|
|
178
|
-
source.mbMap.isStyleLoaded = jest.fn(() => true);
|
|
179
|
-
source.mbMap.getSource = jest.fn(() => true);
|
|
180
|
-
});
|
|
181
|
-
afterEach(() => {
|
|
182
|
-
source.mbMap.getSource.mockRestore();
|
|
183
|
-
source.mbMap.isStyleLoaded.mockRestore();
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
test('should request features on layers ids from styleLayers property', () => {
|
|
187
|
-
source.mbMap.getStyle = jest.fn(() => ({
|
|
188
|
-
layers: [{ id: 'foo' }, { id: 'layer' }, { id: 'bar' }],
|
|
189
|
-
}));
|
|
190
|
-
layer.init(map);
|
|
191
|
-
layer.mapboxLayer.getFeatureInfoAtCoordinate = jest.fn(() =>
|
|
192
|
-
Promise.resolve({ features: [] }),
|
|
193
|
-
);
|
|
194
|
-
layer.getFeatureInfoAtCoordinate([0, 0]).then(() => {});
|
|
195
|
-
expect(layer.mapboxLayer.getFeatureInfoAtCoordinate).toHaveBeenCalledWith(
|
|
196
|
-
[0, 0],
|
|
197
|
-
{ layers: ['layer'], validate: false },
|
|
198
|
-
);
|
|
199
|
-
layer.mapboxLayer.getFeatureInfoAtCoordinate.mockRestore();
|
|
200
|
-
source.mbMap.getStyle.mockRestore();
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
test('should request features on layers ids from styleLayersFilter property', () => {
|
|
204
|
-
source.mbMap.getStyle = jest.fn(() => ({
|
|
205
|
-
layers: [{ id: 'foo' }, { id: 'layer' }, { id: 'bar' }, { id: 'foo2' }],
|
|
206
|
-
}));
|
|
207
|
-
const layer2 = new MapboxStyleLayer({
|
|
208
|
-
name: 'mapbox layer',
|
|
209
|
-
visible: true,
|
|
210
|
-
mapboxLayer: source,
|
|
211
|
-
styleLayer,
|
|
212
|
-
styleLayersFilter: ({ id }) => /foo/.test(id),
|
|
213
|
-
});
|
|
214
|
-
layer2.init(map);
|
|
215
|
-
layer2.mapboxLayer.getFeatureInfoAtCoordinate = jest.fn(() =>
|
|
216
|
-
Promise.resolve({ features: [] }),
|
|
217
|
-
);
|
|
218
|
-
layer2.getFeatureInfoAtCoordinate([0, 0]).then(() => {});
|
|
219
|
-
expect(
|
|
220
|
-
layer2.mapboxLayer.getFeatureInfoAtCoordinate,
|
|
221
|
-
).toHaveBeenCalledWith([0, 0], {
|
|
222
|
-
layers: ['foo', 'foo2'],
|
|
223
|
-
validate: false,
|
|
224
|
-
});
|
|
225
|
-
layer2.mapboxLayer.getFeatureInfoAtCoordinate.mockRestore();
|
|
226
|
-
source.mbMap.getStyle.mockRestore();
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
test('should request features on layers ids from queryRenderedLayersFilter property', () => {
|
|
230
|
-
source.mbMap.getStyle = jest.fn(() => ({
|
|
231
|
-
layers: [
|
|
232
|
-
{ id: 'foo' },
|
|
233
|
-
{ id: 'bar2' },
|
|
234
|
-
{ id: 'layer' },
|
|
235
|
-
{ id: 'bar' },
|
|
236
|
-
{ id: 'foo2' },
|
|
237
|
-
],
|
|
238
|
-
}));
|
|
239
|
-
const layer2 = new MapboxStyleLayer({
|
|
240
|
-
name: 'mapbox layer',
|
|
241
|
-
visible: true,
|
|
242
|
-
mapboxLayer: source,
|
|
243
|
-
styleLayer,
|
|
244
|
-
styleLayersFilter: ({ id }) => /foo/.test(id),
|
|
245
|
-
queryRenderedLayersFilter: ({ id }) => /bar/.test(id),
|
|
246
|
-
});
|
|
247
|
-
layer2.init(map);
|
|
248
|
-
layer2.mapboxLayer.getFeatureInfoAtCoordinate = jest.fn(() =>
|
|
249
|
-
Promise.resolve({ features: [] }),
|
|
250
|
-
);
|
|
251
|
-
layer2.getFeatureInfoAtCoordinate([0, 0]).then(() => {});
|
|
252
|
-
expect(
|
|
253
|
-
layer2.mapboxLayer.getFeatureInfoAtCoordinate,
|
|
254
|
-
).toHaveBeenCalledWith([0, 0], {
|
|
255
|
-
layers: ['bar2', 'bar'],
|
|
256
|
-
validate: false,
|
|
257
|
-
});
|
|
258
|
-
layer2.mapboxLayer.getFeatureInfoAtCoordinate.mockRestore();
|
|
259
|
-
source.mbMap.getStyle.mockRestore();
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import fetch from 'jest-fetch-mock';
|
|
2
|
-
import Map from 'ol/Map';
|
|
3
|
-
import View from 'ol/View';
|
|
4
|
-
import RoutingLayer from './RoutingLayer';
|
|
5
|
-
|
|
6
|
-
let layer;
|
|
7
|
-
let onClick;
|
|
8
|
-
let olMap;
|
|
9
|
-
|
|
10
|
-
describe('RoutingLayer', () => {
|
|
11
|
-
beforeEach(() => {
|
|
12
|
-
global.fetch = fetch;
|
|
13
|
-
fetch.resetMocks();
|
|
14
|
-
|
|
15
|
-
onClick = jest.fn();
|
|
16
|
-
layer = new RoutingLayer({
|
|
17
|
-
onClick,
|
|
18
|
-
apiKey: 'apiKey',
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
olMap = new Map({
|
|
22
|
-
view: new View({
|
|
23
|
-
center: [831634, 5933959],
|
|
24
|
-
zoom: 9,
|
|
25
|
-
}),
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('should be instanced.', () => {
|
|
30
|
-
expect(layer).toBeInstanceOf(RoutingLayer);
|
|
31
|
-
expect(layer.clickCallbacks[0]).toBe(onClick);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test('should called terminate on initalization.', () => {
|
|
35
|
-
const spy = jest.spyOn(layer, 'terminate');
|
|
36
|
-
|
|
37
|
-
fetch.mockResponseOnce(JSON.stringify(global.fetchTrajectoriesResponse));
|
|
38
|
-
|
|
39
|
-
layer.init(olMap);
|
|
40
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('should clone', () => {
|
|
44
|
-
const clone = layer.clone({ name: 'clone' });
|
|
45
|
-
expect(clone).not.toBe(layer);
|
|
46
|
-
expect(clone.name).toBe('clone');
|
|
47
|
-
expect(clone).toBeInstanceOf(RoutingLayer);
|
|
48
|
-
});
|
|
49
|
-
});
|
package/ol/layers/TralisLayer.js
DELETED
|
@@ -1,359 +0,0 @@
|
|
|
1
|
-
import GeoJSON from 'ol/format/GeoJSON';
|
|
2
|
-
import { Layer as OLLayer, Group, Vector as VectorLayer } from 'ol/layer';
|
|
3
|
-
import Source from 'ol/source/Source';
|
|
4
|
-
import { composeCssTransform } from 'ol/transform';
|
|
5
|
-
import { Vector as VectorSource } from 'ol/source';
|
|
6
|
-
import Layer from './Layer';
|
|
7
|
-
import mixin from '../../common/mixins/TralisLayerMixin';
|
|
8
|
-
import { fullTrajectoryStyle } from '../styles';
|
|
9
|
-
|
|
10
|
-
const format = new GeoJSON();
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Responsible for loading and display data from a Tralis service.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* import { TralisLayer } from 'mobility-toolbox-js/ol';
|
|
17
|
-
*
|
|
18
|
-
* const layer = new TralisLayer({
|
|
19
|
-
* url: [yourUrl],
|
|
20
|
-
* apiKey: [yourApiKey],
|
|
21
|
-
* });
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @see <a href="/api/class/src/api/tralis/TralisAPI%20js~TralisAPI%20html">TralisAPI</a>
|
|
25
|
-
*
|
|
26
|
-
* @extends {Layer}
|
|
27
|
-
* @implements {TralisLayerInterface}
|
|
28
|
-
*/
|
|
29
|
-
class TralisLayer extends mixin(Layer) {
|
|
30
|
-
/**
|
|
31
|
-
* Constructor.
|
|
32
|
-
*
|
|
33
|
-
* @param {Object} options
|
|
34
|
-
* @private
|
|
35
|
-
*/
|
|
36
|
-
constructor(options = {}) {
|
|
37
|
-
// We use a group to be able to add custom vector layer in extended class.
|
|
38
|
-
// For example TrajservLayer use a vectorLayer to display the complete trajectory.
|
|
39
|
-
super({
|
|
40
|
-
...options,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
/** @ignore */
|
|
44
|
-
this.olLayer =
|
|
45
|
-
options.olLayer ||
|
|
46
|
-
new Group({
|
|
47
|
-
layers: [
|
|
48
|
-
new VectorLayer({
|
|
49
|
-
source: new VectorSource({ features: [] }),
|
|
50
|
-
style: options.fullTrajectoryStyle || fullTrajectoryStyle,
|
|
51
|
-
}),
|
|
52
|
-
new OLLayer({
|
|
53
|
-
source: new Source({}),
|
|
54
|
-
render: (frameState) => {
|
|
55
|
-
if (!this.tracker || !this.tracker.canvas) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (!this.container) {
|
|
60
|
-
this.container = document.createElement('div');
|
|
61
|
-
this.container.style.position = 'absolute';
|
|
62
|
-
this.container.style.width = '100%';
|
|
63
|
-
this.container.style.height = '100%';
|
|
64
|
-
this.transformContainer = document.createElement('div');
|
|
65
|
-
this.transformContainer.style.position = 'absolute';
|
|
66
|
-
this.transformContainer.style.width = '100%';
|
|
67
|
-
this.transformContainer.style.height = '100%';
|
|
68
|
-
this.container.appendChild(this.transformContainer);
|
|
69
|
-
this.tracker.canvas.style.position = 'absolute';
|
|
70
|
-
this.tracker.canvas.style.top = '0';
|
|
71
|
-
this.tracker.canvas.style.left = '0';
|
|
72
|
-
this.tracker.canvas.style.transformOrigin = 'top left';
|
|
73
|
-
this.transformContainer.appendChild(this.tracker.canvas);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (this.renderedViewState) {
|
|
77
|
-
const { center, resolution, rotation } = frameState.viewState;
|
|
78
|
-
const {
|
|
79
|
-
center: renderedCenter,
|
|
80
|
-
resolution: renderedResolution,
|
|
81
|
-
rotation: renderedRotation,
|
|
82
|
-
} = this.renderedViewState;
|
|
83
|
-
|
|
84
|
-
if (renderedResolution / resolution >= 3) {
|
|
85
|
-
// Avoid having really big points when zooming fast.
|
|
86
|
-
const { canvas } = this.tracker;
|
|
87
|
-
const context = canvas.getContext('2d');
|
|
88
|
-
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
89
|
-
} else {
|
|
90
|
-
const pixelCenterRendered =
|
|
91
|
-
this.map.getPixelFromCoordinate(renderedCenter);
|
|
92
|
-
const pixelCenter = this.map.getPixelFromCoordinate(center);
|
|
93
|
-
this.transformContainer.style.transform = composeCssTransform(
|
|
94
|
-
pixelCenterRendered[0] - pixelCenter[0],
|
|
95
|
-
pixelCenterRendered[1] - pixelCenter[1],
|
|
96
|
-
renderedResolution / resolution,
|
|
97
|
-
renderedResolution / resolution,
|
|
98
|
-
rotation - renderedRotation,
|
|
99
|
-
0,
|
|
100
|
-
0,
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return this.container;
|
|
105
|
-
},
|
|
106
|
-
}),
|
|
107
|
-
],
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
// We store the layer used to highlight the full Trajectory
|
|
111
|
-
this.vectorLayer = this.olLayer.getLayers().item(0);
|
|
112
|
-
|
|
113
|
-
// Options the last render run did happen. If something changes
|
|
114
|
-
// we have to render again
|
|
115
|
-
/** @ignore */
|
|
116
|
-
this.renderState = {
|
|
117
|
-
center: [0, 0],
|
|
118
|
-
zoom: null,
|
|
119
|
-
rotation: 0,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
init(map) {
|
|
124
|
-
super.init(map);
|
|
125
|
-
if (this.map) {
|
|
126
|
-
this.olListenersKeys.push(
|
|
127
|
-
this.map.on(['moveend', 'change:target'], (evt) => {
|
|
128
|
-
const view = this.map.getView();
|
|
129
|
-
if (view.getAnimating() || view.getInteracting()) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const zoom = view.getZoom();
|
|
133
|
-
|
|
134
|
-
// Update the interval between render updates
|
|
135
|
-
if (this.currentZoom !== zoom) {
|
|
136
|
-
this.onZoomEnd(evt);
|
|
137
|
-
}
|
|
138
|
-
this.currentZoom = zoom;
|
|
139
|
-
|
|
140
|
-
this.onMoveEnd(evt);
|
|
141
|
-
}),
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Destroy the container of the tracker.
|
|
148
|
-
*/
|
|
149
|
-
terminate() {
|
|
150
|
-
super.terminate();
|
|
151
|
-
this.container = null;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Detect in the canvas if there is data to query at a specific coordinate.
|
|
156
|
-
* @param {ol/coordinate~Coordinate} coordinate The coordinate to test
|
|
157
|
-
* @returns
|
|
158
|
-
*/
|
|
159
|
-
hasFeatureInfoAtCoordinate(coordinate) {
|
|
160
|
-
if (this.map && this.tracker && this.tracker.canvas) {
|
|
161
|
-
const context = this.tracker.canvas.getContext('2d');
|
|
162
|
-
const pixel = this.map.getPixelFromCoordinate(coordinate);
|
|
163
|
-
return !!context.getImageData(
|
|
164
|
-
pixel[0] * this.pixelRatio,
|
|
165
|
-
pixel[1] * this.pixelRatio,
|
|
166
|
-
1,
|
|
167
|
-
1,
|
|
168
|
-
).data[3];
|
|
169
|
-
}
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Render the trajectories using current map's size, resolution and rotation.
|
|
175
|
-
* @param {boolean} noInterpolate if true, renders the vehicles without interpolating theirs positions.
|
|
176
|
-
* @overrides
|
|
177
|
-
*/
|
|
178
|
-
renderTrajectories(noInterpolate) {
|
|
179
|
-
const view = this.map.getView();
|
|
180
|
-
super.renderTrajectories(
|
|
181
|
-
{
|
|
182
|
-
size: this.map.getSize(),
|
|
183
|
-
center: this.map.getView().getCenter(),
|
|
184
|
-
extent: view.calculateExtent(),
|
|
185
|
-
resolution: view.getResolution(),
|
|
186
|
-
rotation: view.getRotation(),
|
|
187
|
-
zoom: view.getZoom(),
|
|
188
|
-
pixelRatio: this.pixelRatio,
|
|
189
|
-
},
|
|
190
|
-
noInterpolate,
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Launch renderTrajectories. it avoids duplicating code in renderTrajectories methhod.
|
|
196
|
-
* @private
|
|
197
|
-
* @override
|
|
198
|
-
*/
|
|
199
|
-
renderTrajectoriesInternal(viewState, noInterpolate) {
|
|
200
|
-
let isRendered = false;
|
|
201
|
-
|
|
202
|
-
const blockRendering =
|
|
203
|
-
this.map.getView().getAnimating() || this.map.getView().getInteracting();
|
|
204
|
-
|
|
205
|
-
// Don't render the map when the map is animating or interacting.
|
|
206
|
-
isRendered = blockRendering
|
|
207
|
-
? false
|
|
208
|
-
: super.renderTrajectoriesInternal(viewState, noInterpolate);
|
|
209
|
-
|
|
210
|
-
// We update the current render state.
|
|
211
|
-
if (isRendered) {
|
|
212
|
-
this.renderedViewState = { ...viewState };
|
|
213
|
-
|
|
214
|
-
if (this.transformContainer) {
|
|
215
|
-
this.transformContainer.style.transform = '';
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Return the delay in ms before the next rendering.
|
|
222
|
-
*/
|
|
223
|
-
getRefreshTimeInMs() {
|
|
224
|
-
return super.getRefreshTimeInMs(this.map.getView().getZoom());
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
getFeatureInfoAtCoordinate(coordinate, options = {}) {
|
|
228
|
-
const resolution = this.map.getView().getResolution();
|
|
229
|
-
return super.getFeatureInfoAtCoordinate(coordinate, {
|
|
230
|
-
resolution,
|
|
231
|
-
...options,
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* On move end we update the websocket with the new bbox.
|
|
237
|
-
*
|
|
238
|
-
* @param {ol/MapEvent~MapEvent} evt Moveend event
|
|
239
|
-
* @private
|
|
240
|
-
* @override
|
|
241
|
-
*/
|
|
242
|
-
onMoveEnd() {
|
|
243
|
-
if (this.visible && this.isUpdateBboxOnMoveEnd) {
|
|
244
|
-
this.setBbox();
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
if (
|
|
248
|
-
this.visible &&
|
|
249
|
-
this.isUpdateBboxOnMoveEnd &&
|
|
250
|
-
this.isClickActive &&
|
|
251
|
-
this.selectedVehicleId
|
|
252
|
-
) {
|
|
253
|
-
this.highlightTrajectory(this.selectedVehicleId);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Function called on moveend event only when the zoom has changed.
|
|
259
|
-
*
|
|
260
|
-
* @param {ol/MapEvent~MapEvent} evt Moveend event.
|
|
261
|
-
* @private
|
|
262
|
-
* @override
|
|
263
|
-
*/
|
|
264
|
-
// eslint-disable-next-line no-unused-vars
|
|
265
|
-
onZoomEnd(evt) {
|
|
266
|
-
super.onZoomEnd(evt);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Update the cursor style when hovering a vehicle.
|
|
271
|
-
*
|
|
272
|
-
* @private
|
|
273
|
-
* @override
|
|
274
|
-
*/
|
|
275
|
-
onFeatureHover(features, layer, coordinate) {
|
|
276
|
-
super.onFeatureHover(features, layer, coordinate);
|
|
277
|
-
this.map.getTargetElement().style.cursor = features.length
|
|
278
|
-
? 'pointer'
|
|
279
|
-
: 'auto';
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Display the complete trajectory of the vehicle.
|
|
284
|
-
*
|
|
285
|
-
* @private
|
|
286
|
-
* @override
|
|
287
|
-
*/
|
|
288
|
-
onFeatureClick(features, layer, coordinate) {
|
|
289
|
-
super.onFeatureClick(features, layer, coordinate);
|
|
290
|
-
if (!features.length && this.vectorLayer) {
|
|
291
|
-
this.vectorLayer.getSource().clear();
|
|
292
|
-
}
|
|
293
|
-
if (this.selectedVehicleId) {
|
|
294
|
-
this.highlightTrajectory(this.selectedVehicleId);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Remove the trajectory form the list if necessary.
|
|
300
|
-
*
|
|
301
|
-
* @private
|
|
302
|
-
*/
|
|
303
|
-
purgeTrajectory(trajectory, extent, zoom) {
|
|
304
|
-
return super.purgeTrajectory(
|
|
305
|
-
trajectory,
|
|
306
|
-
extent || this.map.getView().calculateExtent(),
|
|
307
|
-
zoom || this.map.getView().getZoom(),
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* Send the current bbox to the websocket
|
|
313
|
-
*
|
|
314
|
-
* @private
|
|
315
|
-
*/
|
|
316
|
-
setBbox(extent, zoom) {
|
|
317
|
-
let newExtent = extent;
|
|
318
|
-
let newZoom = zoom;
|
|
319
|
-
if (!newExtent && this.isUpdateBboxOnMoveEnd) {
|
|
320
|
-
newExtent = extent || this.map.getView().calculateExtent();
|
|
321
|
-
newZoom = Math.floor(this.map.getView().getZoom());
|
|
322
|
-
}
|
|
323
|
-
super.setBbox(newExtent, newZoom);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Highlight the trajectory of journey.
|
|
328
|
-
* @private
|
|
329
|
-
*/
|
|
330
|
-
highlightTrajectory(id) {
|
|
331
|
-
this.api
|
|
332
|
-
.getFullTrajectory(id, this.mode, this.generalizationLevel)
|
|
333
|
-
.then((fullTrajectory) => {
|
|
334
|
-
const vectorSource = this.vectorLayer.getSource();
|
|
335
|
-
vectorSource.clear();
|
|
336
|
-
|
|
337
|
-
if (
|
|
338
|
-
!fullTrajectory ||
|
|
339
|
-
!fullTrajectory.features ||
|
|
340
|
-
!fullTrajectory.features.length
|
|
341
|
-
) {
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
const features = format.readFeatures(fullTrajectory);
|
|
345
|
-
this.vectorLayer.getSource().addFeatures(features);
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Create a copy of the TralisLayer.
|
|
351
|
-
* @param {Object} newOptions Options to override
|
|
352
|
-
* @return {TralisLayer} A TralisLayer
|
|
353
|
-
*/
|
|
354
|
-
clone(newOptions) {
|
|
355
|
-
return new TralisLayer({ ...this.options, ...newOptions });
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
export default TralisLayer;
|