Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getDistance(positionArray: DataPositionInterface[]): number {
let distance = 0;
const excludeFirstPointsArray = positionArray.slice(1);
let firstPosition = positionArray[0];
for (const nextPosition of excludeFirstPointsArray) {
const firstPositionAsDecimal = {
longitude: firstPosition.longitudeDegrees,
latitude: firstPosition.latitudeDegrees,
};
const nextPositionAsDecimal = {
longitude: nextPosition.longitudeDegrees,
latitude: nextPosition.latitudeDegrees,
};
distance += getPreciseDistance(firstPositionAsDecimal, nextPositionAsDecimal);
firstPosition = nextPosition;
}
return distance;
}
}