fix current conditions weather.gov gaps
This commit is contained in:
parent
92822e2ddc
commit
dac15405fa
1 changed files with 15 additions and 9 deletions
|
|
@ -63,7 +63,7 @@ class CurrentWeather extends WeatherDisplay {
|
||||||
dewpoint: this.data.DewPoint + String.fromCharCode(176),
|
dewpoint: this.data.DewPoint + String.fromCharCode(176),
|
||||||
ceiling: this.data.Ceiling === 0 ? 'Unlimited' : `${this.data.Ceiling}${this.data.CeilingUnit}`,
|
ceiling: this.data.Ceiling === 0 ? 'Unlimited' : `${this.data.Ceiling}${this.data.CeilingUnit}`,
|
||||||
visibility: `${this.data.Visibility}${this.data.VisibilityUnit}`,
|
visibility: `${this.data.Visibility}${this.data.VisibilityUnit}`,
|
||||||
pressure: `${this.data.Pressure} ${this.data.PressureDirection}`,
|
pressure: this.data.PressureDirection ? `${this.data.Pressure} ${this.data.PressureDirection}` : this.data.Pressure,
|
||||||
icon: { type: 'img', src: this.data.Icon },
|
icon: { type: 'img', src: this.data.Icon },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -121,10 +121,15 @@ const getCurrentWeatherByHourFromTime = (data) => {
|
||||||
return currDiff < prevDiff ? curr : prev;
|
return currDiff < prevDiff ? curr : prev;
|
||||||
}, availableTimes[0]);
|
}, availableTimes[0]);
|
||||||
|
|
||||||
const diff = (closestTime.pressure_msl ?? 0) - (previousHour.pressure_msl ?? 0);
|
const currentPressure = closestTime.pressure_msl;
|
||||||
let pressureTrend = 'Steady';
|
const previousPressure = previousHour.pressure_msl;
|
||||||
|
let pressureTrend = '';
|
||||||
|
if (Number.isFinite(currentPressure) && Number.isFinite(previousPressure)) {
|
||||||
|
const diff = currentPressure - previousPressure;
|
||||||
|
pressureTrend = 'Steady';
|
||||||
if (diff > 0.5) pressureTrend = 'Rising';
|
if (diff > 0.5) pressureTrend = 'Rising';
|
||||||
if (diff < -0.5) pressureTrend = 'Falling';
|
if (diff < -0.5) pressureTrend = 'Falling';
|
||||||
|
}
|
||||||
closestTime.pressureTrend = pressureTrend;
|
closestTime.pressureTrend = pressureTrend;
|
||||||
closestTime.uv_index_max = data.forecast[currentDateKey]?.uv_index_max ?? closestTime.uv_index ?? 0;
|
closestTime.uv_index_max = data.forecast[currentDateKey]?.uv_index_max ?? closestTime.uv_index ?? 0;
|
||||||
return closestTime;
|
return closestTime;
|
||||||
|
|
@ -144,6 +149,7 @@ const parseData = async (weatherParameters) => {
|
||||||
const visibilityConverter = distanceKilometers();
|
const visibilityConverter = distanceKilometers();
|
||||||
const ceilingMeters = Math.max(0, ((observation.temperature ?? 0) - (observation.dewPoint ?? 0)) * 68);
|
const ceilingMeters = Math.max(0, ((observation.temperature ?? 0) - (observation.dewPoint ?? 0)) * 68);
|
||||||
const pressureValue = observation.pressure ?? currentForecast.pressure_msl ?? null;
|
const pressureValue = observation.pressure ?? currentForecast.pressure_msl ?? null;
|
||||||
|
const resolvedWindGust = observation.windGust ?? currentForecast.wind_gusts_10m ?? 0;
|
||||||
return {
|
return {
|
||||||
city: weatherParameters.city,
|
city: weatherParameters.city,
|
||||||
timeZone: weatherParameters.timeZone,
|
timeZone: weatherParameters.timeZone,
|
||||||
|
|
@ -158,17 +164,17 @@ const parseData = async (weatherParameters) => {
|
||||||
WindSpeedRaw: observation.windSpeed,
|
WindSpeedRaw: observation.windSpeed,
|
||||||
WindDirection: directionToNSEW(observation.windDirection ?? 0),
|
WindDirection: directionToNSEW(observation.windDirection ?? 0),
|
||||||
Pressure: pressureValue === null ? '-' : pressureConverter(pressureValue * 100),
|
Pressure: pressureValue === null ? '-' : pressureConverter(pressureValue * 100),
|
||||||
PressureDirection: currentForecast.pressureTrend ?? 'Steady',
|
PressureDirection: pressureValue === null ? '' : (currentForecast.pressureTrend ?? ''),
|
||||||
Humidity: Math.round(observation.relativeHumidity ?? currentForecast.relative_humidity_2m ?? 0),
|
Humidity: Math.round(observation.relativeHumidity ?? currentForecast.relative_humidity_2m ?? 0),
|
||||||
WindGust: windConverter(observation.windGust),
|
WindGust: windConverter(resolvedWindGust),
|
||||||
WindGustRaw: observation.windGust,
|
WindGustRaw: resolvedWindGust,
|
||||||
WindUnit: windConverter.units,
|
WindUnit: windConverter.units,
|
||||||
TextConditions: Number(observation.weatherCode ?? 0),
|
TextConditions: Number(observation.weatherCode ?? 0),
|
||||||
Icon: getLargeIconFromWmoCodeWithWind(
|
Icon: getLargeIconFromWmoCodeWithWind(
|
||||||
observation.weatherCode,
|
observation.weatherCode,
|
||||||
Boolean(observation.isDay),
|
Boolean(observation.isDay),
|
||||||
observation.windSpeed,
|
observation.windSpeed,
|
||||||
observation.windGust
|
resolvedWindGust
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue