Skip to content

Commit

Permalink
Merge pull request #117 from Ingenjorsarbete-For-Klimatet/hotfix/rate…
Browse files Browse the repository at this point in the history
…limit

hotfix/ratelimit
  • Loading branch information
mgcth authored May 22, 2024
2 parents 3b7dc36 + 905a079 commit 2a93a8c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/smhi/smhi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pandas as pd
from geopy import distance
from geopy.extra.rate_limiter import RateLimiter
from geopy.geocoders import Nominatim
from smhi.metobs import Data, Parameters, Periods, Stations
from smhi.models.metobs_model import MetobsLinks
Expand Down Expand Up @@ -143,7 +144,8 @@ def _find_stations_by_city(
nearby stations
"""
geolocator = Nominatim(user_agent="ifk-smhi")
loc = geolocator.geocode(city)
geocode = RateLimiter(geolocator.geocode, min_delay_seconds=1)
loc = geocode(city)

return self._find_stations_from_gps(
station_response, latitude=loc.latitude, longitude=loc.longitude, dist=dist
Expand Down

0 comments on commit 2a93a8c

Please sign in to comment.