From 2492d44c705725b4a450e1f84589040ebee62432 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Wed, 15 Jul 2020 23:15:38 +0200 Subject: [PATCH 01/15] switching to leaflet-providers for cleaner code and more options --- www/external/leaflet-providers.js | 1011 +++++++++++++++++++++++++++++ www/index.html.de | 1 + www/index.html.en | 1 + www/map.js | 38 +- www/map.js.en | 38 +- www/misc.js | 1 + 6 files changed, 1040 insertions(+), 50 deletions(-) create mode 100644 www/external/leaflet-providers.js diff --git a/www/external/leaflet-providers.js b/www/external/leaflet-providers.js new file mode 100644 index 0000000..0966ff9 --- /dev/null +++ b/www/external/leaflet-providers.js @@ -0,0 +1,1011 @@ +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['leaflet'], factory); + } else if (typeof modules === 'object' && module.exports) { + // define a Common JS module that relies on 'leaflet' + module.exports = factory(require('leaflet')); + } else { + // Assume Leaflet is loaded into global object L already + factory(L); + } +}(this, function (L) { + 'use strict'; + + L.TileLayer.Provider = L.TileLayer.extend({ + initialize: function (arg, options) { + var providers = L.TileLayer.Provider.providers; + + var parts = arg.split('.'); + + var providerName = parts[0]; + var variantName = parts[1]; + + if (!providers[providerName]) { + throw 'No such provider (' + providerName + ')'; + } + + var provider = { + url: providers[providerName].url, + options: providers[providerName].options + }; + + // overwrite values in provider from variant. + if (variantName && 'variants' in providers[providerName]) { + if (!(variantName in providers[providerName].variants)) { + throw 'No such variant of ' + providerName + ' (' + variantName + ')'; + } + var variant = providers[providerName].variants[variantName]; + var variantOptions; + if (typeof variant === 'string') { + variantOptions = { + variant: variant + }; + } else { + variantOptions = variant.options; + } + provider = { + url: variant.url || provider.url, + options: L.Util.extend({}, provider.options, variantOptions) + }; + } + + // replace attribution placeholders with their values from toplevel provider attribution, + // recursively + var attributionReplacer = function (attr) { + if (attr.indexOf('{attribution.') === -1) { + return attr; + } + return attr.replace(/\{attribution.(\w*)\}/g, + function (match, attributionName) { + return attributionReplacer(providers[attributionName].options.attribution); + } + ); + }; + provider.options.attribution = attributionReplacer(provider.options.attribution); + + // Compute final options combining provider options with any user overrides + var layerOpts = L.Util.extend({}, provider.options, options); + L.TileLayer.prototype.initialize.call(this, provider.url, layerOpts); + } + }); + + /** + * Definition of providers. + * see http://leafletjs.com/reference.html#tilelayer for options in the options map. + */ + + L.TileLayer.Provider.providers = { + OpenStreetMap: { + url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + options: { + maxZoom: 19, + attribution: + '© OpenStreetMap contributors' + }, + variants: { + Mapnik: {}, + DE: { + url: 'https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', + options: { + maxZoom: 18 + } + }, + CH: { + url: 'https://tile.osm.ch/switzerland/{z}/{x}/{y}.png', + options: { + maxZoom: 18, + bounds: [[45, 5], [48, 11]] + } + }, + France: { + url: 'https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png', + options: { + maxZoom: 20, + attribution: '© Openstreetmap France | {attribution.OpenStreetMap}' + } + }, + HOT: { + url: 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', + options: { + attribution: + '{attribution.OpenStreetMap}, ' + + 'Tiles style by Humanitarian OpenStreetMap Team ' + + 'hosted by OpenStreetMap France' + } + }, + BZH: { + url: 'https://tile.openstreetmap.bzh/br/{z}/{x}/{y}.png', + options: { + attribution: '{attribution.OpenStreetMap}, Tiles courtesy of Breton OpenStreetMap Team', + bounds: [[46.2, -5.5], [50, 0.7]] + } + } + } + }, + OpenSeaMap: { + url: 'https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', + options: { + attribution: 'Map data: © OpenSeaMap contributors' + } + }, + OpenPtMap: { + url: 'http://openptmap.org/tiles/{z}/{x}/{y}.png', + options: { + maxZoom: 17, + attribution: 'Map data: © OpenPtMap contributors' + } + }, + OpenTopoMap: { + url: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', + options: { + maxZoom: 17, + attribution: 'Map data: {attribution.OpenStreetMap}, SRTM | Map style: © OpenTopoMap (CC-BY-SA)' + } + }, + OpenRailwayMap: { + url: 'https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png', + options: { + maxZoom: 19, + attribution: 'Map data: {attribution.OpenStreetMap} | Map style: © OpenRailwayMap (CC-BY-SA)' + } + }, + OpenFireMap: { + url: 'http://openfiremap.org/hytiles/{z}/{x}/{y}.png', + options: { + maxZoom: 19, + attribution: 'Map data: {attribution.OpenStreetMap} | Map style: © OpenFireMap (CC-BY-SA)' + } + }, + SafeCast: { + url: 'https://s3.amazonaws.com/te512.safecast.org/{z}/{x}/{y}.png', + options: { + maxZoom: 16, + attribution: 'Map data: {attribution.OpenStreetMap} | Map style: © SafeCast (CC-BY-SA)' + } + }, + Stadia: { + url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}{r}.png', + options: { + maxZoom: 20, + attribution: '© Stadia Maps, © OpenMapTiles © OpenStreetMap contributors' + }, + variants: { + AlidadeSmooth: { + url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}{r}.png' + }, + AlidadeSmoothDark: { + url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth_dark/{z}/{x}/{y}{r}.png' + }, + OSMBright: { + url: 'https://tiles.stadiamaps.com/tiles/osm_bright/{z}/{x}/{y}{r}.png' + }, + Outdoors: { + url: 'https://tiles.stadiamaps.com/tiles/outdoors/{z}/{x}/{y}{r}.png' + } + } + }, + Thunderforest: { + url: 'https://{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png?apikey={apikey}', + options: { + attribution: + '© Thunderforest, {attribution.OpenStreetMap}', + variant: 'cycle', + apikey: '', + maxZoom: 22 + }, + variants: { + OpenCycleMap: 'cycle', + Transport: { + options: { + variant: 'transport' + } + }, + TransportDark: { + options: { + variant: 'transport-dark' + } + }, + SpinalMap: { + options: { + variant: 'spinal-map' + } + }, + Landscape: 'landscape', + Outdoors: 'outdoors', + Pioneer: 'pioneer', + MobileAtlas: 'mobile-atlas', + Neighbourhood: 'neighbourhood' + } + }, + CyclOSM: { + url: 'https://dev.{s}.tile.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png', + options: { + maxZoom: 20, + attribution: 'CyclOSM | Map data: {attribution.OpenStreetMap}' + } + }, + Hydda: { + url: 'https://{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png', + options: { + maxZoom: 20, + variant: 'full', + attribution: 'Tiles courtesy of OpenStreetMap Sweden — Map data {attribution.OpenStreetMap}' + }, + variants: { + Full: 'full', + Base: 'base', + RoadsAndLabels: 'roads_and_labels' + } + }, + Jawg: { + url: 'https://{s}.tile.jawg.io/{variant}/{z}/{x}/{y}{r}.png?access-token={accessToken}', + options: { + attribution: + '© JawgMaps ' + + '{attribution.OpenStreetMap}', + minZoom: 0, + maxZoom: 22, + subdomains: 'abcd', + variant: 'jawg-terrain', + // Get your own Jawg access token here : https://www.jawg.io/lab/ + // NB : this is a demonstration key that comes with no guarantee + accessToken: '', + }, + variants: { + Streets: 'jawg-streets', + Terrain: 'jawg-terrain', + Sunny: 'jawg-sunny', + Dark: 'jawg-dark', + Light: 'jawg-light', + Matrix: 'jawg-matrix' + } + }, + MapBox: { + url: 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}{r}?access_token={accessToken}', + options: { + attribution: + '© Mapbox ' + + '{attribution.OpenStreetMap} ' + + 'Improve this map', + tileSize: 512, + maxZoom: 18, + zoomOffset: -1, + id: 'mapbox/streets-v11', + accessToken: '', + } + }, + MapTiler: { + url: 'https://api.maptiler.com/maps/{variant}/{z}/{x}/{y}{r}.{ext}?key={key}', + options: { + attribution: + '© MapTiler © OpenStreetMap contributors', + variant: 'streets', + ext: 'png', + key: '', + tileSize: 512, + zoomOffset: -1, + minZoom: 0, + maxZoom: 21 + }, + variants: { + Streets: 'streets', + Basic: 'basic', + Bright: 'bright', + Pastel: 'pastel', + Positron: 'positron', + Hybrid: { + options: { + variant: 'hybrid', + ext: 'jpg' + } + }, + Toner: 'toner', + Topo: 'topo', + Voyager: 'voyager' + } + }, + Stamen: { + url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}{r}.{ext}', + options: { + attribution: + 'Map tiles by Stamen Design, ' + + 'CC BY 3.0 — ' + + 'Map data {attribution.OpenStreetMap}', + subdomains: 'abcd', + minZoom: 0, + maxZoom: 20, + variant: 'toner', + ext: 'png' + }, + variants: { + Toner: 'toner', + TonerBackground: 'toner-background', + TonerHybrid: 'toner-hybrid', + TonerLines: 'toner-lines', + TonerLabels: 'toner-labels', + TonerLite: 'toner-lite', + Watercolor: { + url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}', + options: { + variant: 'watercolor', + ext: 'jpg', + minZoom: 1, + maxZoom: 16 + } + }, + Terrain: { + options: { + variant: 'terrain', + minZoom: 0, + maxZoom: 18 + } + }, + TerrainBackground: { + options: { + variant: 'terrain-background', + minZoom: 0, + maxZoom: 18 + } + }, + TerrainLabels: { + options: { + variant: 'terrain-labels', + minZoom: 0, + maxZoom: 18 + } + }, + TopOSMRelief: { + url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}', + options: { + variant: 'toposm-color-relief', + ext: 'jpg', + bounds: [[22, -132], [51, -56]] + } + }, + TopOSMFeatures: { + options: { + variant: 'toposm-features', + bounds: [[22, -132], [51, -56]], + opacity: 0.9 + } + } + } + }, + TomTom: { + url: 'https://{s}.api.tomtom.com/map/1/tile/{variant}/{style}/{z}/{x}/{y}.{ext}?key={apikey}', + options: { + variant: 'basic', + maxZoom: 22, + attribution: + '© 1992 - ' + new Date().getFullYear() + ' TomTom. ', + subdomains: 'abcd', + style: 'main', + ext: 'png', + apikey: '', + }, + variants: { + Basic: 'basic', + Hybrid: 'hybrid', + Labels: 'labels' + } + }, + Esri: { + url: 'https://server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}', + options: { + variant: 'World_Street_Map', + attribution: 'Tiles © Esri' + }, + variants: { + WorldStreetMap: { + options: { + attribution: + '{attribution.Esri} — ' + + 'Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012' + } + }, + DeLorme: { + options: { + variant: 'Specialty/DeLorme_World_Base_Map', + minZoom: 1, + maxZoom: 11, + attribution: '{attribution.Esri} — Copyright: ©2012 DeLorme' + } + }, + WorldTopoMap: { + options: { + variant: 'World_Topo_Map', + attribution: + '{attribution.Esri} — ' + + 'Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community' + } + }, + WorldImagery: { + options: { + variant: 'World_Imagery', + attribution: + '{attribution.Esri} — ' + + 'Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community' + } + }, + WorldTerrain: { + options: { + variant: 'World_Terrain_Base', + maxZoom: 13, + attribution: + '{attribution.Esri} — ' + + 'Source: USGS, Esri, TANA, DeLorme, and NPS' + } + }, + WorldShadedRelief: { + options: { + variant: 'World_Shaded_Relief', + maxZoom: 13, + attribution: '{attribution.Esri} — Source: Esri' + } + }, + WorldPhysical: { + options: { + variant: 'World_Physical_Map', + maxZoom: 8, + attribution: '{attribution.Esri} — Source: US National Park Service' + } + }, + OceanBasemap: { + options: { + variant: 'Ocean_Basemap', + maxZoom: 13, + attribution: '{attribution.Esri} — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri' + } + }, + NatGeoWorldMap: { + options: { + variant: 'NatGeo_World_Map', + maxZoom: 16, + attribution: '{attribution.Esri} — National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC' + } + }, + WorldGrayCanvas: { + options: { + variant: 'Canvas/World_Light_Gray_Base', + maxZoom: 16, + attribution: '{attribution.Esri} — Esri, DeLorme, NAVTEQ' + } + } + } + }, + OpenWeatherMap: { + url: 'http://{s}.tile.openweathermap.org/map/{variant}/{z}/{x}/{y}.png?appid={apiKey}', + options: { + maxZoom: 19, + attribution: 'Map data © OpenWeatherMap', + apiKey:'', + opacity: 0.5 + }, + variants: { + Clouds: 'clouds', + CloudsClassic: 'clouds_cls', + Precipitation: 'precipitation', + PrecipitationClassic: 'precipitation_cls', + Rain: 'rain', + RainClassic: 'rain_cls', + Pressure: 'pressure', + PressureContour: 'pressure_cntr', + Wind: 'wind', + Temperature: 'temp', + Snow: 'snow' + } + }, + HERE: { + /* + * HERE maps, formerly Nokia maps. + * These basemaps are free, but you need an api id and app key. Please sign up at + * https://developer.here.com/plans + */ + url: + 'https://{s}.{base}.maps.api.here.com/maptile/2.1/' + + '{type}/{mapID}/{variant}/{z}/{x}/{y}/{size}/{format}?' + + 'app_id={app_id}&app_code={app_code}&lg={language}', + options: { + attribution: + 'Map © 1987-' + new Date().getFullYear() + ' HERE', + subdomains: '1234', + mapID: 'newest', + 'app_id': '', + 'app_code': '', + base: 'base', + variant: 'normal.day', + maxZoom: 20, + type: 'maptile', + language: 'eng', + format: 'png8', + size: '256' + }, + variants: { + normalDay: 'normal.day', + normalDayCustom: 'normal.day.custom', + normalDayGrey: 'normal.day.grey', + normalDayMobile: 'normal.day.mobile', + normalDayGreyMobile: 'normal.day.grey.mobile', + normalDayTransit: 'normal.day.transit', + normalDayTransitMobile: 'normal.day.transit.mobile', + normalDayTraffic: { + options: { + variant: 'normal.traffic.day', + base: 'traffic', + type: 'traffictile' + } + }, + normalNight: 'normal.night', + normalNightMobile: 'normal.night.mobile', + normalNightGrey: 'normal.night.grey', + normalNightGreyMobile: 'normal.night.grey.mobile', + normalNightTransit: 'normal.night.transit', + normalNightTransitMobile: 'normal.night.transit.mobile', + reducedDay: 'reduced.day', + reducedNight: 'reduced.night', + basicMap: { + options: { + type: 'basetile' + } + }, + mapLabels: { + options: { + type: 'labeltile', + format: 'png' + } + }, + trafficFlow: { + options: { + base: 'traffic', + type: 'flowtile' + } + }, + carnavDayGrey: 'carnav.day.grey', + hybridDay: { + options: { + base: 'aerial', + variant: 'hybrid.day' + } + }, + hybridDayMobile: { + options: { + base: 'aerial', + variant: 'hybrid.day.mobile' + } + }, + hybridDayTransit: { + options: { + base: 'aerial', + variant: 'hybrid.day.transit' + } + }, + hybridDayGrey: { + options: { + base: 'aerial', + variant: 'hybrid.grey.day' + } + }, + hybridDayTraffic: { + options: { + variant: 'hybrid.traffic.day', + base: 'traffic', + type: 'traffictile' + } + }, + pedestrianDay: 'pedestrian.day', + pedestrianNight: 'pedestrian.night', + satelliteDay: { + options: { + base: 'aerial', + variant: 'satellite.day' + } + }, + terrainDay: { + options: { + base: 'aerial', + variant: 'terrain.day' + } + }, + terrainDayMobile: { + options: { + base: 'aerial', + variant: 'terrain.day.mobile' + } + } + } + }, + HEREv3: { + /* + * HERE maps API Version 3. + * These basemaps are free, but you need an API key. Please sign up at + * https://developer.here.com/plans + * Version 3 deprecates the app_id and app_code access in favor of apiKey + * + * Supported access methods as of 2019/12/21: + * @see https://developer.here.com/faqs#access-control-1--how-do-you-control-access-to-here-location-services + */ + url: + 'https://{s}.{base}.maps.ls.hereapi.com/maptile/2.1/' + + '{type}/{mapID}/{variant}/{z}/{x}/{y}/{size}/{format}?' + + 'apiKey={apiKey}&lg={language}', + options: { + attribution: + 'Map © 1987-' + new Date().getFullYear() + ' HERE', + subdomains: '1234', + mapID: 'newest', + apiKey: '', + base: 'base', + variant: 'normal.day', + maxZoom: 20, + type: 'maptile', + language: 'eng', + format: 'png8', + size: '256' + }, + variants: { + normalDay: 'normal.day', + normalDayCustom: 'normal.day.custom', + normalDayGrey: 'normal.day.grey', + normalDayMobile: 'normal.day.mobile', + normalDayGreyMobile: 'normal.day.grey.mobile', + normalDayTransit: 'normal.day.transit', + normalDayTransitMobile: 'normal.day.transit.mobile', + normalNight: 'normal.night', + normalNightMobile: 'normal.night.mobile', + normalNightGrey: 'normal.night.grey', + normalNightGreyMobile: 'normal.night.grey.mobile', + normalNightTransit: 'normal.night.transit', + normalNightTransitMobile: 'normal.night.transit.mobile', + reducedDay: 'reduced.day', + reducedNight: 'reduced.night', + basicMap: { + options: { + type: 'basetile' + } + }, + mapLabels: { + options: { + type: 'labeltile', + format: 'png' + } + }, + trafficFlow: { + options: { + base: 'traffic', + type: 'flowtile' + } + }, + carnavDayGrey: 'carnav.day.grey', + hybridDay: { + options: { + base: 'aerial', + variant: 'hybrid.day' + } + }, + hybridDayMobile: { + options: { + base: 'aerial', + variant: 'hybrid.day.mobile' + } + }, + hybridDayTransit: { + options: { + base: 'aerial', + variant: 'hybrid.day.transit' + } + }, + hybridDayGrey: { + options: { + base: 'aerial', + variant: 'hybrid.grey.day' + } + }, + pedestrianDay: 'pedestrian.day', + pedestrianNight: 'pedestrian.night', + satelliteDay: { + options: { + base: 'aerial', + variant: 'satellite.day' + } + }, + terrainDay: { + options: { + base: 'aerial', + variant: 'terrain.day' + } + }, + terrainDayMobile: { + options: { + base: 'aerial', + variant: 'terrain.day.mobile' + } + } + } + }, + FreeMapSK: { + url: 'https://{s}.freemap.sk/T/{z}/{x}/{y}.jpeg', + options: { + minZoom: 8, + maxZoom: 16, + subdomains: 'abcd', + bounds: [[47.204642, 15.996093], [49.830896, 22.576904]], + attribution: + '{attribution.OpenStreetMap}, vizualization CC-By-SA 2.0 Freemap.sk' + } + }, + MtbMap: { + url: 'http://tile.mtbmap.cz/mtbmap_tiles/{z}/{x}/{y}.png', + options: { + attribution: + '{attribution.OpenStreetMap} & USGS' + } + }, + CartoDB: { + url: 'https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png', + options: { + attribution: '{attribution.OpenStreetMap} © CARTO', + subdomains: 'abcd', + maxZoom: 19, + variant: 'light_all' + }, + variants: { + Positron: 'light_all', + PositronNoLabels: 'light_nolabels', + PositronOnlyLabels: 'light_only_labels', + DarkMatter: 'dark_all', + DarkMatterNoLabels: 'dark_nolabels', + DarkMatterOnlyLabels: 'dark_only_labels', + Voyager: 'rastertiles/voyager', + VoyagerNoLabels: 'rastertiles/voyager_nolabels', + VoyagerOnlyLabels: 'rastertiles/voyager_only_labels', + VoyagerLabelsUnder: 'rastertiles/voyager_labels_under' + } + }, + HikeBike: { + url: 'https://tiles.wmflabs.org/{variant}/{z}/{x}/{y}.png', + options: { + maxZoom: 19, + attribution: '{attribution.OpenStreetMap}', + variant: 'hikebike' + }, + variants: { + HikeBike: {}, + HillShading: { + options: { + maxZoom: 15, + variant: 'hillshading' + } + } + } + }, + BasemapAT: { + url: 'https://maps{s}.wien.gv.at/basemap/{variant}/{type}/google3857/{z}/{y}/{x}.{format}', + options: { + maxZoom: 19, + attribution: 'Datenquelle: basemap.at', + subdomains: ['', '1', '2', '3', '4'], + type: 'normal', + format: 'png', + bounds: [[46.358770, 8.782379], [49.037872, 17.189532]], + variant: 'geolandbasemap' + }, + variants: { + basemap: { + options: { + maxZoom: 20, // currently only in Vienna + variant: 'geolandbasemap' + } + }, + grau: 'bmapgrau', + overlay: 'bmapoverlay', + terrain: { + options: { + variant: 'bmapgelaende', + type: 'grau', + format: 'jpeg' + } + }, + surface: { + options: { + variant: 'bmapoberflaeche', + type: 'grau', + format: 'jpeg' + } + }, + highdpi: { + options: { + variant: 'bmaphidpi', + format: 'jpeg' + } + }, + orthofoto: { + options: { + maxZoom: 20, // currently only in Vienna + variant: 'bmaporthofoto30cm', + format: 'jpeg' + } + } + } + }, + nlmaps: { + url: 'https://geodata.nationaalgeoregister.nl/tiles/service/wmts/{variant}/EPSG:3857/{z}/{x}/{y}.png', + options: { + minZoom: 6, + maxZoom: 19, + bounds: [[50.5, 3.25], [54, 7.6]], + attribution: 'Kaartgegevens © Kadaster' + }, + variants: { + 'standaard': 'brtachtergrondkaart', + 'pastel': 'brtachtergrondkaartpastel', + 'grijs': 'brtachtergrondkaartgrijs', + 'luchtfoto': { + 'url': 'https://geodata.nationaalgeoregister.nl/luchtfoto/rgb/wmts/2018_ortho25/EPSG:3857/{z}/{x}/{y}.png', + } + } + }, + NASAGIBS: { + url: 'https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}', + options: { + attribution: + 'Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System ' + + '(ESDIS) with funding provided by NASA/HQ.', + bounds: [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]], + minZoom: 1, + maxZoom: 9, + format: 'jpg', + time: '', + tilematrixset: 'GoogleMapsCompatible_Level' + }, + variants: { + ModisTerraTrueColorCR: 'MODIS_Terra_CorrectedReflectance_TrueColor', + ModisTerraBands367CR: 'MODIS_Terra_CorrectedReflectance_Bands367', + ViirsEarthAtNight2012: { + options: { + variant: 'VIIRS_CityLights_2012', + maxZoom: 8 + } + }, + ModisTerraLSTDay: { + options: { + variant: 'MODIS_Terra_Land_Surface_Temp_Day', + format: 'png', + maxZoom: 7, + opacity: 0.75 + } + }, + ModisTerraSnowCover: { + options: { + variant: 'MODIS_Terra_Snow_Cover', + format: 'png', + maxZoom: 8, + opacity: 0.75 + } + }, + ModisTerraAOD: { + options: { + variant: 'MODIS_Terra_Aerosol', + format: 'png', + maxZoom: 6, + opacity: 0.75 + } + }, + ModisTerraChlorophyll: { + options: { + variant: 'MODIS_Terra_Chlorophyll_A', + format: 'png', + maxZoom: 7, + opacity: 0.75 + } + } + } + }, + NLS: { + // NLS maps are copyright National library of Scotland. + // http://maps.nls.uk/projects/api/index.html + // Please contact NLS for anything other than non-commercial low volume usage + // + // Map sources: Ordnance Survey 1:1m to 1:63K, 1920s-1940s + // z0-9 - 1:1m + // z10-11 - quarter inch (1:253440) + // z12-18 - one inch (1:63360) + url: 'https://nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg', + options: { + attribution: 'National Library of Scotland Historic Maps', + bounds: [[49.6, -12], [61.7, 3]], + minZoom: 1, + maxZoom: 18, + subdomains: '0123', + } + }, + JusticeMap: { + // Justice Map (http://www.justicemap.org/) + // Visualize race and income data for your community, county and country. + // Includes tools for data journalists, bloggers and community activists. + url: 'http://www.justicemap.org/tile/{size}/{variant}/{z}/{x}/{y}.png', + options: { + attribution: 'Justice Map', + // one of 'county', 'tract', 'block' + size: 'county', + // Bounds for USA, including Alaska and Hawaii + bounds: [[14, -180], [72, -56]] + }, + variants: { + income: 'income', + americanIndian: 'indian', + asian: 'asian', + black: 'black', + hispanic: 'hispanic', + multi: 'multi', + nonWhite: 'nonwhite', + white: 'white', + plurality: 'plural' + } + }, + Wikimedia: { + url: 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}{r}.png', + options: { + attribution: 'Wikimedia', + minZoom: 1, + maxZoom: 19 + } + }, + GeoportailFrance: { + url: 'https://wxs.ign.fr/{apikey}/geoportail/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE={style}&TILEMATRIXSET=PM&FORMAT={format}&LAYER={variant}&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}', + options: { + attribution: 'Geoportail France', + bounds: [[-75, -180], [81, 180]], + minZoom: 2, + maxZoom: 18, + // Get your own geoportail apikey here : http://professionnels.ign.fr/ign/contrats/ + // NB : 'choisirgeoportail' is a demonstration key that comes with no guarantee + apikey: 'choisirgeoportail', + format: 'image/jpeg', + style : 'normal', + variant: 'GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN-EXPRESS.STANDARD' + }, + variants: { + parcels: { + options : { + variant: 'CADASTRALPARCELS.PARCELS', + maxZoom: 20, + style : 'bdparcellaire', + format: 'image/png' + } + }, + ignMaps: 'GEOGRAPHICALGRIDSYSTEMS.MAPS', + maps: 'GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN-EXPRESS.STANDARD', + orthos: { + options: { + maxZoom: 19, + variant: 'ORTHOIMAGERY.ORTHOPHOTOS' + } + } + } + }, + OneMapSG: { + url: 'https://maps-{s}.onemap.sg/v3/{variant}/{z}/{x}/{y}.png', + options: { + variant: 'Default', + minZoom: 11, + maxZoom: 18, + bounds: [[1.56073, 104.11475], [1.16, 103.502]], + attribution: ' New OneMap | Map data © contributors, Singapore Land Authority' + }, + variants: { + Default: 'Default', + Night: 'Night', + Original: 'Original', + Grey: 'Grey', + LandLot: 'LandLot' + } + } + }; + + L.tileLayer.provider = function (provider, options) { + return new L.TileLayer.Provider(provider, options); + }; + + return L; +})); diff --git a/www/index.html.de b/www/index.html.de index bf2da40..b433605 100755 --- a/www/index.html.de +++ b/www/index.html.de @@ -35,6 +35,7 @@ + diff --git a/www/index.html.en b/www/index.html.en index e84bc27..7ea1596 100755 --- a/www/index.html.en +++ b/www/index.html.en @@ -35,6 +35,7 @@ + diff --git a/www/map.js b/www/map.js index 076e8e4..cce968e 100644 --- a/www/map.js +++ b/www/map.js @@ -140,39 +140,27 @@ 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']); // create baselayer switch ( config['map']['baselayer'] ) { 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', - maxZoom: 16 - }).addTo(map); + L.tileLayer.provider('Esri.WorldGrayCanvas').addTo(map); break; case 'aerial': // add ESRI WordImagery tile layer - 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); + L.tileLayer.provider('Esri.WorldImagery').addTo(map); + break; + case 'opentopo': // add OpenTopoMap tile layer + L.tileLayer.provider('OpenTopoMap').addTo(map); break; - case 'opentopo': // add OpenTopoMap tile layer https://opentopomap.org/ - map = L.map('map', { zoomControl: false, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); - L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', - { - attribution: 'Kartendaten: © OpenStreetMap contributors, SRTM | Kartendarstellung: © OpenTopoMap (CC-BY-SA)' - }).addTo(map); - break; case 'osmde': // add OpenStreetMap.DE tile layer, default - null; - default: - 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', - }).addTo(map); + L.tileLayer.provider('OpenStreetMap.DE').addTo(map); + break; + case 'mapnik': // add OpenStreetMap.Mapni tile layer + L.tileLayer.provider('OpenStreetMap.Mapnik').addTo(map); + break; + default: // use OpenStreetMap.DE as default + L.tileLayer.provider(config['map']['baselayer']).addTo(map); }; // add controls diff --git a/www/map.js.en b/www/map.js.en index 0b008e2..d63d3a5 100644 --- a/www/map.js.en +++ b/www/map.js.en @@ -140,39 +140,27 @@ 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']); // create baselayer switch ( config['map']['baselayer'] ) { 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', - maxZoom: 16 - }).addTo(map); + L.tileLayer.provider('Esri.WorldGrayCanvas').addTo(map); break; case 'aerial': // add ESRI WordImagery tile layer - 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); + L.tileLayer.provider('Esri.WorldImagery').addTo(map); + break; + case 'opentopo': // add OpenTopoMap tile layer + L.tileLayer.provider('OpenTopoMap').addTo(map); break; - case 'opentopo': // add OpenTopoMap tile layer https://opentopomap.org/ - map = L.map('map', { zoomControl: false, worldCopyJump: true }).setView(config['map']['centerDefault'], config['map']['zoomDefault']); - L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', - { - attribution: 'Kartendaten: © OpenStreetMap contributors, SRTM | Kartendarstellung: © OpenTopoMap (CC-BY-SA)' - }).addTo(map); - break; case 'osmde': // add OpenStreetMap.DE tile layer, default - null; - default: - 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', - }).addTo(map); + L.tileLayer.provider('OpenStreetMap.DE').addTo(map); + break; + case 'mapnik': // add OpenStreetMap.Mapni tile layer + L.tileLayer.provider('OpenStreetMap.Mapnik').addTo(map); + break; + default: // use OpenStreetMap.DE as default + L.tileLayer.provider(config['map']['baselayer']).addTo(map); }; // add controls diff --git a/www/misc.js b/www/misc.js index 420f1fd..77da9dc 100644 --- a/www/misc.js +++ b/www/misc.js @@ -113,6 +113,7 @@ var config = { centerDefault: [51.85, 7.0], timespan: 180, latlngDelta: 0.1, + baselayer: 'OpenStreetMap.DE', }, station: { markerColor: 'darkgreen', From 26adc3432260330e5971a7d729e8f2186f32cbac Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Wed, 15 Jul 2020 23:34:19 +0200 Subject: [PATCH 02/15] remove TileLayer.Grayscale.js --- www/external/TileLayer.Grayscale.js | 56 ----------------------------- www/index.html.de | 1 - www/index.html.en | 1 - 3 files changed, 58 deletions(-) delete mode 100644 www/external/TileLayer.Grayscale.js diff --git a/www/external/TileLayer.Grayscale.js b/www/external/TileLayer.Grayscale.js deleted file mode 100644 index 1dae67c..0000000 --- a/www/external/TileLayer.Grayscale.js +++ /dev/null @@ -1,56 +0,0 @@ -/* - * L.TileLayer.Grayscale is a regular tilelayer with grayscale makeover. - */ - -L.TileLayer.Grayscale = L.TileLayer.extend({ - options: { - quotaRed: 21, - quotaGreen: 71, - quotaBlue: 8, - quotaDividerTune: 0, - quotaDivider: function() { - return this.quotaRed + this.quotaGreen + this.quotaBlue + this.quotaDividerTune; - } - }, - - initialize: function (url, options) { - options = options || {} - options.crossOrigin = true; - L.TileLayer.prototype.initialize.call(this, url, options); - - this.on('tileload', function(e) { - this._makeGrayscale(e.tile); - }); - }, - - _createTile: function () { - var tile = L.TileLayer.prototype._createTile.call(this); - tile.crossOrigin = "Anonymous"; - return tile; - }, - - _makeGrayscale: function (img) { - if (img.getAttribute('data-grayscaled')) - return; - - img.crossOrigin = ''; - var canvas = document.createElement("canvas"); - canvas.width = img.width; - canvas.height = img.height; - var ctx = canvas.getContext("2d"); - ctx.drawImage(img, 0, 0); - - var imgd = ctx.getImageData(0, 0, canvas.width, canvas.height); - var pix = imgd.data; - for (var i = 0, n = pix.length; i < n; i += 4) { - pix[i] = pix[i + 1] = pix[i + 2] = (this.options.quotaRed * pix[i] + this.options.quotaGreen * pix[i + 1] + this.options.quotaBlue * pix[i + 2]) / this.options.quotaDivider(); - } - ctx.putImageData(imgd, 0, 0); - img.setAttribute('data-grayscaled', true); - img.src = canvas.toDataURL(); - } -}); - -L.tileLayer.grayscale = function (url, options) { - return new L.TileLayer.Grayscale(url, options); -}; diff --git a/www/index.html.de b/www/index.html.de index b433605..eb7c421 100755 --- a/www/index.html.de +++ b/www/index.html.de @@ -33,7 +33,6 @@ - diff --git a/www/index.html.en b/www/index.html.en index 7ea1596..a426b51 100755 --- a/www/index.html.en +++ b/www/index.html.en @@ -33,7 +33,6 @@ - From 9bc8c1dc21aaaa336ac227bddd1e679cba265b05 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Thu, 16 Jul 2020 11:20:52 +0200 Subject: [PATCH 03/15] fix easyPrint icon, printing still broken print broken due to browser security violation (see https://github.com/rowanwins/leaflet-easyPrint/issues/82) --- www/external/easyPrint/easyPrint.css | 20 ++++++++------------ www/index.html.de | 1 - www/index.html.en | 1 - www/map.js | 6 +++++- www/map.js.en | 6 +++++- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/www/external/easyPrint/easyPrint.css b/www/external/easyPrint/easyPrint.css index 177e148..65523ea 100644 --- a/www/external/easyPrint/easyPrint.css +++ b/www/external/easyPrint/easyPrint.css @@ -1,20 +1,16 @@ -.leaflet-control-easyPrint a { - background:#fff url(print.png) no-repeat 5px; +.leaflet-control-easyPrint-button a { + background:#fff url(external/easyPrint/print.png) no-repeat 5px; background-size:16px 16px; display: block; - } - - - -@media print { - - html {padding: 0px!important;} - .leaflet-control-easyPrint-button{display: none!important;} - } -#map { +//@media print { + html {padding: 0px!important;} + .leaflet-control-easyPrint-button{display: none!important;} +} + +//#map { width: 1200; height: 800; } diff --git a/www/index.html.de b/www/index.html.de index eb7c421..87e3826 100755 --- a/www/index.html.de +++ b/www/index.html.de @@ -13,7 +13,6 @@ - diff --git a/www/index.html.en b/www/index.html.en index a426b51..449bc3a 100755 --- a/www/index.html.en +++ b/www/index.html.en @@ -13,7 +13,6 @@ - diff --git a/www/map.js b/www/map.js index cce968e..285edfa 100644 --- a/www/map.js +++ b/www/map.js @@ -206,5 +206,9 @@ $(document).ready(function() { }); // print icon - L.easyPrint().addTo(map); + L.easyPrint({ + title: 'print map', + position: 'topright', + sizeModes: ['Current', 'A4Portrait', 'A4Landscape'], + }).addTo(map); }); diff --git a/www/map.js.en b/www/map.js.en index d63d3a5..95dc862 100644 --- a/www/map.js.en +++ b/www/map.js.en @@ -206,5 +206,9 @@ $(document).ready(function() { }); // print icon - L.easyPrint().addTo(map); + L.easyPrint({ + title: 'print map', + position: 'topright', + sizeModes: ['Current', 'A4Portrait', 'A4Landscape'], + }).addTo(map); }); From 25a028b5a7148dc3c65ad99e795a0f3dfde91096 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Thu, 16 Jul 2020 13:09:11 +0200 Subject: [PATCH 04/15] using cdn for leaflet-provider.js plugin --- www/external/leaflet-providers.js | 1011 ----------------------------- www/index.html.de | 2 +- www/index.html.en | 2 +- 3 files changed, 2 insertions(+), 1013 deletions(-) delete mode 100644 www/external/leaflet-providers.js diff --git a/www/external/leaflet-providers.js b/www/external/leaflet-providers.js deleted file mode 100644 index 0966ff9..0000000 --- a/www/external/leaflet-providers.js +++ /dev/null @@ -1,1011 +0,0 @@ -(function (root, factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define(['leaflet'], factory); - } else if (typeof modules === 'object' && module.exports) { - // define a Common JS module that relies on 'leaflet' - module.exports = factory(require('leaflet')); - } else { - // Assume Leaflet is loaded into global object L already - factory(L); - } -}(this, function (L) { - 'use strict'; - - L.TileLayer.Provider = L.TileLayer.extend({ - initialize: function (arg, options) { - var providers = L.TileLayer.Provider.providers; - - var parts = arg.split('.'); - - var providerName = parts[0]; - var variantName = parts[1]; - - if (!providers[providerName]) { - throw 'No such provider (' + providerName + ')'; - } - - var provider = { - url: providers[providerName].url, - options: providers[providerName].options - }; - - // overwrite values in provider from variant. - if (variantName && 'variants' in providers[providerName]) { - if (!(variantName in providers[providerName].variants)) { - throw 'No such variant of ' + providerName + ' (' + variantName + ')'; - } - var variant = providers[providerName].variants[variantName]; - var variantOptions; - if (typeof variant === 'string') { - variantOptions = { - variant: variant - }; - } else { - variantOptions = variant.options; - } - provider = { - url: variant.url || provider.url, - options: L.Util.extend({}, provider.options, variantOptions) - }; - } - - // replace attribution placeholders with their values from toplevel provider attribution, - // recursively - var attributionReplacer = function (attr) { - if (attr.indexOf('{attribution.') === -1) { - return attr; - } - return attr.replace(/\{attribution.(\w*)\}/g, - function (match, attributionName) { - return attributionReplacer(providers[attributionName].options.attribution); - } - ); - }; - provider.options.attribution = attributionReplacer(provider.options.attribution); - - // Compute final options combining provider options with any user overrides - var layerOpts = L.Util.extend({}, provider.options, options); - L.TileLayer.prototype.initialize.call(this, provider.url, layerOpts); - } - }); - - /** - * Definition of providers. - * see http://leafletjs.com/reference.html#tilelayer for options in the options map. - */ - - L.TileLayer.Provider.providers = { - OpenStreetMap: { - url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - options: { - maxZoom: 19, - attribution: - '© OpenStreetMap contributors' - }, - variants: { - Mapnik: {}, - DE: { - url: 'https://{s}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png', - options: { - maxZoom: 18 - } - }, - CH: { - url: 'https://tile.osm.ch/switzerland/{z}/{x}/{y}.png', - options: { - maxZoom: 18, - bounds: [[45, 5], [48, 11]] - } - }, - France: { - url: 'https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png', - options: { - maxZoom: 20, - attribution: '© Openstreetmap France | {attribution.OpenStreetMap}' - } - }, - HOT: { - url: 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', - options: { - attribution: - '{attribution.OpenStreetMap}, ' + - 'Tiles style by Humanitarian OpenStreetMap Team ' + - 'hosted by OpenStreetMap France' - } - }, - BZH: { - url: 'https://tile.openstreetmap.bzh/br/{z}/{x}/{y}.png', - options: { - attribution: '{attribution.OpenStreetMap}, Tiles courtesy of Breton OpenStreetMap Team', - bounds: [[46.2, -5.5], [50, 0.7]] - } - } - } - }, - OpenSeaMap: { - url: 'https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png', - options: { - attribution: 'Map data: © OpenSeaMap contributors' - } - }, - OpenPtMap: { - url: 'http://openptmap.org/tiles/{z}/{x}/{y}.png', - options: { - maxZoom: 17, - attribution: 'Map data: © OpenPtMap contributors' - } - }, - OpenTopoMap: { - url: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', - options: { - maxZoom: 17, - attribution: 'Map data: {attribution.OpenStreetMap}, SRTM | Map style: © OpenTopoMap (CC-BY-SA)' - } - }, - OpenRailwayMap: { - url: 'https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png', - options: { - maxZoom: 19, - attribution: 'Map data: {attribution.OpenStreetMap} | Map style: © OpenRailwayMap (CC-BY-SA)' - } - }, - OpenFireMap: { - url: 'http://openfiremap.org/hytiles/{z}/{x}/{y}.png', - options: { - maxZoom: 19, - attribution: 'Map data: {attribution.OpenStreetMap} | Map style: © OpenFireMap (CC-BY-SA)' - } - }, - SafeCast: { - url: 'https://s3.amazonaws.com/te512.safecast.org/{z}/{x}/{y}.png', - options: { - maxZoom: 16, - attribution: 'Map data: {attribution.OpenStreetMap} | Map style: © SafeCast (CC-BY-SA)' - } - }, - Stadia: { - url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}{r}.png', - options: { - maxZoom: 20, - attribution: '© Stadia Maps, © OpenMapTiles © OpenStreetMap contributors' - }, - variants: { - AlidadeSmooth: { - url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}{r}.png' - }, - AlidadeSmoothDark: { - url: 'https://tiles.stadiamaps.com/tiles/alidade_smooth_dark/{z}/{x}/{y}{r}.png' - }, - OSMBright: { - url: 'https://tiles.stadiamaps.com/tiles/osm_bright/{z}/{x}/{y}{r}.png' - }, - Outdoors: { - url: 'https://tiles.stadiamaps.com/tiles/outdoors/{z}/{x}/{y}{r}.png' - } - } - }, - Thunderforest: { - url: 'https://{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png?apikey={apikey}', - options: { - attribution: - '© Thunderforest, {attribution.OpenStreetMap}', - variant: 'cycle', - apikey: '', - maxZoom: 22 - }, - variants: { - OpenCycleMap: 'cycle', - Transport: { - options: { - variant: 'transport' - } - }, - TransportDark: { - options: { - variant: 'transport-dark' - } - }, - SpinalMap: { - options: { - variant: 'spinal-map' - } - }, - Landscape: 'landscape', - Outdoors: 'outdoors', - Pioneer: 'pioneer', - MobileAtlas: 'mobile-atlas', - Neighbourhood: 'neighbourhood' - } - }, - CyclOSM: { - url: 'https://dev.{s}.tile.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png', - options: { - maxZoom: 20, - attribution: 'CyclOSM | Map data: {attribution.OpenStreetMap}' - } - }, - Hydda: { - url: 'https://{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png', - options: { - maxZoom: 20, - variant: 'full', - attribution: 'Tiles courtesy of OpenStreetMap Sweden — Map data {attribution.OpenStreetMap}' - }, - variants: { - Full: 'full', - Base: 'base', - RoadsAndLabels: 'roads_and_labels' - } - }, - Jawg: { - url: 'https://{s}.tile.jawg.io/{variant}/{z}/{x}/{y}{r}.png?access-token={accessToken}', - options: { - attribution: - '© JawgMaps ' + - '{attribution.OpenStreetMap}', - minZoom: 0, - maxZoom: 22, - subdomains: 'abcd', - variant: 'jawg-terrain', - // Get your own Jawg access token here : https://www.jawg.io/lab/ - // NB : this is a demonstration key that comes with no guarantee - accessToken: '', - }, - variants: { - Streets: 'jawg-streets', - Terrain: 'jawg-terrain', - Sunny: 'jawg-sunny', - Dark: 'jawg-dark', - Light: 'jawg-light', - Matrix: 'jawg-matrix' - } - }, - MapBox: { - url: 'https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}{r}?access_token={accessToken}', - options: { - attribution: - '© Mapbox ' + - '{attribution.OpenStreetMap} ' + - 'Improve this map', - tileSize: 512, - maxZoom: 18, - zoomOffset: -1, - id: 'mapbox/streets-v11', - accessToken: '', - } - }, - MapTiler: { - url: 'https://api.maptiler.com/maps/{variant}/{z}/{x}/{y}{r}.{ext}?key={key}', - options: { - attribution: - '© MapTiler © OpenStreetMap contributors', - variant: 'streets', - ext: 'png', - key: '', - tileSize: 512, - zoomOffset: -1, - minZoom: 0, - maxZoom: 21 - }, - variants: { - Streets: 'streets', - Basic: 'basic', - Bright: 'bright', - Pastel: 'pastel', - Positron: 'positron', - Hybrid: { - options: { - variant: 'hybrid', - ext: 'jpg' - } - }, - Toner: 'toner', - Topo: 'topo', - Voyager: 'voyager' - } - }, - Stamen: { - url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}{r}.{ext}', - options: { - attribution: - 'Map tiles by Stamen Design, ' + - 'CC BY 3.0 — ' + - 'Map data {attribution.OpenStreetMap}', - subdomains: 'abcd', - minZoom: 0, - maxZoom: 20, - variant: 'toner', - ext: 'png' - }, - variants: { - Toner: 'toner', - TonerBackground: 'toner-background', - TonerHybrid: 'toner-hybrid', - TonerLines: 'toner-lines', - TonerLabels: 'toner-labels', - TonerLite: 'toner-lite', - Watercolor: { - url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}', - options: { - variant: 'watercolor', - ext: 'jpg', - minZoom: 1, - maxZoom: 16 - } - }, - Terrain: { - options: { - variant: 'terrain', - minZoom: 0, - maxZoom: 18 - } - }, - TerrainBackground: { - options: { - variant: 'terrain-background', - minZoom: 0, - maxZoom: 18 - } - }, - TerrainLabels: { - options: { - variant: 'terrain-labels', - minZoom: 0, - maxZoom: 18 - } - }, - TopOSMRelief: { - url: 'https://stamen-tiles-{s}.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.{ext}', - options: { - variant: 'toposm-color-relief', - ext: 'jpg', - bounds: [[22, -132], [51, -56]] - } - }, - TopOSMFeatures: { - options: { - variant: 'toposm-features', - bounds: [[22, -132], [51, -56]], - opacity: 0.9 - } - } - } - }, - TomTom: { - url: 'https://{s}.api.tomtom.com/map/1/tile/{variant}/{style}/{z}/{x}/{y}.{ext}?key={apikey}', - options: { - variant: 'basic', - maxZoom: 22, - attribution: - '© 1992 - ' + new Date().getFullYear() + ' TomTom. ', - subdomains: 'abcd', - style: 'main', - ext: 'png', - apikey: '', - }, - variants: { - Basic: 'basic', - Hybrid: 'hybrid', - Labels: 'labels' - } - }, - Esri: { - url: 'https://server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}', - options: { - variant: 'World_Street_Map', - attribution: 'Tiles © Esri' - }, - variants: { - WorldStreetMap: { - options: { - attribution: - '{attribution.Esri} — ' + - 'Source: Esri, DeLorme, NAVTEQ, USGS, Intermap, iPC, NRCAN, Esri Japan, METI, Esri China (Hong Kong), Esri (Thailand), TomTom, 2012' - } - }, - DeLorme: { - options: { - variant: 'Specialty/DeLorme_World_Base_Map', - minZoom: 1, - maxZoom: 11, - attribution: '{attribution.Esri} — Copyright: ©2012 DeLorme' - } - }, - WorldTopoMap: { - options: { - variant: 'World_Topo_Map', - attribution: - '{attribution.Esri} — ' + - 'Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community' - } - }, - WorldImagery: { - options: { - variant: 'World_Imagery', - attribution: - '{attribution.Esri} — ' + - 'Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community' - } - }, - WorldTerrain: { - options: { - variant: 'World_Terrain_Base', - maxZoom: 13, - attribution: - '{attribution.Esri} — ' + - 'Source: USGS, Esri, TANA, DeLorme, and NPS' - } - }, - WorldShadedRelief: { - options: { - variant: 'World_Shaded_Relief', - maxZoom: 13, - attribution: '{attribution.Esri} — Source: Esri' - } - }, - WorldPhysical: { - options: { - variant: 'World_Physical_Map', - maxZoom: 8, - attribution: '{attribution.Esri} — Source: US National Park Service' - } - }, - OceanBasemap: { - options: { - variant: 'Ocean_Basemap', - maxZoom: 13, - attribution: '{attribution.Esri} — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri' - } - }, - NatGeoWorldMap: { - options: { - variant: 'NatGeo_World_Map', - maxZoom: 16, - attribution: '{attribution.Esri} — National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC' - } - }, - WorldGrayCanvas: { - options: { - variant: 'Canvas/World_Light_Gray_Base', - maxZoom: 16, - attribution: '{attribution.Esri} — Esri, DeLorme, NAVTEQ' - } - } - } - }, - OpenWeatherMap: { - url: 'http://{s}.tile.openweathermap.org/map/{variant}/{z}/{x}/{y}.png?appid={apiKey}', - options: { - maxZoom: 19, - attribution: 'Map data © OpenWeatherMap', - apiKey:'', - opacity: 0.5 - }, - variants: { - Clouds: 'clouds', - CloudsClassic: 'clouds_cls', - Precipitation: 'precipitation', - PrecipitationClassic: 'precipitation_cls', - Rain: 'rain', - RainClassic: 'rain_cls', - Pressure: 'pressure', - PressureContour: 'pressure_cntr', - Wind: 'wind', - Temperature: 'temp', - Snow: 'snow' - } - }, - HERE: { - /* - * HERE maps, formerly Nokia maps. - * These basemaps are free, but you need an api id and app key. Please sign up at - * https://developer.here.com/plans - */ - url: - 'https://{s}.{base}.maps.api.here.com/maptile/2.1/' + - '{type}/{mapID}/{variant}/{z}/{x}/{y}/{size}/{format}?' + - 'app_id={app_id}&app_code={app_code}&lg={language}', - options: { - attribution: - 'Map © 1987-' + new Date().getFullYear() + ' HERE', - subdomains: '1234', - mapID: 'newest', - 'app_id': '', - 'app_code': '', - base: 'base', - variant: 'normal.day', - maxZoom: 20, - type: 'maptile', - language: 'eng', - format: 'png8', - size: '256' - }, - variants: { - normalDay: 'normal.day', - normalDayCustom: 'normal.day.custom', - normalDayGrey: 'normal.day.grey', - normalDayMobile: 'normal.day.mobile', - normalDayGreyMobile: 'normal.day.grey.mobile', - normalDayTransit: 'normal.day.transit', - normalDayTransitMobile: 'normal.day.transit.mobile', - normalDayTraffic: { - options: { - variant: 'normal.traffic.day', - base: 'traffic', - type: 'traffictile' - } - }, - normalNight: 'normal.night', - normalNightMobile: 'normal.night.mobile', - normalNightGrey: 'normal.night.grey', - normalNightGreyMobile: 'normal.night.grey.mobile', - normalNightTransit: 'normal.night.transit', - normalNightTransitMobile: 'normal.night.transit.mobile', - reducedDay: 'reduced.day', - reducedNight: 'reduced.night', - basicMap: { - options: { - type: 'basetile' - } - }, - mapLabels: { - options: { - type: 'labeltile', - format: 'png' - } - }, - trafficFlow: { - options: { - base: 'traffic', - type: 'flowtile' - } - }, - carnavDayGrey: 'carnav.day.grey', - hybridDay: { - options: { - base: 'aerial', - variant: 'hybrid.day' - } - }, - hybridDayMobile: { - options: { - base: 'aerial', - variant: 'hybrid.day.mobile' - } - }, - hybridDayTransit: { - options: { - base: 'aerial', - variant: 'hybrid.day.transit' - } - }, - hybridDayGrey: { - options: { - base: 'aerial', - variant: 'hybrid.grey.day' - } - }, - hybridDayTraffic: { - options: { - variant: 'hybrid.traffic.day', - base: 'traffic', - type: 'traffictile' - } - }, - pedestrianDay: 'pedestrian.day', - pedestrianNight: 'pedestrian.night', - satelliteDay: { - options: { - base: 'aerial', - variant: 'satellite.day' - } - }, - terrainDay: { - options: { - base: 'aerial', - variant: 'terrain.day' - } - }, - terrainDayMobile: { - options: { - base: 'aerial', - variant: 'terrain.day.mobile' - } - } - } - }, - HEREv3: { - /* - * HERE maps API Version 3. - * These basemaps are free, but you need an API key. Please sign up at - * https://developer.here.com/plans - * Version 3 deprecates the app_id and app_code access in favor of apiKey - * - * Supported access methods as of 2019/12/21: - * @see https://developer.here.com/faqs#access-control-1--how-do-you-control-access-to-here-location-services - */ - url: - 'https://{s}.{base}.maps.ls.hereapi.com/maptile/2.1/' + - '{type}/{mapID}/{variant}/{z}/{x}/{y}/{size}/{format}?' + - 'apiKey={apiKey}&lg={language}', - options: { - attribution: - 'Map © 1987-' + new Date().getFullYear() + ' HERE', - subdomains: '1234', - mapID: 'newest', - apiKey: '', - base: 'base', - variant: 'normal.day', - maxZoom: 20, - type: 'maptile', - language: 'eng', - format: 'png8', - size: '256' - }, - variants: { - normalDay: 'normal.day', - normalDayCustom: 'normal.day.custom', - normalDayGrey: 'normal.day.grey', - normalDayMobile: 'normal.day.mobile', - normalDayGreyMobile: 'normal.day.grey.mobile', - normalDayTransit: 'normal.day.transit', - normalDayTransitMobile: 'normal.day.transit.mobile', - normalNight: 'normal.night', - normalNightMobile: 'normal.night.mobile', - normalNightGrey: 'normal.night.grey', - normalNightGreyMobile: 'normal.night.grey.mobile', - normalNightTransit: 'normal.night.transit', - normalNightTransitMobile: 'normal.night.transit.mobile', - reducedDay: 'reduced.day', - reducedNight: 'reduced.night', - basicMap: { - options: { - type: 'basetile' - } - }, - mapLabels: { - options: { - type: 'labeltile', - format: 'png' - } - }, - trafficFlow: { - options: { - base: 'traffic', - type: 'flowtile' - } - }, - carnavDayGrey: 'carnav.day.grey', - hybridDay: { - options: { - base: 'aerial', - variant: 'hybrid.day' - } - }, - hybridDayMobile: { - options: { - base: 'aerial', - variant: 'hybrid.day.mobile' - } - }, - hybridDayTransit: { - options: { - base: 'aerial', - variant: 'hybrid.day.transit' - } - }, - hybridDayGrey: { - options: { - base: 'aerial', - variant: 'hybrid.grey.day' - } - }, - pedestrianDay: 'pedestrian.day', - pedestrianNight: 'pedestrian.night', - satelliteDay: { - options: { - base: 'aerial', - variant: 'satellite.day' - } - }, - terrainDay: { - options: { - base: 'aerial', - variant: 'terrain.day' - } - }, - terrainDayMobile: { - options: { - base: 'aerial', - variant: 'terrain.day.mobile' - } - } - } - }, - FreeMapSK: { - url: 'https://{s}.freemap.sk/T/{z}/{x}/{y}.jpeg', - options: { - minZoom: 8, - maxZoom: 16, - subdomains: 'abcd', - bounds: [[47.204642, 15.996093], [49.830896, 22.576904]], - attribution: - '{attribution.OpenStreetMap}, vizualization CC-By-SA 2.0 Freemap.sk' - } - }, - MtbMap: { - url: 'http://tile.mtbmap.cz/mtbmap_tiles/{z}/{x}/{y}.png', - options: { - attribution: - '{attribution.OpenStreetMap} & USGS' - } - }, - CartoDB: { - url: 'https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png', - options: { - attribution: '{attribution.OpenStreetMap} © CARTO', - subdomains: 'abcd', - maxZoom: 19, - variant: 'light_all' - }, - variants: { - Positron: 'light_all', - PositronNoLabels: 'light_nolabels', - PositronOnlyLabels: 'light_only_labels', - DarkMatter: 'dark_all', - DarkMatterNoLabels: 'dark_nolabels', - DarkMatterOnlyLabels: 'dark_only_labels', - Voyager: 'rastertiles/voyager', - VoyagerNoLabels: 'rastertiles/voyager_nolabels', - VoyagerOnlyLabels: 'rastertiles/voyager_only_labels', - VoyagerLabelsUnder: 'rastertiles/voyager_labels_under' - } - }, - HikeBike: { - url: 'https://tiles.wmflabs.org/{variant}/{z}/{x}/{y}.png', - options: { - maxZoom: 19, - attribution: '{attribution.OpenStreetMap}', - variant: 'hikebike' - }, - variants: { - HikeBike: {}, - HillShading: { - options: { - maxZoom: 15, - variant: 'hillshading' - } - } - } - }, - BasemapAT: { - url: 'https://maps{s}.wien.gv.at/basemap/{variant}/{type}/google3857/{z}/{y}/{x}.{format}', - options: { - maxZoom: 19, - attribution: 'Datenquelle: basemap.at', - subdomains: ['', '1', '2', '3', '4'], - type: 'normal', - format: 'png', - bounds: [[46.358770, 8.782379], [49.037872, 17.189532]], - variant: 'geolandbasemap' - }, - variants: { - basemap: { - options: { - maxZoom: 20, // currently only in Vienna - variant: 'geolandbasemap' - } - }, - grau: 'bmapgrau', - overlay: 'bmapoverlay', - terrain: { - options: { - variant: 'bmapgelaende', - type: 'grau', - format: 'jpeg' - } - }, - surface: { - options: { - variant: 'bmapoberflaeche', - type: 'grau', - format: 'jpeg' - } - }, - highdpi: { - options: { - variant: 'bmaphidpi', - format: 'jpeg' - } - }, - orthofoto: { - options: { - maxZoom: 20, // currently only in Vienna - variant: 'bmaporthofoto30cm', - format: 'jpeg' - } - } - } - }, - nlmaps: { - url: 'https://geodata.nationaalgeoregister.nl/tiles/service/wmts/{variant}/EPSG:3857/{z}/{x}/{y}.png', - options: { - minZoom: 6, - maxZoom: 19, - bounds: [[50.5, 3.25], [54, 7.6]], - attribution: 'Kaartgegevens © Kadaster' - }, - variants: { - 'standaard': 'brtachtergrondkaart', - 'pastel': 'brtachtergrondkaartpastel', - 'grijs': 'brtachtergrondkaartgrijs', - 'luchtfoto': { - 'url': 'https://geodata.nationaalgeoregister.nl/luchtfoto/rgb/wmts/2018_ortho25/EPSG:3857/{z}/{x}/{y}.png', - } - } - }, - NASAGIBS: { - url: 'https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}', - options: { - attribution: - 'Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System ' + - '(ESDIS) with funding provided by NASA/HQ.', - bounds: [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]], - minZoom: 1, - maxZoom: 9, - format: 'jpg', - time: '', - tilematrixset: 'GoogleMapsCompatible_Level' - }, - variants: { - ModisTerraTrueColorCR: 'MODIS_Terra_CorrectedReflectance_TrueColor', - ModisTerraBands367CR: 'MODIS_Terra_CorrectedReflectance_Bands367', - ViirsEarthAtNight2012: { - options: { - variant: 'VIIRS_CityLights_2012', - maxZoom: 8 - } - }, - ModisTerraLSTDay: { - options: { - variant: 'MODIS_Terra_Land_Surface_Temp_Day', - format: 'png', - maxZoom: 7, - opacity: 0.75 - } - }, - ModisTerraSnowCover: { - options: { - variant: 'MODIS_Terra_Snow_Cover', - format: 'png', - maxZoom: 8, - opacity: 0.75 - } - }, - ModisTerraAOD: { - options: { - variant: 'MODIS_Terra_Aerosol', - format: 'png', - maxZoom: 6, - opacity: 0.75 - } - }, - ModisTerraChlorophyll: { - options: { - variant: 'MODIS_Terra_Chlorophyll_A', - format: 'png', - maxZoom: 7, - opacity: 0.75 - } - } - } - }, - NLS: { - // NLS maps are copyright National library of Scotland. - // http://maps.nls.uk/projects/api/index.html - // Please contact NLS for anything other than non-commercial low volume usage - // - // Map sources: Ordnance Survey 1:1m to 1:63K, 1920s-1940s - // z0-9 - 1:1m - // z10-11 - quarter inch (1:253440) - // z12-18 - one inch (1:63360) - url: 'https://nls-{s}.tileserver.com/nls/{z}/{x}/{y}.jpg', - options: { - attribution: 'National Library of Scotland Historic Maps', - bounds: [[49.6, -12], [61.7, 3]], - minZoom: 1, - maxZoom: 18, - subdomains: '0123', - } - }, - JusticeMap: { - // Justice Map (http://www.justicemap.org/) - // Visualize race and income data for your community, county and country. - // Includes tools for data journalists, bloggers and community activists. - url: 'http://www.justicemap.org/tile/{size}/{variant}/{z}/{x}/{y}.png', - options: { - attribution: 'Justice Map', - // one of 'county', 'tract', 'block' - size: 'county', - // Bounds for USA, including Alaska and Hawaii - bounds: [[14, -180], [72, -56]] - }, - variants: { - income: 'income', - americanIndian: 'indian', - asian: 'asian', - black: 'black', - hispanic: 'hispanic', - multi: 'multi', - nonWhite: 'nonwhite', - white: 'white', - plurality: 'plural' - } - }, - Wikimedia: { - url: 'https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}{r}.png', - options: { - attribution: 'Wikimedia', - minZoom: 1, - maxZoom: 19 - } - }, - GeoportailFrance: { - url: 'https://wxs.ign.fr/{apikey}/geoportail/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&STYLE={style}&TILEMATRIXSET=PM&FORMAT={format}&LAYER={variant}&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}', - options: { - attribution: 'Geoportail France', - bounds: [[-75, -180], [81, 180]], - minZoom: 2, - maxZoom: 18, - // Get your own geoportail apikey here : http://professionnels.ign.fr/ign/contrats/ - // NB : 'choisirgeoportail' is a demonstration key that comes with no guarantee - apikey: 'choisirgeoportail', - format: 'image/jpeg', - style : 'normal', - variant: 'GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN-EXPRESS.STANDARD' - }, - variants: { - parcels: { - options : { - variant: 'CADASTRALPARCELS.PARCELS', - maxZoom: 20, - style : 'bdparcellaire', - format: 'image/png' - } - }, - ignMaps: 'GEOGRAPHICALGRIDSYSTEMS.MAPS', - maps: 'GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN-EXPRESS.STANDARD', - orthos: { - options: { - maxZoom: 19, - variant: 'ORTHOIMAGERY.ORTHOPHOTOS' - } - } - } - }, - OneMapSG: { - url: 'https://maps-{s}.onemap.sg/v3/{variant}/{z}/{x}/{y}.png', - options: { - variant: 'Default', - minZoom: 11, - maxZoom: 18, - bounds: [[1.56073, 104.11475], [1.16, 103.502]], - attribution: ' New OneMap | Map data © contributors, Singapore Land Authority' - }, - variants: { - Default: 'Default', - Night: 'Night', - Original: 'Original', - Grey: 'Grey', - LandLot: 'LandLot' - } - } - }; - - L.tileLayer.provider = function (provider, options) { - return new L.TileLayer.Provider(provider, options); - }; - - return L; -})); diff --git a/www/index.html.de b/www/index.html.de index 87e3826..32fdf5d 100755 --- a/www/index.html.de +++ b/www/index.html.de @@ -33,7 +33,7 @@ - + diff --git a/www/index.html.en b/www/index.html.en index 449bc3a..158edff 100755 --- a/www/index.html.en +++ b/www/index.html.en @@ -33,7 +33,7 @@ - + From 96f0f913f382e02e2124e99c7c622f0160eec07a Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Thu, 16 Jul 2020 13:13:50 +0200 Subject: [PATCH 05/15] use leaflet.browserPrint instead of leaflet.easyPrint FIXME: printing still broken. --- www/index.html.de | 4 +--- www/index.html.en | 4 +--- www/map.js | 3 +-- www/map.js.en | 3 +-- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/www/index.html.de b/www/index.html.de index 32fdf5d..0ad01b0 100755 --- a/www/index.html.de +++ b/www/index.html.de @@ -13,7 +13,6 @@ - @@ -34,8 +33,7 @@ - - + diff --git a/www/index.html.en b/www/index.html.en index 158edff..481ec43 100755 --- a/www/index.html.en +++ b/www/index.html.en @@ -13,7 +13,6 @@ - @@ -34,8 +33,7 @@ - - + diff --git a/www/map.js b/www/map.js index 285edfa..64cb34d 100644 --- a/www/map.js +++ b/www/map.js @@ -206,9 +206,8 @@ $(document).ready(function() { }); // print icon - L.easyPrint({ + L.control.browserPrint({ title: 'print map', position: 'topright', - sizeModes: ['Current', 'A4Portrait', 'A4Landscape'], }).addTo(map); }); diff --git a/www/map.js.en b/www/map.js.en index 95dc862..d1e6ca3 100644 --- a/www/map.js.en +++ b/www/map.js.en @@ -206,9 +206,8 @@ $(document).ready(function() { }); // print icon - L.easyPrint({ + L.control.browserPrint({ title: 'print map', position: 'topright', - sizeModes: ['Current', 'A4Portrait', 'A4Landscape'], }).addTo(map); }); From 920439267a142667f35beca291eba4b810e7f4e5 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Thu, 16 Jul 2020 13:24:43 +0200 Subject: [PATCH 06/15] use cdn for sprintf.js --- www/external/sprintf.min.js | 3 --- www/external/sprintf.min.js.map | 1 - www/index.html.de | 2 +- www/index.html.en | 2 +- 4 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 www/external/sprintf.min.js delete mode 100644 www/external/sprintf.min.js.map diff --git a/www/external/sprintf.min.js b/www/external/sprintf.min.js deleted file mode 100644 index a3196b8..0000000 --- a/www/external/sprintf.min.js +++ /dev/null @@ -1,3 +0,0 @@ -/*! sprintf-js v1.1.2 | Copyright (c) 2007-present, Alexandru Mărășteanu | BSD-3-Clause */ -!function(){"use strict";var g={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function y(e){return function(e,t){var r,n,i,s,a,o,p,c,l,u=1,f=e.length,d="";for(n=0;n>>0).toString(8);break;case"s":r=String(r),r=s.precision?r.substring(0,s.precision):r;break;case"t":r=String(!!r),r=s.precision?r.substring(0,s.precision):r;break;case"T":r=Object.prototype.toString.call(r).slice(8,-1).toLowerCase(),r=s.precision?r.substring(0,s.precision):r;break;case"u":r=parseInt(r,10)>>>0;break;case"v":r=r.valueOf(),r=s.precision?r.substring(0,s.precision):r;break;case"x":r=(parseInt(r,10)>>>0).toString(16);break;case"X":r=(parseInt(r,10)>>>0).toString(16).toUpperCase()}g.json.test(s.type)?d+=r:(!g.number.test(s.type)||c&&!s.sign?l="":(l=c?"+":"-",r=r.toString().replace(g.sign,"")),o=s.pad_char?"0"===s.pad_char?"0":s.pad_char.charAt(1):" ",p=s.width-(l+r).length,a=s.width&&0= 0\n }\n\n switch (ph.type) {\n case 'b':\n arg = parseInt(arg, 10).toString(2)\n break\n case 'c':\n arg = String.fromCharCode(parseInt(arg, 10))\n break\n case 'd':\n case 'i':\n arg = parseInt(arg, 10)\n break\n case 'j':\n arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0)\n break\n case 'e':\n arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential()\n break\n case 'f':\n arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg)\n break\n case 'g':\n arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg)\n break\n case 'o':\n arg = (parseInt(arg, 10) >>> 0).toString(8)\n break\n case 's':\n arg = String(arg)\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 't':\n arg = String(!!arg)\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'T':\n arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'u':\n arg = parseInt(arg, 10) >>> 0\n break\n case 'v':\n arg = arg.valueOf()\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'x':\n arg = (parseInt(arg, 10) >>> 0).toString(16)\n break\n case 'X':\n arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()\n break\n }\n if (re.json.test(ph.type)) {\n output += arg\n }\n else {\n if (re.number.test(ph.type) && (!is_positive || ph.sign)) {\n sign = is_positive ? '+' : '-'\n arg = arg.toString().replace(re.sign, '')\n }\n else {\n sign = ''\n }\n pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' '\n pad_length = ph.width - (sign + arg).length\n pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''\n output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)\n }\n }\n }\n return output\n }\n\n var sprintf_cache = Object.create(null)\n\n function sprintf_parse(fmt) {\n if (sprintf_cache[fmt]) {\n return sprintf_cache[fmt]\n }\n\n var _fmt = fmt, match, parse_tree = [], arg_names = 0\n while (_fmt) {\n if ((match = re.text.exec(_fmt)) !== null) {\n parse_tree.push(match[0])\n }\n else if ((match = re.modulo.exec(_fmt)) !== null) {\n parse_tree.push('%')\n }\n else if ((match = re.placeholder.exec(_fmt)) !== null) {\n if (match[2]) {\n arg_names |= 1\n var field_list = [], replacement_field = match[2], field_match = []\n if ((field_match = re.key.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {\n if ((field_match = re.key_access.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n }\n else if ((field_match = re.index_access.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n }\n else {\n throw new SyntaxError('[sprintf] failed to parse named argument key')\n }\n }\n }\n else {\n throw new SyntaxError('[sprintf] failed to parse named argument key')\n }\n match[2] = field_list\n }\n else {\n arg_names |= 2\n }\n if (arg_names === 3) {\n throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported')\n }\n\n parse_tree.push(\n {\n placeholder: match[0],\n param_no: match[1],\n keys: match[2],\n sign: match[3],\n pad_char: match[4],\n align: match[5],\n width: match[6],\n precision: match[7],\n type: match[8]\n }\n )\n }\n else {\n throw new SyntaxError('[sprintf] unexpected placeholder')\n }\n _fmt = _fmt.substring(match[0].length)\n }\n return sprintf_cache[fmt] = parse_tree\n }\n\n /**\n * export to either browser or node.js\n */\n /* eslint-disable quote-props */\n if (typeof exports !== 'undefined') {\n exports['sprintf'] = sprintf\n exports['vsprintf'] = vsprintf\n }\n if (typeof window !== 'undefined') {\n window['sprintf'] = sprintf\n window['vsprintf'] = vsprintf\n\n if (typeof define === 'function' && define['amd']) {\n define(function() {\n return {\n 'sprintf': sprintf,\n 'vsprintf': vsprintf\n }\n })\n }\n }\n /* eslint-enable quote-props */\n}(); // eslint-disable-line\n"]} \ No newline at end of file diff --git a/www/index.html.de b/www/index.html.de index 0ad01b0..175489d 100755 --- a/www/index.html.de +++ b/www/index.html.de @@ -20,7 +20,7 @@ - + diff --git a/www/index.html.en b/www/index.html.en index 481ec43..463bd2e 100755 --- a/www/index.html.en +++ b/www/index.html.en @@ -20,7 +20,7 @@ - + From d09692c1d2285ef8f4971bb01095509718284a6b Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Thu, 16 Jul 2020 13:26:20 +0200 Subject: [PATCH 07/15] add markdown support use library showdown.js --- www/index.html.de | 3 ++- www/index.html.en | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/www/index.html.de b/www/index.html.de index 175489d..db5272c 100755 --- a/www/index.html.de +++ b/www/index.html.de @@ -18,9 +18,10 @@ - + + diff --git a/www/index.html.en b/www/index.html.en index 463bd2e..a0712d9 100755 --- a/www/index.html.en +++ b/www/index.html.en @@ -18,9 +18,10 @@ - + + From 601e92e42e70879beae90c4fcbbee54f2c3eb624 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Thu, 16 Jul 2020 15:25:02 +0200 Subject: [PATCH 08/15] replace server-side includes by jQuery get methods * include statetment not supported with nginx * included files can now be written in markdown --- www/index.html.de | 15 +++++++-------- www/index.html.en | 17 ++++++++--------- www/info.inc.de | 1 + www/misc.js | 22 +++++++++++++++++++++- www/more.inc.de | 1 - www/more_de.md | 9 +++++++++ www/more_en.md | 9 +++++++++ 7 files changed, 55 insertions(+), 19 deletions(-) delete mode 100644 www/more.inc.de create mode 100644 www/more_de.md create mode 100644 www/more_en.md diff --git a/www/index.html.de b/www/index.html.de index db5272c..4cbf734 100755 --- a/www/index.html.de +++ b/www/index.html.de @@ -154,20 +154,19 @@

Download als CSV-Datei.

-
+
+

Text wird geladen ...

+

Navigation / Links

- +

Text wird geladen ...

Copyright / Lizenz

- +

Impressum

- -
-
-
- +

Text wird geladen ...

+
diff --git a/www/index.html.en b/www/index.html.en index a0712d9..3d0df3c 100755 --- a/www/index.html.en +++ b/www/index.html.en @@ -154,20 +154,19 @@

Download as CSV file.

-
+
+

Text loading ...

+

Navigation / Links

- -

Copyright / License

- +

Text loading ...

+

Copyright / Lizenz

+

Imprint

- -
-
-
- +

Text loading ...

+
diff --git a/www/info.inc.de b/www/info.inc.de index 2b6c14b..dff3607 100644 --- a/www/info.inc.de +++ b/www/info.inc.de @@ -18,4 +18,5 @@ diff --git a/www/misc.js b/www/misc.js index 77da9dc..5fc1533 100644 --- a/www/misc.js +++ b/www/misc.js @@ -137,7 +137,7 @@ var config = { }, tab: { active: 0, - disabled: [2], + // disabled: [2], max: 4, }, }; @@ -223,4 +223,24 @@ $(document).ready(function() { }).on("ajaxStop", function() { $("#spinner").hide(); }); + + // load more tab content + $.get("more_de.md", function( data ) { + var converter = new showdown.Converter(); + $('.more_de').html(converter.makeHtml(data)); + }); + $.get("more_en.md", function( data ) { + var converter = new showdown.Converter(); + $('.more_en').html(converter.makeHtml(data)); + }); + // load info tab content + $.get("info.inc.de", function( data ) { + $('.info_de, .info_en').html(data); + }); + $.get("copyright.inc.de", function( data ) { + $('.copyright_de, .copyright_en').html(data); + }); + $.get("impressum.inc.de", function( data ) { + $('.imprint_de, .imprint_en').html(data); + }); }); diff --git a/www/more.inc.de b/www/more.inc.de deleted file mode 100644 index bb1dfa7..0000000 --- a/www/more.inc.de +++ /dev/null @@ -1 +0,0 @@ -Das seismologische Netz der Ruhr-Universität besteht aus 13 Stationen. Zwei breitbandige Stationen (BUG und IBBN) sind gleichzeitig Bestandteil des Deutschen Seismologischen Regionalnetzes (GRSN). Sie befinden sich in der Nähe der Ruhr-Universität in einem stillgelegten Stollen der Zeche Klosterbusch bzw. bei Ibbenbüren. Weitere Außenstationen gibt es bei Rheinberg (BRHE) und Hünxe (ZERL, westliches Ruhrgebiet), bei Haltern (BAVN, nörldiches Ruhrgebiet) und Hamm (HMES, östliches Ruhrgebiet). In Ibbenbüren ergänzen die kurzperiodischen Stationen IBBE und IBBS das Stationsnetz. Im Bereich der Ruhr-Universität werden weiterhin 5 kurzperiodische Stationen (BTEZ, BSHA, BKLB, BHOF, BULI) betrieben, die zur Ortung von Ereignissen im Ruhrgebiet verwendet werden. Das von den Seismometern registrierte Messsignal wird an den Stationen digitalisiert und kontinuierlich an die Auswertezentrale an der Ruhr-Universität Bochum übertragen. \ No newline at end of file diff --git a/www/more_de.md b/www/more_de.md new file mode 100644 index 0000000..2fd0d90 --- /dev/null +++ b/www/more_de.md @@ -0,0 +1,9 @@ +# Seismologisches Observatorium +## Stationsnetz + +Das seismologische Observatorium der Ruhr-Universität Bochum betreibt mehrere seismologische Stationen im Ruhrgebiet, im Raum Ibbenbüren und im Alpenvorland. Zwei breitbandige Stationen (BUG und IBBN) sind gleichzeitig Bestandteil des Deutschen Seismologischen Regionalnetzes (GRSN). Sie befinden sich in der Nähe der Ruhr-Universität in einem stillgelegten Stollen der Zeche Klosterbusch bzw. bei Ibbenbüren. + +## Seismologische Netzwerke +### RuhrNet (RN) +### FloodRisk (YD) +### AlpArray (Z3) \ No newline at end of file diff --git a/www/more_en.md b/www/more_en.md new file mode 100644 index 0000000..a3d6304 --- /dev/null +++ b/www/more_en.md @@ -0,0 +1,9 @@ +# Seismological Observatory +## Station Network + +The seismological observatory of the Ruhr-University Bochum (Germany) maintains several seismolocical stations in the Ruhr area, around Ibbenbueren and in the foreland of the Alps. Two broadband stations (BUG and IBBN) are also part of the German Regional Seismological Network (GRSN). These are located near the Ruhr-University in an abandoned coal mine and near the city of Ibbenbueren. + +## Seismological Networks +### RuhrNet (RN) +### FloodRisk (YD) +### AlpArray (Z3) \ No newline at end of file From 844f77e8e89a572b57953e8a05bd61c9a52f7b24 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Sat, 16 Oct 2021 11:53:33 +0200 Subject: [PATCH 09/15] update .gitignore * add MacOS / OSX files * ad VS code files * removed outdated paths --- .gitignore | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index a1760d5..6acdd86 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,44 @@ -/events.xml -/geolocation.js +## Visual Studio Code +# Visual Studio Code files +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +## MacOS / OSX +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +## Project Files wsgi/.idea www/dlsv www/event.xml @@ -7,9 +46,5 @@ www/events.xml www/geolocation.js www/geolocationTable.js www/stations.xml - -.vscode/settings.json - www/index.html - www/favicon.ico From 9faf11d0dfc9c20dbc80525f050fc43868390549 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Sat, 16 Oct 2021 15:51:38 +0200 Subject: [PATCH 10/15] upgrade to python3 fixed some typos --- scripts/mkGeolocationTable.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/scripts/mkGeolocationTable.py b/scripts/mkGeolocationTable.py index 2703d87..7ab80c2 100755 --- a/scripts/mkGeolocationTable.py +++ b/scripts/mkGeolocationTable.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 # -*- coding: utf-8 -*- ''' @@ -8,9 +8,9 @@ The output will will be a javascript structure to be included in the SeisObs map service. - The script should be updated regulary keep the total number of all + The script should be updated regularly keep the total number of all AJAX calls to the Nominatim service small, e. g. : - curl -s "https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/event/1/query?minlat=50&maxlat=54&minlon=3&maxlon=10&minmag=1" | mkGeolocationTable.py > geolocationTable.js + curl -s "https://fdsnws.geophysik.ruhr-uni-bochum.de/fdsnws/event/1/query?minlat=50&maxlat=54&minlon=3&maxlon=10&minmag=1" | mkGeolocationTable.py > geolocationTable.js License Copyright 2020 Kasper D. Fischer @@ -135,18 +135,15 @@ def mkGeolocationTable(file=''): warnings.warn('Request {0} failed'.format(url)) ''' # dump json - print 'var geolocationTable = '+JSON.dumps(geolocationTable, sort_keys=True)+';' + print('var geolocationTable = {0};'.format(JSON.dumps(geolocationTable, sort_keys=True))) # __main__ if __name__ == "__main__": - def printline(line): - print line - # parse arguments import argparse versionText = '$Revision$ ($Date$, $Author$)'.replace('$', '').replace(':','') parser = argparse.ArgumentParser( - description='Reverese geocoding lookup of events in xml format (stdin).', + description='Reverse geocoding lookup of events in xml format (stdin).', epilog=versionText) parser.add_argument('-v', '-V', '--version', action='version', version=versionText) From 9167804f1e02330fcfef18bf2dc8c2581ead8d1e Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Sat, 16 Oct 2021 15:53:15 +0200 Subject: [PATCH 11/15] make reverse geolocation lookup more stableand removed unused modules --- scripts/mkGeolocationTable.py | 67 ++++++++++------------------------- 1 file changed, 19 insertions(+), 48 deletions(-) diff --git a/scripts/mkGeolocationTable.py b/scripts/mkGeolocationTable.py index 7ab80c2..e63130b 100755 --- a/scripts/mkGeolocationTable.py +++ b/scripts/mkGeolocationTable.py @@ -39,12 +39,13 @@ def mkGeolocationTable(file=''): import xml.etree.ElementTree as ET from sys import stdin import warnings - from time import sleep from geopy.geocoders import Photon - import urllib2 as URL + from geopy.extra.rate_limiter import RateLimiter + from geopy.exc import GeocoderServiceError import json as JSON # constants + url = 'https://photon.komoot.io/reverse?lon={lng:.3f}&lat={lat:.3f}' namespaces = {'sc3': 'http://geofon.gfz-potsdam.de/ns/seiscomp3-schema/0.7', 'qml': 'http://quakeml.org/xmlns/bed/1.2'} @@ -66,12 +67,13 @@ def mkGeolocationTable(file=''): # parse event.xml DOM = ET.parse(stdin).getroot() geolocator = Photon() + reverse_geolocate = RateLimiter(geolocator.reverse, min_delay_seconds=1) # iterate over all events for event in DOM.iterfind('qml:eventParameters/qml:event', namespaces): publicID = event.attrib['publicID'].split('/')[2] - lat = event.find('./qml:origin/qml:latitude/qml:value', namespaces).text - lng = event.find('./qml:origin/qml:longitude/qml:value', namespaces).text + lat = float(event.find('./qml:origin/qml:latitude/qml:value', namespaces).text) + lng = float(event.find('./qml:origin/qml:longitude/qml:value', namespaces).text) evaluationMode = event.find('./qml:origin/qml:evaluationMode', namespaces).text if publicID in geolocationTable: @@ -80,60 +82,29 @@ def mkGeolocationTable(file=''): warnings.warn('Skipping automatic event %s' %(publicID)) else: try: - location = geolocator.reverse("{lat}, {lng}".format(lat=lat, lng=lng)) - except: + locations = reverse_geolocate("{lat:.3f}, {lng:.3f}".format(lat=lat, lng=lng),exactly_one=False,limit=5) + except GeocoderServiceError: warnings.warn('Reverse Geolocation failed. Skipping event.') continue place = [] - try: - place = location.raw['properties']['city'] - except KeyError: + for location in locations: try: - place = location.raw['properties']['town'] + place = location.raw['properties']['city'] except KeyError: try: - place = location.raw['properties']['village'] + place = location.raw['properties']['town'] except KeyError: try: - place = location.raw['properties']['county'] + place = location.raw['properties']['village'] except KeyError: - warnings.warn('Could not extract city for event {0} at {1} N / {2} E (URL: {3})'.format(publicID, lat, lng, url)) - geolocationTable[publicID] = place - sleep(1.1) - - ''' - #warnings.warn('Processing event %s' %publicID) - # send and evaluate nominatim request - url = 'https://open.mapquestapi.com/nominatim/v1/reverse.php?key=oE512xGQxeH1n2cueacJ6xzRv7qFlCib&lat={0}&lon={1}&zoom=10&format=json'.format(lat, lng) - response = URL.urlopen(url) - if ( response.msg == 'OK' ): - data = JSON.loads(response.read()) - city = [] - try: - try: - city = data['address']['city'] - except: - warnings.warn('Request {3} for event {0} at {1} N / {2} E did not provide city attribute\n\t(Response: {4})'.format(publicID, lat, lng, url, data)) - try: - city = data['address']['town'] - warnings.warn('Using attribute town ({1}) for event {0}'.format(publicID, city)) - except: try: - city = data['address']['county'] - warnings.warn('Using attribute county ({1}) for event {0}'.format(publicID, city)) - except: - warnings.warn('Skipping event') - continue - countryCode = data['address']['country_code'].upper() - if ( countryCode == 'DE' ): - geolocationTable[publicID] = city.encode('utf-8') - else: - geolocationTable[publicID] = '{0} ({1})'.format(city.encode('utf-8'), countryCode) - except: - warnings.warn('Could not extract city for event {0} at {1} N / {2} E (URL: {3})'.format(publicID, lat, lng, url)) - else: - warnings.warn('Request {0} failed'.format(url)) - ''' + place = location.raw['properties']['county'] + except KeyError: + pass + if not place: + warnings.warn('Could not extract city for event {id} at {lat:.3f} N / {lng:.3f} E (Service: {url})'.format(id=publicID, lat=lat, lng=lng, url=url.format(lat=lat,lng=lng))) + geolocationTable[publicID] = place + # dump json print('var geolocationTable = {0};'.format(JSON.dumps(geolocationTable, sort_keys=True))) From 7fd109b3ea685acdd5d25e908da98aecef32e693 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Sat, 16 Oct 2021 15:55:02 +0200 Subject: [PATCH 12/15] update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 6acdd86..b45e439 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,5 @@ www/geolocationTable.js www/stations.xml www/index.html www/favicon.ico +scripts/*.json +scripts/*.xml From dc1df224cc21db6b879d1df716e215e7027c4ccb Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Sat, 16 Oct 2021 19:27:16 +0200 Subject: [PATCH 13/15] use module logging instead of warning for messages --- scripts/mkGeolocationTable.py | 81 ++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 26 deletions(-) diff --git a/scripts/mkGeolocationTable.py b/scripts/mkGeolocationTable.py index e63130b..2e8e8c3 100755 --- a/scripts/mkGeolocationTable.py +++ b/scripts/mkGeolocationTable.py @@ -13,7 +13,7 @@ curl -s "https://fdsnws.geophysik.ruhr-uni-bochum.de/fdsnws/event/1/query?minlat=50&maxlat=54&minlon=3&maxlon=10&minmag=1" | mkGeolocationTable.py > geolocationTable.js License - Copyright 2020 Kasper D. Fischer + Copyright 2020-2021 Kasper D. 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 @@ -27,32 +27,33 @@ 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$ ''' def mkGeolocationTable(file=''): - # imports + ## imports + + # XML ElementTree try: import xml.etree.cElementTree as ET except ImportError: import xml.etree.ElementTree as ET + + # json + import json as JSON + + # sys stdin from sys import stdin - import warnings + + # geopy from geopy.geocoders import Photon from geopy.extra.rate_limiter import RateLimiter from geopy.exc import GeocoderServiceError - import json as JSON - # constants - url = 'https://photon.komoot.io/reverse?lon={lng:.3f}&lat={lat:.3f}' - namespaces = {'sc3': 'http://geofon.gfz-potsdam.de/ns/seiscomp3-schema/0.7', + ## constants + URL = 'https://photon.komoot.io/reverse?lon={lng:.3f}&lat={lat:.3f}&limit=5' + NAMESPACES = {'sc3': 'http://geofon.gfz-potsdam.de/ns/seiscomp3-schema/0.7', 'qml': 'http://quakeml.org/xmlns/bed/1.2'} - def simple_warning(message, category, filename, lineno, file=None, line=None): - return 'Warning: %s\n' % (message) - warnings.formatwarning = simple_warning - # try loading the file geolocationTable = {} if file : @@ -62,7 +63,7 @@ def mkGeolocationTable(file=''): geolocationTable = JSON.loads(jsonfileContent) except: geolocationTable = {} - warnings.warn('Could not parse file %s' %file) + logging.warning('Could not parse file %s' %file) # parse event.xml DOM = ET.parse(stdin).getroot() @@ -70,21 +71,24 @@ def mkGeolocationTable(file=''): reverse_geolocate = RateLimiter(geolocator.reverse, min_delay_seconds=1) # iterate over all events - for event in DOM.iterfind('qml:eventParameters/qml:event', namespaces): + count = 0 + for event in DOM.iterfind('qml:eventParameters/qml:event', NAMESPACES): + count += 1 publicID = event.attrib['publicID'].split('/')[2] - lat = float(event.find('./qml:origin/qml:latitude/qml:value', namespaces).text) - lng = float(event.find('./qml:origin/qml:longitude/qml:value', namespaces).text) - evaluationMode = event.find('./qml:origin/qml:evaluationMode', namespaces).text + lat = float(event.find('./qml:origin/qml:latitude/qml:value', NAMESPACES).text) + lng = float(event.find('./qml:origin/qml:longitude/qml:value', NAMESPACES).text) + evaluationMode = event.find('./qml:origin/qml:evaluationMode', NAMESPACES).text if publicID in geolocationTable: - warnings.warn('Skipping cached event %s' %(publicID)) + logging.warning('Skipping cached event {id}'.format(id=publicID)) elif evaluationMode == 'automatic': - warnings.warn('Skipping automatic event %s' %(publicID)) + logging.warning('Skipping automatic event {id}'.format(id=publicID)) else: + logging.info('Processing event {id}'.format(id=publicID)) try: locations = reverse_geolocate("{lat:.3f}, {lng:.3f}".format(lat=lat, lng=lng),exactly_one=False,limit=5) except GeocoderServiceError: - warnings.warn('Reverse Geolocation failed. Skipping event.') + logging.warning('Reverse Geolocation failed. Skipping event.') continue place = [] for location in locations: @@ -100,27 +104,52 @@ def mkGeolocationTable(file=''): try: place = location.raw['properties']['county'] except KeyError: - pass + logging.debug('Could not extract city for event {id} at {lat:.3f} N / {lng:.3f} E (Service: {url}), trying next returned result' + .format(id=publicID, lat=lat, lng=lng, url=URL.format(lat=lat,lng=lng))) + logging.debug(location.raw) if not place: - warnings.warn('Could not extract city for event {id} at {lat:.3f} N / {lng:.3f} E (Service: {url})'.format(id=publicID, lat=lat, lng=lng, url=url.format(lat=lat,lng=lng))) + logging.critical('Could not extract city for event {id} at {lat:.3f} N / {lng:.3f} E (Service: {url})' + .format(id=publicID, lat=lat, lng=lng, url=URL.format(lat=lat,lng=lng))) geolocationTable[publicID] = place # dump json print('var geolocationTable = {0};'.format(JSON.dumps(geolocationTable, sort_keys=True))) + logging.info("processed %d events", count) # __main__ if __name__ == "__main__": + # use module logging + import logging + # parse arguments import argparse - versionText = '$Revision$ ($Date$, $Author$)'.replace('$', '').replace(':','') + versionText = 'v0.1 (2021-10-16)' parser = argparse.ArgumentParser( description='Reverse geocoding lookup of events in xml format (stdin).', epilog=versionText) - parser.add_argument('-v', '-V', '--version', action='version', - version=versionText) + parser.add_argument('-V', '--version', action='version', version=versionText, + help="show version") parser.add_argument('-f', '--file', action='store', dest='file', help='read in JSON file containing old output.') + group = parser.add_mutually_exclusive_group() + group.add_argument("-v", "--verbose", action="store_true", + help="increase output verbosity") + group.add_argument("-q", "--quiet", action="store_true", + help="disable output") + group.add_argument("-d", "--debug", action="store_true", + help="show debugging output", + ) cla = parser.parse_args() + # set logging level + if cla.quiet: + logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.ERROR) + elif cla.verbose: + logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO) + elif cla.debug: + logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG) + else: + logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.WARN) + # call mkGeolocationTable(...) mkGeolocationTable(file=cla.file) From 938452b89892c034bfa3b56c5103503031b771e9 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Sun, 17 Oct 2021 13:07:26 +0200 Subject: [PATCH 14/15] renamed mkEvents.csh to fetchEvents.sh, set default values default values: * starttime ($1): 6 month ago if date / gdate works, today otherwise * output file ($2): stdout --- scripts/fetchEvents.sh | 14 ++++++++++++++ scripts/mkEvents.csh | 4 ---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100755 scripts/fetchEvents.sh delete mode 100755 scripts/mkEvents.csh diff --git a/scripts/fetchEvents.sh b/scripts/fetchEvents.sh new file mode 100755 index 0000000..0848b87 --- /dev/null +++ b/scripts/fetchEvents.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# get starting date +# find gdate or date command ( OSX: brew install coreutils) +# the date command on OSX is not compatible to the linux date command +datecmd=$((which gdate || which date )| grep bin) +STIME="${1:-$(${datecmd} -d 6-month-ago +%Y-%m-%d)}" +STIME="${STIME:-$(date +%Y-%m-%d)}" + +# get output filename +OUTPUT="${2:--}" + +# fetch events +curl -s -o ${OUTPUT} "https://fdsnws.geophysik.ruhr-uni-bochum.de/fdsnws/event/1/query?starttime=${STIME}&minlat=50.0&maxlat=53.0&minlon=4.0&maxlon=10.0&minmag=0.7" diff --git a/scripts/mkEvents.csh b/scripts/mkEvents.csh deleted file mode 100755 index 46f6cd4..0000000 --- a/scripts/mkEvents.csh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -STIME=$1 -curl -o events.xml "https://ariadne.geophysik.ruhr-uni-bochum.de/fdsnws/event/1/query?starttime=${STIME}&orderby=time&minlat=50.92&maxlat=52.76&minlon=4.26&maxlon=9.74&minmag=1.1" From a23019b50f8d5c840e3e93e384caba3e27f89a28 Mon Sep 17 00:00:00 2001 From: "Kasper D. Fischer" Date: Sun, 17 Oct 2021 13:28:19 +0200 Subject: [PATCH 15/15] updated version strings for release r20211017 --- scripts/mkGeolocationTable.py | 2 +- www/events.js | 4 ++-- www/events.js.en | 4 ++-- www/map.js | 4 ++-- www/map.js.en | 4 ++-- www/misc.js | 4 ++-- www/stations.js | 4 ++-- www/stations.js.en | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/mkGeolocationTable.py b/scripts/mkGeolocationTable.py index 2e8e8c3..a0a1d3f 100755 --- a/scripts/mkGeolocationTable.py +++ b/scripts/mkGeolocationTable.py @@ -123,7 +123,7 @@ if __name__ == "__main__": # parse arguments import argparse - versionText = 'v0.1 (2021-10-16)' + versionText = 'r20211017 (2021-10-17)' parser = argparse.ArgumentParser( description='Reverse geocoding lookup of events in xml format (stdin).', epilog=versionText) diff --git a/www/events.js b/www/events.js index a830721..6645b6a 100644 --- a/www/events.js +++ b/www/events.js @@ -4,7 +4,7 @@ **********************************************************************/ /* License - Copyright 2020 Kasper D. Fischer + Copyright 2020-2021 Kasper D. 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 @@ -19,7 +19,7 @@ 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$ + Version r20211017 (2021-10-17) */ /* adding row(s) to a table and format date strings afterwards */ diff --git a/www/events.js.en b/www/events.js.en index 4793bb6..e05c575 100644 --- a/www/events.js.en +++ b/www/events.js.en @@ -4,7 +4,7 @@ **********************************************************************/ /* License - Copyright 2020 Kasper D. Fischer + Copyright 2020-2021 Kasper D. 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 @@ -19,7 +19,7 @@ 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$ + Version r20211017 (2021-10-17) */ /* adding row(s) to a table and format date strings afterwards */ diff --git a/www/map.js b/www/map.js index 64cb34d..d277ea4 100644 --- a/www/map.js +++ b/www/map.js @@ -4,7 +4,7 @@ **********************************************************************/ /* License - Copyright 2020 Kasper D. Fischer + Copyright 2020-2021 Kasper D. 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 @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/. - $Id$ + Version r20211017 (2021-10-17) */ /* add station marker */ diff --git a/www/map.js.en b/www/map.js.en index d1e6ca3..bd11add 100644 --- a/www/map.js.en +++ b/www/map.js.en @@ -4,7 +4,7 @@ **********************************************************************/ /* License - Copyright 2020 Kasper D. Fischer + Copyright 2020-2021 Kasper D. 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 @@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/. - $Id$ + Version r20211017 (2021-10-17) */ /* add station marker */ diff --git a/www/misc.js b/www/misc.js index 5fc1533..7a0922a 100644 --- a/www/misc.js +++ b/www/misc.js @@ -4,7 +4,7 @@ **********************************************************************/ /* License - Copyright 2020 Kasper D. Fischer + Copyright 2020-2021 Kasper D. 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 @@ -19,7 +19,7 @@ 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$ + Version r20211017 (2021-10-17) */ /* calculate marker radius from magnitude diff --git a/www/stations.js b/www/stations.js index 92876bd..65463ca 100644 --- a/www/stations.js +++ b/www/stations.js @@ -4,7 +4,7 @@ **********************************************************************/ /* License - Copyright 2020 Kasper D. Fischer + Copyright 2020-2021 Kasper D. 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 @@ -19,7 +19,7 @@ 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$ + Version r20211017 (2021-10-17) */ /* Load the stations using ajax */ diff --git a/www/stations.js.en b/www/stations.js.en index f185b3f..413207f 100644 --- a/www/stations.js.en +++ b/www/stations.js.en @@ -4,7 +4,7 @@ **********************************************************************/ /* License - Copyright 2020 Kasper D. Fischer + Copyright 2020-2021 Kasper D. 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 @@ -19,7 +19,7 @@ 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$ + Version r20211017 (2021-10-17) */ /* Load the stations using ajax */