diff options
-rw-r--r-- | weather.go | 58 |
1 files changed, 47 insertions, 11 deletions
@@ -2,6 +2,8 @@ package main // TODO: allow free-text lookups of place names, rather than ids // TODO: decode weather type number +// TODO: split out met office specific stuff to separate module +// TODO: add other weather providers import ( "encoding/json" @@ -16,20 +18,54 @@ import ( const defid = "310118" var wkey = map[string]string{ - "f": "Feels Like Temperature", - "h": "Humidity", - "p": "Pressure", - "t": "Temperature", - "v": "Visibility", - "wg": "Wind Gust", - "ws": "Wind Speed", - "pp": "Precipitaton Probability", - "uv": "Max UV Index", - "wd": "Wind Direction", - "wt": "Weather Type", + "f": "Feels Like Temperature", + "h": "Humidity", + "p": "Pressure", + "t": "Temperature", + "v": "Visibility", + "wg": "Wind Gust", + "ws": "Wind Speed", + "pp": "Precipitaton Probability", + "uv": "Max UV Index", + "wd": "Wind Direction", + "wt": "Weather Type", "AQIndex": "Air Quality", } +type Response struct { + BestFcst struct { + Location struct { + Days []Day `json:"Day"` + } + } +} + +type Day struct { + DayValues WeatherParam + NightValues WeatherParam + TimeSteps struct { + TimeStep struct { + Time string `json:"@time"` + WeatherParams []WeatherParam + } + } +} + +type WeatherParam struct { + AQIndex float64 + F float64 + H float64 + P float64 + PP float64 + UV float64 + T float64 + V float64 + WD string + WG float64 + WS float64 + WT float64 +} + func main() { var j map[string]interface{} var id string |