summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsiddharth ravikumar <s@ricketyspace.net>2022-08-07 15:15:30 -0400
committersiddharth ravikumar <s@ricketyspace.net>2022-08-07 15:15:30 -0400
commitbfb2a5d84671e05b05912ac1c15d347ba816592b (patch)
tree60396d5e1ea580d9ffc26b1a73df5336dc5d0d33
parent68ef980920082c743b8f33e6c1d95cd7c6f69fad (diff)
weather: update `NewWeather`
Add humidity.
-rw-r--r--weather/weather.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/weather/weather.go b/weather/weather.go
index 3a2f9f8..e72b601 100644
--- a/weather/weather.go
+++ b/weather/weather.go
@@ -31,6 +31,7 @@ type WeatherNow struct {
Forecast string
WindSpeed string
WindDirection string
+ Humidity int
}
type WeatherPeriod struct {
@@ -58,6 +59,12 @@ func NewWeather(lat, lng float32) (*Weather, error, int) {
return nil, nwsErr, nwsErr.Status
}
+ // Get humidity from the grid data.
+ h, err := humidity(fBundle.ForecastGrid)
+ if err != nil {
+ return nil, err, 500
+ }
+
w := new(Weather)
w.Location = fmt.Sprintf("%s, %s",
strings.ToLower(fBundle.Point.Properties.RelativeLocation.Properties.City),
@@ -71,6 +78,7 @@ func NewWeather(lat, lng float32) (*Weather, error, int) {
Forecast: fBundle.ForecastHourly.Properties.Periods[0].ShortForecast,
WindSpeed: fBundle.ForecastHourly.Properties.Periods[0].WindSpeed,
WindDirection: fBundle.ForecastHourly.Properties.Periods[0].WindDirection,
+ Humidity: h,
}
// Build Q2H timeline for the 12 hours.