Add day/night estimation for NWS observations based on solar elevation and update observation model.

This commit is contained in:
2026-01-22 23:15:17 -06:00
parent c675045013
commit da0231b20f
3 changed files with 86 additions and 4 deletions

View File

@@ -76,9 +76,13 @@ func buildObservation(parsed nwsObservationResponse) (model.WeatherObservation,
// Determine canonical WMO condition code.
wmo := mapNWSToWMO(providerDesc, cloudLayers, phenomena)
var isDay *bool
if lat, lon := observationLatLon(parsed.Geometry.Coordinates); lat != nil && lon != nil {
isDay = isDayFromLatLonTime(*lat, *lon, ts)
}
// Canonical condition text comes from our WMO table.
// NWS observation responses typically do not include a day/night flag -> nil.
canonicalText := standards.WMOText(wmo, nil)
canonicalText := standards.WMOText(wmo, isDay)
// Apparent temperature: prefer wind chill when both are supplied.
var apparentC *float64
@@ -95,7 +99,7 @@ func buildObservation(parsed nwsObservationResponse) (model.WeatherObservation,
ConditionCode: wmo,
ConditionText: canonicalText,
IsDay: nil,
IsDay: isDay,
ProviderRawDescription: providerDesc,