summarise data from openmeteo
This commit is contained in:
@@ -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() }()
|
||||
|
||||
Reference in New Issue
Block a user