Fix limits in georeverse.py
This commit is contained in:
parent
155b350e1e
commit
5cacdcb0c4
@ -1,12 +1,13 @@
|
|||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from geopy import Nominatim
|
from geopy import Nominatim
|
||||||
|
from geopy.extra.rate_limiter import RateLimiter
|
||||||
|
|
||||||
|
|
||||||
class Georeverse:
|
class Georeverse:
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
geolocator: Nominatim = Nominatim(user_agent="MyApp")
|
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:
|
def get_city(self, latitude: float, longitude: float) -> str:
|
||||||
return self.__reverse(f'{latitude}, {longitude}')
|
return self.__reverse(f'{latitude}, {longitude}')
|
||||||
|
Loading…
Reference in New Issue
Block a user