Load event details together with the event table.

This commit is contained in:
Kasper D. Fischer 2014-05-08 11:36:20 +00:00
parent 882bd9aa14
commit b38fcddad7
Notes: subgit 2018-03-07 17:58:49 +01:00
r622 www/trunk
2 changed files with 54 additions and 85 deletions

View File

@ -72,6 +72,7 @@ function ajaxLoadEvents(stime, etime) {
minlon: W-config['map']['latlngDelta'],
maxlon: E+config['map']['latlngDelta'],
minmag: config['event']['minMag']-config['event']['minMagDelta'],
includeArrivals: true,
};
$.ajax({
type: "GET",
@ -80,16 +81,24 @@ function ajaxLoadEvents(stime, etime) {
dataType: "xml",
success: function (xml) {
$(xml).find('event').each(function () {
var event = $(this);
var id = $(this).attr('publicID').split('/')[2];
var mag = $(this).find('magnitude > mag > value').text();
var otime = $(this).find('origin > time > value').text();
var lng = $(this).find('origin > longitude > value').text();
var lng_err = $(this).find('origin > longitude > uncertainty').text();
var lat = $(this).find('origin > latitude > value').text();
var lat_err = $(this).find('origin > latitude > uncertainty').text();
var depth = $(this).find('origin > depth > value').text();
var depth_err = $(this).find('origin > depth > uncertainty').text();
var rms = $(this).find('origin > quality > standardError').text();
var gap = $(this).find('origin > quality > azimuthalGap').text();
var phases_count = $(this).find('origin > quality > usedPhaseCount').text();
var evaluationMode = $(this).find('evaluationMode').text();
var evaluationStatus = $(this).find('evaluationStatus').text();
var type = $(this).find('type').last().text();
var location
// try use location with reverse geolocation lookup (nominatim), check cache first
// try to use location with reverse geolocation lookup (nominatim), check cache first
// use getLocation if it fails or description -> text if it also fails
if ( geolocationTable[id] ) {
location = geolocationTable[id];
@ -99,14 +108,50 @@ function ajaxLoadEvents(stime, etime) {
};
// 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'] ) {
// general event info (1st line)
var row = '<tr class="tablesorter-hasChildRow">'
+ '<td class="utctime-date">'+otime.split('.')[0]+'Z</td>'
+ '<td class="utctime-time">'+otime.split('.')[0]+'Z</td>'
+ sprintf('<td class="ar">%.1f</td>', Number(mag))
+ '<td><a href="#" class="toggle" eventid="'+id+'">'+location+'</a><a class="map-link" href="#" eventid="'+id+'">Karte</a></td>'
+ '</tr>';
row += '<tr class="tablesorter-childRow">'
+ '<td colspan="4" eventid="'+id+'">Daten werden geladen ...</td></tr>';
// setting up event details (2nd line)
row += '<tr class="tablesorter-childRow">'
+ '<td colspan="4" eventid="'+id+'">'
+ '<pre>'
+ sprintf("ID %49s\n", id)
+ sprintf("Type %47s\n\n", type)
+ "Origin\n"
+ sprintf("Date %18s\n", otime.split('T')[0])
+ sprintf("Time %18s UTC\n", otime.split('T')[1].substring(0, 11))
+ sprintf("Latitude %14.4f °N +- %4.1f km\n",Number(lat), Number(lat_err))
+ sprintf("Longitude %13.4f °E +- %4.1f km\n", Number(lng), Number(lng_err))
+ sprintf("Depth %14.1f km +- %4.1f km\n", Number(depth)/1000., Number(depth_err)/1000.)
+ sprintf("Magnitude %10.1f\n", Number(mag))
+ sprintf("Residual RMS %7.1f sec\n", Number(rms))
+ sprintf("Azimuthal gap %6.1f °\n\n", Number(gap))
+ sprintf("%d Phase arrivals:\n", Number(phases_count))
+ "sta net dist azi phase time res wt\n";
// adding phase info (TODO sort by distance)
$(this).find('origin > arrival').each(function() {
var pickid = $(this).find('pickID').text();
var azi = $(this).find('azimuth').text();
var dist = $(this).find('distance').text();
var tres = $(this).find('timeResidual').text();
var phase = $(this).find('phase').text();
var tweight = $(this).find('timeWeight').text();
if ( Number(tweight) > 0.0 ) {
var waveformid = event.find('pick[publicID="'+pickid+'"] > waveformID');
var networkcode = waveformid.attr('networkCode');
var stationcode = waveformid.attr('stationCode');
var channel = waveformid.attr('channelCode').substring(2,2);
var phasemode = event.find('pick[publicID="'+pickid+'"] > evaluationMode').text().substring(0,1).toUpperCase();
var picktime = event.find('pick[publicID="'+pickid+'"] > time > value').text().split('T')[1].substring(0,11);
row += sprintf('%-4s %2s %5.1f %5.1f %3s %1s %13s %5.1f %5.2f\n', stationcode, networkcode, Number(dist), Number(azi), phase, phasemode, picktime, Number(tres), Number(tweight));
};
});
row += '</td></tr>';
// add row to table
var added = $('#eventstable tbody').append(row);
added.find('.tablesorter-childRow td').hide();
$('#eventstable').find('td.utctime-date').each(function() {
@ -123,6 +168,8 @@ function ajaxLoadEvents(stime, etime) {
var marker = addEventMarker(id, Number(lat), Number(lng), Number(mag));
var text = sprintf('<h3 eventid="%s">%s</h3>', id, location)
+ sprintf('<p>Ereignis: %s</br>', id)
+ sprintf('Type: %s</br>', type)
+ sprintf('Magnitude: %3.1f</br>', Number(mag))
+ sprintf('Ort: %.4f °N, %.4f °O </br>', Number(lat), Number(lng))
+ sprintf('Zeit: <span class="utctime">%sZ</span></p>', otime.split('.')[0], otime.split('.')[0]);
marker.bindPopup(text);
@ -144,81 +191,6 @@ function ajaxLoadEvents(stime, etime) {
});
};
/* ajaxLoadEventInfo */
function ajaxLoadEventInfo(id) {
var request_data = {
eventid: id,
includeArrivals: true,
};
$.ajax({
type: "GET",
url: config['ajax']['eventURL'],
data: request_data,
dataType: "xml",
success: function (xml) {
eventDetails[id] = true;
$(xml).find('event').each(function () {
var event = $(this);
var mag = $(this).find('magnitude > mag > value').text();
var otime = $(this).find('origin > time > value').text();
var lng = $(this).find('origin > longitude > value').text();
var lng_err = $(this).find('origin > longitude > uncertainty').text();
var lat = $(this).find('origin > latitude > value').text();
var lat_err = $(this).find('origin > latitude > uncertainty').text();
var depth = $(this).find('origin > depth > value').text();
var depth_err = $(this).find('origin > depth > uncertainty').text();
var rms = $(this).find('origin > quality > standardError').text();
var gap = $(this).find('origin > quality > azimuthalGap').text();
var phases_count = $(this).find('origin > quality > usedPhaseCount').text();
var type = $(this).find('type').last().text();
// setting up general event info
var row = "<pre>"
+ sprintf("ID %49s\n", id)
+ sprintf("Type %47s\n\n", type)
+ "Origin\n"
+ sprintf("Date %18s\n", otime.split('T')[0])
+ sprintf("Time %18s UTC\n", otime.split('T')[1].substring(0, 11))
+ sprintf("Latitude %14.4f °N +- %4.1f km\n",Number(lat), Number(lat_err))
+ sprintf("Longitude %13.4f °E +- %4.1f km\n", Number(lng), Number(lng_err))
+ sprintf("Depth %14.1f km +- %4.1f km\n", Number(depth)/1000., Number(depth_err)/1000.)
+ sprintf("Magnitude %10.1f\n", Number(mag))
+ sprintf("Residual RMS %7.1f sec\n", Number(rms))
+ sprintf("Azimuthal gap %6.1f °\n\n", Number(gap))
+ sprintf("%d Phase arrivals:\n", Number(phases_count))
+ "sta net dist azi phase time res wt\n";
// adding phase info (TODO sort by distance)
$(this).find('origin > arrival').each(function() {
var pickid = $(this).find('pickID').text();
var azi = $(this).find('azimuth').text();
var dist = $(this).find('distance').text();
var tres = $(this).find('timeResidual').text();
var phase = $(this).find('phase').text();
var tweight = $(this).find('timeWeight').text();
if ( Number(tweight) > 0.0 ) {
var waveformid = event.find('pick[publicID="'+pickid+'"] > waveformID');
var networkcode = waveformid.attr('networkCode');
var stationcode = waveformid.attr('stationCode');
var channel = waveformid.attr('channelCode').substring(2,2);
var phasemode = event.find('pick[publicID="'+pickid+'"] > evaluationMode').text().substring(0,1).toUpperCase();
var picktime = event.find('pick[publicID="'+pickid+'"] > time > value').text().split('T')[1].substring(0,11);
row = row
+ sprintf('%-4s %2s %5.1f %5.1f %3s %1s %13s %5.1f %5.2f\n', stationcode, networkcode, Number(dist), Number(azi), phase, phasemode, picktime, Number(tres), Number(tweight));
};
});
row = row + '</pre>';
$('#eventstable > tbody > tr.tablesorter-childRow > td[eventid='+id+']').html(row);
});
},
complete: function () {
null;
},
error: function( jqxhr, textStatus, error ) {
var err = textStatus + ", " + error;
console.log( "Request Failed: " + err );
}
});
};
/* toggles visibility of filtered markers
* only events in the event list are shown */
function toggleFilteredMarkers() {
@ -272,7 +244,7 @@ function highlightEvent( id ) {
};
var normalStyle = {
fillColor: config['event']['markerColor'],
color: config['event']['markerColorH']
color: config['event']['markerColor']
};
$("#eventstable > tbody > tr:not(.filtered)").find("a.map-link").each( function() {
if ( $(this).attr("eventid") ) {
@ -336,10 +308,6 @@ $(document).ready(function() {
// show / hide event info
$('#eventstable').delegate('.toggle', 'click' , function(){
// load event details
var eventid = $(this).attr('eventid');
( eventDetails[eventid] ) ? null : ajaxLoadEventInfo(eventid);
// toggle visibility of selected row
$(this).closest('tr').nextUntil('tr.tablesorter-hasChildRow').find('td').toggle('slow');
@ -357,11 +325,12 @@ $(document).ready(function() {
var selected = $(this).hasClass('selected');
if ( selected ) {
$(this).removeClass('selected');
highlightFirstEvent();
} else {
$(this).addClass('selected');
highlightEvent($(this).attr('eventid'));
};
});
return false;
});

View File

@ -104,7 +104,7 @@ function initMapLink() {
$(document).ready(function() {
// create a map in the "map" div, set the view to a given place and zoom
map = L.map('map', { zoomControl: false }).setView(config['map']['centerDefault'], config['map']['zoomDefault']);
map = L.map('map', { zoomControl: false, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']);
new L.Control.Zoom({ position: 'topright' }).addTo(map);
// add MapQuestOSM tile layer