From ec65025ae26c1863c427b0fac978d505d9b22463 Mon Sep 17 00:00:00 2001 From: Matt Walsh Date: Fri, 6 Mar 2026 15:55:28 -0600 Subject: [PATCH] search for 4-letter stations on regional maps close #187 --- server/scripts/modules/regionalforecast-utils.mjs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/server/scripts/modules/regionalforecast-utils.mjs b/server/scripts/modules/regionalforecast-utils.mjs index edd0229..6f4d32f 100644 --- a/server/scripts/modules/regionalforecast-utils.mjs +++ b/server/scripts/modules/regionalforecast-utils.mjs @@ -23,7 +23,7 @@ const buildForecast = (forecast, city, cityXY) => { const getRegionalObservation = async (point, city) => { try { // get stations using centralized safe handling - const stations = await safeJson(`https://api.weather.gov/gridpoints/${point.wfo}/${point.x},${point.y}/stations?limit=1`); + const stations = await safeJson(`https://api.weather.gov/gridpoints/${point.wfo}/${point.x},${point.y}/stations?limit=10`); if (!stations || !stations.features || stations.features.length === 0) { if (debugFlag('verbose-failures')) { @@ -32,9 +32,13 @@ const getRegionalObservation = async (point, city) => { return false; } - // get the first station - const station = stations.features[0].id; - const stationId = stations.features[0].properties.stationIdentifier; + // get the first station with a 4-letter id (generally has appropriate data) + const station4Letter = stations.features.find((station) => { + if (station.properties.stationIdentifier.length === 4) return station.properties; + return false; + }); + const station = station4Letter.id; + const stationId = station4Letter.properties.stationIdentifier; // get the observation data using centralized safe handling const observation = await safeJson(`${station}/observations/latest`);