@wemap/routers 12.10.0 → 12.10.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/dist/index.js CHANGED
@@ -530,15 +530,13 @@ class StepsBuilder {
530
530
  const previousBearing = coordsBeforeStep.bearingTo(stepInfo.coords);
531
531
  const nextBearing = stepInfo.coords.bearingTo(coordsAfterStep);
532
532
  let distance = 0;
533
- const coordsToStopCalculation = stepId !== stepsInfo.length - 1 ? stepsInfo[stepId + 1].coords : pathCoords[pathCoords.length - 1];
533
+ const isLastStep = stepId === stepsInfo.length - 1;
534
+ const coordsToStopCalculation = isLastStep ? pathCoords[pathCoords.length - 1] : stepsInfo[stepId + 1].coords;
534
535
  let currentCoordsId = coordsId;
535
536
  while (!pathCoords[currentCoordsId].equals(coordsToStopCalculation)) {
536
537
  distance += pathCoords[currentCoordsId].distanceTo(pathCoords[currentCoordsId + 1]);
537
538
  currentCoordsId++;
538
539
  }
539
- if (currentCoordsId === pathCoords.length - 1) {
540
- distance += pathCoords[currentCoordsId].distanceTo(end);
541
- }
542
540
  return {
543
541
  coords: stepInfo.coords,
544
542
  name: stepInfo.name || null,
@@ -547,7 +545,7 @@ class StepsBuilder {
547
545
  nextBearing,
548
546
  angle: maths.diffAngle(previousBearing, nextBearing + Math.PI),
549
547
  firstStep: stepId === 0,
550
- lastStep: stepId === stepsInfo.length - 1,
548
+ lastStep: isLastStep,
551
549
  distance,
552
550
  // stepInfo.distance is overwritten
553
551
  duration: stepInfo.duration || getDurationFromLength(distance),