Updated scripts to create events.xml and geolocation.js cache files.

This commit is contained in:
Kasper D. Fischer 2017-12-03 11:18:07 +00:00
parent 23ccbb8d9b
commit 26d6b0f252
Notes: subgit 2018-03-07 17:59:12 +01:00
r869 www/branches/life
4 changed files with 8 additions and 35 deletions

1
.gitattributes vendored
View File

@ -1,5 +1,4 @@
* text=auto !eol
scripts/mkEvents.csh -text
www/.htaccess -text
www/copyright.inc.de -text
www/external/TileLayer.Grayscale.js -text

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
scripts/events.xml
scripts/geolocation.js
www/dlsv
www/event.xml
www/events.xml

View File

@ -1 +1,4 @@
curl -o events.xml "https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/event/1/query?starttime=2015-04-01&orderby=time&minlat=50.92&maxlat=52.76&minlon=4.26&maxlon=9.74&minmag=1.1"
#!/bin/bash
STIME=$1
curl -o events.xml "https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/event/1/query?starttime=${STIME}&orderby=time&minlat=50.92&maxlat=52.76&minlon=4.26&maxlon=9.74&minmag=1.1"

View File

@ -83,6 +83,7 @@ def mkGeolocationTable(file=''):
location = geolocator.reverse("{lat}, {lng}".format(lat=lat, lng=lng))
except:
warnings.warn('Reverse Geolocation failed. Skipping event.')
sleep(1.1)
continue
place = []
try:
@ -98,42 +99,10 @@ def mkGeolocationTable(file=''):
place = location.raw['properties']['county']
except KeyError:
warnings.warn('Could not extract city for event {0} at {1} N / {2} E (URL: {3})'.format(publicID, lat, lng, url))
warnings.warn('Sucessfully looked up location for event {0}.'.format(publicID))
geolocationTable[publicID] = place
sleep(1.1)
'''
#warnings.warn('Processing event %s' %publicID)
# send and evaluate nominatim request
url = 'https://open.mapquestapi.com/nominatim/v1/reverse.php?key=oE512xGQxeH1n2cueacJ6xzRv7qFlCib&lat={0}&lon={1}&zoom=10&format=json'.format(lat, lng)
response = URL.urlopen(url)
if ( response.msg == 'OK' ):
data = JSON.loads(response.read())
city = []
try:
try:
city = data['address']['city']
except:
warnings.warn('Request {3} for event {0} at {1} N / {2} E did not provide city attribute\n\t(Response: {4})'.format(publicID, lat, lng, url, data))
try:
city = data['address']['town']
warnings.warn('Using attribute town ({1}) for event {0}'.format(publicID, city))
except:
try:
city = data['address']['county']
warnings.warn('Using attribute county ({1}) for event {0}'.format(publicID, city))
except:
warnings.warn('Skipping event')
continue
countryCode = data['address']['country_code'].upper()
if ( countryCode == 'DE' ):
geolocationTable[publicID] = city.encode('utf-8')
else:
geolocationTable[publicID] = '{0} ({1})'.format(city.encode('utf-8'), countryCode)
except:
warnings.warn('Could not extract city for event {0} at {1} N / {2} E (URL: {3})'.format(publicID, lat, lng, url))
else:
warnings.warn('Request {0} failed'.format(url))
'''
# dump json
print 'var geolocationTable = '+JSON.dumps(geolocationTable, sort_keys=True)+';'