Weather API fixes (#386)

* add wind to forecast

* missing
This commit is contained in:
Dominic Wong
2022-02-21 16:49:50 +00:00
committed by GitHub
parent f680405f5e
commit 3b7bafbd00
3 changed files with 98 additions and 59 deletions

View File

@@ -117,8 +117,20 @@ func (w *Weather) Forecast(ctx context.Context, req *pb.ForecastRequest, rsp *pb
IconUrl: day["condition"].(map[string]interface{})["icon"].(string),
Sunrise: fc["astro"].(map[string]interface{})["sunrise"].(string),
Sunset: fc["astro"].(map[string]interface{})["sunset"].(string),
MaxWindMph: day["maxwind_mph"].(float64),
MaxWindKph: day["maxwind_kph"].(float64),
})
}
location := respBody["location"].(map[string]interface{})
// set the location
rsp.Location = location["name"].(string)
rsp.Region = location["region"].(string)
rsp.Country = location["region"].(string)
rsp.Latitude = location["lat"].(float64)
rsp.Longitude = location["lon"].(float64)
rsp.Timezone = location["tz_id"].(string)
rsp.LocalTime = location["localtime"].(string)
return nil
}