Add lowerCamelCase JSON tags to canonical model types (observation, forecast, alert) to stabilize the emitted wire format and make payload structure explicit for downstream sinks. Introduce internal/model/doc.go to document these structs as versioned, schema-governed payloads and clarify compatibility expectations (additive changes preferred; breaking changes require schema bumps). No functional behavior changes; this formalizes the canonical output contract ahead of additional sinks and consumers.
57 lines
2.0 KiB
Go
57 lines
2.0 KiB
Go
// FILE: internal/model/observation.go
|
|
package model
|
|
|
|
import "time"
|
|
|
|
type WeatherObservation struct {
|
|
// Identity / metadata
|
|
StationID string `json:"stationId,omitempty"`
|
|
StationName string `json:"stationName,omitempty"`
|
|
Timestamp time.Time `json:"timestamp"`
|
|
|
|
// Canonical internal representation (provider-independent).
|
|
ConditionCode WMOCode `json:"conditionCode"`
|
|
ConditionText string `json:"conditionText,omitempty"`
|
|
IsDay *bool `json:"isDay,omitempty"`
|
|
|
|
// Provider-specific “evidence” for troubleshooting mapping and drift.
|
|
ProviderRawDescription string `json:"providerRawDescription,omitempty"`
|
|
|
|
// Human-facing (legacy / transitional)
|
|
TextDescription string `json:"textDescription,omitempty"`
|
|
|
|
// Provider-specific (legacy / transitional)
|
|
IconURL string `json:"iconUrl,omitempty"`
|
|
|
|
// Core measurements (nullable)
|
|
TemperatureC *float64 `json:"temperatureC,omitempty"`
|
|
DewpointC *float64 `json:"dewpointC,omitempty"`
|
|
|
|
WindDirectionDegrees *float64 `json:"windDirectionDegrees,omitempty"`
|
|
WindSpeedKmh *float64 `json:"windSpeedKmh,omitempty"`
|
|
WindGustKmh *float64 `json:"windGustKmh,omitempty"`
|
|
|
|
BarometricPressurePa *float64 `json:"barometricPressurePa,omitempty"`
|
|
SeaLevelPressurePa *float64 `json:"seaLevelPressurePa,omitempty"`
|
|
VisibilityMeters *float64 `json:"visibilityMeters,omitempty"`
|
|
|
|
RelativeHumidityPercent *float64 `json:"relativeHumidityPercent,omitempty"`
|
|
WindChillC *float64 `json:"windChillC,omitempty"`
|
|
HeatIndexC *float64 `json:"heatIndexC,omitempty"`
|
|
|
|
ElevationMeters *float64 `json:"elevationMeters,omitempty"`
|
|
RawMessage string `json:"rawMessage,omitempty"`
|
|
|
|
PresentWeather []PresentWeather `json:"presentWeather,omitempty"`
|
|
CloudLayers []CloudLayer `json:"cloudLayers,omitempty"`
|
|
}
|
|
|
|
type CloudLayer struct {
|
|
BaseMeters *float64 `json:"baseMeters,omitempty"`
|
|
Amount string `json:"amount,omitempty"`
|
|
}
|
|
|
|
type PresentWeather struct {
|
|
Raw map[string]any `json:"raw,omitempty"`
|
|
}
|