From 9a5c2650e4dd89e16a231bb717b43dd12a7b6e8e Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Fri, 13 Jun 2014 15:02:38 +0000 Subject: [PATCH 1/2] Loading events from chached xml file and performing FDSNWS request for a shorter time only to boost performance. --- www/events.js | 43 +++++++++++++++++++++++++++---------------- www/map.js | 1 + www/misc.js | 1 + 3 files changed, 29 insertions(+), 16 deletions(-) diff --git a/www/events.js b/www/events.js index 2dfc8d0..9a55398 100644 --- a/www/events.js +++ b/www/events.js @@ -66,33 +66,44 @@ function getGeolocation(id, lat, lng) { }; /* Load events using ajax */ -function ajaxLoadEvents(stime, etime, id, target) { +function ajaxLoadEvents(stime, etime, id, url, target) { var mapBounds = map.getBounds(); var request_data = {}; + var rtime; + var ajax_url = config['ajax']['eventURL']; if ( stime == '' || !stime ) { stime = new Date(); stime.setDate(stime.getDate()-config['map']['timespan']); - }; - if ( id ) { - request_data = { eventid: id }; + rtime = new Date(); + rtime.setDate(rtime.getDate()-config['ajax']['timespan']); } else { - request_data = { - starttime: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), - 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']), - maxlon: sprintf('%.2f', mapBounds.getEast()+config['map']['latlngDelta']), - minmag: sprintf('%.1f', config['event']['minMag']-config['event']['minMagDelta']), - }; - if ( etime ) { - request_data['endtime'] = sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()); + rtime = stime; + }; + if ( url ) { + var ajax_url = url; + request_data = {}; + } else { + if ( id ) { + request_data = { eventid: id }; + } else { + request_data = { + starttime: sprintf("%d-%02d-%02d", rtime.getFullYear(), rtime.getMonth()+1, rtime.getDate()), + 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']), + maxlon: sprintf('%.2f', mapBounds.getEast()+config['map']['latlngDelta']), + minmag: sprintf('%.1f', config['event']['minMag']-config['event']['minMagDelta']), + }; + if ( etime ) { + request_data['endtime'] = sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()); + }; }; }; if ( etime == '' || !etime ) { etime = new Date(); }; $.ajax({ type: "GET", - url: config['ajax']['eventURL'], + url: ajax_url, data: request_data, dataType: "xml", success: function (xml) { diff --git a/www/map.js b/www/map.js index 4473cfc..23d1516 100644 --- a/www/map.js +++ b/www/map.js @@ -178,6 +178,7 @@ $(document).ready(function() { eventLayer = new L.MarkerGroup().addTo(map); // load events + ajaxLoadEvents('', '', '', 'events.xml'); ajaxLoadEvents(); specialEvents.map(function(id) { ajaxLoadEvents('', '', id) diff --git a/www/misc.js b/www/misc.js index 9771431..f93bfaf 100644 --- a/www/misc.js +++ b/www/misc.js @@ -97,6 +97,7 @@ var config = { stationURL: 'https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/station/1/query', nominatimURL: '//open.mapquestapi.com/nominatim/v1/reverse.php', // nominatimURL: '//nominatim.openstreetmap.org/reverse', + timespan: 60, }, event: { evaluationBlacklist: ['automatic', 'preliminary', 'rejected'], From ad920ee0fc1c804e73a1d45d0a449676c21c89a3 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Fri, 13 Jun 2014 15:03:02 +0000 Subject: [PATCH 2/2] Loading events from chached xml file and performing FDSNWS request for a shorter time only to boost performance. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5f1e7d6..4f44310 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ www/dlsv www/event.xml +www/events.xml www/geolocation.js www/geolocationTable.js www/stations.xml