diff --git a/www/events.js b/www/events.js index 14b4501..069071a 100644 --- a/www/events.js +++ b/www/events.js @@ -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 = '
' + + 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 += '
Ereignis: %s', id) + + sprintf('Type: %s', type) + + sprintf('Magnitude: %3.1f', Number(mag)) + sprintf('Ort: %.4f °N, %.4f °O ', Number(lat), Number(lng)) + sprintf('Zeit: %sZ
', 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 = "" - + 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 + ''; - $('#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; }); diff --git a/www/map.js b/www/map.js index b53ec36..c8ef474 100644 --- a/www/map.js +++ b/www/map.js @@ -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