Fix limits in georeverse.py

This commit is contained in:
Aleksey Filippov 2023-06-08 01:03:55 +04:00
parent 155b350e1e
commit 5cacdcb0c4

View File

@ -1,12 +1,13 @@
from functools import partial
from geopy import Nominatim
from geopy.extra.rate_limiter import RateLimiter
class Georeverse:
def __init__(self) -> None:
geolocator: Nominatim = Nominatim(user_agent="MyApp")
self.__reverse = partial(geolocator.reverse, language="ru")
self.__reverse = RateLimiter(partial(geolocator.reverse, language="ru"), min_delay_seconds=1)
def get_city(self, latitude: float, longitude: float) -> str:
return self.__reverse(f'{latitude}, {longitude}')