- 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.
24 lines
657 B
Go
24 lines
657 B
Go
// FILE: internal/normalizers/common/id.go
|
|
package common
|
|
|
|
import "fmt"
|
|
|
|
// SynthStationID formats a stable synthetic station identifier for providers that are
|
|
// coordinate-based rather than station-based.
|
|
//
|
|
// Example output:
|
|
//
|
|
// OPENMETEO(38.62700,-90.19940)
|
|
func SynthStationID(prefix string, lat, lon float64) string {
|
|
return fmt.Sprintf("%s(%.5f,%.5f)", prefix, lat, lon)
|
|
}
|
|
|
|
// SynthStationIDPtr is the pointer-friendly variant.
|
|
// If either coordinate is missing, it returns "" (unknown).
|
|
func SynthStationIDPtr(prefix string, lat, lon *float64) string {
|
|
if lat == nil || lon == nil {
|
|
return ""
|
|
}
|
|
return SynthStationID(prefix, *lat, *lon)
|
|
}
|