diff --git a/www/events.js b/www/events.js index 379520d..cd44da9 100644 --- a/www/events.js +++ b/www/events.js @@ -41,15 +41,12 @@ function addTableRow(row, table) { /* do reverse geolocation lookup */ function getGeolocation(id, lat, lng) { if ( !geolocationTable[id] ) { - $.getJSON( config['ajax']['nominatimURL'], { lat: lat, lon: lng, zoom: 10, format: "json" } ) + $.getJSON( config['ajax']['nominatimURL'], { lat: lat, lon: lng } ) .done(function( json ) { - var city = json.address["city"]; - if ( ~city ) { city = json.address["town"]; }; - if ( ~city ) { city = json.address["village"]; }; - var country = json.address["country"]; - var countryCode = json.address["country_code"].toUpperCase(); + var city = json.features[0].properties.city; + var countryCode = json.features[0].properties.country; geolocationTable[id] = city; - ( countryCode != "DE" ) ? geolocationTable[id] = geolocationTable[id] + " ("+countryCode+")" : null; + ( countryCode != "Germany" ) ? geolocationTable[id] = geolocationTable[id] + " ("+countryCode+")" : null; if ( city ) { $("#eventstable a.toggle[eventid="+id+"]").text(geolocationTable[id]); var sort = [[0,1],[1,1],[2,1]]; @@ -120,12 +117,10 @@ function ajaxLoadEvents(stime, etime, eventid, url, target) { var evaluationStatus = $(this).find('origin > evaluationStatus').text(); var type = $(this).find('type').last().text(); var location - // get location, try this in order: - // regional map name, given value, cached value, or nominatim lookup - geolocationTable[id] ? null : getGeolocation(id, lat, lng); // do AJAX lookup if not cached, location will be updated later - location = ( geolocationTable[id] || getLocation(lat, lng)[0] || $(this).find('description > text').text() ); // create table row: Date, Time, Mag, Location if ( !eventTable[id] && $.inArray(type, config['event']['typeWhitelist'] )+1 && $.inArray(evaluationStatus, config['event']['evaluationBlacklist'])<0 && Number(mag)+0.05 >= config['event']['minMag'] ) { + geolocationTable[id] ? null : getGeolocation(id, lat, lng); // do AJAX lookup if not cached, location will be updated later + location = ( geolocationTable[id] || getLocation(lat, lng)[0] || $(this).find('description > text').text() ); // general event info (1st line) var row = '' + ''+otime.split('.')[0]+'Z' diff --git a/www/events.js.en b/www/events.js.en index 0bf8c60..aa2c0b1 100644 --- a/www/events.js.en +++ b/www/events.js.en @@ -41,15 +41,12 @@ function addTableRow(row, table) { /* do reverse geolocation lookup */ function getGeolocation(id, lat, lng) { if ( !geolocationTable[id] ) { - $.getJSON( config['ajax']['nominatimURL'], { lat: lat, lon: lng, zoom: 10, format: "json" } ) + $.getJSON( config['ajax']['nominatimURL'], { lat: lat, lon: lng } ) .done(function( json ) { - var city = json.address["city"]; - if ( ~city ) { city = json.address["town"]; }; - if ( ~city ) { city = json.address["village"]; }; - var country = json.address["country"]; - var countryCode = json.address["country_code"].toUpperCase(); + var city = json.features[0].properties.city; + var countryCode = json.features[0].properties.country; geolocationTable[id] = city; - ( countryCode != "DE" ) ? geolocationTable[id] = geolocationTable[id] + " ("+countryCode+")" : null; + ( countryCode != "Germany" ) ? geolocationTable[id] = geolocationTable[id] + " ("+countryCode+")" : null; if ( city ) { $("#eventstable a.toggle[eventid="+id+"]").text(geolocationTable[id]); var sort = [[0,1],[1,1],[2,1]]; @@ -90,7 +87,7 @@ function ajaxLoadEvents(stime, etime, eventid, url, target) { } else { request_data = { starttime: sprintf("%d-%02d-%02d", rtime.getFullYear(), rtime.getMonth()+1, rtime.getDate()), - orderby: 'time', + orderby: 'time-asc', minlat: sprintf('%.2f', mapBounds.getSouth()-config['map']['latlngDelta']), maxlat: sprintf('%.2f', mapBounds.getNorth()+config['map']['latlngDelta']), minlon: sprintf('%.2f', mapBounds.getWest()-config['map']['latlngDelta']), diff --git a/www/misc.js b/www/misc.js index 809136e..df925d1 100644 --- a/www/misc.js +++ b/www/misc.js @@ -95,9 +95,8 @@ var config = { dlsvURL: 'dlsv', mseedURL: '/fdsnws/dataselect/1/query', stationURL: '/fdsnws/station/1/query', - nominatimURL: '//open.mapquestapi.com/nominatim/v1/reverse.php', - // nominatimURL: '//nominatim.openstreetmap.org/reverse', - timespan: 60, + nominatimURL: 'http://photon.komoot.de/reverse', + timespan: 180, }, event: { evaluationBlacklist: ['automatic', 'preliminary', 'rejected'],