From 3de24436a0485882a7ed0a3473abebf4f191af04 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Sun, 11 May 2014 19:06:23 +0000 Subject: [PATCH 01/12] Updated svn properties. From 55a6c166b6110390597b877d181415a0ae16528b Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Mon, 12 May 2014 15:46:37 +0000 Subject: [PATCH 02/12] Added missing call of getLocation if getGeolocation fails. --- www/events.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/www/events.js b/www/events.js index a632b48..a0e9023 100644 --- a/www/events.js +++ b/www/events.js @@ -87,12 +87,9 @@ function ajaxLoadEvents(stime, etime) { var location // 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]; - } else { - location = getGeolocation(id, lat, lng); - ( location ) ? null : location = $(this).find('description > text').text(); - }; + ( location = geolocationTable[id] ) ? null : location = getGeolocation(id, lat, lng); + ( location ) ? null : location = getLocation(lat, lng)[0]; + ( location ) ? null : $(this).find('description > text').text(); // 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) From 4ed2af95c0a2419e92b82aeb030e1a312c98dca6 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Mon, 12 May 2014 15:54:07 +0000 Subject: [PATCH 03/12] Adding scale control to map. --- www/map.js | 1 + 1 file changed, 1 insertion(+) diff --git a/www/map.js b/www/map.js index c8ef474..ff4eb26 100644 --- a/www/map.js +++ b/www/map.js @@ -106,6 +106,7 @@ $(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, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); new L.Control.Zoom({ position: 'topright' }).addTo(map); + new L.control.scale({position: 'bottomright', imperial: false}).addTo(map); // add MapQuestOSM tile layer // L.tileLayer.grayscale('http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg', From 3161f1542e60be909369fa729790c2d90ffebab7 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Mon, 12 May 2014 16:10:29 +0000 Subject: [PATCH 04/12] Show event details when selecting a marker. Hide when popup closes. TODO: do this without a global variable. --- www/map.js | 22 +++++++++++++++++----- www/misc.js | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/www/map.js b/www/map.js index ff4eb26..d3371fd 100644 --- a/www/map.js +++ b/www/map.js @@ -136,12 +136,24 @@ $(document).ready(function() { map.on('popupopen', function() { // convert date/time to localtime $("div.leaflet-popup span.utctime").each(function(){$(this).addClass("localtime").removeClass("utctime");$.localtime.formatObject($(this), "dd.MM.yyyy - HH:mm")}); - var eventid = $("div.leaflet-popup h3").attr("eventid"); - if ( eventid ) { - // highlight event in table - highlightEvent(eventid); + openMarkerID = $("div.leaflet-popup h3").attr("eventid"); + if ( openMarkerID ) { // update city in popup - $("div.leaflet-popup h3").text(geolocationTable[eventid]); + $("div.leaflet-popup h3").text(geolocationTable[openMarkerID]); + // highlight event in table and show details + // highlightEvent(eventid); + $('#eventstable > tbody > tr > td > a.toggle').each(function() { + if ( $(this).attr('eventid') == openMarkerID ) { + $(this)[0].click(); + }; + }); }; }); + map.on('popupclose', function() { + $('#eventstable > tbody > tr > td > a.toggle').each(function() { + if ( $(this).attr('eventid') == openMarkerID ) { + $(this)[0].click(); + }; + }); + }); }); diff --git a/www/misc.js b/www/misc.js index 7da0a00..702a3d1 100644 --- a/www/misc.js +++ b/www/misc.js @@ -73,6 +73,7 @@ $( window ).resize(function() { /* create global vars */ var map; +var openMarkerID; var eventTable = {}; var eventDetails = {}; var stationTable = {}; From ad14cf44b37b9f378305e0cd02e3489bd1362c49 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Mon, 12 May 2014 16:43:13 +0000 Subject: [PATCH 05/12] Updating svn:keywords to test setting of permissions. From c15e401da545b4d3c82c93cb5eb9f8ec6312d3db Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Mon, 12 May 2014 16:47:48 +0000 Subject: [PATCH 06/12] Updating svn:keywords to test setting of permissions. From 271caf6f20239f84e8a3581970597c8a582f4580 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Wed, 14 May 2014 05:20:06 +0000 Subject: [PATCH 07/12] Fixed HTML code. Should validate now. --- www/index.html.de | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/index.html.de b/www/index.html.de index 72277a4..f575ea5 100644 --- a/www/index.html.de +++ b/www/index.html.de @@ -90,7 +90,7 @@ -

Nominatim Search Courtesy of MapQuest

+

Nominatim Search Courtesy of MapQuest Mapquest Logo

From a73450ac92e7aef7c286637536d4152d94e7dd30 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Wed, 14 May 2014 05:21:19 +0000 Subject: [PATCH 08/12] Added function to parse the URL query string to set config parameters. --- www/misc.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/www/misc.js b/www/misc.js index 702a3d1..54d7f60 100644 --- a/www/misc.js +++ b/www/misc.js @@ -71,6 +71,17 @@ $( window ).resize(function() { setInfoHeight(); }); +/* parseQueryString */ +function parseQueryString() { + var query = (window.location.search || '?').substr(1), + map = {}; + query.replace(/([^&=]+)=?([^&]*)(?:&+|$)/g, function(match, key, value) { + key.toLowerCase(); + (map[key] = map[key] || []).push(value); + }); + return map; +} + /* create global vars */ var map; var openMarkerID; @@ -111,6 +122,21 @@ var config = { * document ready * **********************************************************************/ $(document).ready(function() { + // parse query string + var parameters = parseQueryString(); + if ( Number(parameters['minmag']) ) { + config['event']['minMag'] = Number(parameters['minmag']); + }; + if ( parameters['markercolor'] ) { + config['event']['markerColor'] = parameters['markercolor']; + }; + if ( parameters['markercolorh'] ) { + config['event']['markerColorH'] = parameters['markercolorh']; + }; + if ( Number(parameters['timespan']) ) { + config['map']['timespan'] = Number(parameters['timespan']); + }; + // AJAX setup $.ajaxSetup({timeout: config['ajax']['timeout']}); From acb023cd206fd6e6c05498ddede7582efe73a773 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Wed, 14 May 2014 05:22:21 +0000 Subject: [PATCH 09/12] small changes only. --- www/map.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/map.js b/www/map.js index d3371fd..26c060e 100644 --- a/www/map.js +++ b/www/map.js @@ -124,11 +124,11 @@ $(document).ready(function() { maxZoom: 16 }).addTo(map); */ - // read in stations + // create station and event layer stationLayer = L.geoJson().addTo(map); - - // read in events, process filter eventLayer = L.geoJson().addTo(map); + + // load events ajaxLoadEvents(); toggleFilteredMarkers(); From 8770857bd7384c2e89a753f2b519bc03aad6ca01 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Wed, 14 May 2014 05:24:41 +0000 Subject: [PATCH 10/12] 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. --- www/events.js | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/www/events.js b/www/events.js index a0e9023..1f36c23 100644 --- a/www/events.js +++ b/www/events.js @@ -51,24 +51,25 @@ function getGeolocation(id, lat, lng) { /* Load events using ajax */ function ajaxLoadEvents(stime, etime) { + var request_data = {}; if ( !stime ) { - var stime = new Date(); + stime = new Date(); stime.setDate(stime.getDate()-config['map']['timespan']); }; - if ( !etime ) { - var etime = new Date(); - etime.setDate(etime.getDate()+1); - }; var mapBounds = map.getBounds(); - var request_data = { + request_data = { starttime: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), - endtime: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()), - minlat: mapBounds.getSouth()-config['map']['latlngDelta'], - maxlat: mapBounds.getNorth()+config['map']['latlngDelta'], - minlon: mapBounds.getWest()-config['map']['latlngDelta'], - maxlon: mapBounds.getEast()+config['map']['latlngDelta'], - minmag: config['event']['minMag']-config['event']['minMagDelta'], + 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()); + }; + console.log(request_data); $.ajax({ type: "GET", url: config['ajax']['eventURL'], @@ -81,15 +82,14 @@ function ajaxLoadEvents(stime, etime) { var otime = $(this).find('origin > time > value').text(); 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 type = $(this).find('type').last().text(); var location - // try to use location with reverse geolocation lookup (nominatim), check cache first - // use getLocation if it fails or description -> text if it also fails - ( location = geolocationTable[id] ) ? null : location = getGeolocation(id, lat, lng); - ( location ) ? null : location = getLocation(lat, lng)[0]; - ( location ) ? null : $(this).find('description > text').text(); + // get location, try this in order: + // cached value, nominatim lookup, regional map name, or given value + location = geolocationTable[id] || getGeolocation(id, lat, lng) || getLocation(lat, lng)[0] || $(this).find('description > text').text(); // 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) @@ -107,7 +107,6 @@ function ajaxLoadEvents(stime, etime) { 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()); - 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())); row += '' + '' @@ -133,6 +132,7 @@ function ajaxLoadEvents(stime, etime) { + sprintf('Type: %s
', type) + sprintf('Magnitude: %3.1f
', Number(mag)) + sprintf('Ort: %.4f °N, %.4f °O
', Number(lat), Number(lng)) + + sprintf('Tiefe: %.1f km
', Number(depth)/1000.) + sprintf('Zeit: %sZ

', otime.split('.')[0], otime.split('.')[0]); marker.bindPopup(text); }; From 1c947c98d2e5f6961fda62338b5c88a71f4d5907 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Wed, 14 May 2014 09:40:19 +0000 Subject: [PATCH 11/12] Removed console.log. --- www/events.js | 1 - 1 file changed, 1 deletion(-) diff --git a/www/events.js b/www/events.js index 1f36c23..3ffcf4e 100644 --- a/www/events.js +++ b/www/events.js @@ -69,7 +69,6 @@ function ajaxLoadEvents(stime, etime) { if ( etime ) { request_data['endtime'] = sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()); }; - console.log(request_data); $.ajax({ type: "GET", url: config['ajax']['eventURL'], From 49b9e492aceea3e99bae2775358de5c95f7f2b58 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Wed, 14 May 2014 09:48:04 +0000 Subject: [PATCH 12/12] Added config for station color. Changed colors of events to blue. --- www/map.js | 4 ++-- www/misc.js | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/www/map.js b/www/map.js index 26c060e..9be8ac8 100644 --- a/www/map.js +++ b/www/map.js @@ -30,8 +30,8 @@ function addStationMarker(id, lat, lng) { var corners = [L.latLng(lat+2*a, lng), L.latLng(lat-a, lng+b), L.latLng(lat-a, lng-b)]; var marker = L.polygon(corners, { - fillColor: "#1C771C", - color: "#1C771C", + fillColor: config['station']['markerColor'], + color: config['station']['markerColor'], weight: 1, opacity: 1, fillOpacity: config['station']['markerOpacity'], diff --git a/www/misc.js b/www/misc.js index 54d7f60..5408d60 100644 --- a/www/misc.js +++ b/www/misc.js @@ -100,8 +100,8 @@ var config = { event: { evaluationBlacklist: ['automatic', 'preliminary', 'rejected'], markerOpacity: 0.3, - markerColor: '#FFD500', - markerColorH: '#FF0000', + markerColor: 'blue', + markerColorH: 'red', minMag: 1.2, minMagDelta: 0.1, typeWhitelist: ['earthquake', 'induced or triggered event', 'quarry blast'], @@ -114,6 +114,7 @@ var config = { latlngDelta: 0.1, }, station: { + markerColor: 'darkgreen', markerOpacity: 0.5, }, }; @@ -127,11 +128,14 @@ $(document).ready(function() { if ( Number(parameters['minmag']) ) { config['event']['minMag'] = Number(parameters['minmag']); }; - if ( parameters['markercolor'] ) { - config['event']['markerColor'] = parameters['markercolor']; + if ( parameters['eventcolor'] ) { + config['event']['markerColor'] = parameters['eventcolor']; }; - if ( parameters['markercolorh'] ) { - config['event']['markerColorH'] = parameters['markercolorh']; + if ( parameters['eventcolorh'] ) { + config['event']['markerColorH'] = parameters['eventcolorh']; + }; + if ( parameters['stationcolor'] ) { + config['station']['markerColor'] = parameters['stationcolor']; }; if ( Number(parameters['timespan']) ) { config['map']['timespan'] = Number(parameters['timespan']);