mobility-toolbox-js 3.0.0-beta.19 → 3.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/HttpAPI.d.ts +5 -5
- package/api/RealtimeAPI.d.ts +204 -171
- package/api/RealtimeAPI.js +306 -258
- package/api/RoutingAPI.d.ts +4 -4
- package/api/StopsAPI.d.ts +4 -4
- package/api/WebSocketAPI.d.ts +60 -66
- package/api/WebSocketAPI.js +164 -164
- package/api/index.js +1 -1
- package/common/controls/StopFinderControlCommon.d.ts +11 -11
- package/common/controls/StopFinderControlCommon.js +30 -30
- package/common/index.d.ts +1 -1
- package/common/index.js +1 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +149 -155
- package/common/mixins/RealtimeLayerMixin.js +395 -395
- package/common/styles/realtimeDefaultStyle.js +6 -6
- package/common/styles/realtimeHeadingStyle.js +5 -5
- package/common/utils/getMapGlCopyrights.d.ts +1 -1
- package/common/utils/getMapGlCopyrights.js +3 -3
- package/common/utils/getVehiclePosition.d.ts +2 -2
- package/common/utils/getVehiclePosition.js +7 -7
- package/common/utils/renderTrajectories.js +5 -5
- package/common/utils/sortByDelay.js +5 -5
- package/maplibre/layers/RealtimeLayer.d.ts +59 -64
- package/maplibre/layers/RealtimeLayer.js +8 -8
- package/maplibre/utils/getSourceCoordinates.js +5 -5
- package/mbt.js +7205 -7031
- package/mbt.js.map +4 -4
- package/mbt.min.js +25 -25
- package/mbt.min.js.map +4 -4
- package/ol/controls/RoutingControl.d.ts +81 -87
- package/ol/controls/RoutingControl.js +216 -218
- package/ol/layers/Layer.d.ts +9 -9
- package/ol/layers/MaplibreLayer.d.ts +10 -10
- package/ol/layers/MaplibreLayer.js +9 -3
- package/ol/layers/MaplibreStyleLayer.d.ts +77 -76
- package/ol/layers/MaplibreStyleLayer.js +237 -238
- package/ol/layers/RealtimeLayer.d.ts +92 -96
- package/ol/layers/RealtimeLayer.js +139 -131
- package/ol/mixins/MobilityLayerMixin.d.ts +9 -9
- package/ol/mixins/PropertiesLayerMixin.d.ts +33 -36
- package/ol/mixins/PropertiesLayerMixin.js +73 -72
- package/ol/renderers/MaplibreLayerRenderer.js +3 -3
- package/ol/renderers/MaplibreStyleLayerRenderer.d.ts +6 -6
- package/ol/renderers/MaplibreStyleLayerRenderer.js +14 -17
- package/ol/renderers/RealtimeLayerRenderer.d.ts +6 -6
- package/ol/renderers/RealtimeLayerRenderer.js +54 -52
- package/ol/utils/getFeatureInfoAtCoordinate.d.ts +1 -1
- package/ol/utils/getFeatureInfoAtCoordinate.js +10 -16
- package/package.json +6 -5
- package/setupTests.js +3 -4
- package/types/common.d.ts +53 -49
- package/types/index.d.ts +1 -1
- package/types/realtime.d.ts +91 -93
- package/types/routing.d.ts +60 -60
- package/types/stops.d.ts +62 -62
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import debounce from 'lodash.debounce';
|
|
1
2
|
import GeoJSON from 'ol/format/GeoJSON';
|
|
2
3
|
import { Vector as VectorLayer } from 'ol/layer';
|
|
3
|
-
import Source from 'ol/source/Source';
|
|
4
|
-
import { Vector as VectorSource } from 'ol/source';
|
|
5
|
-
import debounce from 'lodash.debounce';
|
|
6
4
|
import Layer from 'ol/layer/Layer';
|
|
5
|
+
import { Vector as VectorSource } from 'ol/source';
|
|
6
|
+
import Source from 'ol/source/Source';
|
|
7
7
|
import RealtimeLayerMixin from '../../common/mixins/RealtimeLayerMixin';
|
|
8
|
-
import { fullTrajectoryStyle } from '../styles';
|
|
9
8
|
import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
10
9
|
import RealtimeLayerRenderer from '../renderers/RealtimeLayerRenderer';
|
|
10
|
+
import { fullTrajectoryStyle } from '../styles';
|
|
11
11
|
/** @private */
|
|
12
12
|
const format = new GeoJSON();
|
|
13
13
|
/**
|
|
@@ -30,7 +30,7 @@ const format = new GeoJSON();
|
|
|
30
30
|
* @classproperty {boolean} allowRenderWhenAnimating - Allow rendering of the layer when the map is animating.
|
|
31
31
|
* @public
|
|
32
32
|
*/
|
|
33
|
-
// @ts-
|
|
33
|
+
// @ts-expect-error
|
|
34
34
|
class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
35
35
|
/**
|
|
36
36
|
* Constructor.
|
|
@@ -52,48 +52,42 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
52
52
|
// We store the layer used to highlight the full Trajectory
|
|
53
53
|
/** @private */
|
|
54
54
|
this.vectorLayer = new VectorLayer({
|
|
55
|
-
updateWhileAnimating: this.allowRenderWhenAnimating,
|
|
56
|
-
updateWhileInteracting: true,
|
|
57
55
|
source: new VectorSource({ features: [] }),
|
|
58
56
|
style: (feature, resolution) => {
|
|
59
57
|
return (options.fullTrajectoryStyle || fullTrajectoryStyle)(feature, resolution, this.styleOptions);
|
|
60
58
|
},
|
|
59
|
+
updateWhileAnimating: this.allowRenderWhenAnimating,
|
|
60
|
+
updateWhileInteracting: true,
|
|
61
61
|
});
|
|
62
62
|
// Options the last render run did happen. If something changes
|
|
63
63
|
// we have to render again
|
|
64
64
|
/** @private */
|
|
65
65
|
this.renderState = {
|
|
66
66
|
center: [0, 0],
|
|
67
|
-
zoom: undefined,
|
|
68
67
|
rotation: 0,
|
|
68
|
+
zoom: undefined,
|
|
69
69
|
};
|
|
70
70
|
/** @private */
|
|
71
71
|
this.onZoomEndDebounced = debounce(this.onZoomEnd, 100);
|
|
72
72
|
/** @private */
|
|
73
73
|
this.onMoveEndDebounced = debounce(this.onMoveEnd, 100);
|
|
74
74
|
}
|
|
75
|
-
/**
|
|
76
|
-
* @private
|
|
77
|
-
*/
|
|
78
|
-
createRenderer() {
|
|
79
|
-
return new RealtimeLayerRenderer(this);
|
|
80
|
-
}
|
|
81
75
|
/** @private */
|
|
82
76
|
attachToMap(map) {
|
|
83
77
|
super.attachToMap(map);
|
|
84
78
|
if (this.map) {
|
|
85
79
|
// If the layer is visible we start the rendering clock
|
|
86
|
-
if (this.
|
|
80
|
+
if (this.getVisible()) {
|
|
87
81
|
this.start();
|
|
88
82
|
}
|
|
89
|
-
// @ts-expect-error
|
|
83
|
+
// @ts-expect-error - bad ts check RealtimeLayer is a BaseLayer
|
|
90
84
|
const index = this.map.getLayers().getArray().indexOf(this);
|
|
91
85
|
this.map.getLayers().insertAt(index, this.vectorLayer);
|
|
92
86
|
this.olEventsKeys.push(...this.map.on(['moveend', 'change:target'],
|
|
93
|
-
// @ts-expect-error
|
|
87
|
+
// @ts-expect-error - bad ol definitions
|
|
94
88
|
(evt) => {
|
|
95
89
|
const view = (evt.map || evt.target).getView();
|
|
96
|
-
if (view.getAnimating() || view.getInteracting()) {
|
|
90
|
+
if (!view || (view === null || view === void 0 ? void 0 : view.getAnimating()) || (view === null || view === void 0 ? void 0 : view.getInteracting())) {
|
|
97
91
|
return;
|
|
98
92
|
}
|
|
99
93
|
const zoom = view.getZoom();
|
|
@@ -105,7 +99,7 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
105
99
|
this.currentZoom = zoom;
|
|
106
100
|
this.onMoveEndDebounced(evt);
|
|
107
101
|
}), this.on('change:visible', (evt) => {
|
|
108
|
-
if (evt.target.
|
|
102
|
+
if (evt.target.getVisible()) {
|
|
109
103
|
this.start();
|
|
110
104
|
}
|
|
111
105
|
else {
|
|
@@ -120,13 +114,18 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
120
114
|
}
|
|
121
115
|
}
|
|
122
116
|
/**
|
|
123
|
-
*
|
|
117
|
+
* Create a copy of the RealtimeLayer.
|
|
118
|
+
* @param {Object} newOptions Options to override
|
|
119
|
+
* @return {RealtimeLayer} A RealtimeLayer
|
|
120
|
+
*/
|
|
121
|
+
clone(newOptions) {
|
|
122
|
+
return new RealtimeLayer(Object.assign(Object.assign({}, this.options), newOptions));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
124
125
|
* @private
|
|
125
126
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
(_a = this.map) === null || _a === void 0 ? void 0 : _a.removeLayer(this.vectorLayer);
|
|
129
|
-
super.detachFromMap();
|
|
127
|
+
createRenderer() {
|
|
128
|
+
return new RealtimeLayerRenderer(this);
|
|
130
129
|
}
|
|
131
130
|
/**
|
|
132
131
|
* Render the trajectories using current map's size, resolution and rotation.
|
|
@@ -134,63 +133,25 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
134
133
|
* @overrides
|
|
135
134
|
* @private
|
|
136
135
|
*/
|
|
137
|
-
// @ts-ignore
|
|
138
|
-
renderTrajectories(noInterpolate) {
|
|
139
|
-
if (!this.map) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
const view = this.map.getView();
|
|
143
|
-
// it could happen that the view is set but without center yet,
|
|
144
|
-
// so the calcualteExtent will trigger an error.
|
|
145
|
-
if (!view.getCenter()) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
super.renderTrajectories({
|
|
149
|
-
size: this.map.getSize(),
|
|
150
|
-
center: view.getCenter(),
|
|
151
|
-
extent: view.calculateExtent(),
|
|
152
|
-
resolution: view.getResolution(),
|
|
153
|
-
rotation: view.getRotation(),
|
|
154
|
-
zoom: view.getZoom(),
|
|
155
|
-
pixelRatio: this.pixelRatio,
|
|
156
|
-
}, noInterpolate);
|
|
157
|
-
}
|
|
158
136
|
/**
|
|
159
|
-
*
|
|
137
|
+
* Destroy the container of the tracker.
|
|
160
138
|
* @private
|
|
161
|
-
* @override
|
|
162
139
|
*/
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
let isRendered = false;
|
|
168
|
-
const blockRendering = this.allowRenderWhenAnimating
|
|
169
|
-
? false
|
|
170
|
-
: this.map.getView().getAnimating() ||
|
|
171
|
-
this.map.getView().getInteracting();
|
|
172
|
-
// Don't render the map when the map is animating or interacting.
|
|
173
|
-
isRendered = blockRendering
|
|
174
|
-
? false
|
|
175
|
-
: super.renderTrajectoriesInternal(viewState, noInterpolate);
|
|
176
|
-
// We update the current render state.
|
|
177
|
-
if (isRendered) {
|
|
178
|
-
/** @private */
|
|
179
|
-
this.renderedViewState = Object.assign({}, viewState);
|
|
180
|
-
// @ts-expect-error - we are in the same class
|
|
181
|
-
const { container } = this.getRenderer();
|
|
182
|
-
if (container) {
|
|
183
|
-
container.style.transform = '';
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return isRendered;
|
|
140
|
+
detachFromMap() {
|
|
141
|
+
var _a;
|
|
142
|
+
(_a = this.map) === null || _a === void 0 ? void 0 : _a.removeLayer(this.vectorLayer);
|
|
143
|
+
super.detachFromMap();
|
|
187
144
|
}
|
|
188
145
|
/**
|
|
189
146
|
* Return the delay in ms before the next rendering.
|
|
190
147
|
* @private
|
|
191
148
|
*/
|
|
192
149
|
getRefreshTimeInMs() {
|
|
193
|
-
|
|
150
|
+
var _a;
|
|
151
|
+
return super.getRefreshTimeInMs(((_a = this.map.getView()) === null || _a === void 0 ? void 0 : _a.getZoom()) || 0);
|
|
152
|
+
}
|
|
153
|
+
highlight(feature) {
|
|
154
|
+
this.highlightVehicle(feature === null || feature === void 0 ? void 0 : feature.get('train_id'));
|
|
194
155
|
}
|
|
195
156
|
/**
|
|
196
157
|
* On move end we update the websocket with the new bbox.
|
|
@@ -198,12 +159,36 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
198
159
|
* @private
|
|
199
160
|
* @override
|
|
200
161
|
*/
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Highlight the trajectory of journey.
|
|
164
|
+
* @private
|
|
165
|
+
*/
|
|
166
|
+
highlightTrajectory(id) {
|
|
167
|
+
var _a, _b, _c, _d;
|
|
168
|
+
if (!id) {
|
|
169
|
+
(_b = (_a = this.vectorLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear(true);
|
|
170
|
+
return Promise.resolve([]);
|
|
205
171
|
}
|
|
206
|
-
this.
|
|
172
|
+
return this.api
|
|
173
|
+
.getFullTrajectory(id, this.mode, this.getGeneralizationLevelByZoom(Math.floor(((_d = (_c = this.map) === null || _c === void 0 ? void 0 : _c.getView()) === null || _d === void 0 ? void 0 : _d.getZoom()) || 0)))
|
|
174
|
+
.then((data) => {
|
|
175
|
+
var _a, _b, _c, _d, _e;
|
|
176
|
+
const fullTrajectory = data.content;
|
|
177
|
+
if (!((_a = fullTrajectory === null || fullTrajectory === void 0 ? void 0 : fullTrajectory.features) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
178
|
+
return [];
|
|
179
|
+
}
|
|
180
|
+
const features = format.readFeatures(fullTrajectory);
|
|
181
|
+
(_c = (_b = this.vectorLayer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.clear(true);
|
|
182
|
+
if (features.length) {
|
|
183
|
+
(_e = (_d = this.vectorLayer) === null || _d === void 0 ? void 0 : _d.getSource()) === null || _e === void 0 ? void 0 : _e.addFeatures(features);
|
|
184
|
+
}
|
|
185
|
+
return features;
|
|
186
|
+
})
|
|
187
|
+
.catch(() => {
|
|
188
|
+
var _a, _b;
|
|
189
|
+
(_b = (_a = this.vectorLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear(true);
|
|
190
|
+
return [];
|
|
191
|
+
});
|
|
207
192
|
}
|
|
208
193
|
/**
|
|
209
194
|
* Function called on moveend event only when the zoom has changed.
|
|
@@ -212,22 +197,37 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
212
197
|
* @private
|
|
213
198
|
* @override
|
|
214
199
|
*/
|
|
200
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
201
|
+
onMoveEnd(evt) {
|
|
202
|
+
if (!this.isUpdateBboxOnMoveEnd || !this.getVisible()) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
this.setBbox();
|
|
206
|
+
}
|
|
215
207
|
// eslint-disable-next-line no-unused-vars
|
|
216
208
|
onZoomEnd() {
|
|
217
209
|
super.onZoomEnd();
|
|
218
|
-
if (!this.isUpdateBboxOnMoveEnd || !this.
|
|
210
|
+
if (!this.isUpdateBboxOnMoveEnd || !this.getVisible()) {
|
|
219
211
|
return;
|
|
220
212
|
}
|
|
221
213
|
if (this.selectedVehicleId) {
|
|
222
214
|
this.highlightTrajectory(this.selectedVehicleId);
|
|
223
215
|
}
|
|
224
216
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
217
|
+
/**
|
|
218
|
+
* Remove the trajectory form the list if necessary.
|
|
219
|
+
*
|
|
220
|
+
* @private
|
|
221
|
+
*/
|
|
222
|
+
purgeTrajectory(trajectory, extent, zoom) {
|
|
223
|
+
var _a;
|
|
224
|
+
const center = (_a = this.map.getView()) === null || _a === void 0 ? void 0 : _a.getCenter();
|
|
225
|
+
if (!extent && !center) {
|
|
226
|
+
// In that case the view is not zoomed yet so we can't calculate the extent of the map,
|
|
227
|
+
// it will trigger a js error on calculateExtent function.
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
return super.purgeTrajectory(trajectory, extent || this.map.getView().calculateExtent(), zoom || this.map.getView().getZoom() || 0);
|
|
231
231
|
}
|
|
232
232
|
// /**
|
|
233
233
|
// * Update the cursor style when hovering a vehicle.
|
|
@@ -259,19 +259,61 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
259
259
|
// super.onFeatureClick(features, layer, coordinate);
|
|
260
260
|
// this.highlightTrajectory(this.selectedVehicleId);
|
|
261
261
|
// }
|
|
262
|
+
// @ts-expect-error
|
|
263
|
+
renderTrajectories(noInterpolate) {
|
|
264
|
+
if (!this.map) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const view = this.map.getView();
|
|
268
|
+
// it could happen that the view is set but without center yet,
|
|
269
|
+
// so the calcualteExtent will trigger an error.
|
|
270
|
+
if (!(view === null || view === void 0 ? void 0 : view.getCenter())) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
super.renderTrajectories({
|
|
274
|
+
center: view.getCenter(),
|
|
275
|
+
extent: view.calculateExtent(),
|
|
276
|
+
pixelRatio: this.pixelRatio,
|
|
277
|
+
resolution: view.getResolution(),
|
|
278
|
+
rotation: view.getRotation(),
|
|
279
|
+
size: this.map.getSize(),
|
|
280
|
+
zoom: view.getZoom(),
|
|
281
|
+
}, noInterpolate);
|
|
282
|
+
}
|
|
262
283
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
284
|
+
* Launch renderTrajectories. it avoids duplicating code in renderTrajectories methhod.
|
|
265
285
|
* @private
|
|
286
|
+
* @override
|
|
266
287
|
*/
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
if (!
|
|
270
|
-
// In that case the view is not zoomed yet so we can't calculate the extent of the map,
|
|
271
|
-
// it will trigger a js error on calculateExtent function.
|
|
288
|
+
renderTrajectoriesInternal(viewState, noInterpolate) {
|
|
289
|
+
var _a;
|
|
290
|
+
if (!((_a = this.map) === null || _a === void 0 ? void 0 : _a.getView())) {
|
|
272
291
|
return false;
|
|
273
292
|
}
|
|
274
|
-
|
|
293
|
+
let isRendered = false;
|
|
294
|
+
const blockRendering = this.allowRenderWhenAnimating
|
|
295
|
+
? false
|
|
296
|
+
: this.map.getView().getAnimating() ||
|
|
297
|
+
this.map.getView().getInteracting();
|
|
298
|
+
// Don't render the map when the map is animating or interacting.
|
|
299
|
+
isRendered = blockRendering
|
|
300
|
+
? false
|
|
301
|
+
: super.renderTrajectoriesInternal(viewState, noInterpolate);
|
|
302
|
+
// We update the current render state.
|
|
303
|
+
if (isRendered) {
|
|
304
|
+
/** @private */
|
|
305
|
+
this.renderedViewState = Object.assign({}, viewState);
|
|
306
|
+
// @ts-expect-error - we are in the same class
|
|
307
|
+
const { container } = this.getRenderer();
|
|
308
|
+
if (container) {
|
|
309
|
+
container.style.transform = '';
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return isRendered;
|
|
313
|
+
}
|
|
314
|
+
select(feature) {
|
|
315
|
+
this.selectVehicle(feature === null || feature === void 0 ? void 0 : feature.get('train_id'));
|
|
316
|
+
this.highlightTrajectory(feature === null || feature === void 0 ? void 0 : feature.get('train_id'));
|
|
275
317
|
}
|
|
276
318
|
/**
|
|
277
319
|
* Send the current bbox to the websocket
|
|
@@ -279,47 +321,13 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
279
321
|
* @private
|
|
280
322
|
*/
|
|
281
323
|
setBbox(extent, zoom) {
|
|
282
|
-
super.setBbox(extent ||
|
|
283
|
-
this.map.getView().calculateExtent(), zoom || this.map.getView().getZoom() || 0);
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* Highlight the trajectory of journey.
|
|
287
|
-
* @private
|
|
288
|
-
*/
|
|
289
|
-
highlightTrajectory(id) {
|
|
290
324
|
var _a, _b, _c, _d;
|
|
291
|
-
|
|
292
|
-
(_b = (_a = this.
|
|
293
|
-
|
|
325
|
+
const extentt = extent ||
|
|
326
|
+
((_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getView()) === null || _b === void 0 ? void 0 : _b.calculateExtent());
|
|
327
|
+
if (!extentt) {
|
|
328
|
+
return;
|
|
294
329
|
}
|
|
295
|
-
|
|
296
|
-
.getFullTrajectory(id, this.mode, this.getGeneralizationLevelByZoom(Math.floor(((_d = (_c = this.map) === null || _c === void 0 ? void 0 : _c.getView()) === null || _d === void 0 ? void 0 : _d.getZoom()) || 0)))
|
|
297
|
-
.then((data) => {
|
|
298
|
-
var _a, _b, _c, _d, _e;
|
|
299
|
-
const fullTrajectory = data.content;
|
|
300
|
-
if (!((_a = fullTrajectory === null || fullTrajectory === void 0 ? void 0 : fullTrajectory.features) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
301
|
-
return [];
|
|
302
|
-
}
|
|
303
|
-
const features = format.readFeatures(fullTrajectory);
|
|
304
|
-
(_c = (_b = this.vectorLayer) === null || _b === void 0 ? void 0 : _b.getSource()) === null || _c === void 0 ? void 0 : _c.clear(true);
|
|
305
|
-
if (features.length) {
|
|
306
|
-
(_e = (_d = this.vectorLayer) === null || _d === void 0 ? void 0 : _d.getSource()) === null || _e === void 0 ? void 0 : _e.addFeatures(features);
|
|
307
|
-
}
|
|
308
|
-
return features;
|
|
309
|
-
})
|
|
310
|
-
.catch(() => {
|
|
311
|
-
var _a, _b;
|
|
312
|
-
(_b = (_a = this.vectorLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear(true);
|
|
313
|
-
return [];
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Create a copy of the RealtimeLayer.
|
|
318
|
-
* @param {Object} newOptions Options to override
|
|
319
|
-
* @return {RealtimeLayer} A RealtimeLayer
|
|
320
|
-
*/
|
|
321
|
-
clone(newOptions) {
|
|
322
|
-
return new RealtimeLayer(Object.assign(Object.assign({}, this.options), newOptions));
|
|
330
|
+
super.setBbox(extentt, zoom || ((_d = (_c = this.map) === null || _c === void 0 ? void 0 : _c.getView()) === null || _d === void 0 ? void 0 : _d.getZoom()) || 0);
|
|
323
331
|
}
|
|
324
332
|
}
|
|
325
333
|
export default RealtimeLayer;
|
|
@@ -7,8 +7,13 @@ type GConstructor<T = {}> = new (...args: any[]) => T;
|
|
|
7
7
|
export type Layerable = GConstructor<Omit<Layer, keyof string>>;
|
|
8
8
|
declare function MobilityLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
9
9
|
new (...args: any[]): {
|
|
10
|
-
options?: PropertiesLayerMixinOptions;
|
|
11
10
|
olEventsKeys: import("ol/events").EventsKey[];
|
|
11
|
+
options?: PropertiesLayerMixinOptions;
|
|
12
|
+
attachToMap(map: import("ol").Map): void;
|
|
13
|
+
detachFromMap(): void;
|
|
14
|
+
flat(): any[];
|
|
15
|
+
onChildrenChange(oldValue: Layer[]): void;
|
|
16
|
+
setMapInternal: ((map: import("ol").Map) => void) & ((map: import("ol").default | null) => void);
|
|
12
17
|
children: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
13
18
|
get copyrights(): string;
|
|
14
19
|
set copyrights(newCopyrights: string | string[]);
|
|
@@ -21,17 +26,10 @@ declare function MobilityLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
21
26
|
olLayer: Layer;
|
|
22
27
|
parent: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
23
28
|
visible: boolean;
|
|
24
|
-
setMapInternal: ((map: import("ol").Map) => void) & ((map: import("ol").default | null) => void);
|
|
25
|
-
onChildrenChange(oldValue: Layer[]): void;
|
|
26
|
-
attachToMap(map: import("ol").Map): void;
|
|
27
|
-
detachFromMap(): void;
|
|
28
|
-
flat(): any[];
|
|
29
|
-
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
30
|
-
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
31
29
|
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
32
|
-
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
33
30
|
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
34
31
|
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
32
|
+
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
35
33
|
getSource: () => import("ol/source").Source | null;
|
|
36
34
|
getRenderSource: () => import("ol/source").Source | null;
|
|
37
35
|
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<Array<import("ol/Feature").FeatureLike>>;
|
|
@@ -89,9 +87,11 @@ declare function MobilityLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
89
87
|
unset: (key: string, silent?: boolean | undefined) => void;
|
|
90
88
|
changed: () => void;
|
|
91
89
|
getRevision: () => number;
|
|
90
|
+
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
92
91
|
dispatchEvent: (event: import("ol/events/Event").default | string) => boolean | undefined;
|
|
93
92
|
getListeners: (type: string) => Array<import("ol/events").Listener> | undefined;
|
|
94
93
|
hasListener: (type?: string | undefined) => boolean;
|
|
94
|
+
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
95
95
|
dispose: () => void;
|
|
96
96
|
};
|
|
97
97
|
} & TBase;
|
|
@@ -1,31 +1,45 @@
|
|
|
1
|
-
import { Layer } from 'ol/layer';
|
|
2
|
-
import { EventsKey } from 'ol/events';
|
|
3
1
|
import { Map } from 'ol';
|
|
2
|
+
import { EventsKey } from 'ol/events';
|
|
3
|
+
import { Layer } from 'ol/layer';
|
|
4
4
|
import type { Options } from 'ol/layer/Layer';
|
|
5
5
|
import type { Layerable } from './MobilityLayerMixin';
|
|
6
|
-
export type PropertiesLayerMixinOptions =
|
|
7
|
-
key?: string;
|
|
8
|
-
name?: string;
|
|
9
|
-
group?: string;
|
|
10
|
-
copyrights?: string[];
|
|
6
|
+
export type PropertiesLayerMixinOptions = {
|
|
11
7
|
children?: any[];
|
|
12
|
-
|
|
8
|
+
copyrights?: string[];
|
|
13
9
|
disabled?: boolean;
|
|
10
|
+
group?: string;
|
|
14
11
|
hitTolerance?: number;
|
|
15
|
-
|
|
16
|
-
[x: string]: any;
|
|
17
|
-
};
|
|
12
|
+
key?: string;
|
|
18
13
|
map?: Map;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
name?: string;
|
|
15
|
+
properties?: Record<string, any>;
|
|
16
|
+
visible?: boolean;
|
|
17
|
+
} & Options & Record<string, any>;
|
|
22
18
|
/**
|
|
23
19
|
* This mixin adds some properties to access ol custom properties easily.
|
|
24
20
|
*/
|
|
25
21
|
declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
26
22
|
new (...args: any[]): {
|
|
27
|
-
options?: PropertiesLayerMixinOptions;
|
|
28
23
|
olEventsKeys: EventsKey[];
|
|
24
|
+
options?: PropertiesLayerMixinOptions;
|
|
25
|
+
/**
|
|
26
|
+
* Initialize the layer with the map passed in parameters.
|
|
27
|
+
*
|
|
28
|
+
* @param {ol/Map~Map} map A map.
|
|
29
|
+
*/
|
|
30
|
+
attachToMap(map: Map): void;
|
|
31
|
+
/**
|
|
32
|
+
* Terminate what was initialized in init function. Remove layer, events...
|
|
33
|
+
*/
|
|
34
|
+
detachFromMap(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
|
|
37
|
+
* @deprecated
|
|
38
|
+
*/
|
|
39
|
+
flat(): any[];
|
|
40
|
+
/** @private */
|
|
41
|
+
onChildrenChange(oldValue: Layer[]): void;
|
|
42
|
+
setMapInternal(map: Map): void;
|
|
29
43
|
/** @deprecated */
|
|
30
44
|
children: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>[];
|
|
31
45
|
/** @deprecated */
|
|
@@ -35,6 +49,7 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
35
49
|
/** @deprecated */
|
|
36
50
|
disabled: boolean;
|
|
37
51
|
/** @deprecated */
|
|
52
|
+
/** @deprecated */
|
|
38
53
|
readonly group: string;
|
|
39
54
|
/** @deprecated */
|
|
40
55
|
readonly hitTolerance: number;
|
|
@@ -48,30 +63,10 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
48
63
|
parent: Layer<import("ol/source").Source, import("ol/renderer/Layer").default<any>>;
|
|
49
64
|
/** @deprecated */
|
|
50
65
|
visible: boolean;
|
|
51
|
-
setMapInternal(map: Map): void;
|
|
52
|
-
/** @private */
|
|
53
|
-
onChildrenChange(oldValue: Layer[]): void;
|
|
54
|
-
/**
|
|
55
|
-
* Initialize the layer with the map passed in parameters.
|
|
56
|
-
*
|
|
57
|
-
* @param {ol/Map~Map} map A map.
|
|
58
|
-
*/
|
|
59
|
-
attachToMap(map: Map): void;
|
|
60
|
-
/**
|
|
61
|
-
* Terminate what was initialized in init function. Remove layer, events...
|
|
62
|
-
*/
|
|
63
|
-
detachFromMap(): void;
|
|
64
|
-
/**
|
|
65
|
-
* Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
|
|
66
|
-
* @deprecated
|
|
67
|
-
*/
|
|
68
|
-
flat(): any[];
|
|
69
|
-
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
70
|
-
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
71
66
|
on: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
72
|
-
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
73
67
|
once: import("ol/layer/Layer").LayerOnSignature<import("ol/events").EventsKey>;
|
|
74
68
|
un: import("ol/layer/Layer").LayerOnSignature<void>;
|
|
69
|
+
render: (frameState: import("ol/Map").FrameState | null, target: HTMLElement) => HTMLElement | null;
|
|
75
70
|
getSource: () => import("ol/source").Source | null;
|
|
76
71
|
getRenderSource: () => import("ol/source").Source | null;
|
|
77
72
|
getFeatures: (pixel: import("ol/pixel").Pixel) => Promise<Array<import("ol/Feature").FeatureLike>>;
|
|
@@ -129,9 +124,11 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
129
124
|
unset: (key: string, silent?: boolean | undefined) => void;
|
|
130
125
|
changed: () => void;
|
|
131
126
|
getRevision: () => number;
|
|
127
|
+
addEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
132
128
|
dispatchEvent: (event: import("ol/events/Event").default | string) => boolean | undefined;
|
|
133
129
|
getListeners: (type: string) => Array<import("ol/events").Listener> | undefined;
|
|
134
130
|
hasListener: (type?: string | undefined) => boolean;
|
|
131
|
+
removeEventListener: (type: string, listener: import("ol/events").Listener) => void;
|
|
135
132
|
dispose: () => void;
|
|
136
133
|
};
|
|
137
134
|
} & TBase;
|