From 8d8e0c5ff7248abd6fe786146a0d17ce3a684f4d Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Tue, 20 May 2014 11:08:59 +0000 Subject: [PATCH 1/9] Added support for special events. use different markers for EQ, quarry blast or induced events. --- www/events.js | 55 ++++++++++++++++++++++++++------------------ www/index.html.de | 1 + www/map.js | 23 +++++++++++++----- www/specialevents.js | 2 ++ 4 files changed, 52 insertions(+), 29 deletions(-) create mode 100644 www/specialevents.js diff --git a/www/events.js b/www/events.js index 1cfee10..a4f3659 100644 --- a/www/events.js +++ b/www/events.js @@ -22,6 +22,22 @@ $Id$ */ +/* adding row(s) to a table and format date strings afterwards */ +function addTableRow(row, table) { + var added = $('#'+table+' tbody').append(row); + added.find('.tablesorter-childRow td').hide(); + $('#'+table).find('td.utctime-date').each(function() { + $.localtime.formatObject($(this), "dd.MM.yyyy"); + $(this).removeClass('utctime-date'); + $(this).addClass('localtime-date'); + }); + $('#'+table).find('td.utctime-time').each(function() { + $.localtime.formatObject($(this), "HH:mm"); + $(this).removeClass('utctime-time'); + $(this).addClass('localtime-time'); + }); +}; + /* do reverse geolocation lookup */ function getGeolocation(id, lat, lng) { if ( !geolocationTable[id] ) { @@ -50,17 +66,16 @@ function getGeolocation(id, lat, lng) { }; /* Load events using ajax */ -function ajaxLoadEvents(stime, etime, id) { +function ajaxLoadEvents(stime, etime, id, target) { var mapBounds = map.getBounds(); var request_data = {}; + if ( stime == '' || !stime ) { + stime = new Date(); + stime.setDate(stime.getDate()-config['map']['timespan']); + }; if ( id ) { - if ( id == 'bug2014jptq' ) console.log('Loading special event '+id); request_data = { eventid: id }; } else { - if ( !stime ) { - stime = new Date(); - stime.setDate(stime.getDate()-config['map']['timespan']); - }; request_data = { starttime: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), orderby: 'time-asc', @@ -74,6 +89,7 @@ function ajaxLoadEvents(stime, etime, id) { 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'], @@ -97,7 +113,6 @@ function ajaxLoadEvents(stime, etime, id) { location = ( geolocationTable[id] || getGeolocation(id, lat, lng) ); // 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 ( id == 'bug2014jptq' ) console.log('Adding row for special event '+id); // general event info (1st line) var row = '' + ''+otime.split('.')[0]+'Z' @@ -111,28 +126,22 @@ function ajaxLoadEvents(stime, etime, id) { // setting up download links (3nd line) var xmlurl = sprintf('%s?formatted=true&includearrivals=true&eventid=%s', config['ajax']['eventURL'], id); var oTime = new Date(otime); - var stime = new Date(oTime.getTime()-10*1000.-oTime.getMilliseconds()); - var etime = new Date(oTime.getTime()+50*1000.-oTime.getMilliseconds()); - 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 sTime = new Date(oTime.getTime()-10*1000.-oTime.getMilliseconds()); + var eTime = new Date(oTime.getTime()+50*1000.-oTime.getMilliseconds()); + 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 += '' + '' + sprintf('Download QuakeML or miniSEED', xmlurl, mseedurl) + ''; // add row to table - var added = $('#eventstable tbody').append(row); - added.find('.tablesorter-childRow td').hide(); - $('#eventstable').find('td.utctime-date').each(function() { - $.localtime.formatObject($(this), "dd.MM.yyyy"); - $(this).removeClass('utctime-date'); - $(this).addClass('localtime-date'); - }); - $('#eventstable').find('td.utctime-time').each(function() { - $.localtime.formatObject($(this), "HH:mm"); - $(this).removeClass('utctime-time'); - $(this).addClass('localtime-time'); - }); + if ( stime <= oTime && etime >= oTime ) { + addTableRow(row, 'eventstable'); + }; + if ( target ) { + addTableRow(row, target); + } // create marker - var marker = addEventMarker(id, Number(lat), Number(lng), Number(mag)); + var marker = addEventMarker(id, Number(lat), Number(lng), Number(mag), type); var text = sprintf('

%s

', id, location) + sprintf('

Ereignis: %s
', id) + sprintf('Type: %s
', type) diff --git a/www/index.html.de b/www/index.html.de index 078bd3b..580e3c8 100644 --- a/www/index.html.de +++ b/www/index.html.de @@ -40,6 +40,7 @@ + diff --git a/www/map.js b/www/map.js index 19f578c..4473cfc 100644 --- a/www/map.js +++ b/www/map.js @@ -41,11 +41,9 @@ function addStationMarker(id, lat, lng, station) { }; /* add event marker */ -function addEventMarker(id, lat, lng, mag) { - if ( id == 'bug2014jptq' ) console.log('Adding marker for special event '+id); +function addEventMarker(id, lat, lng, mag, type) { if ( eventTable[id] ) { return eventTable[id]; - console.log('Marker allready exists ID: '+id); } else { var markerOptions = { gradient: true, @@ -58,7 +56,19 @@ function addEventMarker(id, lat, lng, mag) { className: id+' eventMarker', radius: mag2radius(mag) }; - var marker = L.circleMarker(L.latLng(lat, lng), markerOptions); + var marker; + switch ( type ) { + case 'earthquake': + marker = L.starMarker(L.latLng(lat, lng), markerOptions); + break; + case 'quarry blast': + markerOptions['numberOfPoints'] = 7; + markerOptions['innerRadius'] = 0.3*markerOptions['radius']; + marker = L.starMarker(L.latLng(lat, lng), markerOptions); + break; + default: + marker = L.circleMarker(L.latLng(lat, lng), markerOptions); + }; eventLayer.addLayer(marker); eventTable[id] = marker; return marker; @@ -169,8 +179,9 @@ $(document).ready(function() { // load events ajaxLoadEvents(); - //ajaxLoadEvents([], [], ['bug2014jptq', 'gfz2013yvko']); - ajaxLoadEvents([], [], 'bug2014jptq'); + specialEvents.map(function(id) { + ajaxLoadEvents('', '', id) + }); toggleFilteredMarkers(); // bind popupopen event diff --git a/www/specialevents.js b/www/specialevents.js new file mode 100644 index 0000000..91352d2 --- /dev/null +++ b/www/specialevents.js @@ -0,0 +1,2 @@ +/* $Id$ */ +var specialEvents = ['bug2014jptq', 'gfz2013yvko']; From 78ea7b0397f8c05eb4ec2caeab841f80b3a72666 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Tue, 20 May 2014 12:27:07 +0000 Subject: [PATCH 2/9] Added column for type information in eventstable. --- www/events.js | 39 +++++++++++++++++++++++++++++++++++---- www/index.html.de | 6 +++++- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/www/events.js b/www/events.js index a4f3659..e60d8cf 100644 --- a/www/events.js +++ b/www/events.js @@ -106,6 +106,17 @@ function ajaxLoadEvents(stime, etime, id, target) { var evaluationMode = $(this).find('evaluationMode').text(); var evaluationStatus = $(this).find('evaluationStatus').text(); var type = $(this).find('type').last().text(); + var typeId; + switch ( type ) { + case 'earthquake': + typeId = 'EQ'; + break; + case 'quarry blast': + typeId = 'QB'; + break; + default: + typeId = 'IE'; + }; var location // get location, try this in order: // regional map name, given value, cached value, or nominatim lookup @@ -119,10 +130,11 @@ function ajaxLoadEvents(stime, etime, id, target) { + ''+otime.split('.')[0]+'Z' + sprintf('%.1f', Number(mag)) + ''+location+'Karte' + + ''+typeId+'' + ''; // setting up event details (2nd line) row += '' - + 'Daten werden geladen ...'; + + 'Daten werden geladen ...'; // setting up download links (3nd line) var xmlurl = sprintf('%s?formatted=true&includearrivals=true&eventid=%s', config['ajax']['eventURL'], id); var oTime = new Date(otime); @@ -130,7 +142,7 @@ function ajaxLoadEvents(stime, etime, id, target) { var eTime = new Date(oTime.getTime()+50*1000.-oTime.getMilliseconds()); 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 += '' - + '' + + '' + sprintf('Download QuakeML or miniSEED', xmlurl, mseedurl) + ''; // add row to table @@ -248,16 +260,17 @@ function ajaxLoadEventInfo(id) { /* toggles visibility of filtered markers * only events in the event list are shown */ function toggleFilteredMarkers() { + console.log('toggleFilteredMarkers'); // show all shown events in map $("#eventstable > tbody > tr:not(.filtered) > td > a.map-link").each( function() { if ( $(this).attr("eventid") ) { - eventTable[$(this).attr("eventid")].setStyle({opacity: 1, strokeOpacity: 1, fillOpacity: config['event']['markerOpacity']}); + map.addLayer(eventTable[$(this).attr("eventid")]); }; }); // hide filtered events in map $("#eventstable > tbody > tr.filtered > td > a.map-link").each( function() { if ( $(this).attr("eventid") ) { - eventTable[$(this).attr("eventid")].setStyle({opacity: 0, strokeOpacity: 0, fillOpacity: 0}); + map.removeLayer(eventTable[$(this).attr("eventid")]); }; }); highlightFirstEvent(); @@ -394,4 +407,22 @@ $(document).ready(function() { }); return false; }); + // update selection / type info + $("#events-timespan").text(config['map']['timespan']); + $("#events-minmag").text(sprintf('%.1f', config['event']['minMag'])); + config['event']['typeWhitelist'].map(function(type) { + var typetext; + switch ( type ) { + case 'earthquake': + typetext = 'EQ - tektonisches Erdbeben'; + break; + case 'induced or triggered event': + typetext = 'IE - (bergbau-)induziertes Ereignis'; + break; + case 'quarry blast': + typetext = 'QB - Steinbruchsprengung'; + break; + }; + $("#events-type").append(' '+typetext); + }); }); diff --git a/www/index.html.de b/www/index.html.de index 580e3c8..f363da1 100644 --- a/www/index.html.de +++ b/www/index.html.de @@ -56,6 +56,7 @@

+

Ereignisse der letzten 180 Tage ab Magnitude 1.2

First Prev @@ -79,6 +80,7 @@ + @@ -86,12 +88,14 @@ Zeit Mag. Ort + Typ -

Nominatim Search Courtesy of MapQuest Mapquest Logo

+

Typ:
+ Nominatim Search Courtesy of MapQuest Mapquest Logo

From 63f9d9d43a62aed104de5b2b457eb39dc891b502 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Tue, 20 May 2014 12:35:55 +0000 Subject: [PATCH 3/9] Added noscript information. --- www/index.html.de | 8 ++++++++ www/main.css | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/www/index.html.de b/www/index.html.de index f363da1..e3a7140 100644 --- a/www/index.html.de +++ b/www/index.html.de @@ -47,6 +47,14 @@ +
  • Ereignisse
  • diff --git a/www/main.css b/www/main.css index e17d826..ccfe67d 100644 --- a/www/main.css +++ b/www/main.css @@ -13,6 +13,15 @@ height: 100%; font-family: sans-serif; } + div.noscript { + z-index: 20000; + position: absolute; + left: 0px; + top: 0px; + width: 100%; + height: 100%; + background: rgb(255, 255, 255); + } div.info { z-index: 10000; position: absolute; From 021046ec29a9e1490ea75070cd7ad383be5c5713 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Tue, 20 May 2014 13:46:00 +0000 Subject: [PATCH 4/9] Added eventstable caption with symbol information and download link. Removed type column from table. --- www/events.js | 31 +++++++++++-------------------- www/index.html.de | 15 ++++++++++----- www/main.css | 3 +++ 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/www/events.js b/www/events.js index e60d8cf..df4bd69 100644 --- a/www/events.js +++ b/www/events.js @@ -106,17 +106,6 @@ function ajaxLoadEvents(stime, etime, id, target) { var evaluationMode = $(this).find('evaluationMode').text(); var evaluationStatus = $(this).find('evaluationStatus').text(); var type = $(this).find('type').last().text(); - var typeId; - switch ( type ) { - case 'earthquake': - typeId = 'EQ'; - break; - case 'quarry blast': - typeId = 'QB'; - break; - default: - typeId = 'IE'; - }; var location // get location, try this in order: // regional map name, given value, cached value, or nominatim lookup @@ -129,12 +118,11 @@ function ajaxLoadEvents(stime, etime, id, target) { + ''+otime.split('.')[0]+'Z' + ''+otime.split('.')[0]+'Z' + sprintf('%.1f', Number(mag)) - + ''+location+'Karte' - + ''+typeId+'' + + ''+location+' Karte' + ''; // setting up event details (2nd line) row += '' - + 'Daten werden geladen ...'; + + 'Daten werden geladen ...'; // setting up download links (3nd line) var xmlurl = sprintf('%s?formatted=true&includearrivals=true&eventid=%s', config['ajax']['eventURL'], id); var oTime = new Date(otime); @@ -142,7 +130,7 @@ function ajaxLoadEvents(stime, etime, id, target) { var eTime = new Date(oTime.getTime()+50*1000.-oTime.getMilliseconds()); 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 += '' - + '' + + '' + sprintf('Download QuakeML or miniSEED', xmlurl, mseedurl) + ''; // add row to table @@ -180,6 +168,9 @@ function ajaxLoadEvents(stime, etime, id, target) { console.log( "Request Failed: " + err ); } }); + // create events csv download link + request_data['format'] = 'text'; + if ( id == '' || !id ) { $('#events-csv-link').attr('href', config['ajax']['eventURL']+'?'+$.param(request_data)) }; }; /* ajaxLoadEventInfo */ @@ -260,7 +251,6 @@ function ajaxLoadEventInfo(id) { /* toggles visibility of filtered markers * only events in the event list are shown */ function toggleFilteredMarkers() { - console.log('toggleFilteredMarkers'); // show all shown events in map $("#eventstable > tbody > tr:not(.filtered) > td > a.map-link").each( function() { if ( $(this).attr("eventid") ) { @@ -412,17 +402,18 @@ $(document).ready(function() { $("#events-minmag").text(sprintf('%.1f', config['event']['minMag'])); config['event']['typeWhitelist'].map(function(type) { var typetext; + ( $("#events-type").text() == "Symbole:" ) ? typetext = ' ' : typetext = ', '; switch ( type ) { case 'earthquake': - typetext = 'EQ - tektonisches Erdbeben'; + typetext += 'tektonisches Erdbeben (Stern)'; break; case 'induced or triggered event': - typetext = 'IE - (bergbau-)induziertes Ereignis'; + typetext += '(bergbau-)induziertes Ereignis (Kreis)'; break; case 'quarry blast': - typetext = 'QB - Steinbruchsprengung'; + typetext += 'Steinbruchsprengung (Rad)'; break; }; - $("#events-type").append(' '+typetext); + $("#events-type").append(typetext); }); }); diff --git a/www/index.html.de b/www/index.html.de index e3a7140..d9a8b3a 100644 --- a/www/index.html.de +++ b/www/index.html.de @@ -64,7 +64,6 @@
-

Ereignisse der letzten 180 Tage ab Magnitude 1.2

First Prev @@ -96,14 +95,20 @@ Zeit Mag. Ort - Typ -

Typ:
- Nominatim Search Courtesy of MapQuest Mapquest Logo

+

+ Ereignisse der letzten 180 Tage ab Magnitude 1.2 im Bereich der Karte und besondere Ereignisse in angrenzenden Bereichen. Download als CSV. +

+

+ Symbole: +

+

+ Nominatim Search Courtesy of MapQuest Mapquest Logo +

@@ -142,7 +147,7 @@ -

Download als CSV

+

Download als CSV.

diff --git a/www/main.css b/www/main.css index ccfe67d..bc0c37d 100644 --- a/www/main.css +++ b/www/main.css @@ -73,4 +73,7 @@ td.ar { text-align: right; } + p.table-caption { + font-size: smaller; + } From 2238086066baee0838d6c841c91497ce94be94d5 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Tue, 20 May 2014 16:09:36 +0000 Subject: [PATCH 5/9] Bug fix: really don't show preliminary or automatic results. --- www/events.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/events.js b/www/events.js index df4bd69..7a234b2 100644 --- a/www/events.js +++ b/www/events.js @@ -103,8 +103,8 @@ function ajaxLoadEvents(stime, etime, id, target) { var lng = $(this).find('origin > longitude > 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 evaluationStatus = $(this).find('evaluationStatus').text(); + var evaluationMode = $(this).find('origin > evaluationMode').text(); + var evaluationStatus = $(this).find('origin > evaluationStatus').text(); var type = $(this).find('type').last().text(); var location // get location, try this in order: From 264036fe53f25c77372034daa76e66fcef054f57 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Tue, 20 May 2014 16:10:26 +0000 Subject: [PATCH 6/9] Added error handler to AJAX request in stations.js. --- www/stations.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/www/stations.js b/www/stations.js index f9d5d36..e6295b2 100644 --- a/www/stations.js +++ b/www/stations.js @@ -105,6 +105,10 @@ function loadStations(stime, etime) { $("#stationstable > tbody > tr:even").addClass("odd"); $("#stationstable > tbody > tr:odd").addClass("even"); stationLayer.bringToFront(); + }, + error: function( jqxhr, textStatus, error ) { + var err = textStatus + ", " + error; + console.log( "Request Failed: " + err ); } }); // create stations csv download link From b42911ada598e6b501249eeb1ab20b139736103a Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Tue, 20 May 2014 16:11:30 +0000 Subject: [PATCH 7/9] Updated table caption text. --- www/index.html.de | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/index.html.de b/www/index.html.de index d9a8b3a..3f33458 100644 --- a/www/index.html.de +++ b/www/index.html.de @@ -101,7 +101,7 @@

- Ereignisse der letzten 180 Tage ab Magnitude 1.2 im Bereich der Karte und besondere Ereignisse in angrenzenden Bereichen. Download als CSV. + Ereignisse der letzten 180 Tage ab Magnitude 1.2 im Bereich der Karte und besondere Ereignisse in angrenzenden Bereichen. Download als CSV-Datei.

Symbole: @@ -147,7 +147,7 @@ -

Download als CSV.

+

Download als CSV-Datei.

From 210ea267479d1d3b06ee2d806fab41ddcff88db8 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Tue, 20 May 2014 16:16:11 +0000 Subject: [PATCH 8/9] Added some more special events. Which should be included? When should they be removed from the list? --- www/specialevents.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/www/specialevents.js b/www/specialevents.js index 91352d2..f2b9763 100644 --- a/www/specialevents.js +++ b/www/specialevents.js @@ -1,2 +1,9 @@ /* $Id$ */ -var specialEvents = ['bug2014jptq', 'gfz2013yvko']; +var specialEvents = [ + 'bug2014jptq', // Seeheim-Jugenheim + 'bug2014infb', // Troisdorf + 'bug2014ilxd', // Bassum + 'bug2014gfzw', // Darmstadt + 'bug2014datb', // Groningen + 'bug2013yvko', // Haltern 3.4 +]; From 85eb830ef1b34b51d4e9987a79bc144493573707 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Tue, 20 May 2014 16:16:35 +0000 Subject: [PATCH 9/9] Changed svn:ignore property. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1c5f384..5f1e7d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ www/dlsv www/event.xml www/geolocation.js +www/geolocationTable.js www/stations.xml