Filter meteo warnings by local county
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { MeteoStationPosition, SynopStation } from "@/types/imgw";
|
||||
import type { LocationSearchResult, SelectedLocation } from "@/types/location";
|
||||
import { getCountyTerytForLocation } from "@/lib/warning-regions";
|
||||
|
||||
const stationAliases: Record<string, string> = {
|
||||
gdansk: "gdanskrebiechowo",
|
||||
@@ -51,7 +52,7 @@ export function locateSynopStations(stations: SynopStation[], positions: MeteoSt
|
||||
}
|
||||
|
||||
export function findNearestSynopStation(
|
||||
location: Pick<LocationSearchResult, "name" | "province" | "latitude" | "longitude">,
|
||||
location: Pick<LocationSearchResult, "name" | "province" | "district" | "latitude" | "longitude">,
|
||||
stations: LocatedSynopStation[],
|
||||
): SelectedLocation | null {
|
||||
const nearest = stations.reduce<{ station: LocatedSynopStation; distanceKm: number } | null>((best, station) => {
|
||||
@@ -62,6 +63,8 @@ export function findNearestSynopStation(
|
||||
return {
|
||||
name: location.name,
|
||||
province: location.province,
|
||||
district: location.district,
|
||||
countyTeryt: getCountyTerytForLocation(location.province, location.district, location.name),
|
||||
latitude: location.latitude,
|
||||
longitude: location.longitude,
|
||||
stationId: nearest.station.id,
|
||||
|
||||
Reference in New Issue
Block a user