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)
|
||
|
|
}
|