From 26d6b0f252762ab40c47eef1e4031ee8bbb870b2 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Sun, 3 Dec 2017 11:18:07 +0000 Subject: [PATCH] Updated scripts to create events.xml and geolocation.js cache files. --- .gitattributes | 1 - .gitignore | 2 ++ scripts/mkEvents.csh | 5 ++++- scripts/mkGeolocationTable.py | 35 ++--------------------------------- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/.gitattributes b/.gitattributes index 1c8be81..5737ea1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/.gitignore b/.gitignore index 4f44310..905c7ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +scripts/events.xml +scripts/geolocation.js www/dlsv www/event.xml www/events.xml diff --git a/scripts/mkEvents.csh b/scripts/mkEvents.csh index 4b6d670..46f6cd4 100755 --- a/scripts/mkEvents.csh +++ b/scripts/mkEvents.csh @@ -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" diff --git a/scripts/mkGeolocationTable.py b/scripts/mkGeolocationTable.py index 64082c5..6e0a1fd 100755 --- a/scripts/mkGeolocationTable.py +++ b/scripts/mkGeolocationTable.py @@ -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)+';'