use "city, state, country" for formatted location name when available
This commit is contained in:
parent
14303f354c
commit
398bd7e117
1 changed files with 14 additions and 1 deletions
|
@ -19,6 +19,19 @@ class Module(ModuleManager.BaseModule):
|
||||||
timezone = result["annotations"]["timezone"]["name"]
|
timezone = result["annotations"]["timezone"]["name"]
|
||||||
lat = result["geometry"]["lat"]
|
lat = result["geometry"]["lat"]
|
||||||
lon = result["geometry"]["lng"]
|
lon = result["geometry"]["lng"]
|
||||||
name = result["formatted"]
|
|
||||||
|
name_parts = []
|
||||||
|
components = result["components"]
|
||||||
|
if "city" in components:
|
||||||
|
name_parts.append(components["city"])
|
||||||
|
if "state" in components:
|
||||||
|
name_parts.append(components["state"])
|
||||||
|
if "country" in components:
|
||||||
|
name_parts.append(components["country"])
|
||||||
|
|
||||||
|
if not name_parts:
|
||||||
|
name_parts.append(result["formatted"])
|
||||||
|
|
||||||
|
name = ", ".join(name_parts)
|
||||||
|
|
||||||
return {"timezone": timezone, "lat": lat, "lon": lon, "name": name}
|
return {"timezone": timezone, "lat": lat, "lon": lon, "name": name}
|
||||||
|
|
Loading…
Reference in a new issue