summarise data from openmeteo

This commit is contained in:
2026-01-26 13:20:30 +11:00
parent c315811ec3
commit 7526a7af93
3 changed files with 246 additions and 6 deletions

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"net/url"
"time"
@@ -38,12 +39,19 @@ func (o *OpenMeteo) Fetch(ctxDone <-chan struct{}, site Site, model string) (*Fo
q.Set("latitude", fmt.Sprintf("%.6f", site.Latitude))
q.Set("longitude", fmt.Sprintf("%.6f", site.Longitude))
q.Set("hourly", join(hourly))
q.Set("timezone", "UTC")
q.Set("wind_speed_unit", "ms")
q.Set("temperature_unit", "celsius")
q.Set("precipitation_unit", "mm")
u.RawQuery = q.Encode()
safeURL := *u
safeQuery := safeURL.Query()
if safeQuery.Has("apikey") {
safeQuery.Set("apikey", "redacted")
}
safeURL.RawQuery = safeQuery.Encode()
log.Printf("open-meteo request url=%s", safeURL.String())
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
go func() { <-ctxDone; cancel() }()