Changed request_parameters. Endtime will only be used when necessary. Truncated numerical values to 1 or 2 digits after the decimal point. Added orderby parameter.
Shortend construct to determine event location.
This commit is contained in:
parent
acb023cd20
commit
8770857bd7
Notes:
subgit
2018-03-07 17:58:52 +01:00
r639 www/trunk
@ -51,24 +51,25 @@ function getGeolocation(id, lat, lng) {
|
|||||||
|
|
||||||
/* Load events using ajax */
|
/* Load events using ajax */
|
||||||
function ajaxLoadEvents(stime, etime) {
|
function ajaxLoadEvents(stime, etime) {
|
||||||
|
var request_data = {};
|
||||||
if ( !stime ) {
|
if ( !stime ) {
|
||||||
var stime = new Date();
|
stime = new Date();
|
||||||
stime.setDate(stime.getDate()-config['map']['timespan']);
|
stime.setDate(stime.getDate()-config['map']['timespan']);
|
||||||
};
|
};
|
||||||
if ( !etime ) {
|
|
||||||
var etime = new Date();
|
|
||||||
etime.setDate(etime.getDate()+1);
|
|
||||||
};
|
|
||||||
var mapBounds = map.getBounds();
|
var mapBounds = map.getBounds();
|
||||||
var request_data = {
|
request_data = {
|
||||||
starttime: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()),
|
starttime: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()),
|
||||||
endtime: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()),
|
orderby: 'time-asc',
|
||||||
minlat: mapBounds.getSouth()-config['map']['latlngDelta'],
|
minlat: sprintf('%.2f', mapBounds.getSouth()-config['map']['latlngDelta']),
|
||||||
maxlat: mapBounds.getNorth()+config['map']['latlngDelta'],
|
maxlat: sprintf('%.2f', mapBounds.getNorth()+config['map']['latlngDelta']),
|
||||||
minlon: mapBounds.getWest()-config['map']['latlngDelta'],
|
minlon: sprintf('%.2f', mapBounds.getWest()-config['map']['latlngDelta']),
|
||||||
maxlon: mapBounds.getEast()+config['map']['latlngDelta'],
|
maxlon: sprintf('%.2f', mapBounds.getEast()+config['map']['latlngDelta']),
|
||||||
minmag: config['event']['minMag']-config['event']['minMagDelta'],
|
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());
|
||||||
|
};
|
||||||
|
console.log(request_data);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: config['ajax']['eventURL'],
|
url: config['ajax']['eventURL'],
|
||||||
@ -81,15 +82,14 @@ function ajaxLoadEvents(stime, etime) {
|
|||||||
var otime = $(this).find('origin > time > value').text();
|
var otime = $(this).find('origin > time > value').text();
|
||||||
var lng = $(this).find('origin > longitude > value').text();
|
var lng = $(this).find('origin > longitude > value').text();
|
||||||
var lat = $(this).find('origin > latitude > value').text();
|
var lat = $(this).find('origin > latitude > value').text();
|
||||||
|
var depth = $(this).find('origin > depth > value').text();
|
||||||
var evaluationMode = $(this).find('evaluationMode').text();
|
var evaluationMode = $(this).find('evaluationMode').text();
|
||||||
var evaluationStatus = $(this).find('evaluationStatus').text();
|
var evaluationStatus = $(this).find('evaluationStatus').text();
|
||||||
var type = $(this).find('type').last().text();
|
var type = $(this).find('type').last().text();
|
||||||
var location
|
var location
|
||||||
// try to use location with reverse geolocation lookup (nominatim), check cache first
|
// get location, try this in order:
|
||||||
// use getLocation if it fails or description -> text if it also fails
|
// cached value, nominatim lookup, regional map name, or given value
|
||||||
( location = geolocationTable[id] ) ? null : location = getGeolocation(id, lat, lng);
|
location = geolocationTable[id] || getGeolocation(id, lat, lng) || getLocation(lat, lng)[0] || $(this).find('description > text').text();
|
||||||
( location ) ? null : location = getLocation(lat, lng)[0];
|
|
||||||
( location ) ? null : $(this).find('description > text').text();
|
|
||||||
// create table row: Date, Time, Mag, Location
|
// 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'] ) {
|
if ( !eventTable[id] && $.inArray(type, config['event']['typeWhitelist'] )+1 && $.inArray(evaluationStatus, config['event']['evaluationBlacklist'])<0 && Number(mag)+0.05 >= config['event']['minMag'] ) {
|
||||||
// general event info (1st line)
|
// general event info (1st line)
|
||||||
@ -107,7 +107,6 @@ function ajaxLoadEvents(stime, etime) {
|
|||||||
var oTime = new Date(otime);
|
var oTime = new Date(otime);
|
||||||
var stime = new Date(oTime.getTime()-10*1000.-oTime.getMilliseconds());
|
var stime = new Date(oTime.getTime()-10*1000.-oTime.getMilliseconds());
|
||||||
var etime = new Date(oTime.getTime()+50*1000.-oTime.getMilliseconds());
|
var etime = new Date(oTime.getTime()+50*1000.-oTime.getMilliseconds());
|
||||||
console.log(oTime, stime, etime);
|
|
||||||
var mseedurl = sprintf('%s?net=GE,GR,RN&cha=EH?,HH?&start=%04d-%02d-%02dT%02d:%02d:%02d&end=%04d-%02d-%02dT%02d:%02d:%02d', config['ajax']['mseedURL'], Number(stime.getUTCFullYear()), Number(stime.getUTCMonth())+1, Number(stime.getUTCDate()), Number(stime.getUTCHours()), Number(stime.getUTCMinutes()), Number(stime.getUTCSeconds()), Number(etime.getUTCFullYear()), Number(etime.getUTCMonth())+1, Number(etime.getUTCDate()), Number(etime.getUTCHours()), Number(etime.getUTCMinutes()), Number(etime.getUTCSeconds()));
|
var mseedurl = sprintf('%s?net=GE,GR,RN&cha=EH?,HH?&start=%04d-%02d-%02dT%02d:%02d:%02d&end=%04d-%02d-%02dT%02d:%02d:%02d', config['ajax']['mseedURL'], Number(stime.getUTCFullYear()), Number(stime.getUTCMonth())+1, Number(stime.getUTCDate()), Number(stime.getUTCHours()), Number(stime.getUTCMinutes()), Number(stime.getUTCSeconds()), Number(etime.getUTCFullYear()), Number(etime.getUTCMonth())+1, Number(etime.getUTCDate()), Number(etime.getUTCHours()), Number(etime.getUTCMinutes()), Number(etime.getUTCSeconds()));
|
||||||
row += '<tr class="tablesorter-childRow event-download">'
|
row += '<tr class="tablesorter-childRow event-download">'
|
||||||
+ '<td colspan="4" eventid="'+id+'">'
|
+ '<td colspan="4" eventid="'+id+'">'
|
||||||
@ -133,6 +132,7 @@ function ajaxLoadEvents(stime, etime) {
|
|||||||
+ sprintf('Type: %s</br>', type)
|
+ sprintf('Type: %s</br>', type)
|
||||||
+ sprintf('Magnitude: %3.1f</br>', Number(mag))
|
+ sprintf('Magnitude: %3.1f</br>', Number(mag))
|
||||||
+ sprintf('Ort: %.4f °N, %.4f °O </br>', Number(lat), Number(lng))
|
+ sprintf('Ort: %.4f °N, %.4f °O </br>', Number(lat), Number(lng))
|
||||||
|
+ sprintf('Tiefe: %.1f km</br>', Number(depth)/1000.)
|
||||||
+ sprintf('Zeit: <span class="utctime">%sZ</span></p>', otime.split('.')[0], otime.split('.')[0]);
|
+ sprintf('Zeit: <span class="utctime">%sZ</span></p>', otime.split('.')[0], otime.split('.')[0]);
|
||||||
marker.bindPopup(text);
|
marker.bindPopup(text);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user