summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--weather.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/weather.go b/weather.go
index 284c7ff..dad9f2d 100644
--- a/weather.go
+++ b/weather.go
@@ -175,6 +175,17 @@ func processBBC(b []byte) []Weather {
return weather
}
+func parseMetWeather(wp WeatherParams) Weather {
+ var w Weather
+
+ w.temperature = wp.T
+ w.precipitation = wp.PP
+ w.weathertype = wp.WT
+ w.windspeed = wp.WS * mpsToMphMultiplier
+
+ return w
+}
+
func processMet(b []byte) []Weather {
var r MetResponse
var weather []Weather
@@ -185,29 +196,20 @@ func processMet(b []byte) []Weather {
}
for _, d := range r.BestFcst.Forecast.Location.Days {
+ w = parseMetWeather(d.DayValues.WeatherParameters)
w.date = d.Date
w.time = "Day "
- w.temperature = d.DayValues.WeatherParameters.T
- w.precipitation = d.DayValues.WeatherParameters.PP
- w.weathertype = d.DayValues.WeatherParameters.WT
- w.windspeed = d.DayValues.WeatherParameters.WS * mpsToMphMultiplier
weather = append(weather, w)
+ w = parseMetWeather(d.NightValues.WeatherParameters)
w.date = d.Date
w.time = "Night "
- w.temperature = d.DayValues.WeatherParameters.T
- w.precipitation = d.DayValues.WeatherParameters.PP
- w.weathertype = d.DayValues.WeatherParameters.WT
- w.windspeed = d.DayValues.WeatherParameters.WS * mpsToMphMultiplier
weather = append(weather, w)
for _, t := range d.TimeSteps.TimeStep {
+ w = parseMetWeather(t.WeatherParameters)
w.date = d.Date
w.time = t.Time
- w.temperature = t.WeatherParameters.T
- w.precipitation = t.WeatherParameters.PP
- w.weathertype = t.WeatherParameters.WT
- w.windspeed = t.WeatherParameters.WS * mpsToMphMultiplier
weather = append(weather, w)
}
}