2014-05-06 15:14:30 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* misc.js *
|
|
|
|
* script for unspecific functions and setup *
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
/* License
|
|
|
|
Copyright 2014 Kasper D. Fischer <kasper.fischer@rub.de>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by the Free
|
|
|
|
Software Foundation, either version 3 of the License, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* calculate marker radius from magnitude
|
|
|
|
* both formulas have equal radii at mag=1.2 */
|
2014-05-06 13:26:47 +02:00
|
|
|
function mag2radius(mag) {
|
|
|
|
return 400*mag; // radius proportional to magagnitude
|
|
|
|
// return 8.104*Math.pow(30,mag) // radius proportional to energy
|
|
|
|
};
|
|
|
|
|
2014-05-06 15:14:30 +02:00
|
|
|
/* set height of eventlist div */
|
2014-05-06 13:26:47 +02:00
|
|
|
function setInfoHeight() {
|
|
|
|
var height = $('div.map').height() - 36;
|
|
|
|
$('div.info').height(height);
|
|
|
|
};
|
|
|
|
|
|
|
|
/* get region and regionID of a location */
|
|
|
|
function getLocation(lat, lng) {
|
|
|
|
var region = false;
|
|
|
|
var regionID;
|
|
|
|
var regions = [
|
|
|
|
['Monschau', 'Schleiden', 'Bad Münstereifel', 'Rheinland-Pfalz', 'Rheinland-Pfalz', 'Rheinland-Pfalz', 'Hessen', 'Hessen', 'Hessen', 'Hessen'],
|
|
|
|
['Aachen', 'Zülpich', 'Euskirchen', 'Bonn', 'Rheinland-Pfalz', 'Rheinland-Pfalz', 'Hessen', 'Hessen', 'Hessen', 'Hessen'],
|
|
|
|
['Geilenkirchen', 'Düren', 'Köln', 'Köln-Mülheim', 'Waldbröl', 'Freudenberg', 'Siegen', 'Hessen', 'Hessen', 'Hessen'],
|
|
|
|
['Heinsberg', 'Mönchengladbach', 'Neuss', 'Solingen', 'Gummersbach', 'Olpe', 'Schmallenberg', 'Bad Berleburg', 'Hessen', 'Hessen'],
|
|
|
|
['Nettetal', 'Krefeld', 'Düsseldorf', 'Wuppertal', 'Hagen', 'Iserlohn', 'Arnsberg', 'Brilon', 'Hessen', 'Hessen'],
|
|
|
|
['Geldern', 'Moers', 'Duisburg', 'Essen', 'Dortmund', 'Unna', 'Soest', 'Büren', 'Marsberg', 'Warburg'],
|
|
|
|
['Kleve', 'Wesel', 'Dorsten', 'Recklinghausen', 'Lünen', 'Hamm/Westfalen', 'Beckum', 'Lippstadt', 'Paderborn', 'Bad Driburg'],
|
|
|
|
['Emmerich am Rhein', 'Bocholt', 'Borken', 'Coesfeld', 'Münster', 'Warendorf', 'Rheda-Wiedenbrück', 'Gütersloh', 'Detmold', 'Bad Pyrmont'],
|
|
|
|
['The Netherlands', 'The Netherlands', 'Vreden', 'Ahaus', 'Steinfurt', 'Lengerich', 'Bad Ilburg', 'Bielefeld', 'Herford', 'Niedersachsen'],
|
|
|
|
['The Netherlands', 'The Netherlands', 'The Netherlands', 'Niedersachsen', 'Rheine', 'Ibbenbüren', 'Niedersachsen', 'Lübbecke', 'Minden', 'Niedersachsen']
|
|
|
|
];
|
|
|
|
if ( lat >= 50.4 && lat < 52.4 && lng >= 6.0 && lng < 9.333333 ) {
|
|
|
|
var latIndex = Math.floor((lat-50.4)*5); // 5 tiles per degree
|
|
|
|
var lngIndex = Math.floor((lng-6.0)*3); // 3 tiles per degree
|
|
|
|
region = regions[latIndex][lngIndex];
|
|
|
|
};
|
|
|
|
if ( region != 'The Netherlands' ) {
|
|
|
|
regionID = 5500-latIndex*200+lngIndex*2+2;
|
|
|
|
};
|
|
|
|
if ( lat >= 50.9 && lat < 51.1 && lng >= 5.666666 && lng < 6.0 ) {
|
|
|
|
region = 'Selfkant';
|
|
|
|
regionID = 5000;
|
|
|
|
};
|
|
|
|
return [ region, regionID ];
|
|
|
|
};
|
|
|
|
|
2014-05-06 15:14:30 +02:00
|
|
|
/* window resize */
|
2014-05-06 13:26:47 +02:00
|
|
|
$( window ).resize(function() {
|
|
|
|
setInfoHeight();
|
|
|
|
});
|
|
|
|
|
2014-05-14 07:21:19 +02:00
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2014-05-06 15:14:30 +02:00
|
|
|
/* create global vars */
|
2014-05-06 16:18:20 +02:00
|
|
|
var map;
|
2014-05-12 18:16:01 +02:00
|
|
|
var openMarkerID;
|
2014-05-06 13:26:47 +02:00
|
|
|
var eventTable = {};
|
|
|
|
var eventDetails = {};
|
|
|
|
var stationTable = {};
|
2014-05-06 16:18:20 +02:00
|
|
|
var config = {
|
2014-05-06 16:40:32 +02:00
|
|
|
ajax: {
|
|
|
|
timeout: 150000, // 15 seconds
|
|
|
|
eventURL: 'https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/event/1/query',
|
2014-05-09 09:00:03 +02:00
|
|
|
mseedURL: 'https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/dataselect/1/query',
|
2014-05-06 16:40:32 +02:00
|
|
|
stationURL: 'https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/station/1/query',
|
|
|
|
nominatimURL: '//open.mapquestapi.com/nominatim/v1/reverse.php',
|
|
|
|
// nominatimURL: '//nominatim.openstreetmap.org/reverse',
|
|
|
|
},
|
2014-05-06 16:18:20 +02:00
|
|
|
event: {
|
2014-05-07 14:30:27 +02:00
|
|
|
evaluationBlacklist: ['automatic', 'preliminary', 'rejected'],
|
2014-05-06 16:18:20 +02:00
|
|
|
markerOpacity: 0.3,
|
2014-05-14 11:48:04 +02:00
|
|
|
markerColor: 'blue',
|
|
|
|
markerColorH: 'red',
|
2014-05-06 16:18:20 +02:00
|
|
|
minMag: 1.2,
|
2014-05-06 16:40:32 +02:00
|
|
|
minMagDelta: 0.1,
|
2014-05-11 20:55:45 +02:00
|
|
|
typeWhitelist: ['earthquake', 'induced or triggered event'],
|
2014-05-06 16:18:20 +02:00
|
|
|
},
|
|
|
|
map: {
|
|
|
|
zoomDefault: 9,
|
|
|
|
zoomFocus: 12,
|
|
|
|
centerDefault: [51.85, 7.0],
|
2014-05-06 16:40:32 +02:00
|
|
|
timespan: 180,
|
|
|
|
latlngDelta: 0.1,
|
2014-05-06 16:18:20 +02:00
|
|
|
},
|
|
|
|
station: {
|
2014-05-14 11:48:04 +02:00
|
|
|
markerColor: 'darkgreen',
|
2014-05-06 16:18:20 +02:00
|
|
|
markerOpacity: 0.5,
|
|
|
|
},
|
|
|
|
};
|
2014-05-06 13:26:47 +02:00
|
|
|
|
2014-05-06 15:14:30 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* document ready *
|
|
|
|
**********************************************************************/
|
2014-05-06 13:26:47 +02:00
|
|
|
$(document).ready(function() {
|
2014-05-14 07:21:19 +02:00
|
|
|
// parse query string
|
|
|
|
var parameters = parseQueryString();
|
|
|
|
if ( Number(parameters['minmag']) ) {
|
|
|
|
config['event']['minMag'] = Number(parameters['minmag']);
|
|
|
|
};
|
2014-05-14 11:48:04 +02:00
|
|
|
if ( parameters['eventcolor'] ) {
|
|
|
|
config['event']['markerColor'] = parameters['eventcolor'];
|
2014-05-14 07:21:19 +02:00
|
|
|
};
|
2014-05-14 11:48:04 +02:00
|
|
|
if ( parameters['eventcolorh'] ) {
|
|
|
|
config['event']['markerColorH'] = parameters['eventcolorh'];
|
|
|
|
};
|
|
|
|
if ( parameters['stationcolor'] ) {
|
|
|
|
config['station']['markerColor'] = parameters['stationcolor'];
|
2014-05-14 07:21:19 +02:00
|
|
|
};
|
|
|
|
if ( Number(parameters['timespan']) ) {
|
|
|
|
config['map']['timespan'] = Number(parameters['timespan']);
|
|
|
|
};
|
|
|
|
|
2014-05-06 13:26:47 +02:00
|
|
|
// AJAX setup
|
2014-05-06 16:40:32 +02:00
|
|
|
$.ajaxSetup({timeout: config['ajax']['timeout']});
|
|
|
|
|
2014-05-06 13:26:47 +02:00
|
|
|
// adjust height of infocontainer
|
|
|
|
setInfoHeight();
|
2014-05-06 16:40:32 +02:00
|
|
|
|
2014-05-06 13:26:47 +02:00
|
|
|
// create tabs
|
|
|
|
var tabOptions = {
|
|
|
|
active: 0,
|
|
|
|
disabled: [2, 3],
|
|
|
|
};
|
|
|
|
$('#tabs').tabs(tabOptions);
|
|
|
|
});
|
|
|
|
|