Small preact-based (like React.js) project
https://inga-lovinde.github.io/static/komoot-demo/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
476 B
16 lines
476 B
import haversineDistance from 'haversine-distance';
|
|
import { Coordinates } from './types';
|
|
|
|
export const getRouteLength = (points: Coordinates[]) => {
|
|
let result = 0;
|
|
for (let i = 0; i < points.length; i++) {
|
|
const currentPoint = points[i];
|
|
const previousPoint = points[i - 1];
|
|
if (!currentPoint || !previousPoint) {
|
|
continue;
|
|
}
|
|
result += haversineDistance(previousPoint, currentPoint);
|
|
}
|
|
|
|
return result;
|
|
};
|
|
|