Re-implement Travel Forecast under OpenMeteo

This commit is contained in:
mrkmntal 2026-04-07 16:51:50 -04:00
commit ff30f68013
2 changed files with 40 additions and 22 deletions

View file

@ -30,6 +30,24 @@ const getOpenMeteoForecast = async (lat, lon) => {
return forecast;
};
const getAggregatedOpenMeteoForecast = async (lat, lon) => {
const forecast = await getOpenMeteoForecast(lat, lon);
if (!forecast) return false;
const aggregatedForecast = aggregateWeatherForecastData(forecast);
if (!aggregatedForecast) {
if (debugFlag('verbose-failures')) {
console.warn(`Unable to aggregate Open-Meteo forecast for ${lat},${lon}`);
}
return false;
}
return {
forecast,
aggregatedForecast,
};
};
const weatherConditions = [
{ codes: [0], text: ['Clear sky'] },
{ codes: [1, 2, 3], text: ['Mainly clear', 'Partly cloudy', 'Overcast'] },
@ -124,6 +142,7 @@ const aggregateWeatherForecastData = (forecastResponse) => {
export {
getPoint,
getOpenMeteoForecast,
getAggregatedOpenMeteoForecast,
aggregateWeatherForecastData,
getConditionText,
};