fix scripts/mkGeolocationTable.py

* increase query limit to 10
* increase min_delay_seconds of RateLimiter to 2 seconds
This commit is contained in:
Kasper D. Fischer 2022-02-23 15:17:08 +01:00
parent 08047bcff8
commit a7d16e5b8a

View File

@ -52,7 +52,7 @@ def mkGeolocationTable(file=''):
from geopy.exc import GeocoderServiceError
## constants
URL = 'https://photon.komoot.io/reverse?lon={lng:.3f}&lat={lat:.3f}&limit=5'
URL = 'https://photon.komoot.io/reverse?lon={lng:.3f}&lat={lat:.3f}&limit=10'
NAMESPACES = {'sc3': 'http://geofon.gfz-potsdam.de/ns/seiscomp3-schema/0.7',
'qml': 'http://quakeml.org/xmlns/bed/1.2'}
@ -70,7 +70,7 @@ def mkGeolocationTable(file=''):
# parse event.xml
DOM = ET.parse(stdin).getroot()
geolocator = Photon()
reverse_geolocate = RateLimiter(geolocator.reverse, min_delay_seconds=1)
reverse_geolocate = RateLimiter(geolocator.reverse, min_delay_seconds=2)
# iterate over all events
count = 0
@ -88,7 +88,7 @@ def mkGeolocationTable(file=''):
else:
logging.info('Processing event {id}'.format(id=publicID))
try:
locations = reverse_geolocate("{lat:.3f}, {lng:.3f}".format(lat=lat, lng=lng),exactly_one=False,limit=5)
locations = reverse_geolocate("{lat:.3f}, {lng:.3f}".format(lat=lat, lng=lng),exactly_one=False,limit=10)
except GeocoderServiceError:
logging.warning('Reverse Geolocation failed. Skipping event.')
continue