export type LatLng = { lat: number; lng: number } /** * Storsirkel-avstand mellom to koordinater, i meter. Ren klient-side * beregning -- ingen Mapbox-kall (ADR-048 kostnadskontroll-invariant B). */ export function haversineMeters(a: LatLng, b: LatLng): number { const R = 6371000 const toRad = (d: number) => (d * Math.PI) / 180 const dLat = toRad(b.lat - a.lat) const dLng = toRad(b.lng - a.lng) const h = Math.sin(dLat / 2) ** 2 + Math.cos(toRad(a.lat)) * Math.cos(toRad(b.lat)) * Math.sin(dLng / 2) ** 2 return 2 * R * Math.asin(Math.sqrt(h)) }