Files
gpx.studio/website/src/lib/geo/coordinates.ts
T

11 lines
323 B
TypeScript
Raw Normal View History

2026-10-31 18:08:22 +01:00
import { LngLat } from 'maplibre-gl';
export type Coordinates = {
lat: number;
lng: number;
};
/** The distance in meters between two coordinates (haversine formula). */
export function distance(a: Coordinates, b: Coordinates): number {
return new LngLat(a.lng, a.lat).distanceTo(new LngLat(b.lng, b.lat));
}