Loading events from chached xml file and performing FDSNWS request for a shorter time only to boost performance.
This commit is contained in:
parent
f83b3aed22
commit
9a5c2650e4
Notes:
subgit
2018-03-07 17:59:02 +01:00
r698 www/trunk
@ -66,33 +66,44 @@ function getGeolocation(id, lat, lng) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* Load events using ajax */
|
/* Load events using ajax */
|
||||||
function ajaxLoadEvents(stime, etime, id, target) {
|
function ajaxLoadEvents(stime, etime, id, url, target) {
|
||||||
var mapBounds = map.getBounds();
|
var mapBounds = map.getBounds();
|
||||||
var request_data = {};
|
var request_data = {};
|
||||||
|
var rtime;
|
||||||
|
var ajax_url = config['ajax']['eventURL'];
|
||||||
if ( stime == '' || !stime ) {
|
if ( stime == '' || !stime ) {
|
||||||
stime = new Date();
|
stime = new Date();
|
||||||
stime.setDate(stime.getDate()-config['map']['timespan']);
|
stime.setDate(stime.getDate()-config['map']['timespan']);
|
||||||
};
|
rtime = new Date();
|
||||||
if ( id ) {
|
rtime.setDate(rtime.getDate()-config['ajax']['timespan']);
|
||||||
request_data = { eventid: id };
|
|
||||||
} else {
|
} else {
|
||||||
request_data = {
|
rtime = stime;
|
||||||
starttime: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()),
|
};
|
||||||
orderby: 'time-asc',
|
if ( url ) {
|
||||||
minlat: sprintf('%.2f', mapBounds.getSouth()-config['map']['latlngDelta']),
|
var ajax_url = url;
|
||||||
maxlat: sprintf('%.2f', mapBounds.getNorth()+config['map']['latlngDelta']),
|
request_data = {};
|
||||||
minlon: sprintf('%.2f', mapBounds.getWest()-config['map']['latlngDelta']),
|
} else {
|
||||||
maxlon: sprintf('%.2f', mapBounds.getEast()+config['map']['latlngDelta']),
|
if ( id ) {
|
||||||
minmag: sprintf('%.1f', config['event']['minMag']-config['event']['minMagDelta']),
|
request_data = { eventid: id };
|
||||||
};
|
} else {
|
||||||
if ( etime ) {
|
request_data = {
|
||||||
request_data['endtime'] = sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate());
|
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(); };
|
if ( etime == '' || !etime ) { etime = new Date(); };
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: config['ajax']['eventURL'],
|
url: ajax_url,
|
||||||
data: request_data,
|
data: request_data,
|
||||||
dataType: "xml",
|
dataType: "xml",
|
||||||
success: function (xml) {
|
success: function (xml) {
|
||||||
|
@ -178,6 +178,7 @@ $(document).ready(function() {
|
|||||||
eventLayer = new L.MarkerGroup().addTo(map);
|
eventLayer = new L.MarkerGroup().addTo(map);
|
||||||
|
|
||||||
// load events
|
// load events
|
||||||
|
ajaxLoadEvents('', '', '', 'events.xml');
|
||||||
ajaxLoadEvents();
|
ajaxLoadEvents();
|
||||||
specialEvents.map(function(id) {
|
specialEvents.map(function(id) {
|
||||||
ajaxLoadEvents('', '', id)
|
ajaxLoadEvents('', '', id)
|
||||||
|
@ -97,6 +97,7 @@ var config = {
|
|||||||
stationURL: 'https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/station/1/query',
|
stationURL: 'https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/station/1/query',
|
||||||
nominatimURL: '//open.mapquestapi.com/nominatim/v1/reverse.php',
|
nominatimURL: '//open.mapquestapi.com/nominatim/v1/reverse.php',
|
||||||
// nominatimURL: '//nominatim.openstreetmap.org/reverse',
|
// nominatimURL: '//nominatim.openstreetmap.org/reverse',
|
||||||
|
timespan: 60,
|
||||||
},
|
},
|
||||||
event: {
|
event: {
|
||||||
evaluationBlacklist: ['automatic', 'preliminary', 'rejected'],
|
evaluationBlacklist: ['automatic', 'preliminary', 'rejected'],
|
||||||
|
Loading…
Reference in New Issue
Block a user