return location always
This commit is contained in:
parent
85fcf2d6b5
commit
8430260527
@ -38,12 +38,12 @@ DEFAULT_FORMAT = '%Y-%m-%d %H:%M:%S%z'
|
|||||||
basepath = os.path.dirname(os.path.abspath(__file__))
|
basepath = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
|
||||||
|
|
||||||
class Location:
|
class Location(object):
|
||||||
"""
|
"""
|
||||||
Represents a location with name, latitude and longitude
|
Represents a location with name, latitude and longitude
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name: str, latitude: float, longitude: float):
|
def __init__(self, name: str = None, latitude: float = 0.0, longitude: float = 0.0):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.latitude = latitude
|
self.latitude = latitude
|
||||||
self.longitude = longitude
|
self.longitude = longitude
|
||||||
@ -180,10 +180,12 @@ def resolve_location_remote(query):
|
|||||||
geolocator = Nominatim(user_agent=user_agent)
|
geolocator = Nominatim(user_agent=user_agent)
|
||||||
try:
|
try:
|
||||||
location = geolocator.geocode(query)
|
location = geolocator.geocode(query)
|
||||||
|
if location:
|
||||||
write_to_cache(query, location)
|
write_to_cache(query, location)
|
||||||
return location
|
return location
|
||||||
except GeocoderTimedOut:
|
except GeocoderTimedOut:
|
||||||
logger.info("Timed out resolving location. Try specifying a timezone directly")
|
logger.info("Timed out resolving location. Try specifying a timezone directly")
|
||||||
|
return Location()
|
||||||
|
|
||||||
|
|
||||||
def parse_query(query):
|
def parse_query(query):
|
||||||
|
Loading…
Reference in New Issue
Block a user