refactor(normalizers): deduplicate synthetic station ID generation
- Add common SynthStationID helpers for coordinate-based providers - Use shared helper for Open-Meteo and OpenWeather station ID synthesis - Require both lat/lon when generating synthetic IDs to avoid misleading defaults - Remove unused Open-Meteo normalizer wrapper code This reduces cross-provider duplication while keeping provider-specific mapping logic explicit and readable.
This commit is contained in:
@@ -78,18 +78,8 @@ func buildObservation(parsed omResponse) (model.WeatherObservation, time.Time, e
|
||||
canonicalText := standards.WMOText(wmo, isDay)
|
||||
|
||||
// Station identity: Open-Meteo is not a station feed; synthesize from coordinates.
|
||||
stationID := ""
|
||||
if parsed.Latitude != nil || parsed.Longitude != nil {
|
||||
lat := 0.0
|
||||
lon := 0.0
|
||||
if parsed.Latitude != nil {
|
||||
lat = *parsed.Latitude
|
||||
}
|
||||
if parsed.Longitude != nil {
|
||||
lon = *parsed.Longitude
|
||||
}
|
||||
stationID = fmt.Sprintf("OPENMETEO(%.5f,%.5f)", lat, lon)
|
||||
}
|
||||
// Require BOTH lat/lon to avoid misleading OPENMETEO(0.00000,...) IDs.
|
||||
stationID := normcommon.SynthStationIDPtr("OPENMETEO", parsed.Latitude, parsed.Longitude)
|
||||
|
||||
obs := model.WeatherObservation{
|
||||
StationID: stationID,
|
||||
|
||||
Reference in New Issue
Block a user