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:
@@ -4,6 +4,8 @@ package openweather
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
normcommon "gitea.maximumdirect.net/ejr/weatherfeeder/internal/normalizers/common"
|
||||
)
|
||||
|
||||
// This file holds provider-specific helpers that are shared across multiple
|
||||
@@ -67,5 +69,5 @@ func openWeatherStationID(parsed owmResponse) string {
|
||||
return fmt.Sprintf("OPENWEATHER(%d)", parsed.ID)
|
||||
}
|
||||
// Fallback: synthesize from coordinates.
|
||||
return fmt.Sprintf("OPENWEATHER(%.5f,%.5f)", parsed.Coord.Lat, parsed.Coord.Lon)
|
||||
return normcommon.SynthStationID("OPENWEATHER", parsed.Coord.Lat, parsed.Coord.Lon)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user