use reverse geocoding to turn location to latlon for weather
This commit is contained in:
parent
759324bb65
commit
69bab50335
1 changed files with 11 additions and 7 deletions
|
@ -44,13 +44,17 @@ class Module(ModuleManager.BaseModule):
|
||||||
|
|
||||||
args = {"units": "metric", "APPID": api_key}
|
args = {"units": "metric", "APPID": api_key}
|
||||||
|
|
||||||
location_name = None
|
|
||||||
if location:
|
if location == None:
|
||||||
|
location_info = self.exports.get_one("get-location")(event["args"])
|
||||||
|
if location_info == None:
|
||||||
|
raise utils.EventError("Unknown location")
|
||||||
|
location = [location_info["lat"], location_info["lon"],
|
||||||
|
location_info.get("name", None)]
|
||||||
|
|
||||||
lat, lon, location_name = location
|
lat, lon, location_name = location
|
||||||
args["lat"] = lat
|
args["lat"] = lat
|
||||||
args["lon"] = lon
|
args["lon"] = lon
|
||||||
else:
|
|
||||||
args["q"] = event["args"]
|
|
||||||
|
|
||||||
page = utils.http.request(URL_WEATHER, get_params=args, json=True)
|
page = utils.http.request(URL_WEATHER, get_params=args, json=True)
|
||||||
if page:
|
if page:
|
||||||
|
|
Loading…
Reference in a new issue