diff options
author | Nick White <git@njw.name> | 2021-02-05 14:14:22 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2021-02-05 14:14:22 +0000 |
commit | e346933cf5f3e2a652e89f3a3467c569b0330291 (patch) | |
tree | 93444a5b04f0c988f8cf73ee36077a035a7fec17 | |
parent | e17745805618d64026f254bbf9657e0e0a2b095e (diff) | |
download | weather-e346933cf5f3e2a652e89f3a3467c569b0330291.tar.bz2 weather-e346933cf5f3e2a652e89f3a3467c569b0330291.zip |
Convert windspeed from metoffice to mph
-rw-r--r-- | weather.go | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -1,10 +1,6 @@ package main // TODO: allow free-text lookups of place names, rather than ids -// TODO: convert metoffice windspeed to mph -// TODO: split output into days -// TODO: add -n flag to only output a certain number of days -// TODO: human friendly dates import ( "encoding/json" @@ -21,6 +17,8 @@ const bbcdefid = "2654675" const meturl = "https://www.metoffice.gov.uk/public/data/PWSCache/BestForecast/Forecast/%s.json?concise=true" const bbcurl = "https://weather-broker-cdn.api.bbci.co.uk/en/forecast/aggregated/%s" +const mpsToMphMultiplier = 2.23693629 + // BBC structures type BBCResponse struct { Forecasts []struct { @@ -187,7 +185,7 @@ func processMet(b []byte) []Weather { w.temperature = d.DayValues.WeatherParameters.T w.precipitation = d.DayValues.WeatherParameters.PP w.weathertype = d.DayValues.WeatherParameters.WT - w.windspeed = d.DayValues.WeatherParameters.WS + w.windspeed = d.DayValues.WeatherParameters.WS * mpsToMphMultiplier weather = append(weather, w) w.date = d.Date @@ -195,7 +193,7 @@ func processMet(b []byte) []Weather { w.temperature = d.DayValues.WeatherParameters.T w.precipitation = d.DayValues.WeatherParameters.PP w.weathertype = d.DayValues.WeatherParameters.WT - w.windspeed = d.DayValues.WeatherParameters.WS + w.windspeed = d.DayValues.WeatherParameters.WS * mpsToMphMultiplier weather = append(weather, w) for _, t := range d.TimeSteps.TimeStep { @@ -204,7 +202,7 @@ func processMet(b []byte) []Weather { w.temperature = t.WeatherParameters.T w.precipitation = t.WeatherParameters.PP w.weathertype = t.WeatherParameters.WT - w.windspeed = t.WeatherParameters.WS + w.windspeed = t.WeatherParameters.WS * mpsToMphMultiplier weather = append(weather, w) } } |