Skip to content

Commit

Permalink
Merge pull request #9 from T0biii/update-koordinatencheck
Browse files Browse the repository at this point in the history
  • Loading branch information
awlx committed Jan 2, 2022
2 parents 4c95236 + 1ccda06 commit 5a515f6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions unifi_respondd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

from json import load
from geopy.point import Point
from unificontrol import UnifiClient
from typing import List
from geopy.geocoders import Nominatim
Expand Down Expand Up @@ -93,9 +94,13 @@ def get_location_by_address(address, app):
"""This function returns latitude and longitude of a given address."""
time.sleep(1)
try:
return app.geocode(address).raw["lat"], app.geocode(address).raw["lon"]
except:
return get_location_by_address(address)
point = Point().from_string(address)
return point.latitude, point.longitude
except:
try:
return app.geocode(address).raw["lat"], app.geocode(address).raw["lon"]
except:
return get_location_by_address(address)


def get_infos():
Expand Down

0 comments on commit 5a515f6

Please sign in to comment.