Commit f16079cb authored by Loic Baron's avatar Loic Baron
Browse files

fixed address get location

parent abf9d3fc
Pipeline #1990 failed with stage
in 23 seconds
......@@ -40,7 +40,7 @@ class Resource(Entity):
def getJsonLocation(self, location):
dir_path = os.path.dirname(os.path.realpath(__file__))
with open(dir_path+'/resources.json') as json_data:
with open(dir_path+'/resources.json', encoding='utf-8') as json_data:
resources = json.load(json_data)
except Exception as e:
......@@ -54,10 +54,9 @@ class Resource(Entity):
# print("Resource without location in JSON")
# pprint(r)
raise ValueError("location not found in JSON")
raise ValueError("location {} not found in JSON".format(location))
def get_component(self, location, component_types):
# Nominatim OpenStreetMap format
if 'address' in location.raw:
for key, value in location.raw['address'].items():
......@@ -72,6 +71,7 @@ class Resource(Entity):
def get_address(self, location):
address = None
# if city or country are not specified, get it from the coordinates
if ('city' not in location or not location['city']) and ('country' not in location or not location['country']):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment