mobility-toolbox-js 3.0.1-beta.6 → 3.0.1-beta.8
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/mbt.js +67 -49
- package/mbt.js.map +2 -2
- package/mbt.min.js +1 -1
- package/mbt.min.js.map +3 -3
- package/ol/layers/MaplibreLayer.d.ts +1 -0
- package/ol/layers/MaplibreLayer.js +6 -0
- package/ol/layers/RealtimeLayer.d.ts +21 -6
- package/ol/layers/RealtimeLayer.js +70 -38
- package/package.json +8 -8
package/mbt.js
CHANGED
|
@@ -45998,6 +45998,11 @@ uniform ${i3} ${a3} u_${s3};
|
|
|
45998
45998
|
detachFromMap() {
|
|
45999
45999
|
unByKey(this.olEventsKeys);
|
|
46000
46000
|
}
|
|
46001
|
+
disposeInternal() {
|
|
46002
|
+
const source = this.getSource();
|
|
46003
|
+
super.disposeInternal();
|
|
46004
|
+
this.setSource(source);
|
|
46005
|
+
}
|
|
46001
46006
|
getStyle() {
|
|
46002
46007
|
if (this.style && typeof this.style === "object" && this.style.name && this.style.version) {
|
|
46003
46008
|
return this.style;
|
|
@@ -47438,11 +47443,6 @@ uniform ${i3} ${a3} u_${s3};
|
|
|
47438
47443
|
if (this.getVisible()) {
|
|
47439
47444
|
this.engine.start();
|
|
47440
47445
|
}
|
|
47441
|
-
const index = mapInternal.getLayers().getArray().indexOf(this);
|
|
47442
|
-
if (this.vectorLayer.getMapInternal() === mapInternal) {
|
|
47443
|
-
this.getMapInternal()?.removeLayer(this.vectorLayer);
|
|
47444
|
-
}
|
|
47445
|
-
mapInternal.getLayers().insertAt(index, this.vectorLayer);
|
|
47446
47446
|
this.olEventsKeys.push(
|
|
47447
47447
|
...mapInternal.on(
|
|
47448
47448
|
["moveend", "change:target"],
|
|
@@ -47499,29 +47499,49 @@ uniform ${i3} ${a3} u_${s3};
|
|
|
47499
47499
|
this.engine.detachFromMap();
|
|
47500
47500
|
}
|
|
47501
47501
|
/**
|
|
47502
|
-
* Get
|
|
47502
|
+
* Get the full trajectory of a vehicle as features.
|
|
47503
47503
|
*
|
|
47504
|
-
* @param {
|
|
47505
|
-
* @returns
|
|
47506
|
-
|
|
47507
|
-
|
|
47508
|
-
|
|
47509
|
-
|
|
47510
|
-
|
|
47511
|
-
|
|
47512
|
-
|
|
47513
|
-
this.
|
|
47514
|
-
Math.floor(this.getMapInternal()?.getView()?.getZoom() || 0)
|
|
47515
|
-
)
|
|
47504
|
+
* @param {string} id A vehicle's id.
|
|
47505
|
+
* @returns {Promise<Feature[]>} A list of features representing a full trajectory.
|
|
47506
|
+
* @public
|
|
47507
|
+
*/
|
|
47508
|
+
async getFullTrajectory(id) {
|
|
47509
|
+
const data = await this.engine.api.getFullTrajectory(
|
|
47510
|
+
id,
|
|
47511
|
+
this.engine.mode,
|
|
47512
|
+
this.engine.getGeneralizationLevelByZoom(
|
|
47513
|
+
Math.floor(this.getMapInternal()?.getView()?.getZoom() || 0)
|
|
47516
47514
|
)
|
|
47517
|
-
|
|
47518
|
-
|
|
47519
|
-
|
|
47520
|
-
|
|
47521
|
-
|
|
47522
|
-
|
|
47523
|
-
|
|
47524
|
-
|
|
47515
|
+
);
|
|
47516
|
+
if (data?.content?.features?.length) {
|
|
47517
|
+
return format2.readFeatures(data?.content);
|
|
47518
|
+
}
|
|
47519
|
+
return [];
|
|
47520
|
+
}
|
|
47521
|
+
/**
|
|
47522
|
+
* Get the stop sequences of a vehicle.
|
|
47523
|
+
*
|
|
47524
|
+
* @param {string} id A vehicle's id.
|
|
47525
|
+
* @returns {Promise<RealtimeStopSequence[]>} An array of stop sequences.
|
|
47526
|
+
* @public
|
|
47527
|
+
*/
|
|
47528
|
+
async getStopSequences(id) {
|
|
47529
|
+
const data = await this.engine.api.getStopSequence(id);
|
|
47530
|
+
return data?.content;
|
|
47531
|
+
}
|
|
47532
|
+
/**
|
|
47533
|
+
* Get full trajectory and stop sequences of a vehicle.
|
|
47534
|
+
*
|
|
47535
|
+
* @param {RealtimeTrainId} id A vehicle's id.
|
|
47536
|
+
* @returns {Promise<{fullTrajectory: Feature[], stopSequences: RealtimeStopSequence[]}>} An object containing the full trajectory and the stop sequences.
|
|
47537
|
+
*/
|
|
47538
|
+
async getTrajectoryInfos(id) {
|
|
47539
|
+
const promises = [this.getStopSequences(id), this.getFullTrajectory(id)];
|
|
47540
|
+
const [stopSequences, fullTrajectory] = await Promise.all(promises);
|
|
47541
|
+
return {
|
|
47542
|
+
fullTrajectory,
|
|
47543
|
+
stopSequences
|
|
47544
|
+
};
|
|
47525
47545
|
}
|
|
47526
47546
|
getVehicles(filterFunc) {
|
|
47527
47547
|
return this.engine.getVehicles(filterFunc);
|
|
@@ -47553,32 +47573,30 @@ uniform ${i3} ${a3} u_${s3};
|
|
|
47553
47573
|
/**
|
|
47554
47574
|
* Highlight the trajectory of journey.
|
|
47555
47575
|
*/
|
|
47556
|
-
highlightTrajectory(id) {
|
|
47576
|
+
async highlightTrajectory(id) {
|
|
47577
|
+
this.vectorLayer?.getSource()?.clear(true);
|
|
47578
|
+
this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer);
|
|
47557
47579
|
if (!id) {
|
|
47558
|
-
|
|
47559
|
-
return Promise.resolve([]);
|
|
47580
|
+
return;
|
|
47560
47581
|
}
|
|
47561
|
-
|
|
47562
|
-
|
|
47563
|
-
|
|
47564
|
-
|
|
47565
|
-
|
|
47566
|
-
)
|
|
47567
|
-
|
|
47568
|
-
|
|
47569
|
-
|
|
47570
|
-
|
|
47571
|
-
|
|
47572
|
-
|
|
47573
|
-
this.
|
|
47574
|
-
if (
|
|
47575
|
-
this.
|
|
47582
|
+
const features = await this.getFullTrajectory(id);
|
|
47583
|
+
if (!features?.length) {
|
|
47584
|
+
return;
|
|
47585
|
+
}
|
|
47586
|
+
if (features.length) {
|
|
47587
|
+
this.vectorLayer?.getSource()?.addFeatures(features);
|
|
47588
|
+
}
|
|
47589
|
+
const zIndex = this.getZIndex();
|
|
47590
|
+
if (zIndex !== void 0) {
|
|
47591
|
+
this.vectorLayer.setZIndex(zIndex - 1);
|
|
47592
|
+
this.getMapInternal()?.addLayer(this.vectorLayer);
|
|
47593
|
+
} else {
|
|
47594
|
+
const index = this.getMapInternal()?.getLayers().getArray().indexOf(this) || 0;
|
|
47595
|
+
if (index) {
|
|
47596
|
+
this.getMapInternal()?.getLayers().insertAt(index, this.vectorLayer);
|
|
47576
47597
|
}
|
|
47577
|
-
|
|
47578
|
-
|
|
47579
|
-
this.vectorLayer?.getSource()?.clear(true);
|
|
47580
|
-
return [];
|
|
47581
|
-
});
|
|
47598
|
+
}
|
|
47599
|
+
return features;
|
|
47582
47600
|
}
|
|
47583
47601
|
onMoveEnd() {
|
|
47584
47602
|
if (!this.engine.isUpdateBboxOnMoveEnd || !this.getVisible()) {
|