feat: add consent-based GPS location
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user