Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speedup lookup #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions unifi_respondd/unifi_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,14 @@ def get_ap_channel_usage(ssids, cfg):

def get_location_by_address(address, app):
"""This function returns latitude and longitude of a given address."""
time.sleep(1)
try:
point = Point().from_string(address)
return point.latitude, point.longitude
except:
try:
return app.geocode(address).raw["lat"], app.geocode(address).raw["lon"]
time.sleep(1)
geocode = app.geocode(address)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also should use cache for this:
https://operations.osmfoundation.org/policies/nominatim/

Results must be cached on your side. Clients sending repeatedly the same query may be classified as faulty and blocked.

or setup a own instance of nominatim:
https://nominatim.org/release-docs/latest/admin/Installation/

return geocode.raw["lat"], geocode.raw["lon"]
except:
return get_location_by_address(address)

Expand Down
Loading