import haversineDistance from 'haversine-distance';
import { toPairs } from './collections';
import { Waypoint } from './types';

export const getRouteLength = (points: Waypoint[]) =>
    toPairs(points)
        .map(([a, b]) => haversineDistance(a.coordinates, b.coordinates))
        .reduce((sum, value) => sum + value, 0);
