mobility-toolbox-js 3.2.0 → 3.2.1
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 +62 -57
- package/mbt.js.map +2 -2
- package/mbt.min.js +1 -1
- package/mbt.min.js.map +3 -3
- package/ol/controls/RoutingControl.d.ts +13 -13
- package/ol/controls/RoutingControl.js +64 -48
- package/ol/layers/RealtimeLayer.js +2 -8
- package/package.json +2 -2
- package/types/routing.d.ts +63 -63
- package/types/stops.d.ts +65 -65
package/mbt.js
CHANGED
|
@@ -47309,6 +47309,30 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
47309
47309
|
}
|
|
47310
47310
|
});
|
|
47311
47311
|
}
|
|
47312
|
+
get active() {
|
|
47313
|
+
return this.get("active");
|
|
47314
|
+
}
|
|
47315
|
+
set active(newValue) {
|
|
47316
|
+
this.set("active", newValue);
|
|
47317
|
+
}
|
|
47318
|
+
get loading() {
|
|
47319
|
+
return this.get("loading");
|
|
47320
|
+
}
|
|
47321
|
+
set loading(newValue) {
|
|
47322
|
+
this.set("loading", newValue);
|
|
47323
|
+
}
|
|
47324
|
+
get modify() {
|
|
47325
|
+
return this.get("modify");
|
|
47326
|
+
}
|
|
47327
|
+
set modify(newValue) {
|
|
47328
|
+
this.set("modify", newValue);
|
|
47329
|
+
}
|
|
47330
|
+
get mot() {
|
|
47331
|
+
return this.get("mot");
|
|
47332
|
+
}
|
|
47333
|
+
set mot(newValue) {
|
|
47334
|
+
this.set("mot", newValue);
|
|
47335
|
+
}
|
|
47312
47336
|
/**
|
|
47313
47337
|
* Calculate at which resolutions corresponds each generalizations.
|
|
47314
47338
|
*
|
|
@@ -47316,10 +47340,12 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
47316
47340
|
*/
|
|
47317
47341
|
static getGraphsResolutions(graphs, map) {
|
|
47318
47342
|
const view = map.getView();
|
|
47319
|
-
return graphs.map(([, minZoom, maxZoom]) =>
|
|
47320
|
-
|
|
47321
|
-
|
|
47322
|
-
|
|
47343
|
+
return graphs.map(([, minZoom, maxZoom]) => {
|
|
47344
|
+
return [
|
|
47345
|
+
view.getResolutionForZoom(minZoom),
|
|
47346
|
+
view.getResolutionForZoom(maxZoom || minZoom + 1)
|
|
47347
|
+
];
|
|
47348
|
+
});
|
|
47323
47349
|
}
|
|
47324
47350
|
/**
|
|
47325
47351
|
* Aborts viapoint and route requests
|
|
@@ -47397,7 +47423,9 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
47397
47423
|
this.element = document.createElement("button");
|
|
47398
47424
|
this.element.id = "ol-toggle-routing";
|
|
47399
47425
|
this.element.innerHTML = "Toggle Route Control";
|
|
47400
|
-
this.element.onclick = () =>
|
|
47426
|
+
this.element.onclick = () => {
|
|
47427
|
+
return this.active ? this.deactivate() : this.activate();
|
|
47428
|
+
};
|
|
47401
47429
|
Object.assign(this.element.style, {
|
|
47402
47430
|
position: "absolute",
|
|
47403
47431
|
right: "10px",
|
|
@@ -47415,9 +47443,9 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
47415
47443
|
const feats = e.target?.getFeaturesAtPixel(e.pixel, {
|
|
47416
47444
|
hitTolerance: 5
|
|
47417
47445
|
}) || [];
|
|
47418
|
-
const viaPoint = feats.find(
|
|
47419
|
-
|
|
47420
|
-
);
|
|
47446
|
+
const viaPoint = feats.find((feat) => {
|
|
47447
|
+
return feat.getGeometry()?.getType() === "Point" && feat.get("index");
|
|
47448
|
+
});
|
|
47421
47449
|
if (click(e) && viaPoint) {
|
|
47422
47450
|
this.removeViaPoint(viaPoint.get("index"));
|
|
47423
47451
|
return true;
|
|
@@ -47487,7 +47515,6 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
47487
47515
|
{
|
|
47488
47516
|
"coord-punish": 1e3,
|
|
47489
47517
|
"coord-radius": 100,
|
|
47490
|
-
// @ts-expect-error missing property in swagger
|
|
47491
47518
|
elevation: false,
|
|
47492
47519
|
graph,
|
|
47493
47520
|
mot: this.mot,
|
|
@@ -47504,9 +47531,9 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
47504
47531
|
const uniqueVias = this.segments.reduce(
|
|
47505
47532
|
(resultVias, currentFeat) => {
|
|
47506
47533
|
const segTrg = currentFeat.get("trg");
|
|
47507
|
-
return resultVias.find(
|
|
47508
|
-
|
|
47509
|
-
) ? resultVias : [...resultVias, segTrg];
|
|
47534
|
+
return resultVias.find((via) => {
|
|
47535
|
+
return via[0] === segTrg[0] && via[1] === segTrg[1];
|
|
47536
|
+
}) ? resultVias : [...resultVias, segTrg];
|
|
47510
47537
|
},
|
|
47511
47538
|
[]
|
|
47512
47539
|
);
|
|
@@ -47575,7 +47602,9 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
47575
47602
|
return fetch(
|
|
47576
47603
|
`${this.stopsApiUrl}lookup/${stationId}?key=${this.stopsApiKey}`,
|
|
47577
47604
|
{ signal: abortController.signal }
|
|
47578
|
-
).then((res) =>
|
|
47605
|
+
).then((res) => {
|
|
47606
|
+
return res.json();
|
|
47607
|
+
}).then((stationData) => {
|
|
47579
47608
|
const { coordinates: coordinates2 } = stationData?.features?.[0]?.geometry || {};
|
|
47580
47609
|
if (!coordinates2) {
|
|
47581
47610
|
console.log(
|
|
@@ -47627,7 +47656,9 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
47627
47656
|
return fetch(
|
|
47628
47657
|
`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${stationName}&limit=1`,
|
|
47629
47658
|
{ signal: abortController.signal }
|
|
47630
|
-
).then((res) =>
|
|
47659
|
+
).then((res) => {
|
|
47660
|
+
return res.json();
|
|
47661
|
+
}).then((stationData) => {
|
|
47631
47662
|
const { coordinates: coordinates2 } = stationData.features[0].geometry;
|
|
47632
47663
|
this.cacheStationData[viaPoint] = fromLonLat2(coordinates2);
|
|
47633
47664
|
pointFeature.set("viaPointTrack", track);
|
|
@@ -47664,11 +47695,13 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
47664
47695
|
onMapClick(evt) {
|
|
47665
47696
|
const feats = evt.target.getFeaturesAtPixel(evt.pixel, {
|
|
47666
47697
|
hitTolerance: 5,
|
|
47667
|
-
layerFilter: (layer) =>
|
|
47698
|
+
layerFilter: (layer) => {
|
|
47699
|
+
return layer === this.routingLayer;
|
|
47700
|
+
}
|
|
47701
|
+
});
|
|
47702
|
+
const viaPoint = feats.find((feat) => {
|
|
47703
|
+
return feat.getGeometry()?.getType() === "Point" && feat.get("viaPointIdx") !== void 0;
|
|
47668
47704
|
});
|
|
47669
|
-
const viaPoint = feats.find(
|
|
47670
|
-
(feat) => feat.getGeometry()?.getType() === "Point" && feat.get("viaPointIdx") !== void 0
|
|
47671
|
-
);
|
|
47672
47705
|
if (viaPoint) {
|
|
47673
47706
|
this.removeViaPoint(viaPoint.get("viaPointIdx"));
|
|
47674
47707
|
return;
|
|
@@ -47702,9 +47735,9 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
47702
47735
|
*/
|
|
47703
47736
|
onModifyStart(evt) {
|
|
47704
47737
|
let segmentIndex = -1;
|
|
47705
|
-
const route = evt.features.getArray().find(
|
|
47706
|
-
|
|
47707
|
-
);
|
|
47738
|
+
const route = evt.features.getArray().find((feat) => {
|
|
47739
|
+
return feat.getGeometry()?.getType() === "LineString";
|
|
47740
|
+
});
|
|
47708
47741
|
if (route?.getGeometry() && evt.mapBrowserEvent.coordinate) {
|
|
47709
47742
|
const closestExtent = buffer(
|
|
47710
47743
|
new Point_default(
|
|
@@ -47713,11 +47746,13 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
47713
47746
|
).getExtent(),
|
|
47714
47747
|
1e-3
|
|
47715
47748
|
);
|
|
47716
|
-
segmentIndex = this.segments.findIndex(
|
|
47717
|
-
|
|
47718
|
-
);
|
|
47749
|
+
segmentIndex = this.segments.findIndex((segment) => {
|
|
47750
|
+
return segment.getGeometry()?.intersectsExtent(closestExtent);
|
|
47751
|
+
});
|
|
47719
47752
|
}
|
|
47720
|
-
const viaPoint = (evt.features.getArray().filter((feat) =>
|
|
47753
|
+
const viaPoint = (evt.features.getArray().filter((feat) => {
|
|
47754
|
+
return feat.getGeometry()?.getType() === "Point";
|
|
47755
|
+
}) || [])[0];
|
|
47721
47756
|
this.initialRouteDrag = {
|
|
47722
47757
|
oldRoute: route?.clone(),
|
|
47723
47758
|
segmentIndex,
|
|
@@ -47776,30 +47811,6 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
47776
47811
|
this.drawRoute();
|
|
47777
47812
|
this.dispatchEvent(new Event_default("change:route"));
|
|
47778
47813
|
}
|
|
47779
|
-
get active() {
|
|
47780
|
-
return this.get("active");
|
|
47781
|
-
}
|
|
47782
|
-
set active(newValue) {
|
|
47783
|
-
this.set("active", newValue);
|
|
47784
|
-
}
|
|
47785
|
-
get loading() {
|
|
47786
|
-
return this.get("loading");
|
|
47787
|
-
}
|
|
47788
|
-
set loading(newValue) {
|
|
47789
|
-
this.set("loading", newValue);
|
|
47790
|
-
}
|
|
47791
|
-
get modify() {
|
|
47792
|
-
return this.get("modify");
|
|
47793
|
-
}
|
|
47794
|
-
set modify(newValue) {
|
|
47795
|
-
this.set("modify", newValue);
|
|
47796
|
-
}
|
|
47797
|
-
get mot() {
|
|
47798
|
-
return this.get("mot");
|
|
47799
|
-
}
|
|
47800
|
-
set mot(newValue) {
|
|
47801
|
-
this.set("mot", newValue);
|
|
47802
|
-
}
|
|
47803
47814
|
};
|
|
47804
47815
|
var RoutingControl_default = RoutingControl;
|
|
47805
47816
|
|
|
@@ -50212,15 +50223,8 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
50212
50223
|
* Highlight the trajectory of journey.
|
|
50213
50224
|
*/
|
|
50214
50225
|
async highlightTrajectory(id) {
|
|
50215
|
-
if (!id) {
|
|
50216
|
-
this.cleanVectorLayer();
|
|
50217
|
-
return;
|
|
50218
|
-
}
|
|
50219
50226
|
const features = await this.getFullTrajectory(id);
|
|
50220
|
-
|
|
50221
|
-
this.cleanVectorLayer();
|
|
50222
|
-
return;
|
|
50223
|
-
}
|
|
50227
|
+
this.cleanVectorLayer();
|
|
50224
50228
|
if (features.length) {
|
|
50225
50229
|
this.vectorLayer?.getSource()?.addFeatures(features);
|
|
50226
50230
|
}
|
|
@@ -50272,6 +50276,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
50272
50276
|
select(feature2) {
|
|
50273
50277
|
const id = feature2?.get("train_id");
|
|
50274
50278
|
if (this.selectedVehicleId !== id) {
|
|
50279
|
+
this.cleanVectorLayer();
|
|
50275
50280
|
this.selectedVehicleId = id;
|
|
50276
50281
|
this.engine.renderTrajectories(true);
|
|
50277
50282
|
}
|