mobility-toolbox-js 3.0.1-beta.0 → 3.0.1-beta.2
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/README.md +11 -3
- package/api/HttpAPI.js +1 -3
- package/api/RealtimeAPI.d.ts +47 -47
- package/api/RealtimeAPI.js +74 -74
- package/api/WebSocketAPI.js +0 -1
- package/common/controls/StopFinderControlCommon.d.ts +1 -1
- package/common/controls/StopFinderControlCommon.js +1 -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/typedefs.d.ts +0 -117
- package/common/typedefs.js +0 -31
- package/common/utils/RealtimeEngine.d.ts +214 -0
- package/common/utils/RealtimeEngine.js +554 -0
- package/common/utils/getLayersAsFlatArray.d.ts +0 -1
- package/common/utils/getLayersAsFlatArray.js +0 -1
- package/common/utils/getVehiclePosition.js +1 -4
- package/common/utils/realtimeConfig.d.ts +1 -1
- package/common/utils/realtimeConfig.js +0 -1
- package/common/utils/renderTrajectories.d.ts +1 -0
- package/common/utils/renderTrajectories.js +1 -0
- package/common/utils/sortAndFilterDepartures.d.ts +1 -0
- package/common/utils/sortAndFilterDepartures.js +1 -0
- package/maplibre/controls/CopyrightControl.d.ts +9 -6
- package/maplibre/controls/CopyrightControl.js +11 -8
- package/maplibre/layers/Layer.d.ts +7 -6
- package/maplibre/layers/Layer.js +1 -2
- package/maplibre/layers/RealtimeLayer.d.ts +54 -111
- package/maplibre/layers/RealtimeLayer.js +126 -114
- package/maplibre/utils/getSourceCoordinates.d.ts +1 -0
- package/maplibre/utils/getSourceCoordinates.js +5 -4
- package/mbt.js +6960 -14605
- package/mbt.js.map +4 -4
- package/mbt.min.js +68 -71
- package/mbt.min.js.map +4 -4
- package/ol/controls/CopyrightControl.d.ts +13 -5
- package/ol/controls/CopyrightControl.js +13 -5
- package/ol/controls/RoutingControl.d.ts +29 -18
- package/ol/controls/RoutingControl.js +44 -56
- package/ol/controls/StopFinderControl.d.ts +21 -2
- package/ol/controls/StopFinderControl.js +22 -3
- package/ol/index.d.ts +0 -1
- package/ol/index.js +0 -1
- package/ol/layers/Layer.d.ts +17 -92
- package/ol/layers/Layer.js +17 -3
- package/ol/layers/MaplibreLayer.d.ts +47 -114
- package/ol/layers/MaplibreLayer.js +102 -46
- package/ol/layers/MaplibreStyleLayer.d.ts +67 -147
- package/ol/layers/MaplibreStyleLayer.js +170 -123
- package/ol/layers/RealtimeLayer.d.ts +85 -218
- package/ol/layers/RealtimeLayer.js +170 -181
- package/ol/layers/VectorLayer.d.ts +1 -2
- package/ol/layers/VectorLayer.js +7 -6
- package/ol/renderers/MaplibreLayerRenderer.d.ts +9 -0
- package/ol/renderers/MaplibreLayerRenderer.js +35 -137
- package/ol/renderers/MaplibreStyleLayerRenderer.js +2 -2
- package/ol/renderers/RealtimeLayerRenderer.d.ts +1 -1
- 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 +13 -10
- package/ol/utils/defineDeprecatedProperties.d.ts +10 -0
- package/ol/utils/defineDeprecatedProperties.js +180 -0
- package/package.json +40 -39
- package/setupTests.js +14 -0
- package/types/common.d.ts +4 -27
- package/types/realtime.d.ts +7 -2
- package/common/mixins/RealtimeLayerMixin.d.ts +0 -267
- package/common/mixins/RealtimeLayerMixin.js +0 -751
- package/ol/mixins/MobilityLayerMixin.d.ts +0 -96
- package/ol/mixins/MobilityLayerMixin.js +0 -6
- package/ol/mixins/PropertiesLayerMixin.d.ts +0 -136
- package/ol/mixins/PropertiesLayerMixin.js +0 -178
- package/ol/mixins/index.d.ts +0 -1
- package/ol/mixins/index.js +0 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import debounce from 'lodash.debounce';
|
|
2
2
|
import GeoJSON from 'ol/format/GeoJSON';
|
|
3
|
-
import { Vector as VectorLayer } from 'ol/layer';
|
|
4
3
|
import Layer from 'ol/layer/Layer';
|
|
4
|
+
import VectorLayer from 'ol/layer/Vector';
|
|
5
|
+
import { unByKey } from 'ol/Observable';
|
|
5
6
|
import { Vector as VectorSource } from 'ol/source';
|
|
6
7
|
import Source from 'ol/source/Source';
|
|
7
|
-
import
|
|
8
|
-
import MobilityLayerMixin from '../mixins/MobilityLayerMixin';
|
|
8
|
+
import RealtimeEngine from '../../common/utils/RealtimeEngine';
|
|
9
9
|
import RealtimeLayerRenderer from '../renderers/RealtimeLayerRenderer';
|
|
10
10
|
import { fullTrajectoryStyle } from '../styles';
|
|
11
|
-
|
|
11
|
+
import defineDeprecatedProperties from '../utils/defineDeprecatedProperties';
|
|
12
12
|
const format = new GeoJSON();
|
|
13
13
|
/**
|
|
14
14
|
* An OpenLayers layer able to display data from the [geOps Realtime API](https://developer.geops.io/apis/realtime/).
|
|
@@ -24,66 +24,104 @@ const format = new GeoJSON();
|
|
|
24
24
|
*
|
|
25
25
|
*
|
|
26
26
|
* @see <a href="/api/class/src/api/RealtimeAPI%20js~RealtimeAPI%20html">RealtimeAPI</a>
|
|
27
|
+
* @see <a href="/example/ol-realtime">OpenLayers Realtime layer example</a>
|
|
28
|
+
*
|
|
27
29
|
*
|
|
28
30
|
* @extends {ol/layer/Layer~Layer}
|
|
29
31
|
*
|
|
32
|
+
*
|
|
30
33
|
* @classproperty {boolean} allowRenderWhenAnimating - Allow rendering of the layer when the map is animating.
|
|
31
34
|
* @public
|
|
32
35
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
class RealtimeLayer extends Layer {
|
|
37
|
+
get api() {
|
|
38
|
+
return this.engine.api;
|
|
39
|
+
}
|
|
40
|
+
set api(api) {
|
|
41
|
+
this.engine.api = api;
|
|
42
|
+
}
|
|
43
|
+
get canvas() {
|
|
44
|
+
return this.engine.canvas;
|
|
45
|
+
}
|
|
46
|
+
get filter() {
|
|
47
|
+
return this.engine.filter;
|
|
48
|
+
}
|
|
49
|
+
set filter(filter) {
|
|
50
|
+
this.engine.filter = filter;
|
|
51
|
+
}
|
|
52
|
+
get hoverVehicleId() {
|
|
53
|
+
return this.engine.hoverVehicleId;
|
|
54
|
+
}
|
|
55
|
+
set hoverVehicleId(id) {
|
|
56
|
+
this.engine.hoverVehicleId = id;
|
|
57
|
+
}
|
|
58
|
+
get mode() {
|
|
59
|
+
return this.engine.mode;
|
|
60
|
+
}
|
|
61
|
+
set mode(mode) {
|
|
62
|
+
this.engine.mode = mode;
|
|
63
|
+
}
|
|
64
|
+
get pixelRatio() {
|
|
65
|
+
return this.engine.pixelRatio;
|
|
66
|
+
}
|
|
67
|
+
get selectedVehicleId() {
|
|
68
|
+
return this.engine.selectedVehicleId;
|
|
69
|
+
}
|
|
70
|
+
set selectedVehicleId(id) {
|
|
71
|
+
this.engine.selectedVehicleId = id;
|
|
72
|
+
}
|
|
73
|
+
get sort() {
|
|
74
|
+
return this.engine.sort;
|
|
75
|
+
}
|
|
76
|
+
set sort(sort) {
|
|
77
|
+
this.engine.sort = sort;
|
|
78
|
+
}
|
|
79
|
+
get trajectories() {
|
|
80
|
+
return this.engine.trajectories;
|
|
81
|
+
}
|
|
35
82
|
/**
|
|
36
83
|
* Constructor.
|
|
37
84
|
*
|
|
38
85
|
* @param {RealtimeLayerOptions} options
|
|
39
86
|
* @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.
|
|
42
|
-
*
|
|
87
|
+
* @param {string} options.apiKey Access key for [geOps APIs](https://developer.geops.io/).
|
|
88
|
+
* @param {string} [options.url="wss://api.geops.io/tracker-ws/v1/"] The [geOps Realtime API](https://developer.geops.io/apis/realtime/) url.
|
|
89
|
+
* @public
|
|
43
90
|
*/
|
|
44
91
|
constructor(options) {
|
|
45
92
|
// We use a group to be able to add custom vector layer in extended class.
|
|
46
93
|
// For example TrajservLayer use a vectorLayer to display the complete trajectory.
|
|
47
94
|
super(Object.assign({ source: new Source({}) }, options));
|
|
48
|
-
/** @private */
|
|
49
95
|
this.allowRenderWhenAnimating = false;
|
|
50
|
-
|
|
96
|
+
this.maxNbFeaturesRequested = 100;
|
|
97
|
+
this.olEventsKeys = [];
|
|
98
|
+
// For backward compatibility with v2
|
|
99
|
+
defineDeprecatedProperties(this, options);
|
|
100
|
+
this.engine = new RealtimeEngine(Object.assign({ getViewState: this.getViewState.bind(this), onRender: this.onRealtimeEngineRender.bind(this) }, options));
|
|
51
101
|
this.allowRenderWhenAnimating = !!options.allowRenderWhenAnimating;
|
|
52
102
|
// We store the layer used to highlight the full Trajectory
|
|
53
|
-
/** @private */
|
|
54
103
|
this.vectorLayer = new VectorLayer({
|
|
55
104
|
source: new VectorSource({ features: [] }),
|
|
56
105
|
style: (feature, resolution) => {
|
|
57
|
-
return (options.fullTrajectoryStyle || fullTrajectoryStyle)(feature, resolution, this.styleOptions);
|
|
106
|
+
return (options.fullTrajectoryStyle || fullTrajectoryStyle)(feature, resolution, this.engine.styleOptions);
|
|
58
107
|
},
|
|
59
108
|
updateWhileAnimating: this.allowRenderWhenAnimating,
|
|
60
109
|
updateWhileInteracting: true,
|
|
61
110
|
});
|
|
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
111
|
this.onZoomEndDebounced = debounce(this.onZoomEnd, 100);
|
|
72
|
-
/** @private */
|
|
73
112
|
this.onMoveEndDebounced = debounce(this.onMoveEnd, 100);
|
|
74
113
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (
|
|
114
|
+
attachToMap() {
|
|
115
|
+
this.engine.attachToMap();
|
|
116
|
+
const mapInternal = this.getMapInternal();
|
|
117
|
+
if (mapInternal) {
|
|
79
118
|
// If the layer is visible we start the rendering clock
|
|
80
119
|
if (this.getVisible()) {
|
|
81
|
-
this.start();
|
|
120
|
+
this.engine.start();
|
|
82
121
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.
|
|
86
|
-
this.olEventsKeys.push(...this.map.on(['moveend', 'change:target'],
|
|
122
|
+
const index = mapInternal.getLayers().getArray().indexOf(this);
|
|
123
|
+
mapInternal.getLayers().insertAt(index, this.vectorLayer);
|
|
124
|
+
this.olEventsKeys.push(...mapInternal.on(['moveend', 'change:target'],
|
|
87
125
|
// @ts-expect-error - bad ol definitions
|
|
88
126
|
(evt) => {
|
|
89
127
|
const view = (evt.map || evt.target).getView();
|
|
@@ -95,15 +133,14 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
95
133
|
if (this.currentZoom !== zoom) {
|
|
96
134
|
this.onZoomEndDebounced(evt);
|
|
97
135
|
}
|
|
98
|
-
/** @private */
|
|
99
136
|
this.currentZoom = zoom;
|
|
100
137
|
this.onMoveEndDebounced(evt);
|
|
101
138
|
}), this.on('change:visible', (evt) => {
|
|
102
139
|
if (evt.target.getVisible()) {
|
|
103
|
-
this.start();
|
|
140
|
+
this.engine.start();
|
|
104
141
|
}
|
|
105
142
|
else {
|
|
106
|
-
this.stop();
|
|
143
|
+
this.engine.stop();
|
|
107
144
|
}
|
|
108
145
|
}), this.on('propertychange', (evt) => {
|
|
109
146
|
// We apply every property change event related to visiblity to the vectorlayer
|
|
@@ -115,53 +152,77 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
115
152
|
}
|
|
116
153
|
/**
|
|
117
154
|
* Create a copy of the RealtimeLayer.
|
|
118
|
-
*
|
|
155
|
+
*
|
|
156
|
+
* @param {Object} newOptions Options to override. See constructor.
|
|
119
157
|
* @return {RealtimeLayer} A RealtimeLayer
|
|
158
|
+
* @public
|
|
120
159
|
*/
|
|
121
160
|
clone(newOptions) {
|
|
122
|
-
return new RealtimeLayer(Object.assign(Object.assign({}, this.options), newOptions));
|
|
161
|
+
return new RealtimeLayer(Object.assign(Object.assign({}, this.get('options')), newOptions));
|
|
123
162
|
}
|
|
124
|
-
/**
|
|
125
|
-
* @private
|
|
126
|
-
*/
|
|
127
163
|
createRenderer() {
|
|
128
164
|
return new RealtimeLayerRenderer(this);
|
|
129
165
|
}
|
|
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
166
|
/**
|
|
137
167
|
* Destroy the container of the tracker.
|
|
138
|
-
* @private
|
|
139
168
|
*/
|
|
140
169
|
detachFromMap() {
|
|
141
170
|
var _a;
|
|
142
|
-
(
|
|
143
|
-
|
|
171
|
+
unByKey(this.olEventsKeys);
|
|
172
|
+
(_a = this.getMapInternal()) === null || _a === void 0 ? void 0 : _a.removeLayer(this.vectorLayer);
|
|
173
|
+
this.engine.detachFromMap();
|
|
144
174
|
}
|
|
145
175
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
176
|
+
* Get some informations about a trajectory.
|
|
177
|
+
*
|
|
178
|
+
* @param {RealtimeTrainId} id A vehicle's id.
|
|
179
|
+
* @returns
|
|
148
180
|
*/
|
|
149
|
-
|
|
150
|
-
var _a;
|
|
151
|
-
|
|
181
|
+
getTrajectoryInfos(id) {
|
|
182
|
+
var _a, _b;
|
|
183
|
+
// When a vehicle is selected, we request the complete stop sequence and the complete full trajectory.
|
|
184
|
+
// Then we combine them in one response and send them to inherited layers.
|
|
185
|
+
const promises = [
|
|
186
|
+
this.engine.api.getStopSequence(id),
|
|
187
|
+
this.engine.api.getFullTrajectory(id, this.engine.mode, this.engine.getGeneralizationLevelByZoom(Math.floor(((_b = (_a = this.getMapInternal()) === null || _a === void 0 ? void 0 : _a.getView()) === null || _b === void 0 ? void 0 : _b.getZoom()) || 0))),
|
|
188
|
+
];
|
|
189
|
+
return Promise.all(promises).then(([stopSequence, fullTrajectory]) => {
|
|
190
|
+
const response = {
|
|
191
|
+
fullTrajectory,
|
|
192
|
+
stopSequence,
|
|
193
|
+
};
|
|
194
|
+
return response;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
getVehicles(filterFunc) {
|
|
198
|
+
return this.engine.getVehicles(filterFunc);
|
|
199
|
+
}
|
|
200
|
+
getViewState() {
|
|
201
|
+
const mapInternal = this.getMapInternal();
|
|
202
|
+
if (!(mapInternal === null || mapInternal === void 0 ? void 0 : mapInternal.getView())) {
|
|
203
|
+
return {};
|
|
204
|
+
}
|
|
205
|
+
const view = mapInternal.getView();
|
|
206
|
+
return {
|
|
207
|
+
center: view.getCenter(),
|
|
208
|
+
extent: view.calculateExtent(),
|
|
209
|
+
pixelRatio: this.engine.pixelRatio,
|
|
210
|
+
resolution: view.getResolution(),
|
|
211
|
+
rotation: view.getRotation(),
|
|
212
|
+
size: mapInternal.getSize(),
|
|
213
|
+
visible: this.getVisible(),
|
|
214
|
+
zoom: view.getZoom(),
|
|
215
|
+
};
|
|
152
216
|
}
|
|
153
217
|
highlight(feature) {
|
|
154
|
-
|
|
218
|
+
const id = feature === null || feature === void 0 ? void 0 : feature.get('train_id');
|
|
219
|
+
if (this.hoverVehicleId !== id) {
|
|
220
|
+
this.hoverVehicleId = id;
|
|
221
|
+
this.engine.renderTrajectories(true);
|
|
222
|
+
}
|
|
155
223
|
}
|
|
156
|
-
/**
|
|
157
|
-
* On move end we update the websocket with the new bbox.
|
|
158
|
-
*
|
|
159
|
-
* @private
|
|
160
|
-
* @override
|
|
161
|
-
*/
|
|
162
224
|
/**
|
|
163
225
|
* Highlight the trajectory of journey.
|
|
164
|
-
* @private
|
|
165
226
|
*/
|
|
166
227
|
highlightTrajectory(id) {
|
|
167
228
|
var _a, _b, _c, _d;
|
|
@@ -169,8 +230,8 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
169
230
|
(_b = (_a = this.vectorLayer) === null || _a === void 0 ? void 0 : _a.getSource()) === null || _b === void 0 ? void 0 : _b.clear(true);
|
|
170
231
|
return Promise.resolve([]);
|
|
171
232
|
}
|
|
172
|
-
return this.api
|
|
173
|
-
.getFullTrajectory(id, this.mode, this.getGeneralizationLevelByZoom(Math.floor(((_d = (_c = this.
|
|
233
|
+
return this.engine.api
|
|
234
|
+
.getFullTrajectory(id, this.engine.mode, this.engine.getGeneralizationLevelByZoom(Math.floor(((_d = (_c = this.getMapInternal()) === null || _c === void 0 ? void 0 : _c.getView()) === null || _d === void 0 ? void 0 : _d.getZoom()) || 0)))
|
|
174
235
|
.then((data) => {
|
|
175
236
|
var _a, _b, _c, _d, _e;
|
|
176
237
|
const fullTrajectory = data.content;
|
|
@@ -190,144 +251,72 @@ class RealtimeLayer extends RealtimeLayerMixin(MobilityLayerMixin(Layer)) {
|
|
|
190
251
|
return [];
|
|
191
252
|
});
|
|
192
253
|
}
|
|
254
|
+
onMoveEnd() {
|
|
255
|
+
if (!this.engine.isUpdateBboxOnMoveEnd || !this.getVisible()) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
this.engine.setBbox();
|
|
259
|
+
}
|
|
193
260
|
/**
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* @param {ol/MapEvent~MapEvent} evt Moveend event.
|
|
197
|
-
* @private
|
|
198
|
-
* @override
|
|
261
|
+
* Callback when the RealtimeEngine has rendered successfully.
|
|
199
262
|
*/
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
263
|
+
onRealtimeEngineRender(renderState, viewState) {
|
|
264
|
+
this.renderedViewState = Object.assign({}, viewState);
|
|
265
|
+
// @ts-expect-error - we are in the same class
|
|
266
|
+
const { container } = this.getRenderer();
|
|
267
|
+
if (container) {
|
|
268
|
+
container.style.transform = '';
|
|
204
269
|
}
|
|
205
|
-
this.setBbox();
|
|
206
270
|
}
|
|
207
|
-
// eslint-disable-next-line no-unused-vars
|
|
208
271
|
onZoomEnd() {
|
|
209
|
-
|
|
210
|
-
if (!this.isUpdateBboxOnMoveEnd || !this.getVisible()) {
|
|
272
|
+
this.engine.onZoomEnd();
|
|
273
|
+
if (!this.engine.isUpdateBboxOnMoveEnd || !this.getVisible()) {
|
|
211
274
|
return;
|
|
212
275
|
}
|
|
213
276
|
if (this.selectedVehicleId) {
|
|
214
277
|
this.highlightTrajectory(this.selectedVehicleId);
|
|
215
278
|
}
|
|
216
279
|
}
|
|
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;
|
|
280
|
+
select(feature) {
|
|
281
|
+
const id = feature === null || feature === void 0 ? void 0 : feature.get('train_id');
|
|
282
|
+
if (this.selectedVehicleId !== id) {
|
|
283
|
+
this.selectedVehicleId = id;
|
|
284
|
+
this.engine.renderTrajectories(true);
|
|
229
285
|
}
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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;
|
|
286
|
+
this.highlightTrajectory(id);
|
|
287
|
+
}
|
|
288
|
+
setMapInternal(map) {
|
|
289
|
+
if (map) {
|
|
290
|
+
super.setMapInternal(map);
|
|
291
|
+
this.attachToMap();
|
|
266
292
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (!(view === null || view === void 0 ? void 0 : view.getCenter())) {
|
|
271
|
-
return;
|
|
293
|
+
else {
|
|
294
|
+
this.detachFromMap();
|
|
295
|
+
super.setMapInternal(map);
|
|
272
296
|
}
|
|
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
297
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
|
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
|
|
298
|
+
shouldRender() {
|
|
299
|
+
var _a, _b;
|
|
300
|
+
return this.allowRenderWhenAnimating
|
|
300
301
|
? false
|
|
301
|
-
:
|
|
302
|
-
|
|
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;
|
|
302
|
+
: ((_a = this.getMapInternal()) === null || _a === void 0 ? void 0 : _a.getView().getAnimating()) ||
|
|
303
|
+
((_b = this.getMapInternal()) === null || _b === void 0 ? void 0 : _b.getView().getInteracting());
|
|
313
304
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
305
|
+
/**
|
|
306
|
+
* Start the rendering.
|
|
307
|
+
*
|
|
308
|
+
* @public
|
|
309
|
+
*/
|
|
310
|
+
start() {
|
|
311
|
+
this.engine.start();
|
|
317
312
|
}
|
|
318
313
|
/**
|
|
319
|
-
*
|
|
314
|
+
* Stop the rendering.
|
|
320
315
|
*
|
|
321
|
-
* @
|
|
316
|
+
* @public
|
|
322
317
|
*/
|
|
323
|
-
|
|
324
|
-
|
|
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;
|
|
329
|
-
}
|
|
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);
|
|
318
|
+
stop() {
|
|
319
|
+
this.engine.stop();
|
|
331
320
|
}
|
|
332
321
|
}
|
|
333
322
|
export default RealtimeLayer;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Coordinate } from 'ol/coordinate';
|
|
2
2
|
import { LayerGetFeatureInfoResponse } from '../../types';
|
|
3
|
-
import { MobilityLayerOptions } from '
|
|
4
|
-
import Layer from './Layer';
|
|
3
|
+
import Layer, { MobilityLayerOptions } from './Layer';
|
|
5
4
|
/**
|
|
6
5
|
* @deprecated
|
|
7
6
|
*/
|
package/ol/layers/VectorLayer.js
CHANGED
|
@@ -7,19 +7,20 @@ class VectorLayer extends Layer {
|
|
|
7
7
|
* @deprecated
|
|
8
8
|
*/
|
|
9
9
|
clone(newOptions) {
|
|
10
|
-
return new VectorLayer(Object.assign(Object.assign({}, this.options), newOptions));
|
|
10
|
+
return new VectorLayer(Object.assign(Object.assign({}, this.get('options')), newOptions));
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* @deprecated
|
|
14
14
|
*/
|
|
15
15
|
getFeatureInfoAtCoordinate(coordinate) {
|
|
16
16
|
let features = [];
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const mapInternal = this.getMapInternal();
|
|
18
|
+
if (mapInternal) {
|
|
19
|
+
const pixel = mapInternal.getPixelFromCoordinate(coordinate);
|
|
19
20
|
features =
|
|
20
|
-
|
|
21
|
-
hitTolerance: this.hitTolerance || 5,
|
|
22
|
-
layerFilter: (l) => l === this
|
|
21
|
+
mapInternal.getFeaturesAtPixel(pixel, {
|
|
22
|
+
hitTolerance: this.get('hitTolerance') || 5,
|
|
23
|
+
layerFilter: (l) => l === this,
|
|
23
24
|
}) || [];
|
|
24
25
|
}
|
|
25
26
|
return Promise.resolve({
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MapLibreLayerRenderer } from '@geoblocks/ol-maplibre-layer/lib';
|
|
2
|
+
import { FrameState } from 'ol/Map';
|
|
3
|
+
import { MaplibreLayer } from '../layers';
|
|
4
|
+
export default class MaplibreLayerRenderer extends MapLibreLayerRenderer {
|
|
5
|
+
ignoreNextRender: boolean;
|
|
6
|
+
constructor(layer: MaplibreLayer);
|
|
7
|
+
renderFrame(frameState: FrameState): HTMLElement;
|
|
8
|
+
setIsReady(): void;
|
|
9
|
+
}
|