mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-11-01 20:19:39 +00:00
11 lines
323 B
TypeScript
11 lines
323 B
TypeScript
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));
|
||
|
|
}
|