2026-03-27 12:58:23 -05:00
|
|
|
// FILE: internal/sources/nws/forecast_hourly.go
|
2026-01-13 18:14:21 -06:00
|
|
|
package nws
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"gitea.maximumdirect.net/ejr/feedkit/config"
|
2026-02-08 09:15:07 -06:00
|
|
|
"gitea.maximumdirect.net/ejr/weatherfeeder/standards"
|
2026-01-13 18:14:21 -06:00
|
|
|
)
|
|
|
|
|
|
2026-03-27 12:58:23 -05:00
|
|
|
// HourlyForecastSource polls an NWS hourly forecast endpoint and emits a RAW forecast Event.
|
feat(nws, normalizers): add NWS hourly forecast normalization and enforce canonical float rounding
- Implement full NWS hourly forecast normalizer (raw.nws.hourly.forecast.v1 → weather.forecast.v1)
- Add GeoJSON forecast types and helpers for NWS gridpoint hourly payloads
- Normalize temperatures, winds, humidity, PoP, and infer WMO condition codes from forecast text/icons
- Treat forecast IssuedAt as EffectiveAt for stable, dedupe-friendly event IDs
- Introduce project-wide float rounding at normalization finalization
- Round all float values in canonical payloads to 2 decimal places
- Apply consistently across pointers, slices, maps, and nested structs
- Preserve opaque structs (e.g., time.Time) unchanged
- Add SchemaRawNWSHourlyForecastV1 and align schema matching/comments
- Clean up NWS helper organization and comments
- Update documentation to reflect numeric wire-format and normalization policies
This establishes a complete, deterministic hourly forecast pipeline for NWS
and improves JSON output stability across all canonical weather schemas.
2026-01-16 10:28:32 -06:00
|
|
|
//
|
|
|
|
|
// It intentionally emits the *entire* upstream payload as json.RawMessage and only decodes
|
|
|
|
|
// minimal metadata for Event.EffectiveAt and Event.ID.
|
|
|
|
|
//
|
|
|
|
|
// Output schema (current implementation):
|
|
|
|
|
// - standards.SchemaRawNWSHourlyForecastV1
|
2026-03-27 12:58:23 -05:00
|
|
|
type HourlyForecastSource struct {
|
2026-03-28 12:01:07 -05:00
|
|
|
*forecastSource
|
2026-01-13 18:14:21 -06:00
|
|
|
}
|
|
|
|
|
|
2026-03-27 12:58:23 -05:00
|
|
|
func NewHourlyForecastSource(cfg config.SourceConfig) (*HourlyForecastSource, error) {
|
2026-06-11 02:08:36 +00:00
|
|
|
src, err := newForecastSource(cfg, DriverForecastHourly, standards.SchemaRawNWSHourlyForecastV1)
|
feat(nws, normalizers): add NWS hourly forecast normalization and enforce canonical float rounding
- Implement full NWS hourly forecast normalizer (raw.nws.hourly.forecast.v1 → weather.forecast.v1)
- Add GeoJSON forecast types and helpers for NWS gridpoint hourly payloads
- Normalize temperatures, winds, humidity, PoP, and infer WMO condition codes from forecast text/icons
- Treat forecast IssuedAt as EffectiveAt for stable, dedupe-friendly event IDs
- Introduce project-wide float rounding at normalization finalization
- Round all float values in canonical payloads to 2 decimal places
- Apply consistently across pointers, slices, maps, and nested structs
- Preserve opaque structs (e.g., time.Time) unchanged
- Add SchemaRawNWSHourlyForecastV1 and align schema matching/comments
- Clean up NWS helper organization and comments
- Update documentation to reflect numeric wire-format and normalization policies
This establishes a complete, deterministic hourly forecast pipeline for NWS
and improves JSON output stability across all canonical weather schemas.
2026-01-16 10:28:32 -06:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
2026-01-13 18:14:21 -06:00
|
|
|
}
|
|
|
|
|
|
2026-03-28 12:01:07 -05:00
|
|
|
return &HourlyForecastSource{forecastSource: src}, nil
|
2026-01-13 18:14:21 -06:00
|
|
|
}
|