Files
faceclaw/app/native/declination.ts
T
2026-09-18 23:30:07 -07:00

14 lines
632 B
TypeScript

import { magneticDeclinationDegrees } from './geomagnetic'
import { getCurrentLocation } from './location'
export function restoreDeclination(latitude: number, longitude: number, _degrees: number): number | null {
return magneticDeclinationDegrees(latitude, longitude)
}
export async function getCurrentDeclination(): Promise<{ latitude: number; longitude: number; degrees: number }> {
const location = await getCurrentLocation()
const degrees = magneticDeclinationDegrees(location.latitude, location.longitude)
if (degrees === null) throw new Error('Magnetic declination unavailable')
return { ...location, degrees }
}