mobility-toolbox-js 3.0.1-beta.7 → 3.0.1-beta.9
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 +70 -48
- package/mbt.js.map +2 -2
- package/mbt.min.js +1 -1
- package/mbt.min.js.map +3 -3
- package/ol/layers/RealtimeLayer.d.ts +22 -6
- package/ol/layers/RealtimeLayer.js +83 -40
- package/package.json +8 -8
package/mbt.js
CHANGED
|
@@ -47443,11 +47443,6 @@ uniform ${i3} ${a3} u_${s3};
|
|
|
47443
47443
|
if (this.getVisible()) {
|
|
47444
47444
|
this.engine.start();
|
|
47445
47445
|
}
|
|
47446
|
-
const index = mapInternal.getLayers().getArray().indexOf(this);
|
|
47447
|
-
if (this.vectorLayer.getMapInternal() === mapInternal) {
|
|
47448
|
-
this.getMapInternal()?.removeLayer(this.vectorLayer);
|
|
47449
|
-
}
|
|
47450
|
-
mapInternal.getLayers().insertAt(index, this.vectorLayer);
|
|
47451
47446
|
this.olEventsKeys.push(
|
|
47452
47447
|
...mapInternal.on(
|
|
47453
47448
|
["moveend", "change:target"],
|
|
@@ -47482,6 +47477,10 @@ uniform ${i3} ${a3} u_${s3};
|
|
|
47482
47477
|
);
|
|
47483
47478
|
}
|
|
47484
47479
|
}
|
|
47480
|
+
cleanVectorLayer() {
|
|
47481
|
+
this.vectorLayer?.getSource()?.clear(true);
|
|
47482
|
+
this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer);
|
|
47483
|
+
}
|
|
47485
47484
|
/**
|
|
47486
47485
|
* Create a copy of the RealtimeLayer.
|
|
47487
47486
|
*
|
|
@@ -47504,29 +47503,49 @@ uniform ${i3} ${a3} u_${s3};
|
|
|
47504
47503
|
this.engine.detachFromMap();
|
|
47505
47504
|
}
|
|
47506
47505
|
/**
|
|
47507
|
-
* Get
|
|
47506
|
+
* Get the full trajectory of a vehicle as features.
|
|
47508
47507
|
*
|
|
47509
|
-
* @param {
|
|
47510
|
-
* @returns
|
|
47511
|
-
|
|
47512
|
-
|
|
47513
|
-
|
|
47514
|
-
|
|
47515
|
-
|
|
47516
|
-
|
|
47517
|
-
|
|
47518
|
-
this.
|
|
47519
|
-
Math.floor(this.getMapInternal()?.getView()?.getZoom() || 0)
|
|
47520
|
-
)
|
|
47508
|
+
* @param {string} id A vehicle's id.
|
|
47509
|
+
* @returns {Promise<Feature[]>} A list of features representing a full trajectory.
|
|
47510
|
+
* @public
|
|
47511
|
+
*/
|
|
47512
|
+
async getFullTrajectory(id) {
|
|
47513
|
+
const data = await this.engine.api.getFullTrajectory(
|
|
47514
|
+
id,
|
|
47515
|
+
this.engine.mode,
|
|
47516
|
+
this.engine.getGeneralizationLevelByZoom(
|
|
47517
|
+
Math.floor(this.getMapInternal()?.getView()?.getZoom() || 0)
|
|
47521
47518
|
)
|
|
47522
|
-
|
|
47523
|
-
|
|
47524
|
-
|
|
47525
|
-
|
|
47526
|
-
|
|
47527
|
-
|
|
47528
|
-
|
|
47529
|
-
|
|
47519
|
+
);
|
|
47520
|
+
if (data?.content?.features?.length) {
|
|
47521
|
+
return format2.readFeatures(data?.content);
|
|
47522
|
+
}
|
|
47523
|
+
return [];
|
|
47524
|
+
}
|
|
47525
|
+
/**
|
|
47526
|
+
* Get the stop sequences of a vehicle.
|
|
47527
|
+
*
|
|
47528
|
+
* @param {string} id A vehicle's id.
|
|
47529
|
+
* @returns {Promise<RealtimeStopSequence[]>} An array of stop sequences.
|
|
47530
|
+
* @public
|
|
47531
|
+
*/
|
|
47532
|
+
async getStopSequences(id) {
|
|
47533
|
+
const data = await this.engine.api.getStopSequence(id);
|
|
47534
|
+
return data?.content;
|
|
47535
|
+
}
|
|
47536
|
+
/**
|
|
47537
|
+
* Get full trajectory and stop sequences of a vehicle.
|
|
47538
|
+
*
|
|
47539
|
+
* @param {RealtimeTrainId} id A vehicle's id.
|
|
47540
|
+
* @returns {Promise<{fullTrajectory: Feature[], stopSequences: RealtimeStopSequence[]}>} An object containing the full trajectory and the stop sequences.
|
|
47541
|
+
*/
|
|
47542
|
+
async getTrajectoryInfos(id) {
|
|
47543
|
+
const promises = [this.getStopSequences(id), this.getFullTrajectory(id)];
|
|
47544
|
+
const [stopSequences, fullTrajectory] = await Promise.all(promises);
|
|
47545
|
+
return {
|
|
47546
|
+
fullTrajectory,
|
|
47547
|
+
stopSequences
|
|
47548
|
+
};
|
|
47530
47549
|
}
|
|
47531
47550
|
getVehicles(filterFunc) {
|
|
47532
47551
|
return this.engine.getVehicles(filterFunc);
|
|
@@ -47558,32 +47577,35 @@ uniform ${i3} ${a3} u_${s3};
|
|
|
47558
47577
|
/**
|
|
47559
47578
|
* Highlight the trajectory of journey.
|
|
47560
47579
|
*/
|
|
47561
|
-
highlightTrajectory(id) {
|
|
47580
|
+
async highlightTrajectory(id) {
|
|
47562
47581
|
if (!id) {
|
|
47563
|
-
this.
|
|
47564
|
-
return
|
|
47582
|
+
this.cleanVectorLayer();
|
|
47583
|
+
return;
|
|
47565
47584
|
}
|
|
47566
|
-
|
|
47567
|
-
|
|
47568
|
-
this.
|
|
47569
|
-
|
|
47570
|
-
|
|
47571
|
-
|
|
47572
|
-
|
|
47573
|
-
|
|
47574
|
-
|
|
47575
|
-
|
|
47585
|
+
const features = await this.getFullTrajectory(id);
|
|
47586
|
+
if (!features?.length) {
|
|
47587
|
+
this.cleanVectorLayer();
|
|
47588
|
+
return;
|
|
47589
|
+
}
|
|
47590
|
+
if (features.length) {
|
|
47591
|
+
this.vectorLayer?.getSource()?.addFeatures(features);
|
|
47592
|
+
}
|
|
47593
|
+
if (this.vectorLayer.getMapInternal() && this.vectorLayer.getMapInternal() !== this.getMapInternal()) {
|
|
47594
|
+
this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer);
|
|
47595
|
+
}
|
|
47596
|
+
const zIndex = this.getZIndex();
|
|
47597
|
+
if (zIndex !== void 0) {
|
|
47598
|
+
this.vectorLayer.setZIndex(zIndex - 1);
|
|
47599
|
+
if (!this.vectorLayer.getMapInternal()) {
|
|
47600
|
+
this.getMapInternal()?.addLayer(this.vectorLayer);
|
|
47576
47601
|
}
|
|
47577
|
-
|
|
47578
|
-
this.
|
|
47579
|
-
if (
|
|
47580
|
-
this.
|
|
47602
|
+
} else if (!this.vectorLayer.getMapInternal()) {
|
|
47603
|
+
const index = this.getMapInternal()?.getLayers().getArray().indexOf(this) || 0;
|
|
47604
|
+
if (index) {
|
|
47605
|
+
this.getMapInternal()?.getLayers().insertAt(index, this.vectorLayer);
|
|
47581
47606
|
}
|
|
47582
|
-
|
|
47583
|
-
|
|
47584
|
-
this.vectorLayer?.getSource()?.clear(true);
|
|
47585
|
-
return [];
|
|
47586
|
-
});
|
|
47607
|
+
}
|
|
47608
|
+
return features;
|
|
47587
47609
|
}
|
|
47588
47610
|
onMoveEnd() {
|
|
47589
47611
|
if (!this.engine.isUpdateBboxOnMoveEnd || !this.getVisible()) {
|