@wemap/routers 12.10.1 → 12.10.3
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/dist/index.js +4 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/ItineraryInfoManager.ts +1 -5
- package/src/model/Itinerary.ts +3 -25
- package/src/remote/cityway/CitywayRemoteRouter.spec.ts +1 -1
- package/src/remote/geovelo/GeoveloRemoteRouter.spec.ts +1 -1
- package/src/remote/osrm/OsrmRemoteRouter.spec.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -711,12 +711,7 @@ class Itinerary {
|
|
|
711
711
|
if (typeof duration === "number") {
|
|
712
712
|
this.duration = duration;
|
|
713
713
|
} else {
|
|
714
|
-
|
|
715
|
-
const lastLeg = this.legs[this.legs.length - 1];
|
|
716
|
-
const lastCoords = lastLeg.coords[lastLeg.coords.length - 1];
|
|
717
|
-
const originProjectionDuration = getDurationFromLength(this.origin.distanceTo(firstCoords));
|
|
718
|
-
const destinationProjectionDuration = getDurationFromLength(this.destination.distanceTo(lastCoords));
|
|
719
|
-
this.duration = this.legs.reduce((dur, leg) => dur + leg.duration, originProjectionDuration + destinationProjectionDuration);
|
|
714
|
+
this.duration = this.legs.reduce((dur, leg) => dur + leg.duration, 0);
|
|
720
715
|
}
|
|
721
716
|
this.startTime = typeof startTime === "number" ? startTime : null;
|
|
722
717
|
this.endTime = typeof endTime === "number" ? endTime : null;
|
|
@@ -764,7 +759,7 @@ class Itinerary {
|
|
|
764
759
|
}
|
|
765
760
|
get distance() {
|
|
766
761
|
if (this._distance === null) {
|
|
767
|
-
this._distance = Utils.calcDistance(
|
|
762
|
+
this._distance = Utils.calcDistance(this.coords);
|
|
768
763
|
}
|
|
769
764
|
return this._distance;
|
|
770
765
|
}
|
|
@@ -914,12 +909,12 @@ class Itinerary {
|
|
|
914
909
|
};
|
|
915
910
|
}
|
|
916
911
|
/**
|
|
912
|
+
* TODO: Remove it in router v3
|
|
917
913
|
* Update steps info thanks to the coordinates of the whole itinerary.
|
|
918
914
|
* This method will update:
|
|
919
915
|
* - all steps number
|
|
920
916
|
* - first/last steps
|
|
921
917
|
* - previousBearing/nextBearing/angle of first and last step of each leg
|
|
922
|
-
* - distance/duration of first and last step of each leg
|
|
923
918
|
*/
|
|
924
919
|
updateStepsFromLegs() {
|
|
925
920
|
const itineraryCoords = this.coords.filter((coords, idx, arr) => idx === 0 || !arr[idx - 1].equals(coords));
|
|
@@ -934,21 +929,9 @@ class Itinerary {
|
|
|
934
929
|
step.previousBearing = coordsBeforeStep.bearingTo(step.coords);
|
|
935
930
|
step.nextBearing = step.coords.bearingTo(coordsAfterStep);
|
|
936
931
|
step.angle = diffAngle(step.previousBearing, step.nextBearing + Math.PI);
|
|
937
|
-
const stepDistanceBefore = step.distance;
|
|
938
|
-
step.distance = 0;
|
|
939
|
-
const coordsToStopCalculation = stepId !== steps.length - 1 ? steps[stepId + 1].coords : itineraryCoords[itineraryCoords.length - 1];
|
|
940
|
-
let currentCoordsId = coordsId;
|
|
941
|
-
while (!itineraryCoords[currentCoordsId].equals(coordsToStopCalculation)) {
|
|
942
|
-
step.distance += itineraryCoords[currentCoordsId].distanceTo(itineraryCoords[currentCoordsId + 1]);
|
|
943
|
-
currentCoordsId++;
|
|
944
|
-
}
|
|
945
|
-
if (currentCoordsId === itineraryCoords.length - 1) {
|
|
946
|
-
step.distance += itineraryCoords[currentCoordsId].distanceTo(this.destination);
|
|
947
|
-
}
|
|
948
932
|
step.number = stepId + 1;
|
|
949
933
|
step.firstStep = stepId === 0;
|
|
950
934
|
step.lastStep = stepId === steps.length - 1;
|
|
951
|
-
step.duration += getDurationFromLength(step.distance - stepDistanceBefore);
|
|
952
935
|
});
|
|
953
936
|
}
|
|
954
937
|
}
|
|
@@ -4840,9 +4823,7 @@ class ItineraryInfoManager {
|
|
|
4840
4823
|
this._coordsPreviousStep = new Array(itinerary.coords.length);
|
|
4841
4824
|
this._coordsDistanceTraveled = new Array(itinerary.coords.length);
|
|
4842
4825
|
this._coordsLeg = new Array(itinerary.coords.length);
|
|
4843
|
-
|
|
4844
|
-
const destinationProjectionDistance = this._itinerary.destination.distanceTo(this._itinerary.coords[this._itinerary.coords.length - 1]);
|
|
4845
|
-
this._itineraryDistanceWithoutProjections = itinerary.distance - originProjectionDistance - destinationProjectionDistance;
|
|
4826
|
+
this._itineraryDistanceWithoutProjections = itinerary.distance;
|
|
4846
4827
|
let stepId = 0;
|
|
4847
4828
|
let previousStep = null;
|
|
4848
4829
|
let nextStep = this._steps[0];
|