mobility-toolbox-js 3.0.0-beta.31 → 3.0.0-beta.33
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.js +1 -3
- package/api/RealtimeAPI.d.ts +3 -3
- package/api/WebSocketAPI.js +0 -1
- package/common/styles/realtimeDefaultStyle.js +0 -5
- package/common/styles/realtimeHeadingStyle.js +0 -5
- package/common/styles/realtimeSimpleStyle.d.ts +0 -1
- package/common/styles/realtimeSimpleStyle.js +0 -1
- package/common/utils/RealtimeEngine.d.ts +224 -0
- package/common/utils/RealtimeEngine.js +565 -0
- package/common/utils/getLayersAsFlatArray.d.ts +0 -1
- package/common/utils/getLayersAsFlatArray.js +0 -1
- package/common/utils/realtimeConfig.d.ts +1 -1
- package/common/utils/realtimeConfig.js +0 -1
- package/maplibre/layers/RealtimeLayer.d.ts +50 -109
- package/maplibre/layers/RealtimeLayer.js +108 -111
- package/mbt.js +5122 -13362
- package/mbt.js.map +4 -4
- package/mbt.min.js +67 -70
- package/mbt.min.js.map +4 -4
- package/ol/controls/RoutingControl.d.ts +5 -4
- package/ol/controls/RoutingControl.js +2 -29
- package/ol/controls/StopFinderControl.d.ts +2 -5
- package/ol/controls/StopFinderControl.js +0 -3
- package/ol/layers/MaplibreLayer.d.ts +29 -18
- package/ol/layers/MaplibreLayer.js +18 -10
- package/ol/layers/MaplibreStyleLayer.d.ts +39 -27
- package/ol/layers/MaplibreStyleLayer.js +33 -28
- package/ol/layers/RealtimeLayer.d.ts +72 -124
- package/ol/layers/RealtimeLayer.js +130 -168
- package/ol/mixins/PropertiesLayerMixin.d.ts +4 -6
- package/ol/mixins/PropertiesLayerMixin.js +0 -2
- package/ol/renderers/RealtimeLayerRenderer.js +6 -31
- package/ol/styles/fullTrajectoryDelayStyle.js +5 -7
- package/ol/styles/fullTrajectoryStyle.d.ts +1 -2
- package/ol/styles/fullTrajectoryStyle.js +5 -7
- package/ol/styles/routingStyle.d.ts +0 -1
- package/ol/styles/routingStyle.js +2 -7
- package/package.json +31 -30
- package/types/common.d.ts +2 -1
- package/common/mixins/RealtimeLayerMixin.d.ts +0 -267
- package/common/mixins/RealtimeLayerMixin.js +0 -751
|
@@ -4,11 +4,10 @@ import { Vector as VectorLayer } from 'ol/layer';
|
|
|
4
4
|
import Layer from 'ol/layer/Layer';
|
|
5
5
|
import { Vector as VectorSource } from 'ol/source';
|
|
6
6
|
import Source from 'ol/source/Source';
|
|
7
|
-
import
|
|
7
|
+
import RealtimeEngine from '../../common/utils/RealtimeEngine';
|
|
8
8
|
import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
9
9
|
import RealtimeLayerRenderer from '../renderers/RealtimeLayerRenderer';
|
|
10
10
|
import { fullTrajectoryStyle } from '../styles';
|
|
11
|
-
/** @private */
|
|
12
11
|
const format = new GeoJSON();
|
|
13
12
|
/**
|
|
14
13
|
* An OpenLayers layer able to display data from the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
|
|
@@ -30,57 +29,44 @@ const format = new GeoJSON();
|
|
|
30
29
|
* @classproperty {boolean} allowRenderWhenAnimating - Allow rendering of the layer when the map is animating.
|
|
31
30
|
* @public
|
|
32
31
|
*/
|
|
33
|
-
|
|
34
|
-
class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
32
|
+
class RealtimeLayer extends MobilityLayerMixin(Layer) {
|
|
35
33
|
/**
|
|
36
34
|
* Constructor.
|
|
37
35
|
*
|
|
38
36
|
* @param {RealtimeLayerOptions} options
|
|
39
37
|
* @param {boolean} [options.allowRenderWhenAnimating=false] Allow rendering of the layer when the map is animating.
|
|
40
|
-
* @param {string} options.apiKey Access key for [geOps
|
|
41
|
-
* @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The geOps Realtime API url.
|
|
38
|
+
* @param {string} options.apiKey Access key for [geOps APIs](https://developer.geops.io/).
|
|
39
|
+
* @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The [geOps Realtime API](https://developer.geops.io/apis/realtime/) url.
|
|
42
40
|
*
|
|
43
41
|
*/
|
|
44
42
|
constructor(options) {
|
|
45
43
|
// We use a group to be able to add custom vector layer in extended class.
|
|
46
44
|
// For example TrajservLayer use a vectorLayer to display the complete trajectory.
|
|
47
45
|
super(Object.assign({ source: new Source({}) }, options));
|
|
48
|
-
/** @private */
|
|
49
46
|
this.allowRenderWhenAnimating = false;
|
|
50
|
-
|
|
47
|
+
this.maxNbFeaturesRequested = 100;
|
|
48
|
+
this.engine = new RealtimeEngine(Object.assign({ getViewState: this.getViewState.bind(this), onRender: this.onRealtimeEngineRender.bind(this) }, options));
|
|
51
49
|
this.allowRenderWhenAnimating = !!options.allowRenderWhenAnimating;
|
|
52
50
|
// We store the layer used to highlight the full Trajectory
|
|
53
|
-
/** @private */
|
|
54
51
|
this.vectorLayer = new VectorLayer({
|
|
55
52
|
source: new VectorSource({ features: [] }),
|
|
56
53
|
style: (feature, resolution) => {
|
|
57
|
-
return (options.fullTrajectoryStyle || fullTrajectoryStyle)(feature, resolution, this.styleOptions);
|
|
54
|
+
return (options.fullTrajectoryStyle || fullTrajectoryStyle)(feature, resolution, this.engine.styleOptions);
|
|
58
55
|
},
|
|
59
56
|
updateWhileAnimating: this.allowRenderWhenAnimating,
|
|
60
57
|
updateWhileInteracting: true,
|
|
61
58
|
});
|
|
62
|
-
// Options the last render run did happen. If something changes
|
|
63
|
-
// we have to render again
|
|
64
|
-
/** @private */
|
|
65
|
-
this.renderState = {
|
|
66
|
-
center: [0, 0],
|
|
67
|
-
rotation: 0,
|
|
68
|
-
zoom: undefined,
|
|
69
|
-
};
|
|
70
|
-
/** @private */
|
|
71
59
|
this.onZoomEndDebounced = debounce(this.onZoomEnd, 100);
|
|
72
|
-
/** @private */
|
|
73
60
|
this.onMoveEndDebounced = debounce(this.onMoveEnd, 100);
|
|
74
61
|
}
|
|
75
|
-
/** @private */
|
|
76
62
|
attachToMap(map) {
|
|
77
63
|
super.attachToMap(map);
|
|
64
|
+
this.engine.attachToMap();
|
|
78
65
|
if (this.map) {
|
|
79
66
|
// If the layer is visible we start the rendering clock
|
|
80
67
|
if (this.getVisible()) {
|
|
81
|
-
this.start();
|
|
68
|
+
this.engine.start();
|
|
82
69
|
}
|
|
83
|
-
// @ts-expect-error - bad ts check RealtimeLayer is a BaseLayer
|
|
84
70
|
const index = this.map.getLayers().getArray().indexOf(this);
|
|
85
71
|
this.map.getLayers().insertAt(index, this.vectorLayer);
|
|
86
72
|
this.olEventsKeys.push(...this.map.on(['moveend', 'change:target'],
|
|
@@ -95,15 +81,14 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
95
81
|
if (this.currentZoom !== zoom) {
|
|
96
82
|
this.onZoomEndDebounced(evt);
|
|
97
83
|
}
|
|
98
|
-
/** @private */
|
|
99
84
|
this.currentZoom = zoom;
|
|
100
85
|
this.onMoveEndDebounced(evt);
|
|
101
86
|
}), this.on('change:visible', (evt) => {
|
|
102
87
|
if (evt.target.getVisible()) {
|
|
103
|
-
this.start();
|
|
88
|
+
this.engine.start();
|
|
104
89
|
}
|
|
105
90
|
else {
|
|
106
|
-
this.stop();
|
|
91
|
+
this.engine.stop();
|
|
107
92
|
}
|
|
108
93
|
}), this.on('propertychange', (evt) => {
|
|
109
94
|
// We apply every property change event related to visiblity to the vectorlayer
|
|
@@ -115,53 +100,74 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
115
100
|
}
|
|
116
101
|
/**
|
|
117
102
|
* Create a copy of the RealtimeLayer.
|
|
118
|
-
*
|
|
103
|
+
*
|
|
104
|
+
* @param {Object} newOptions Options to override. See constructor.
|
|
119
105
|
* @return {RealtimeLayer} A RealtimeLayer
|
|
106
|
+
* @public
|
|
120
107
|
*/
|
|
121
108
|
clone(newOptions) {
|
|
122
109
|
return new RealtimeLayer(Object.assign(Object.assign({}, this.options), newOptions));
|
|
123
110
|
}
|
|
124
|
-
/**
|
|
125
|
-
* @private
|
|
126
|
-
*/
|
|
127
111
|
createRenderer() {
|
|
128
112
|
return new RealtimeLayerRenderer(this);
|
|
129
113
|
}
|
|
130
|
-
/**
|
|
131
|
-
* Render the trajectories using current map's size, resolution and rotation.
|
|
132
|
-
* @param {boolean} noInterpolate if true, renders the vehicles without interpolating theirs positions.
|
|
133
|
-
* @overrides
|
|
134
|
-
* @private
|
|
135
|
-
*/
|
|
136
114
|
/**
|
|
137
115
|
* Destroy the container of the tracker.
|
|
138
|
-
* @private
|
|
139
116
|
*/
|
|
140
117
|
detachFromMap() {
|
|
141
118
|
var _a;
|
|
142
119
|
(_a = this.map) === null || _a === void 0 ? void 0 : _a.removeLayer(this.vectorLayer);
|
|
120
|
+
this.engine.detachFromMap();
|
|
143
121
|
super.detachFromMap();
|
|
144
122
|
}
|
|
145
123
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
124
|
+
* Get some informations about a trajectory.
|
|
125
|
+
*
|
|
126
|
+
* @param {RealtimeTrainId} id A vehicle's id.
|
|
127
|
+
* @returns
|
|
148
128
|
*/
|
|
149
|
-
|
|
129
|
+
getTrajectoryInfos(id) {
|
|
130
|
+
var _a, _b;
|
|
131
|
+
// When a vehicle is selected, we request the complete stop sequence and the complete full trajectory.
|
|
132
|
+
// Then we combine them in one response and send them to inherited layers.
|
|
133
|
+
const promises = [
|
|
134
|
+
this.engine.api.getStopSequence(id),
|
|
135
|
+
this.engine.api.getFullTrajectory(id, this.engine.mode, this.engine.getGeneralizationLevelByZoom(Math.floor(((_b = (_a = this.map) === null || _a === void 0 ? void 0 : _a.getView()) === null || _b === void 0 ? void 0 : _b.getZoom()) || 0))),
|
|
136
|
+
];
|
|
137
|
+
return Promise.all(promises).then(([stopSequence, fullTrajectory]) => {
|
|
138
|
+
const response = {
|
|
139
|
+
fullTrajectory,
|
|
140
|
+
stopSequence,
|
|
141
|
+
};
|
|
142
|
+
return response;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
getViewState() {
|
|
150
146
|
var _a;
|
|
151
|
-
|
|
147
|
+
if (!((_a = this.map) === null || _a === void 0 ? void 0 : _a.getView())) {
|
|
148
|
+
return {};
|
|
149
|
+
}
|
|
150
|
+
const view = this.map.getView();
|
|
151
|
+
return {
|
|
152
|
+
center: view.getCenter(),
|
|
153
|
+
extent: view.calculateExtent(),
|
|
154
|
+
pixelRatio: this.engine.pixelRatio,
|
|
155
|
+
resolution: view.getResolution(),
|
|
156
|
+
rotation: view.getRotation(),
|
|
157
|
+
size: this.map.getSize(),
|
|
158
|
+
visible: this.getVisible(),
|
|
159
|
+
zoom: view.getZoom(),
|
|
160
|
+
};
|
|
152
161
|
}
|
|
153
162
|
highlight(feature) {
|
|
154
|
-
|
|
163
|
+
const id = feature === null || feature === void 0 ? void 0 : feature.get('train_id');
|
|
164
|
+
if (this.hoverVehicleId !== id) {
|
|
165
|
+
this.hoverVehicleId = id;
|
|
166
|
+
this.engine.renderTrajectories(true);
|
|
167
|
+
}
|
|
155
168
|
}
|
|
156
|
-
/**
|
|
157
|
-
* On move end we update the websocket with the new bbox.
|
|
158
|
-
*
|
|
159
|
-
* @private
|
|
160
|
-
* @override
|
|
161
|
-
*/
|
|
162
169
|
/**
|
|
163
170
|
* Highlight the trajectory of journey.
|
|
164
|
-
* @private
|
|
165
171
|
*/
|
|
166
172
|
highlightTrajectory(id) {
|
|
167
173
|
var _a, _b, _c, _d;
|
|
@@ -169,8 +175,8 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
169
175
|
(_b = (_a = this.vectorLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear(true);
|
|
170
176
|
return Promise.resolve([]);
|
|
171
177
|
}
|
|
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)))
|
|
178
|
+
return this.engine.api
|
|
179
|
+
.getFullTrajectory(id, this.engine.mode, this.engine.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
180
|
.then((data) => {
|
|
175
181
|
var _a, _b, _c, _d, _e;
|
|
176
182
|
const fullTrajectory = data.content;
|
|
@@ -190,144 +196,100 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
190
196
|
return [];
|
|
191
197
|
});
|
|
192
198
|
}
|
|
199
|
+
onMoveEnd() {
|
|
200
|
+
if (!this.engine.isUpdateBboxOnMoveEnd || !this.getVisible()) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
this.engine.setBbox();
|
|
204
|
+
}
|
|
193
205
|
/**
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* @param {ol/MapEvent~MapEvent} evt Moveend event.
|
|
197
|
-
* @private
|
|
198
|
-
* @override
|
|
206
|
+
* Callback when the RealtimeEngine has rendered successfully.
|
|
199
207
|
*/
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
208
|
+
onRealtimeEngineRender(renderState, viewState) {
|
|
209
|
+
this.renderedViewState = Object.assign({}, viewState);
|
|
210
|
+
// @ts-expect-error - we are in the same class
|
|
211
|
+
const { container } = this.getRenderer();
|
|
212
|
+
if (container) {
|
|
213
|
+
container.style.transform = '';
|
|
204
214
|
}
|
|
205
|
-
this.setBbox();
|
|
206
215
|
}
|
|
207
|
-
// eslint-disable-next-line no-unused-vars
|
|
208
216
|
onZoomEnd() {
|
|
209
|
-
|
|
210
|
-
if (!this.isUpdateBboxOnMoveEnd || !this.getVisible()) {
|
|
217
|
+
this.engine.onZoomEnd();
|
|
218
|
+
if (!this.engine.isUpdateBboxOnMoveEnd || !this.getVisible()) {
|
|
211
219
|
return;
|
|
212
220
|
}
|
|
213
221
|
if (this.selectedVehicleId) {
|
|
214
222
|
this.highlightTrajectory(this.selectedVehicleId);
|
|
215
223
|
}
|
|
216
224
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
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
|
-
}
|
|
232
|
-
// /**
|
|
233
|
-
// * Update the cursor style when hovering a vehicle.
|
|
234
|
-
// *
|
|
235
|
-
// * @private
|
|
236
|
-
// * @override
|
|
237
|
-
// */
|
|
238
|
-
// onFeatureHover(
|
|
239
|
-
// features: Feature[],
|
|
240
|
-
// layer: RealtimeLayer,
|
|
241
|
-
// coordinate: Coordinate,
|
|
242
|
-
// ) {
|
|
243
|
-
// super.onFeatureHover(features, layer, coordinate);
|
|
244
|
-
// this.map.getTargetElement().style.cursor = features.length
|
|
245
|
-
// ? 'pointer'
|
|
246
|
-
// : 'auto';
|
|
247
|
-
// }
|
|
248
|
-
// /**
|
|
249
|
-
// * Display the complete trajectory of the vehicle.
|
|
250
|
-
// *
|
|
251
|
-
// * @private
|
|
252
|
-
// * @override
|
|
253
|
-
// */
|
|
254
|
-
// onFeatureClick(
|
|
255
|
-
// features: Feature[],
|
|
256
|
-
// layer: RealtimeLayer,
|
|
257
|
-
// coordinate: Coordinate,
|
|
258
|
-
// ) {
|
|
259
|
-
// super.onFeatureClick(features, layer, coordinate);
|
|
260
|
-
// this.highlightTrajectory(this.selectedVehicleId);
|
|
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;
|
|
225
|
+
select(feature) {
|
|
226
|
+
const id = feature === null || feature === void 0 ? void 0 : feature.get('train_id');
|
|
227
|
+
if (this.selectedVehicleId !== id) {
|
|
228
|
+
this.selectedVehicleId = id;
|
|
229
|
+
this.engine.renderTrajectories(true);
|
|
272
230
|
}
|
|
273
|
-
|
|
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);
|
|
231
|
+
this.highlightTrajectory(id);
|
|
282
232
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
* @private
|
|
286
|
-
* @override
|
|
287
|
-
*/
|
|
288
|
-
renderTrajectoriesInternal(viewState, noInterpolate) {
|
|
289
|
-
var _a;
|
|
290
|
-
if (!((_a = this.map) === null || _a === void 0 ? void 0 : _a.getView())) {
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
let isRendered = false;
|
|
294
|
-
const blockRendering = this.allowRenderWhenAnimating
|
|
233
|
+
shouldRender() {
|
|
234
|
+
return this.allowRenderWhenAnimating
|
|
295
235
|
? false
|
|
296
236
|
: this.map.getView().getAnimating() ||
|
|
297
237
|
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
238
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
239
|
+
/**
|
|
240
|
+
* Start the rendering.
|
|
241
|
+
*
|
|
242
|
+
* @public
|
|
243
|
+
*/
|
|
244
|
+
start() {
|
|
245
|
+
this.engine.start();
|
|
317
246
|
}
|
|
318
247
|
/**
|
|
319
|
-
*
|
|
248
|
+
* Stop the rendering.
|
|
320
249
|
*
|
|
321
|
-
* @
|
|
250
|
+
* @public
|
|
322
251
|
*/
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
252
|
+
stop() {
|
|
253
|
+
this.engine.stop();
|
|
254
|
+
}
|
|
255
|
+
get api() {
|
|
256
|
+
return this.engine.api;
|
|
257
|
+
}
|
|
258
|
+
set api(api) {
|
|
259
|
+
this.engine.api = api;
|
|
260
|
+
}
|
|
261
|
+
get canvas() {
|
|
262
|
+
return this.engine.canvas;
|
|
263
|
+
}
|
|
264
|
+
get filter() {
|
|
265
|
+
return this.engine.filter;
|
|
266
|
+
}
|
|
267
|
+
get hoverVehicleId() {
|
|
268
|
+
return this.engine.hoverVehicleId;
|
|
269
|
+
}
|
|
270
|
+
set hoverVehicleId(id) {
|
|
271
|
+
this.engine.hoverVehicleId = id;
|
|
272
|
+
}
|
|
273
|
+
get mode() {
|
|
274
|
+
return this.engine.mode;
|
|
275
|
+
}
|
|
276
|
+
set mode(mode) {
|
|
277
|
+
this.engine.mode = mode;
|
|
278
|
+
}
|
|
279
|
+
get pixelRatio() {
|
|
280
|
+
return this.engine.pixelRatio;
|
|
281
|
+
}
|
|
282
|
+
get selectedVehicleId() {
|
|
283
|
+
return this.engine.selectedVehicleId;
|
|
284
|
+
}
|
|
285
|
+
set selectedVehicleId(id) {
|
|
286
|
+
this.engine.selectedVehicleId = id;
|
|
287
|
+
}
|
|
288
|
+
get sort() {
|
|
289
|
+
return this.engine.sort;
|
|
290
|
+
}
|
|
291
|
+
get trajectories() {
|
|
292
|
+
return this.engine.trajectories;
|
|
331
293
|
}
|
|
332
294
|
}
|
|
333
295
|
export default RealtimeLayer;
|
|
@@ -3,7 +3,7 @@ import { EventsKey } from 'ol/events';
|
|
|
3
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 =
|
|
6
|
+
export type PropertiesLayerMixinOptions = {
|
|
7
7
|
children?: any[];
|
|
8
8
|
copyrights?: string[];
|
|
9
9
|
disabled?: boolean;
|
|
@@ -14,7 +14,7 @@ export type PropertiesLayerMixinOptions = Options & Record<string, any> & {
|
|
|
14
14
|
name?: string;
|
|
15
15
|
properties?: Record<string, any>;
|
|
16
16
|
visible?: boolean;
|
|
17
|
-
}
|
|
17
|
+
} & Options & Record<string, any>;
|
|
18
18
|
/**
|
|
19
19
|
* This mixin adds some properties to access ol custom properties easily.
|
|
20
20
|
*/
|
|
@@ -37,7 +37,6 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
37
37
|
* @deprecated
|
|
38
38
|
*/
|
|
39
39
|
flat(): any[];
|
|
40
|
-
/** @private */
|
|
41
40
|
onChildrenChange(oldValue: Layer[]): void;
|
|
42
41
|
setMapInternal(map: Map): void;
|
|
43
42
|
/** @deprecated */
|
|
@@ -49,7 +48,6 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
49
48
|
/** @deprecated */
|
|
50
49
|
disabled: boolean;
|
|
51
50
|
/** @deprecated */
|
|
52
|
-
/** @deprecated */
|
|
53
51
|
readonly group: string;
|
|
54
52
|
/** @deprecated */
|
|
55
53
|
hitTolerance: number;
|
|
@@ -86,7 +84,7 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
86
84
|
getBackground: () => import("ol/layer/Base").BackgroundColor | false;
|
|
87
85
|
getClassName: () => string;
|
|
88
86
|
getLayerState: (managed?: boolean | undefined) => import("ol/layer/Layer").State;
|
|
89
|
-
getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer").default>;
|
|
87
|
+
getLayersArray: (array?: import("ol/layer/Layer").default<import("ol/source").default, import("ol/renderer/Layer").default<any>>[] | undefined) => Array<import("ol/layer/Layer" /** @deprecated */).default>;
|
|
90
88
|
getLayerStatesArray: (states?: import("ol/layer/Layer").State[] | undefined) => Array<import("ol/layer/Layer").State>;
|
|
91
89
|
getExtent: () => import("ol/extent").Extent | undefined;
|
|
92
90
|
getMaxResolution: () => number;
|
|
@@ -116,7 +114,7 @@ declare function PropertiesLayerMixin<TBase extends Layerable>(Base: TBase): {
|
|
|
116
114
|
} | null;
|
|
117
115
|
hasProperties: () => boolean;
|
|
118
116
|
notify: (key: string, oldValue: any) => void;
|
|
119
|
-
addChangeListener: (key: string, listener: import("ol/events"
|
|
117
|
+
addChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
120
118
|
removeChangeListener: (key: string, listener: import("ol/events").Listener) => void;
|
|
121
119
|
set: (key: string, value: any, silent?: boolean | undefined) => void;
|
|
122
120
|
setProperties: (values: {
|
|
@@ -65,7 +65,6 @@ function PropertiesLayerMixin(Base) {
|
|
|
65
65
|
deprecated('Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead.');
|
|
66
66
|
return getLayersAsFlatArray(this);
|
|
67
67
|
}
|
|
68
|
-
/** @private */
|
|
69
68
|
onChildrenChange(oldValue) {
|
|
70
69
|
// Set the parent property
|
|
71
70
|
(oldValue || []).forEach((child) => {
|
|
@@ -120,7 +119,6 @@ function PropertiesLayerMixin(Base) {
|
|
|
120
119
|
this.set('disabled', newValue);
|
|
121
120
|
}
|
|
122
121
|
/** @deprecated */
|
|
123
|
-
/** @deprecated */
|
|
124
122
|
get group() {
|
|
125
123
|
deprecated("Layer.group is deprecated. Use the Layer.get('group') method instead.");
|
|
126
124
|
return this.get('group');
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import { buffer, containsCoordinate } from 'ol/extent';
|
|
2
1
|
import GeoJSON from 'ol/format/GeoJSON';
|
|
3
2
|
import CanvasLayerRenderer from 'ol/renderer/canvas/Layer';
|
|
4
3
|
import { composeCssTransform } from 'ol/transform';
|
|
5
|
-
/** @private */
|
|
6
4
|
const format = new GeoJSON();
|
|
7
5
|
/**
|
|
8
6
|
* This class is a renderer for Maplibre Layer to be able to use the native ol
|
|
9
7
|
* functionnalities like map.getFeaturesAtPixel or map.hasFeatureAtPixel.
|
|
10
8
|
* @private
|
|
11
9
|
*/
|
|
12
|
-
// @ts-expect-error
|
|
13
10
|
export default class RealtimeLayerRenderer extends CanvasLayerRenderer {
|
|
14
11
|
forEachFeatureAtCoordinate(coordinate, frameState, hitTolerance, callback) {
|
|
15
12
|
const features = this.getFeaturesAtCoordinate(coordinate, hitTolerance);
|
|
16
13
|
features.forEach((feature) => {
|
|
17
|
-
// @ts-expect-error
|
|
14
|
+
// @ts-expect-error defintion to fix
|
|
18
15
|
callback(feature, this.layer_, feature.getGeometry());
|
|
19
16
|
});
|
|
20
17
|
return features === null || features === void 0 ? void 0 : features[0];
|
|
@@ -43,37 +40,15 @@ export default class RealtimeLayerRenderer extends CanvasLayerRenderer {
|
|
|
43
40
|
return Promise.resolve(this.getFeaturesAtCoordinate(coordinate));
|
|
44
41
|
}
|
|
45
42
|
getFeaturesAtCoordinate(coordinate, hitTolerance = 5) {
|
|
46
|
-
var _a;
|
|
47
43
|
if (!coordinate) {
|
|
48
44
|
return [];
|
|
49
45
|
}
|
|
50
46
|
const layer = this.getLayer();
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
let trajectories = Object.values(layer.trajectories || {});
|
|
57
|
-
if (layer.sort) {
|
|
58
|
-
// @ts-expect-error
|
|
59
|
-
trajectories = trajectories.sort(this.sort);
|
|
60
|
-
}
|
|
61
|
-
const vehicles = [];
|
|
62
|
-
for (let i = 0; i < trajectories.length; i += 1) {
|
|
63
|
-
const trajectory = trajectories[i];
|
|
64
|
-
if (
|
|
65
|
-
// @ts-expect-error coordinate is added by the RealtimeLayer
|
|
66
|
-
trajectory.properties.coordinate &&
|
|
67
|
-
// @ts-expect-error coordinate is added by the RealtimeLayer
|
|
68
|
-
containsCoordinate(ext, trajectory.properties.coordinate)) {
|
|
69
|
-
vehicles.push(trajectories[i]);
|
|
70
|
-
}
|
|
71
|
-
if (vehicles.length === nb) {
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
features = vehicles.map((vehicle) => format.readFeature(vehicle));
|
|
76
|
-
return features;
|
|
47
|
+
const featureCollection = layer.engine.getVehiclesAtCoordinate(coordinate, {
|
|
48
|
+
hitTolerance,
|
|
49
|
+
nb: layer.maxNbFeaturesRequested,
|
|
50
|
+
});
|
|
51
|
+
return format.readFeatures(featureCollection);
|
|
77
52
|
}
|
|
78
53
|
// eslint-disable-next-line class-methods-use-this
|
|
79
54
|
prepareFrame() {
|
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/** @private */
|
|
1
|
+
import { Circle, Fill, Stroke, Style } from 'ol/style';
|
|
3
2
|
const stroke = new Style({
|
|
4
|
-
zIndex: 2,
|
|
5
3
|
image: new Circle({
|
|
6
|
-
radius: 5,
|
|
7
4
|
fill: new Fill({
|
|
8
5
|
color: '#000000',
|
|
9
6
|
}),
|
|
7
|
+
radius: 5,
|
|
10
8
|
}),
|
|
11
9
|
stroke: new Stroke({
|
|
12
10
|
color: '#000000',
|
|
13
11
|
width: 6,
|
|
14
12
|
}),
|
|
13
|
+
zIndex: 2,
|
|
15
14
|
});
|
|
16
|
-
/** @private */
|
|
17
15
|
const fill = new Style({
|
|
18
|
-
zIndex: 3,
|
|
19
16
|
image: new Circle({
|
|
20
|
-
radius: 4,
|
|
21
17
|
fill: new Fill({
|
|
22
18
|
color: '#a0a0a0',
|
|
23
19
|
}),
|
|
20
|
+
radius: 4,
|
|
24
21
|
}),
|
|
25
22
|
stroke: new Stroke({
|
|
26
23
|
color: '#a0a0a0',
|
|
27
24
|
width: 4,
|
|
28
25
|
}),
|
|
26
|
+
zIndex: 3,
|
|
29
27
|
});
|
|
30
28
|
/**
|
|
31
29
|
* @private
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { FeatureLike } from 'ol/Feature';
|
|
2
1
|
import { Style } from 'ol/style';
|
|
3
|
-
|
|
2
|
+
import type { FeatureLike } from 'ol/Feature';
|
|
4
3
|
declare const fullTrajectorystyle: (feature: FeatureLike, resolution: number, options: any) => Style[];
|
|
5
4
|
export default fullTrajectorystyle;
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/** @private */
|
|
1
|
+
import { Circle, Fill, Stroke, Style } from 'ol/style';
|
|
3
2
|
const borderStyle = new Style({
|
|
4
|
-
zIndex: 2,
|
|
5
3
|
image: new Circle({
|
|
6
|
-
radius: 5,
|
|
7
4
|
fill: new Fill({
|
|
8
5
|
color: '#000000',
|
|
9
6
|
}),
|
|
7
|
+
radius: 5,
|
|
10
8
|
}),
|
|
11
9
|
stroke: new Stroke({
|
|
12
10
|
color: '#000000',
|
|
13
11
|
width: 6,
|
|
14
12
|
}),
|
|
13
|
+
zIndex: 2,
|
|
15
14
|
});
|
|
16
|
-
/** @private */
|
|
17
15
|
const fullTrajectorystyle = (feature, resolution, options) => {
|
|
18
16
|
let lineColor = '#ffffff'; // white
|
|
19
17
|
const type = feature.get('type');
|
|
@@ -27,17 +25,17 @@ const fullTrajectorystyle = (feature, resolution, options) => {
|
|
|
27
25
|
const style = [
|
|
28
26
|
borderStyle,
|
|
29
27
|
new Style({
|
|
30
|
-
zIndex: 3,
|
|
31
28
|
image: new Circle({
|
|
32
|
-
radius: 4,
|
|
33
29
|
fill: new Fill({
|
|
34
30
|
color: lineColor,
|
|
35
31
|
}),
|
|
32
|
+
radius: 4,
|
|
36
33
|
}),
|
|
37
34
|
stroke: new Stroke({
|
|
38
35
|
color: lineColor,
|
|
39
36
|
width: 4,
|
|
40
37
|
}),
|
|
38
|
+
zIndex: 3,
|
|
41
39
|
}),
|
|
42
40
|
];
|
|
43
41
|
return style;
|