diff options
-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) } } |