Add day/night estimation for NWS observations based on solar elevation and update observation model.
This commit is contained in:
@@ -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,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user