feat: add consent-based GPS location

This commit is contained in:
zv
2026-06-01 20:28:03 +02:00
parent f5898ced4f
commit ce2e1176fa
9 changed files with 256 additions and 4 deletions

View File

@@ -50,7 +50,10 @@ export function locateSynopStations(stations: SynopStation[], positions: MeteoSt
});
}
export function findNearestSynopStation(location: LocationSearchResult, stations: LocatedSynopStation[]): SelectedLocation | null {
export function findNearestSynopStation(
location: Pick<LocationSearchResult, "name" | "province" | "latitude" | "longitude">,
stations: LocatedSynopStation[],
): SelectedLocation | null {
const nearest = stations.reduce<{ station: LocatedSynopStation; distanceKm: number } | null>((best, station) => {
const distance = distanceKm(location.latitude, location.longitude, station.latitude, station.longitude);
return !best || distance < best.distanceKm ? { station, distanceKm: distance } : best;