Updated model and normalizers to map provider “feels like” fields into a single ApparentTemperatureC field.

This commit is contained in:
2026-01-17 10:36:19 -06:00
parent c12cf91115
commit b4a67e208c
8 changed files with 33 additions and 14 deletions

View File

@@ -25,7 +25,7 @@ import (
// Event.EmittedAt when present, otherwise the first hourly time.
// - Hourly payloads are array-oriented; missing fields are treated as nil per-period.
// - Snowfall is provided in centimeters and is converted to millimeters.
// - apparent_temperature is ignored (no canonical "feels like" field).
// - apparent_temperature is mapped to ApparentTemperatureC when present.
type ForecastNormalizer struct{}
func (ForecastNormalizer) Match(e event.Event) bool {
@@ -121,6 +121,9 @@ func buildForecast(parsed omForecastResponse, fallbackIssued time.Time) (model.W
if v := floatAt(parsed.Hourly.Temperature2m, i); v != nil {
period.TemperatureC = v
}
if v := floatAt(parsed.Hourly.ApparentTemp, i); v != nil {
period.ApparentTemperatureC = v
}
if v := floatAt(parsed.Hourly.DewPoint2m, i); v != nil {
period.DewpointC = v
}

View File

@@ -107,6 +107,10 @@ func buildObservation(parsed omResponse) (model.WeatherObservation, time.Time, e
v := *parsed.Current.Temperature2m
obs.TemperatureC = &v
}
if parsed.Current.ApparentTemperature != nil {
v := *parsed.Current.ApparentTemperature
obs.ApparentTemperatureC = &v
}
if parsed.Current.RelativeHumidity2m != nil {
v := *parsed.Current.RelativeHumidity2m

View File

@@ -18,9 +18,10 @@ type omResponse struct {
type omCurrent struct {
Time string `json:"time"` // e.g. "2026-01-10T12:30" (often no timezone suffix)
Temperature2m *float64 `json:"temperature_2m"`
RelativeHumidity2m *float64 `json:"relative_humidity_2m"`
WeatherCode *int `json:"weather_code"`
Temperature2m *float64 `json:"temperature_2m"`
ApparentTemperature *float64 `json:"apparent_temperature"`
RelativeHumidity2m *float64 `json:"relative_humidity_2m"`
WeatherCode *int `json:"weather_code"`
WindSpeed10m *float64 `json:"wind_speed_10m"` // km/h (per Open-Meteo docs for these fields)
WindDirection10m *float64 `json:"wind_direction_10m"` // degrees