@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.js
CHANGED
|
@@ -713,12 +713,7 @@ class Itinerary {
|
|
|
713
713
|
if (typeof duration === "number") {
|
|
714
714
|
this.duration = duration;
|
|
715
715
|
} else {
|
|
716
|
-
|
|
717
|
-
const lastLeg = this.legs[this.legs.length - 1];
|
|
718
|
-
const lastCoords = lastLeg.coords[lastLeg.coords.length - 1];
|
|
719
|
-
const originProjectionDuration = getDurationFromLength(this.origin.distanceTo(firstCoords));
|
|
720
|
-
const destinationProjectionDuration = getDurationFromLength(this.destination.distanceTo(lastCoords));
|
|
721
|
-
this.duration = this.legs.reduce((dur, leg) => dur + leg.duration, originProjectionDuration + destinationProjectionDuration);
|
|
716
|
+
this.duration = this.legs.reduce((dur, leg) => dur + leg.duration, 0);
|
|
722
717
|
}
|
|
723
718
|
this.startTime = typeof startTime === "number" ? startTime : null;
|
|
724
719
|
this.endTime = typeof endTime === "number" ? endTime : null;
|
|
@@ -766,7 +761,7 @@ class Itinerary {
|
|
|
766
761
|
}
|
|
767
762
|
get distance() {
|
|
768
763
|
if (this._distance === null) {
|
|
769
|
-
this._distance = geo.Utils.calcDistance(
|
|
764
|
+
this._distance = geo.Utils.calcDistance(this.coords);
|
|
770
765
|
}
|
|
771
766
|
return this._distance;
|
|
772
767
|
}
|
|
@@ -916,12 +911,12 @@ class Itinerary {
|
|
|
916
911
|
};
|
|
917
912
|
}
|
|
918
913
|
/**
|
|
914
|
+
* TODO: Remove it in router v3
|
|
919
915
|
* Update steps info thanks to the coordinates of the whole itinerary.
|
|
920
916
|
* This method will update:
|
|
921
917
|
* - all steps number
|
|
922
918
|
* - first/last steps
|
|
923
919
|
* - previousBearing/nextBearing/angle of first and last step of each leg
|
|
924
|
-
* - distance/duration of first and last step of each leg
|
|
925
920
|
*/
|
|
926
921
|
updateStepsFromLegs() {
|
|
927
922
|
const itineraryCoords = this.coords.filter((coords, idx, arr) => idx === 0 || !arr[idx - 1].equals(coords));
|
|
@@ -936,21 +931,9 @@ class Itinerary {
|
|
|
936
931
|
step.previousBearing = coordsBeforeStep.bearingTo(step.coords);
|
|
937
932
|
step.nextBearing = step.coords.bearingTo(coordsAfterStep);
|
|
938
933
|
step.angle = maths.diffAngle(step.previousBearing, step.nextBearing + Math.PI);
|
|
939
|
-
const stepDistanceBefore = step.distance;
|
|
940
|
-
step.distance = 0;
|
|
941
|
-
const coordsToStopCalculation = stepId !== steps.length - 1 ? steps[stepId + 1].coords : itineraryCoords[itineraryCoords.length - 1];
|
|
942
|
-
let currentCoordsId = coordsId;
|
|
943
|
-
while (!itineraryCoords[currentCoordsId].equals(coordsToStopCalculation)) {
|
|
944
|
-
step.distance += itineraryCoords[currentCoordsId].distanceTo(itineraryCoords[currentCoordsId + 1]);
|
|
945
|
-
currentCoordsId++;
|
|
946
|
-
}
|
|
947
|
-
if (currentCoordsId === itineraryCoords.length - 1) {
|
|
948
|
-
step.distance += itineraryCoords[currentCoordsId].distanceTo(this.destination);
|
|
949
|
-
}
|
|
950
934
|
step.number = stepId + 1;
|
|
951
935
|
step.firstStep = stepId === 0;
|
|
952
936
|
step.lastStep = stepId === steps.length - 1;
|
|
953
|
-
step.duration += getDurationFromLength(step.distance - stepDistanceBefore);
|
|
954
937
|
});
|
|
955
938
|
}
|
|
956
939
|
}
|
|
@@ -4842,9 +4825,7 @@ class ItineraryInfoManager {
|
|
|
4842
4825
|
this._coordsPreviousStep = new Array(itinerary.coords.length);
|
|
4843
4826
|
this._coordsDistanceTraveled = new Array(itinerary.coords.length);
|
|
4844
4827
|
this._coordsLeg = new Array(itinerary.coords.length);
|
|
4845
|
-
|
|
4846
|
-
const destinationProjectionDistance = this._itinerary.destination.distanceTo(this._itinerary.coords[this._itinerary.coords.length - 1]);
|
|
4847
|
-
this._itineraryDistanceWithoutProjections = itinerary.distance - originProjectionDistance - destinationProjectionDistance;
|
|
4828
|
+
this._itineraryDistanceWithoutProjections = itinerary.distance;
|
|
4848
4829
|
let stepId = 0;
|
|
4849
4830
|
let previousStep = null;
|
|
4850
4831
|
let nextStep = this._steps[0];
|