@wemap/routers 12.10.2 → 12.10.4

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 CHANGED
@@ -713,12 +713,7 @@ class Itinerary {
713
713
  if (typeof duration === "number") {
714
714
  this.duration = duration;
715
715
  } else {
716
- const firstCoords = this.legs[0].coords[0];
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;
@@ -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
  }