Loading events from chached xml file and performing FDSNWS request for a shorter time only to boost performance.

This commit is contained in:
Kasper D. Fischer 2014-06-13 15:02:38 +00:00
parent f83b3aed22
commit 9a5c2650e4
Notes: subgit 2018-03-07 17:59:02 +01:00
r698 www/trunk
3 changed files with 29 additions and 16 deletions

View File

@ -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) {

View File

@ -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)

View File

@ -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'],