diff --git a/.gitattributes b/.gitattributes index 5737ea1..8bc052e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,6 @@ * text=auto !eol +scripts/mkEvents.csh -text +wsgi/showEnv.py -text www/.htaccess -text www/copyright.inc.de -text www/external/TileLayer.Grayscale.js -text diff --git a/.gitignore b/.gitignore index 905c7ae..1f9e2a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ scripts/events.xml scripts/geolocation.js +wsgi/.idea www/dlsv www/event.xml www/events.xml diff --git a/wsgi/plotFDSN.py b/wsgi/plotFDSN.py new file mode 100755 index 0000000..09ba15a --- /dev/null +++ b/wsgi/plotFDSN.py @@ -0,0 +1,407 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" + Get waveform data from FDSN web service and create a fancy plot + This programme runs as a script or as a WSGI application. + + Subversion information: + $Id$ + + :license + Copyright 2015 Kasper Fischer + + 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 2 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, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + MA 02110-1301, USA. +""" + + +def utc2local(utctime, timezone='Europe/Berlin'): + """ + utc2local(utctime, timezone='Europe/Berlin') + converts the UTCDateTime object utctime into a + datetime object of the given timezone + """ + + import pytz + + utc = pytz.utc + local = pytz.timezone(timezone) + utctime = utc.localize(utctime.datetime) + return local.normalize(utctime.astimezone(local)) + + +def fancy_plot(st, wsgi=False, img_format='png', color=True): + """ + creating fancy plot from ObsPy stream st + returns cStringIO object if wsgi == True + :type st: ObsPy Stream object + :type wsgi: bool + :type img_format: str + :type color: bool + """ + + import matplotlib as mpl + from matplotlib.dates import date2num, AutoDateLocator, AutoDateFormatter + + if wsgi: + try: + import cStringIO as StringIO + except ImportError: + import StringIO as StringIO + import matplotlib.pyplot as plt + from numpy import arange + + # setup figure parameters + if wsgi: + mpl.rcParams['figure.figsize'] = [12.0, 6.75] # 16:9 aspect ratio + else: + mpl.rcParams['figure.figsize'] = [16.0, 9.0] # 16:9 aspect ratio + + # get starttime, endtime, localtime and timezone + tr = st[0] + stime = tr.stats.starttime + etime = tr.stats.endtime + localtime = utc2local(stime) + if localtime.tzname() == u'CET': + tzname = u'MEZ' + else: + tzname = u'MESZ' + tz = localtime.timetz().tzinfo + + # create proper time vector + d = arange(date2num(stime), date2num(etime), (date2num(etime) - date2num(stime)) / tr.stats.npts) + + # setup time axis decorator + locator = AutoDateLocator(interval_multiples=True, minticks=5, maxticks=8, tz=tz) + minor_locator = AutoDateLocator(interval_multiples=True, minticks=9, maxticks=70, tz=tz) + formatter = AutoDateFormatter(locator, tz=tz) + formatter.scaled[1. / (24. * 60.)] = '%H:%M:%S' + formatter.scaled[1. / (24. * 60. * 60. * 10.)] = '%H:%M:%S.%f' + + # draw figure + if color: + trace_color = {'Z': 'r', 'N': 'b', 'E': 'g'} + else: + trace_color = {'Z': 'k', 'N': 'k', 'E': 'k'} + + fig = plt.figure() + + ax1 = fig.add_subplot(311) + ax1.xaxis.set_major_locator(locator) + ax1.xaxis.set_major_formatter(formatter) + ax1.plot_date(d, st.select(component='Z')[0].data * 1000., trace_color['Z'], label=u'Z', tz=tz) + plt.title(u'Station %s' % st[0].stats.station, fontsize=24) + plt.legend(loc='upper right') + ax1.grid(b=True) + + ax2 = fig.add_subplot(312, sharex=ax1, sharey=ax1) + ax2.plot_date(d, st.select(component='N')[0].data * 1000., trace_color['N'], label=u'N', tz=tz) + ax2.grid(b=True) + plt.ylabel(u'Geschwindigkeit [mm/s]', fontsize=16) + plt.legend(loc='upper right') + + ax3 = fig.add_subplot(313, sharex=ax1, sharey=ax1) + ax3.plot_date(d, st.select(component='E')[0].data * 1000., trace_color['E'], label=u'E', tz=tz) + ax3.grid(b=True) + plt.legend(loc='upper right') + + plt.xlabel(u'%s (%s)' % (localtime.strftime('%d.%m.%Y'), tzname), fontsize=16) + ax1.minorticks_on() + ax1.xaxis.set_minor_locator(minor_locator) + + if wsgi: + buf = StringIO.StringIO() + plt.savefig(buf, format=img_format, facecolor="lightgray") + return buf + else: + if cla['filename']: + plt.savefig(cla['filename'], dpi=300, transparent=True) + else: + plt.show() + + +def trace_dayplot(st, deltat = None, + ftype='none', fmin=1.0, fmax=7.0, + col=('b', 'r', 'g'), interval=20, outpattern='', + wsgi=False): + """ + + :type st: object + :type ftype: str + :type fmin: float + :type fmax: float + :type col: tuple + :type interval: float + :type outpattern: str + :type wsgi: bool + """ + + if wsgi: + try: + import cStringIO as StringIO + except ImportError: + import StringIO as StringIO + + # filter + if (ftype == 'bandpass') or (ftype == 'bandstop'): + st.filter(ftype, freqmin=fmin, freqmax=fmax) + elif (ftype == 'lowpass') or (ftype == 'highpass'): + st.filter(ftype, freq=fmin) + st.merge() + + stime = st[0].stats.starttime + if deltat: + etime = stime + deltat + else: + etime = st[0].stats.endtime + + # plot + for i in range(0, len(st)): + if wsgi: + buf = StringIO.StringIO() + st[i].plot(outfile=buf, format=outpattern, type='dayplot', color=col, interval=interval, + starttime=stime, endtime=etime) + return buf + else: + if outpattern != '': + imagefile = outpattern.format(st[i].stats.network, + st[i].stats.station, + st[i].stats.channel, + st[i].stats.starttime.year, + st[i].stats.starttime.julday) + st[i].plot(type='dayplot', color=col, interval=interval, + outfile=imagefile) + else: + st[i].plot(type='dayplot', color=col, interval=interval) + + +def get_fdsn(bulk_request, output='VEL', base_url='https://ariadne.geophysik.ruhr-uni-bochum.de'): + """ + Fetches waveform data from FDSN web service and returns + instrument corrected seismogram of type given in parameter output. + Acceptable values for output are "VEL", "DISP" and "ACC" (see ObsPy documentation) + + :rtype : object + :param bulk_request: list + :param output: str + :param base_url: str + :return: ObsPy Stream() object + """ + import warnings + from obspy.fdsn import Client + from obspy.fdsn.header import FDSNException + + try: + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + client = Client(base_url=base_url, debug=False) + st = client.get_waveforms_bulk(bulk_request, attach_response=True) + + st.merge() + stime = st[0].stats.starttime + etime = st[0].stats.endtime + for trace in st.traces: + stime = max(stime, trace.stats.starttime) + etime = min(etime, trace.stats.endtime) + st.trim(starttime=stime, endtime=etime) + + # choose 1 s taper + taper_fraction = 1 / (etime - stime) + for trace in st.traces: + # filter, remove response + trace.filter('bandpass', freqmin=0.01, freqmax=25, corners=3, zerophase=False). \ + remove_response(output=output, zero_mean=True, taper=True, taper_fraction=taper_fraction) + return st + except FDSNException: + return None + + +def main(backend=None, args=None, wsgi=False): + """ + Main function to create a waveform plot. + This functions calls get_fdsn and fancy_plot to create the figure. + If wsgi == True it returns an ioString object containing the figure. + + :type backend: str + :type args: dict + :type wsgi: bool + :rtype : object + :param backend: + :param args: + :param wsgi: + :return: ioString object with created image + """ + + import warnings + import matplotlib as mpl + + if wsgi: + backend = 'Agg' + if backend: + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + mpl.use(backend) + from obspy import UTCDateTime + + if args: + deltat = args['length'] + if args['stime']: + otime = UTCDateTime(args['stime']) + else: + otime = UTCDateTime() - 3600. - deltat + network = args['station'].split('.')[0] + station = args['station'].split('.')[1] + if args['type'] == 'dayplot': + if network == 'Z3': + channel = 'HHZ' + else: + channel = 'BHZ' + else: + if args['length'] < 3600.: + channel = 'HH?' + else: + if network == 'Z3': + channel = 'HH?' + else: + channel = 'BH?' + else: + otime = UTCDateTime() - 3600. + deltat = 30 + network = 'GR' + station = 'BUG' + channel = 'HH?' + + st = get_fdsn([(network, station, '*', channel, otime, otime + deltat)], base_url=args['server']) + if st is not None: + stime = max(st[0].stats.starttime, otime) + etime = min(st[0].stats.endtime, otime + deltat) + st.trim(starttime=stime, endtime=etime) + + if wsgi: + if args['type'] == 'dayplot': + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + return trace_dayplot(st, outpattern=args['format'], wsgi=wsgi, deltat=deltat) + else: + return fancy_plot(st, wsgi=wsgi, img_format=args['format'], color=args['color']) + else: + if args['type'] == 'dayplot': + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + trace_dayplot(st, wsgi=wsgi) + else: + fancy_plot(st, color=args['color']) + elif not wsgi: + warnings.warn('No data available!') + + +def application(environ, start_response): + """ + Function application - Wrapper to process wsgi request + :param environ: contains information on the wsgi environment + :type environ: dict + :param start_response: function to process response header by the wsgi server + :type start_response: function + :return: response to be sent to the client by the wsgi server + :rtype: list + """ + + import os + from cgi import FieldStorage + + # set HOME environment variable to a directory the httpd server can write to + # otherwise matplotlib won't work + os.environ['HOME'] = '/tmp/wsgi-kasper' + try: + os.mkdir('/tmp/wsgi-kasper') + except OSError: + pass + + # fake command line arguments + # setting needed default values + wsgi_args = {'server': 'http://localhost/'} + + # fill wsgi_args with environment variables + form = FieldStorage(fp=environ['wsgi.input'], environ=environ) + wsgi_args['station'] = form.getfirst('station', 'GR.BUG').upper() + wsgi_args['stime'] = form.getfirst('start_time', []) + wsgi_args['length'] = form.getfirst('length', '30') + wsgi_args['length'] = abs(int(wsgi_args['length'])) + wsgi_args['format'] = form.getfirst('format', 'png').lower() + if wsgi_args['format'] != 'png' and wsgi_args['format'] != 'svg': + wsgi_args['format'] = 'png' + wsgi_args['color'] = form.getfirst('color', 'TRUE').upper() + if wsgi_args['color'] == 'FALSE': + wsgi_args['color'] = False + else: + wsgi_args['color'] = True + wsgi_args['type'] = form.getfirst('type', '').lower() + if (wsgi_args['type'] != 'dayplot' and wsgi_args['type'] != 'normal') or wsgi_args['type'] == '': + if wsgi_args['length'] < 43200: + wsgi_args['type'] = 'normal' + else: + wsgi_args['type'] = 'dayplot' + + # process the request + buf = main(args=wsgi_args, backend='Agg', wsgi=True) + if buf is not None: + data = buf.getvalue() + buf.close() + data_length = len(data) + + if wsgi_args['format'] == 'svg': + wsgi_args['format'] = 'svg+xml' + start_response('200 OK', [('Content-Type', 'image/%s' % wsgi_args['format']), ('Content-Length', '%d' % data_length)]) + return [data] + else: + start_response('400 Bad Request', []) + return [] + +# __main__ +if __name__ == "__main__": + import os + import argparse + + parser = argparse.ArgumentParser( + description=u'Get event waveform data of all RuhrNet stations.', + epilog=u'$Revision$ ($Date$, $Author$)'.replace( + "$", "")) + parser.add_argument(u'-v', u'-V', u'--version', action='version', + version=u'$Revision$ ($Date$, \ + $Author$)'.replace('$', '')) + parser.add_argument(u'-u', u'--url', action='store', dest='server', + default=u'https://ariadne.geophysik.ruhr-uni-bochum.de', + help=u'Base URL of the FDSN web service (https://ariadne.geophysik.ruhr-uni-bochum.de).') + parser.add_argument(u'-t', u'--type', action='store', dest='type', metavar='TYPE', + help=u'Type of plot: normal or dayplot.') + parser.add_argument(u'-f', u'--file', action='store', dest='filename', metavar='FILENAME', + help=u'Save plot to file FILENAME') + parser.add_argument(u'-c', u'--color', action='store_true', help=u'Create color plot.') + parser.add_argument(u'-l', u'--length', action='store', type=int, default=30, + help=u'Length of waveform window in seconds (30 s).') + group = parser.add_mutually_exclusive_group(required=True) + group.add_argument(u'-s', u'--start_time', dest='stime', action='store', metavar='START', + help=u'Start time of waveform window.') + group.add_argument(u'-e', u'--event', action='store', metavar='EVENTID', + help=u'Get starttime from event P-phase onset at station.') + parser.add_argument(u'station', action='store', metavar='NET.STATION', + help=u'Station to plot.') + + cla = vars(parser.parse_args()) + + if os.getenv('DISPLAY'): + main(args=cla) + else: + main('Agg', cla) diff --git a/wsgi/showEnv.py b/wsgi/showEnv.py new file mode 100644 index 0000000..fc28441 --- /dev/null +++ b/wsgi/showEnv.py @@ -0,0 +1,17 @@ +def application(environ, start_response): + """ + Function application - Wrapper to process wsgi request + :param environ: contains information on the wsgi environment + :type environ: dict + :param start_response: function to process response header by the wsgi server + :type start_response: function + :return: response to be sent to the client by the wsgi server + :rtype: list + """ + + from cgi import FieldStorage + + form = FieldStorage(fp=environ['wsgi.input'], environ=environ) + + start_response('200 OK', [('Content-Type', 'text/html')]) + return [form] \ No newline at end of file diff --git a/wsgi/traceDayplot.py b/wsgi/traceDayplot.py new file mode 100755 index 0000000..9056f8f --- /dev/null +++ b/wsgi/traceDayplot.py @@ -0,0 +1,117 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- +""" +Produce a dayplot from seismogram recordings + +Subversion information: +$Id$ + +license: gpl3 +Copyright 2012-2015 Seismological Observatory, Ruhr-University Bochum +http://www.gmg.ruhr-uni-bochum.de/geophysik/seisobs +Contributors: + Martina Rische + Kasper D. Fischer + Sebastian Wehling-Benatelli + +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/. +""" + + +def trace_dayplot(st, ftype='bandpass', fmin=1.0, fmax=7.0, + col=('b', 'r', 'g'), interval=20.0, outpattern=''): + """ + + :type st: object + :type ftype: str + :type fmin: float + :type fmax: float + :type col: tuple + :type interval: float + :type outpattern: str + """ + + # filter + if (ftype == 'bandpass') or (ftype == 'bandstop'): + st.filter(ftype, freqmin=fmin, freqmax=fmax) + elif (ftype == 'lowpass') or (ftype == 'highpass'): + st.filter(ftype, freq=fmin) + st.merge() + + # plot + for i in range(0, len(st)): + if outpattern != '': + imagefile = outpattern.format(st[i].stats.network, + st[i].stats.station, + st[i].stats.channel, + st[i].stats.starttime.year, + st[i].stats.starttime.julday) + st[i].plot(type='dayplot', color=col, interval=interval, + outfile=imagefile) + else: + st[i].plot(type='dayplot', color=col, interval=interval) + + +# __main__ +if __name__ == "__main__": + + # parse arguments + import argparse + from obspy.core import read + + parser = argparse.ArgumentParser( + description='Produce filtered 24h-plot (dayplot).', + epilog='$Rev: 403 $ ($Date: 2012-04-13 12:16:22 +0200 (Fri, 13 Apr 2012) $, $Author: kasper $)') + parser.add_argument('-v', '-V', '--version', action='version', + version='$Rev: 403 $ ($Date: 2012-04-13 12:16:22 +0200 (Fri, 13 Apr 2012) $, $Author: kasper $)') + parser.add_argument('file', action='store', metavar='FILE', nargs='+', + help='File(s) to use for the dayplot. One dayplot will be used for every file. \ + Use wildcards to use multiple file for one plot') + parser.add_argument('-f', '--filter', action='store', dest='ftype', + default='bandpass', + choices=['none', 'bandpass', 'bandstop', 'lowpass', 'highpass'], + help='Select filtertype to filter the data (default: bandpass)\ + Note: For low- and highpass only fmin is used.') + parser.add_argument('--fmin', action='store', type=float, dest='fmin', + default=1.0, + help='Lower frequency of the filter in Hz (default: 1.0)') + parser.add_argument('--fmax', action='store', type=float, dest='fmax', + default=7.0, + help='Upper frequency of the filter in Hz (default: 7.0)') + parser.add_argument('-c', '--color', '--colour', action='store', dest='color', + default=('b', 'r', 'g'), + help='Color selection to use in the dayplot (default: brg)') + parser.add_argument('-i', '--interval', action='store', type=int, dest='interval', + default=20, + help='Interval length to show in each line of the dayplot in minutes (default: 20)') + parser.add_argument('-o', '--output', action='store', dest='outpattern', + default='', + help="Output filename pattern for the plot. (default: unset, show plot on screen only), \ + Use {0} to substitute network code, \ + {1} to substitute station code, \ + {2} to substitute station channel, \ + {3} to substitute year, \ + {4} to substitute doy number \ + .format (supported formats: emf, eps, pdf, png, ps, raw, rgba, svg, svgz)") + + cla = parser.parse_args() + if cla.fmin < 0: + cla.fmin = -cla.fmin + if cla.fmax < 0: + cla.fmax = -cla.fmax + + # call trace_dayplot(...) for each file + for datafile in cla.file: + trace_dayplot(read(datafile), cla.ftype, cla.fmin, cla.fmax, cla.color, + cla.interval, cla.outpattern) \ No newline at end of file diff --git a/www/.htaccess b/www/.htaccess index 605d2f4..93cdb28 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -1 +1,7 @@ Allow from all +Header always set Access-Control-Allow-Origin "https://fdsnws.geophysik.ruhr-uni-bochum.de" +Header always append Access-Control-Allow-Origin "https://photon.komoot.de" +Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT" +Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token" +Header always set Access-Control-Expose-Headers "Content-Security-Policy, Location" +Header always set Access-Control-Max-Age "600" diff --git a/www/events.js b/www/events.js index cd44da9..6cd209f 100644 --- a/www/events.js +++ b/www/events.js @@ -40,21 +40,23 @@ function addTableRow(row, table) { /* do reverse geolocation lookup */ function getGeolocation(id, lat, lng) { - if ( !geolocationTable[id] ) { + if ( $.inArray(id, geolocationTable) == -1 ) { $.getJSON( config['ajax']['nominatimURL'], { lat: lat, lon: lng } ) .done(function( json ) { - var city = json.features[0].properties.city; - var countryCode = json.features[0].properties.country; - geolocationTable[id] = city; - ( countryCode != "Germany" ) ? geolocationTable[id] = geolocationTable[id] + " ("+countryCode+")" : null; - if ( city ) { - $("#eventstable a.toggle[eventid="+id+"]").text(geolocationTable[id]); - var sort = [[0,1],[1,1],[2,1]]; - $("#eventstable").trigger("update", [true]); - $("#eventstable").trigger("updateCache"); - $("#eventstable").trigger("sorton", [sort]); - } else { - // console.log("Nominatim did not provide a city tag for "+lat+" / "+lng); + if ( json.features[0] ) { + var city = json.features[0].properties.city; + var countryCode = json.features[0].properties.country; + geolocationTable[id] = city; + ( countryCode != "Germany" ) ? geolocationTable[id] = geolocationTable[id] + " ("+countryCode+")" : null; + if ( city ) { + $("#eventstable a.toggle[eventid="+id+"]").text(geolocationTable[id]); + var sort = [[0,1],[1,1],[2,1]]; + $("#eventstable").trigger("update", [true]); + $("#eventstable").trigger("updateCache"); + $("#eventstable").trigger("sorton", [sort]); + } else { + // console.log("Nominatim did not provide a city tag for "+lat+" / "+lng); + }; }; }) .fail(function( jqxhr, textStatus, error ) { @@ -118,7 +120,7 @@ function ajaxLoadEvents(stime, etime, eventid, url, target) { var type = $(this).find('type').last().text(); var location // 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 ( !eventTable[id] && $.inArray(type, config['event']['typeWhitelist'] ) >= 0 && $.inArray(evaluationStatus, config['event']['evaluationBlacklist'])<0 && Number(mag)+0.05 >= config['event']['minMag'] ) { geolocationTable[id] ? null : getGeolocation(id, lat, lng); // do AJAX lookup if not cached, location will be updated later location = ( geolocationTable[id] || getLocation(lat, lng)[0] || $(this).find('description > text').text() ); // general event info (1st line) @@ -419,11 +421,19 @@ $(document).ready(function() { case 'earthquake': typetext += 'tektonisches Erdbeben (Stern)'; break; + case 'explosion': + typetext += 'Explosion (Sechseck)'; + break; case 'induced or triggered event': typetext += '(bergbau-)induziertes Ereignis (Kreis)'; break; case 'quarry blast': - typetext += 'Steinbruchsprengung (Rad)'; + case 'controlled explosion': + case 'explosion': + typetext += 'Sprengung (Rad)'; + break; + case 'nuclear explosion': + typetext += 'Atomwaffentest (Viereck)'; break; }; $("#events-type").append(typetext); diff --git a/www/events.js.en b/www/events.js.en index aa2c0b1..e06e2c9 100644 --- a/www/events.js.en +++ b/www/events.js.en @@ -40,21 +40,23 @@ function addTableRow(row, table) { /* do reverse geolocation lookup */ function getGeolocation(id, lat, lng) { - if ( !geolocationTable[id] ) { + if ( $.inArray(id, geolocationTable) == -1 ) { $.getJSON( config['ajax']['nominatimURL'], { lat: lat, lon: lng } ) .done(function( json ) { - var city = json.features[0].properties.city; - var countryCode = json.features[0].properties.country; - geolocationTable[id] = city; - ( countryCode != "Germany" ) ? geolocationTable[id] = geolocationTable[id] + " ("+countryCode+")" : null; - if ( city ) { - $("#eventstable a.toggle[eventid="+id+"]").text(geolocationTable[id]); - var sort = [[0,1],[1,1],[2,1]]; - $("#eventstable").trigger("update", [true]); - $("#eventstable").trigger("updateCache"); - $("#eventstable").trigger("sorton", [sort]); - } else { - // console.log("Nominatim did not provide a city tag for "+lat+" / "+lng); + if ( json.features[0] ) { + var city = json.features[0].properties.city; + var countryCode = json.features[0].properties.country; + geolocationTable[id] = city; + ( countryCode != "Germany" ) ? geolocationTable[id] = geolocationTable[id] + " ("+countryCode+")" : null; + if ( city ) { + $("#eventstable a.toggle[eventid="+id+"]").text(geolocationTable[id]); + var sort = [[0,1],[1,1],[2,1]]; + $("#eventstable").trigger("update", [true]); + $("#eventstable").trigger("updateCache"); + $("#eventstable").trigger("sorton", [sort]); + } else { + // console.log("Nominatim did not provide a city tag for "+lat+" / "+lng); + }; }; }) .fail(function( jqxhr, textStatus, error ) { @@ -117,12 +119,10 @@ function ajaxLoadEvents(stime, etime, eventid, url, target) { var evaluationStatus = $(this).find('origin > evaluationStatus').text(); var type = $(this).find('type').last().text(); var location - // get location, try this in order: - // regional map name, given value, cached value, or nominatim lookup - geolocationTable[id] ? null : getGeolocation(id, lat, lng); // do AJAX lookup if not cached, location will be updated later - location = ( geolocationTable[id] || 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'] ) { + if ( !eventTable[id] && $.inArray(type, config['event']['typeWhitelist'] ) >= 0 && $.inArray(evaluationStatus, config['event']['evaluationBlacklist'])<0 && Number(mag)+0.05 >= config['event']['minMag'] ) { + geolocationTable[id] ? null : getGeolocation(id, lat, lng); // do AJAX lookup if not cached, location will be updated later + location = ( geolocationTable[id] || getLocation(lat, lng)[0] || $(this).find('description > text').text() ); // general event info (1st line) var row = '' + ''+otime.split('.')[0]+'Z' @@ -428,8 +428,13 @@ $(document).ready(function() { typetext += '(mining-)induced event (circle)'; break; case 'quarry blast': + case 'controlled explosion': + case 'explosion': typetext += 'quarry blast (wheel)'; break; + case 'nuclear explosion': + typetext += 'nuclear weapon test (square)'; + break; }; $("#events-type").append(typetext); }); diff --git a/www/index.html.de b/www/index.html.de index 5cb2541..0943ff0 100755 --- a/www/index.html.de +++ b/www/index.html.de @@ -15,6 +15,7 @@ + @@ -36,7 +37,11 @@ - + + + + + diff --git a/www/index.html.en b/www/index.html.en index 619ca49..7d1e4e2 100755 --- a/www/index.html.en +++ b/www/index.html.en @@ -15,7 +15,7 @@ - + @@ -37,9 +37,12 @@ - - + + + + + @@ -96,7 +99,6 @@ - diff --git a/www/map.js b/www/map.js index 157345f..5d7fd21 100644 --- a/www/map.js +++ b/www/map.js @@ -17,14 +17,14 @@ 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/. + with this program. If not, see https://www.gnu.org/licenses/. $Id$ */ /* add station marker */ function addStationMarker(id, lat, lng, station) { - var marker = L.triangleMarker(L.latLng(lat, lng), + var marker = L.triangleMarker(L.latLng(lat, lng), { gradient: true, fillColor: config['station']['markerColor'], @@ -38,7 +38,7 @@ function addStationMarker(id, lat, lng, station) { marker.bindLabel('Station '+station); stationLayer.addLayer(marker); stationTable[id] = marker; -}; +}; /* add event marker */ function addEventMarker(id, lat, lng, mag, type) { @@ -61,6 +61,12 @@ function addEventMarker(id, lat, lng, mag, type) { case 'earthquake': marker = L.starMarker(L.latLng(lat, lng), markerOptions); break; + case 'nuclear explosion': + markerOptions['numberOfSides'] = 4; + markerOptions['radius'] = 2.0*markerOptions['radius']; + markerOptions['innerRadius'] = 0.3*markerOptions['radius']; + marker = L.regularPolygonMarker(L.latLng(lat, lng), markerOptions); + break; case 'explosion': markerOptions['numberOfSides'] = 6; markerOptions['radius'] = 2.0*markerOptions['radius']; @@ -68,6 +74,7 @@ function addEventMarker(id, lat, lng, mag, type) { marker = L.regularPolygonMarker(L.latLng(lat, lng), markerOptions); break; case 'quarry blast': + case 'controlled explosion': markerOptions['numberOfPoints'] = 7; markerOptions['innerRadius'] = 0.3*markerOptions['radius']; marker = L.starMarker(L.latLng(lat, lng), markerOptions); @@ -79,7 +86,7 @@ function addEventMarker(id, lat, lng, mag, type) { eventTable[id] = marker; return marker; }; -}; +}; /* handle to show events on map */ function initMapLink() { @@ -133,19 +140,18 @@ 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, 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); - + // create baselayer switch ( config['map']['baselayer'] ) { case 'osmde': // add OpenStreetMap.DE tile layer - L.tileLayer('http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', + map = L.map('map', { zoomControl: false, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); + L.tileLayer('https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap contributors, CC-BY-SA', + attribution: '© OpenStreetMap contributors, CC-BY-SA', }).addTo(map); break; case 'esrigray': // add ESRI Grayscale World Map (neither city nor road names) + map = L.map('map', { zoomControl: false, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); L.tileLayer('//server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ', @@ -153,36 +159,49 @@ $(document).ready(function() { }).addTo(map); break; case 'aerial': // add ESRI WordImagery tile layer - L.tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', + map = L.map('map', { zoomControl: false, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); + L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community' }).addTo(map); break; case 'komoot': // add OpenStreetMap.DE tile layer + map = L.map('map', { zoomControl: false, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); L.tileLayer('//www.komoot.de/tiles/{s}/{z}/{x}/{y}.png', { - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA | Tiles Courtesy of Komoot', + attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA | Tiles Courtesy of Komoot', }).addTo(map); break; case 'mapquestgray': // add MapQuestOSM tile layer - L.tileLayer.grayscale('http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg', - { - subdomains: '1234', - detectRetina: true, - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA | Tiles Courtesy of MapQuest ', - }).addTo(map); - break; + null; + // map = L.map('map', { zoomControl: false, worldCopyJump: true, layers: mapLayer }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); + // L.tileLayer.grayscale('https://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg', + // { + // subdomains: '1234', + // detectRetina: true, + // attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA | Tiles Courtesy of MapQuest ', + //}).addTo(map); + //break; case 'mapquest': // add MapQuestOSM tile layer null; default: - L.tileLayer('http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg', - { - subdomains: '1234', - detectRetina: true, - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA | Tiles Courtesy of MapQuest ', - }).addTo(map); + var mapLayer = MQ.mapLayer(); + map = L.map('map', { + zoomControl: false, + worldCopyJump: true, + layers: mapLayer, + }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); + //L.tileLayer('https://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg', + //{ + //subdomains: '1234', + //detectRetina: true, + //attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA | Tiles Courtesy of MapQuest ', + //}).addTo(map); }; + // add controls + new L.Control.Zoom({ position: 'topright' }).addTo(map); + new L.control.scale({position: 'bottomright', imperial: false}).addTo(map); // create station and event layer // stationLayer = L.geoJson().addTo(map); @@ -221,4 +240,7 @@ $(document).ready(function() { }; }); }); + + // print icon + L.easyPrint().addTo(map); }); diff --git a/www/map.js.en b/www/map.js.en index 867aef8..7a46b22 100644 --- a/www/map.js.en +++ b/www/map.js.en @@ -17,7 +17,7 @@ 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/. + with this program. If not, see https://www.gnu.org/licenses/. $Id$ */ @@ -61,6 +61,12 @@ function addEventMarker(id, lat, lng, mag, type) { case 'earthquake': marker = L.starMarker(L.latLng(lat, lng), markerOptions); break; + case 'nuclear explosion': + markerOptions['numberOfSides'] = 4; + markerOptions['radius'] = 2.0*markerOptions['radius']; + markerOptions['innerRadius'] = 0.3*markerOptions['radius']; + marker = L.regularPolygonMarker(L.latLng(lat, lng), markerOptions); + break; case 'explosion': markerOptions['numberOfSides'] = 6; markerOptions['radius'] = 2.0*markerOptions['radius']; @@ -68,6 +74,7 @@ function addEventMarker(id, lat, lng, mag, type) { marker = L.regularPolygonMarker(L.latLng(lat, lng), markerOptions); break; case 'quarry blast': + case 'controlled explosion': markerOptions['numberOfPoints'] = 7; markerOptions['innerRadius'] = 0.3*markerOptions['radius']; marker = L.starMarker(L.latLng(lat, lng), markerOptions); @@ -133,19 +140,19 @@ 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, 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); + // create baselayer switch ( config['map']['baselayer'] ) { case 'osmde': // add OpenStreetMap.DE tile layer - L.tileLayer('http://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', + map = L.map('map', { zoomControl: false, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); + L.tileLayer('https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', { - attribution: '© OpenStreetMap contributors, CC-BY-SA', + attribution: '© OpenStreetMap contributors, CC-BY-SA', }).addTo(map); break; case 'esrigray': // add ESRI Grayscale World Map (neither city nor road names) + map = L.map('map', { zoomControl: false, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); L.tileLayer('//server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri — Esri, DeLorme, NAVTEQ', @@ -153,35 +160,48 @@ $(document).ready(function() { }).addTo(map); break; case 'aerial': // add ESRI WordImagery tile layer - L.tileLayer('http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', + map = L.map('map', { zoomControl: false, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); + L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', { attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community' }).addTo(map); break; case 'komoot': // add OpenStreetMap.DE tile layer + map = L.map('map', { zoomControl: false, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); L.tileLayer('//www.komoot.de/tiles/{s}/{z}/{x}/{y}.png', { - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA | Tiles Courtesy of Komoot', + attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA | Tiles Courtesy of Komoot', }).addTo(map); break; case 'mapquestgray': // add MapQuestOSM tile layer - L.tileLayer.grayscale('http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg', - { - subdomains: '1234', - detectRetina: true, - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA | Tiles Courtesy of MapQuest ', - }).addTo(map); - break; + null; + // map = L.map('map', { zoomControl: false, worldCopyJump: true, layers: mapLayer }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); + // L.tileLayer.grayscale('https://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg', + // { + // subdomains: '1234', + // detectRetina: true, + // attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA | Tiles Courtesy of MapQuest ', + //}).addTo(map); + //break; case 'mapquest': // add MapQuestOSM tile layer null; default: - L.tileLayer('http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg', - { - subdomains: '1234', - detectRetina: true, - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA | Tiles Courtesy of MapQuest ', - }).addTo(map); + var mapLayer = MQ.mapLayer(); + map = L.map('map', { + zoomControl: false, + worldCopyJump: true, + layers: mapLayer, + }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); + //L.tileLayer('https://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg', + //{ + //subdomains: '1234', + //detectRetina: true, + //attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA | Tiles Courtesy of MapQuest ', + //}).addTo(map); }; + // add controls + new L.Control.Zoom({ position: 'topright' }).addTo(map); + new L.control.scale({position: 'bottomright', imperial: false}).addTo(map); // create station and event layer // stationLayer = L.geoJson().addTo(map); @@ -220,4 +240,7 @@ $(document).ready(function() { }; }); }); + + // print icon + L.easyPrint().addTo(map); }); diff --git a/www/misc.js b/www/misc.js index 69c0a8a..d0a8c31 100644 --- a/www/misc.js +++ b/www/misc.js @@ -90,11 +90,11 @@ var eventDetails = {}; var stationTable = {}; var config = { ajax: { - timeout: 10000, // 10 seconds - eventURL: '/fdsnws/event/1/query', + timeout: 20000, // 20 seconds + eventURL: 'https://fdsnws.geophysik.ruhr-uni-bochum.de/fdsnws/event/1/query', dlsvURL: 'dlsv', - mseedURL: '/fdsnws/dataselect/1/query', - stationURL: '/fdsnws/station/1/query', + mseedURL: 'https://fdsnws.geophysik.ruhr-uni-bochum.de/fdsnws/dataselect/1/query', + stationURL: 'https://fdsnws.geophysik.ruhr-uni-bochum.de/fdsnws/station/1/query', nominatimURL: 'https://photon.komoot.de/reverse', timespan: 180, }, @@ -105,7 +105,9 @@ var config = { markerColorH: 'red', minMag: 1.2, minMagDelta: 0.1, - typeWhitelist: ['earthquake', 'induced or triggered event'], + typeWhitelist: ['earthquake', 'induced or triggered event', 'controlled explosion'], + // typeWhitelist: ['earthquake', 'induced or triggered event', 'controlled explosion', 'nuclear explosion'], + // typeWhitelist: ['earthquake', 'induced or triggered event'], }, map: { zoomDefault: 9, @@ -128,7 +130,11 @@ var config = { NL_WIT: 3, NL_WTSB: 3, }, - networkBlacklist: ['NL', 'X5'], + networkBlacklist: ['NL', 'X5', '1A', 'AM'], + stationBlacklist: ['RN_WEA2', 'RN_ACN', 'RN_BHE', 'RN_ENT', 'RN_GSH', 'RN_HES', 'RN_JCKS', 'RN_LOH', + 'RN_OLF', 'RN_PLH', 'RN_RWB', 'RN_SOR', 'RN_TDN', 'RN_WBS', + 'RN_HAM1', 'RN_HAM2', 'RN_HAM3', 'RN_HAM4', 'RN_HAM5', 'RN_HAM6', 'RN_HAM7', 'RN_HAM8', 'RN_HAM9', + 'RN_HAM10', 'RN_HAM11', 'RN_HAM12', 'RN_HAM13', 'RN_HAM14', 'RN_HAM15', 'RN_HAM16', 'RN_HAM17'], }, tab: { active: 0, @@ -139,13 +145,18 @@ var config = { var networkURL = { GE: 'http://dx.doi.org/10.14470/TR560404', GR: 'http://www.bgr.bund.de/DE/Themen/Erdbeben-Gefaehrdungsanalysen/Seismologie/Seismologie/Seismometer_Stationen/Stationsnetze/d_stationsnetz_node.html', + NH: 'http://www.gd.nrw.de/gg_le.htm', NL: 'http://www.knmi.nl/seismologie/seismisch_network_knmi3.html', + RN: 'https://doi.org/10.7914/SN/RN', + YD: 'https://doi.org/10.7914/SN/YD_2020', }; var networkText = { - GE: 'GEOFON Program, GFZ Potsdam', + GE: 'GEOFON Seismic Network - Deutsches GeoForschungsZentrum GFZ', GR: 'German Regional Seismic Network, BGR Hannover', + NH: 'Geologischer Dienst NRW, Krefeld', NL: 'Netherlands Seismic Network, The Netherlands', - RN: 'RuhrNet - Ruhr-University Bochum, Germany', + RN: 'RuhrNet - Ruhr-University Bochum, Germany', + YD: 'FloodRisk Seismic Network', }; var bochumStation = ['BUG', 'IBBN', 'KERA', 'KARP']; diff --git a/www/specialevents.js b/www/specialevents.js index 5ecfd56..057017a 100644 --- a/www/specialevents.js +++ b/www/specialevents.js @@ -9,6 +9,29 @@ var specialEvents = [ //'bug2014ilxd', // Bassum //'bug2014gfzw', // Darmstadt //'bug2014datb', // Groningen - 'bug2013yvko', // Haltern 3.4 - 'bug2015fdpy', // Darmstadt 3.0 + // 'bug2013yvko', // Haltern 3.4 + // 'bug2015fdpy', // Darmstadt 3.0 + // 'bug2016ajgm', // CTBT violation North Korea + // 'bug2016cqkd', // Taunusstein 2.5 + // 'bug2016hdae', // Aldenhoven 2.6 + // 'bug2016hdaj', // Aldenhoven 2.4 + // 'bug2016kkrq', // Bottrop 3.3 + // 'bug2016qphy', // Central Italy 6.1 + // 'bug2016rslt', // CTBT violation North Korea + // 'bug2016ueqo', // Darmstadt 2.4 + // 'bug2016ufpi', // Darmstadt 3.0 + // 'bug2016vico', // Central Italy 6.5 + // 'bug2016vrnc', // Nörvenich 3.2 + // 'bug2016zawb', // St Goar 3.2 + // 'bug2017iyhl', // Hürtgenwald 2.1 + // 'bug2017omwg', // Brühl 2.3 + // 'bug2017rfxe', // CTBT violation North Korea 6.1 + // 'bug2017rjvq', // Dreieich / Hessen 2.6 + // 'bug2017vxmm', // Brühl / Hürth 3.1 + // 'bug2018nyax' // Ochtendung 2.7 + // 'bug2019cxga', // Ochtendung 3.0 + // 'bug2019czbt', // Ochtendung 2.9 + // 'bug2019fura', // Sprengung Duisburg-Hochheide (Weißer Riese) 2.0 + // 'bug2019yeij', // Tektonisch, Hambach 2.2 + 'bug2020fqxf' // Meckenheim, 2.5 ]; diff --git a/www/stations.js b/www/stations.js index fb41de5..00982ea 100644 --- a/www/stations.js +++ b/www/stations.js @@ -23,7 +23,7 @@ */ /* Load the stations using ajax */ -function loadStations(stime, etime) { +function loadStations(station, stime, etime) { var mapBounds = map.getBounds(); var N = mapBounds.getNorth(); var E = mapBounds.getEast(); @@ -37,14 +37,23 @@ function loadStations(stime, etime) { var etime = new Date(); etime.setDate(etime.getDate()+1); }; - var request_data = { - endafter: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), - startbefore: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()), - level: 'channel', - minlat: S-config['map']['latlngDelta'], - maxlat: N+config['map']['latlngDelta'], - minlon: W-config['map']['latlngDelta'], - maxlon: E+config['map']['latlngDelta'], + if ( !station ) { + var request_data = { + endafter: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), + startbefore: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()), + level: 'station', + minlat: S-config['map']['latlngDelta'], + maxlat: N+config['map']['latlngDelta'], + minlon: W-config['map']['latlngDelta'], + maxlon: E+config['map']['latlngDelta'], + }; + } else { + var request_data = { + endafter: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), + startbefore: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()), + level: 'channel', + station: station, + }; }; $.ajax({ type: "GET", @@ -61,13 +70,13 @@ function loadStations(stime, etime) { lng = $(this).find('Longitude:first').text(), stationID = network+'_'+station, stationText = network+'.'+station; - if ( !stationTable[stationID] ) { + if ( !stationTable[stationID] && $.inArray(stationID, config['station']['stationBlacklist']) <0 ) { // general station info (1st line) var row = sprintf('%s%s%7.4f%7.4f' , network, station, Number(lat), Number(lng)); // setting up network details (2nd line) row += sprintf('%s', networkText[network] || ''); row += ( $.inArray(station, bochumStation)+1 ) ? '
Betreiber: Ruhr-Universität Bochum' : '' ; - if ( network == 'RN' || network == 'X5' || $.inArray(station, bochumStation)+1 ) { + if ( network == 'RN' || network == 'Z3' || network == '1A' || network == 'YD' || $.inArray(station, bochumStation)+1 ) { // setting up station details (3rd line) row += ''; row += stationDetails(station, network, lat, lng, stationID, stationText, $(this)); @@ -114,7 +123,16 @@ function loadStations(stime, etime) { } }); // create stations csv download link - request_data['format'] = 'text'; + var request_data = { + endafter: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), + startbefore: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()), + level: 'station', + minlat: S-config['map']['latlngDelta'], + maxlat: N+config['map']['latlngDelta'], + minlon: W-config['map']['latlngDelta'], + maxlon: E+config['map']['latlngDelta'], + format: 'text', + }; $('#stations-csv-link').attr('href', config['ajax']['stationURL']+'?'+$.param(request_data)); }; @@ -205,6 +223,20 @@ function initStationTable() { **********************************************************************/ $(document).ready(function() { loadStations(); + loadStations('A100A'); + loadStations('A101B'); + loadStations('A102A'); + loadStations('A103A'); + loadStations('A103B'); + loadStations('A104A'); + loadStations('A104B'); + loadStations('A105A'); + loadStations('A106B'); + loadStations('A107C'); + loadStations('A108A'); + loadStations('A109A'); + // loadStations('KERA'); + // loadStations('KARP'); // show / hide station info $('#stationstable').delegate('.toggle', 'click' , function(){ // toggle visibility of selected row diff --git a/www/stations.js.en b/www/stations.js.en index 255ec32..c20f615 100644 --- a/www/stations.js.en +++ b/www/stations.js.en @@ -23,7 +23,7 @@ */ /* Load the stations using ajax */ -function loadStations(stime, etime) { +function loadStations(station, stime, etime) { var mapBounds = map.getBounds(); var N = mapBounds.getNorth(); var E = mapBounds.getEast(); @@ -37,14 +37,23 @@ function loadStations(stime, etime) { var etime = new Date(); etime.setDate(etime.getDate()+1); }; - var request_data = { - endafter: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), - startbefore: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()), - level: 'channel', - minlat: S-config['map']['latlngDelta'], - maxlat: N+config['map']['latlngDelta'], - minlon: W-config['map']['latlngDelta'], - maxlon: E+config['map']['latlngDelta'], + if ( !station ) { + var request_data = { + endafter: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), + startbefore: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()), + level: 'station', + minlat: S-config['map']['latlngDelta'], + maxlat: N+config['map']['latlngDelta'], + minlon: W-config['map']['latlngDelta'], + maxlon: E+config['map']['latlngDelta'], + }; + } else { + var request_data = { + endafter: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), + startbefore: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()), + level: 'channel', + station: station, + }; }; $.ajax({ type: "GET", @@ -61,13 +70,13 @@ function loadStations(stime, etime) { lng = $(this).find('Longitude:first').text(), stationID = network+'_'+station, stationText = network+'.'+station; - if ( !stationTable[stationID] ) { + if ( !stationTable[stationID] && $.inArray(stationID, config['station']['stationBlacklist']) <0 ) { // general station info (1st line) var row = sprintf('%s%s%7.4f%7.4f' , network, station, Number(lat), Number(lng)); // setting up network details (2nd line) row += sprintf('%s', networkText[network] || ''); - row += ( $.inArray(station, bochumStation)+1 ) ? '
Operator: Ruhr-University Bochum' : '' ; - if ( network == 'RN' || network == 'X5' || $.inArray(station, bochumStation)+1 ) { + row += ( $.inArray(station, bochumStation)+1 ) ? '
Operator: Ruhr-University Bochum, Germany' : '' ; + if ( network == 'RN' || network == 'Z3' || network == '1A' || network == 'YD' || $.inArray(station, bochumStation)+1 ) { // setting up station details (3rd line) row += ''; row += stationDetails(station, network, lat, lng, stationID, stationText, $(this)); @@ -114,7 +123,16 @@ function loadStations(stime, etime) { } }); // create stations csv download link - request_data['format'] = 'text'; + var request_data = { + endafter: sprintf("%d-%02d-%02d", stime.getFullYear(), stime.getMonth()+1, stime.getDate()), + startbefore: sprintf("%d-%02d-%02d", etime.getFullYear(), etime.getMonth()+1, etime.getDate()), + level: 'station', + minlat: S-config['map']['latlngDelta'], + maxlat: N+config['map']['latlngDelta'], + minlon: W-config['map']['latlngDelta'], + maxlon: E+config['map']['latlngDelta'], + format: 'text', + }; $('#stations-csv-link').attr('href', config['ajax']['stationURL']+'?'+$.param(request_data)); }; @@ -130,7 +148,7 @@ function stationDetails(station, network, lat, lng, stationId, stationText, stat var code = $(this).attr('code'); var sensor = $(this).find('Sensor > Type').text().split(',')[0]; var sampleRate = $(this).find('SampleRate').text(); - output += '
Chanel ' + code + ', Samplingrate ' + sampleRate + ' Hz, Sensor ' + sensor; + output += '
Channel ' + code + ', Samplingrate ' + sampleRate + ' Hz, Sensor ' + sensor; }); output += ''; return output; @@ -205,6 +223,20 @@ function initStationTable() { **********************************************************************/ $(document).ready(function() { loadStations(); + loadStations('A100A'); + loadStations('A101B'); + loadStations('A102A'); + loadStations('A103A'); + loadStations('A103B'); + loadStations('A104A'); + loadStations('A104B'); + loadStations('A105A'); + loadStations('A106B'); + loadStations('A107C'); + loadStations('A108A'); + loadStations('A109A'); + // loadStations('KERA'); + // loadStations('KARP'); // show / hide station info $('#stationstable').delegate('.toggle', 'click' , function(){ // toggle visibility of selected row