From 73a837e6f52cb4180391effcd97039ea9623197b Mon Sep 17 00:00:00 2001 From: dieghernan Date: Sun, 25 Oct 2020 14:10:24 +0100 Subject: [PATCH] v1.10 --- CHANGELOG.md | 44 +- dev/leaflet-providersESP.js | 4 +- dist/leaflet-providersESP.js | 847 ++++++++++++++++++----------------- 3 files changed, 480 insertions(+), 415 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73d230b..e94e7ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,35 @@ +# v1.1.0 - *2020-10-25* + +## Added + +- `Hidrografia`: `Cuencas,Subcuencas` +- `Militar`: `CEGETM682, CECAF1M` +- `ADIF` +- `Copernicus` +- `Parques Naturales` +- `LimitesMaritimos` + +## Changed + +- Refactor of code +- `LPESP_composenames` renamed to `providerOpts` +- Strict mode added, global scope +- Attributions simplified + +## Removed + +NA + +## Fixed + +NA + +### Checks + +- [x] Bump version on script +- [x] Beautify +- [x] Lint + # v1.0.0 - *2020-10-23* @@ -29,24 +61,12 @@ NA ## Added -- `Hidrografia`: `Cuencas,Subcuencas` -- `Militar`: `CEGETM682, CECAF1M` -- `ADIF` -- `Copernicus` -- `Parques Naturales` -- `LimitesMaritimos` ## Changed -- Refactor of code -- `LPESP_composenames` renamed to `providerOpts` -- Strict mode added, global scope -- Attributions simplified ## Removed -NA ## Fixed -NA diff --git a/dev/leaflet-providersESP.js b/dev/leaflet-providersESP.js index 4bd1333..078b117 100644 --- a/dev/leaflet-providersESP.js +++ b/dev/leaflet-providersESP.js @@ -1,4 +1,4 @@ -// leaflet-providersESP.js plugin v1.0.1-dev2 +// leaflet-providersESP.js plugin v1.1.0 // (c) D. Hernangomez - MIT License // https://dieghernan.github.io/leaflet-providersESP/ // Issues: https://dieghernan.github.io/leaflet-providersESP/issues @@ -449,4 +449,4 @@ L.tileLayer.providerESP = function (name, opts) { } else { return L.tileLayer.wms(newprov.url, newprov.options); } -} +} \ No newline at end of file diff --git a/dist/leaflet-providersESP.js b/dist/leaflet-providersESP.js index 3a0d0f0..078b117 100644 --- a/dist/leaflet-providersESP.js +++ b/dist/leaflet-providersESP.js @@ -1,407 +1,452 @@ - -/* - leaflet-providersESP.js plugin v1.0.0 - (c) D. Hernangomez - MIT License - https://dieghernan.github.io/leaflet-providersESP/ - Issues: https://dieghernan.github.io/leaflet-providersESP/issues - All providers are open source. Please check attributions - Feel free to contribute */ - -var providersESPversion = 'v1.0.0'; +// leaflet-providersESP.js plugin v1.1.0 +// (c) D. Hernangomez - MIT License +// https://dieghernan.github.io/leaflet-providersESP/ +// Issues: https://dieghernan.github.io/leaflet-providersESP/issues +// All providers are open source. Please check attributions +// Feel free to contribute +"use strict"; +var providersESPversion = 'v1.0.1-dev2'; // Databases // WMTS Servers - Tile Maps - Mapas de Teselas +var completeWMTS = "&style=default&tilematrixset=GoogleMapsCompatible&TileMatrix={z}&TileRow={y}&TileCol={x}"; var providersESP = { - IDErioja: { - url: 'https://rts.larioja.org/wmts/mapa_base_rioja?service=WMTS&request=GetTile&version=1.0.0&Format=image/png&layer=mapa_base_rioja&style=default&tilematrixset=GoogleMapsCompatible&TileMatrix={z}&TileRow={y}&TileCol={x}', - options: { - attribution: 'CC BY 4.0 www.iderioja.org' - } - }, - // IGN Mapa Base - IGNBase: { - url: 'https://www.ign.es/wmts/ign-base?service=WMTS&request=GetTile&version=1.0.0&Format=image/{ext}&layer={variant}&style=default&tilematrixset=GoogleMapsCompatible&TileMatrix={z}&TileRow={y}&TileCol={x}', - options: { - attribution: 'CC BY 4.0 scne.es. Sistema Geográfico Nacional IGN ', - variant: 'IGNBaseTodo', - ext: 'png' - }, - variants: { - Todo: 'IGNBaseTodo', - Gris: { - options: { - variant: 'IGNBase-gris', - ext: 'jpeg' - } - }, - TodoNoFondo: { - options: { - variant: 'IGNBaseTodo-nofondo', - bounds: [ - [27, -19], - [44, 5] - ], - minZoom: 4, - } - }, - Orto: { - options: { - variant: 'IGNBaseOrto', - bounds: [ - [27, -19], - [44, 5] - ], - minZoom: 5, - } - } - } - }, - // MDT - MDT: { - url: 'https://servicios.idee.es/wmts/mdt?service=WMTS&request=GetTile&version=1.0.0&Format=image/png&layer={variant}&style=default&tilematrixset=GoogleMapsCompatible&TileMatrix={z}&TileRow={y}&TileCol={x}', - options: { - attribution: 'Infraestructura de Datos Espaciales de España (IDEE)', - variant: 'EL.GridCoverage', - bounds: [ - [22.173559281306314, - - 47.0716243806546 - ], - [66.88067635831743, - 40.8749629405498 - ] - ] - }, - variants: { - Elevaciones: {}, - Relieve: 'Relieve', - CurvasNivel: { - url: 'http://www.ign.es/wms-inspire/mdt?', - options: { - layers: 'EL.ContourLine', - transparent: true, - format: 'image/png', - minZoom: 12 - } - } - } - }, - // Mapa Topografico Nacional - MTN: { - url: 'https://ign.es/wmts/mapa-raster?service=WMTS&request=GetTile&version=1.0.0&Format=image/jpeg&layer=MTN&style=default&tilematrixset=GoogleMapsCompatible&TileMatrix={z}&TileRow={y}&TileCol={x}', - options: { - attribution: 'CC BY 4.0 ign.es', - minZoom: 4, - bounds: [ - [22.173559281306314, - - 47.0716243806546 - ], - [66.88067635831743, - 40.8749629405498 - ] - ] - } - }, - // Plan Nacional de Ortofotografia Aerea - PNOA: { - url: 'https://www.ign.es/wmts/pnoa-ma?service=WMTS&request=GetTile&version=1.0.0&Format=image/png&layer=OI.OrthoimageCoverage&style=default&tilematrixset=GoogleMapsCompatible&TileMatrix={z}&TileRow={y}&TileCol={x}', - options: { - attribution: 'CC BY 4.0 scne.es. Infraestructura de Datos Espaciales de España (IDEE)', - minZoom: 4, - bounds: [ - [22.173559281306314, - - 47.0716243806546 - ], - [66.88067635831743, - 40.8749629405498 - ] - ] - } - }, - // Ocupacion Suelo - OcupacionSuelo: { - url: 'https://servicios.idee.es/wmts/ocupacion-suelo?service=WMTS&request=GetTile&version=1.0.0&Format=image/png&layer={variant}&style=default&tilematrixset=GoogleMapsCompatible&TileMatrix={z}&TileRow={y}&TileCol={x}', - options: { - attribution: 'CC BY 4.0 scne.es. Infraestructura de Datos Espaciales de España (IDEE)', - variant: 'LC.LandCoverSurfaces', - }, - variants: { - Ocupacion: {}, - Usos: 'LU.ExistingLandUse' - } - }, - // Light Detection and Ranging - LiDAR - LiDAR: { - url: 'https://wmts-mapa-lidar.idee.es/lidar?service=WMTS&request=GetTile&version=1.0.0&Format=image/png&layer={variant}&style=default&tilematrixset=GoogleMapsCompatible&TileMatrix={z}&TileRow={y}&TileCol={x}', - options: { - attribution: 'CC BY 4.0 scne.es. Infraestructura de Datos Espaciales de España (IDEE)', - variant: 'EL.GridCoverageDSM', - } - }, - - //WMS Servers - Geofisica: { - url: 'https://www.ign.es/wms-inspire/geofisica?', - options: { - layers: 'Ultimos10dias', - format: 'image/png', - transparent: true, - attribution: 'CC BY 4.0 ign.es Instituto Geográfico Nacional' - }, - // Selected - variants: { - Terremotos10dias: {}, - Terremotos30dias: 'Ultimos30dias', - Terremotos365dias: 'Ultimos365dias', - VigilanciaVolcanica: 'VigilanciaVolcanica' - } - }, - CaminoDeSantiago: { - url: 'https://www.ign.es/wms-inspire/camino-santiago?', - options: { - layers: 'camino_frances', - format: 'image/png', - transparent: true, - attribution: 'CC BY 4.0 ign.es. Federación Española de Asociaciones de Amigos del Camino de Santiago (FEAACS)' - }, - variants: { - CaminoFrances: {}, - CaminosTuronensis: 'caminos_turonensis', - CaminosGalicia: 'caminos_galicia', - CaminosDelNorte: 'caminos_norte', - CaminosAndaluces: 'caminos_andaluces', - CaminosCentro: 'caminos_centro', - CaminosEste: 'caminos_este', - CaminosCatalanes: 'caminos_catalanes', - CaminosSureste: 'caminos_sureste', - CaminosInsulares: 'caminos_insulares', - CaminosPiemonts: 'caminos_piemonts', - CaminosTolosana: 'caminos_tolosana', - CaminosPortugueses: 'caminos_portugueses' - } - }, - Catastro: { - url: 'https://ovc.catastro.meh.es/cartografia/INSPIRE/spadgcwms.aspx', - options: { - layers: 'CP.CadastralParcel', - transparent: true, - minZoom: 15, - format: 'image/png', - attribution: 'Spanish General Directorate for Cadastre' - }, - variants: { - Catastro: { - url: 'http://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx', - options: { - layers: 'Catastro', - minZoom: 1, - transparent: false - } - }, - Parcela: { - url: 'http://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx', - options: { - layers: 'PARCELA', - minZoom: 15 - } - }, - CadastralParcel: {}, - CadastralZoning: 'CP.CadastralZoning', - Address: 'AD.Address', - Building: 'BU.Building' - } - }, - RedTransporte: { - url: 'https://servicios.idee.es/wms-inspire/transportes', - options: { - layers: 'TN.RoadTransportNetwork.RoadLink', - transparent: true, - format: 'image/png', - attribution: 'Sistema Geográfico Nacional SCNE' - }, - variants: { - // Selected, there are more, feel free to contribute - Carreteras: {}, - Ferroviario: 'TN.RailTransportNetwork.RailwayLink', - Aerodromo: 'TN.AirTransportNetwork.AerodromeArea', - AreaServicio: 'TN.RoadTransportNetwork.RoadServiceArea', - EstacionesFerroviario: 'TN.RailTransportNetwork.RailwayStationArea', - Puertos: 'TN.WaterTransportNetwork.PortArea', - } - }, - Cartociudad: { - url: 'https://www.cartociudad.es/wms-inspire/direcciones-ccpp', - options: { - attribution: 'CC BY 4.0 scne.es Cartociudad', - layers: 'codigo-postal', - transparent: true, - minZoom: 14, - format: 'image/png' - }, - variants: { - CodigosPostales: {}, - Direcciones: { - options: { - layers: 'AD.Address', - minZoom: 15 - } - } - } - }, - NombresGeograficos: { - url: 'https://www.ign.es/wms-inspire/ngbe?', - options: { - layers: 'GN.GeographicalNames', - format: 'image/png', - transparent: true, - attribution: 'Instituto Geográfico Nacional' - - } - }, - UnidadesAdm: { - url: 'https://www.ign.es/wms-inspire/unidades-administrativas?', - options: { - layers: 'AU.AdministrativeBoundary', - format: 'image/png', - transparent: true, - attribution: 'CC BY 4.0 ign.es Instituto Geográfico Nacional' - - }, - variants: { - Limites: 'AU.AdministrativeBoundary', - Unidades: 'AU.AdministrativeUnit' - } - }, - Hidrografia: { - url: 'https://servicios.idee.es/wms-inspire/hidrografia?', - options: { - layers: 'HY.PhysicalWaters.Waterbodies', - format: 'image/png', - transparent: true, - attribution: 'CC BY 4.0 scne.es SCNE' - }, - // Selected, there are more, feel free to contribute - variants: { - MasaAgua: {} - } - }, - Militar: { - url: 'http://wms-defensa.idee.es/mapas?', - options: { - layers: 'CEGET_1M', - format: 'image/png', - transparent: true, - attribution: "Centro Geográfico del Ejército de Tierra (CEGET)" - }, - variants: { - CEGET1M: {}, - CEGETM7814: 'CEGET_M7814', - CEGETM7815: 'CEGET_M7815' - } - - } + IDErioja: { + url: "https://rts.larioja.org/wmts/mapa_base_rioja?service=WMTS&request=GetTile&version=1.0.0&Format=image/png&layer=mapa_base_rioja" + completeWMTS, + options: { + attribution: "CC BY 4.0 www.iderioja.org" + } + }, + // IGN Mapa Base + IGNBase: { + url: "https://www.ign.es/wmts/ign-base?service=WMTS&request=GetTile&version=1.0.0&Format=image/{ext}&layer={variant}" + completeWMTS, + options: { + attribution: "CC BY 4.0 scne.es. Sistema Geográfico Nacional IGN ", + variant: "IGNBaseTodo", + ext: "png" + }, + variants: { + Todo: "IGNBaseTodo", + Gris: { + options: { + variant: "IGNBase-gris", + ext: "jpeg" + } + }, + TodoNoFondo: { + options: { + variant: "IGNBaseTodo-nofondo", + bounds: [ + [27, -19], + [44, 5] + ], + minZoom: 4 + } + }, + Orto: { + options: { + variant: "IGNBaseOrto", + bounds: [ + [27, -19], + [44, 5] + ], + minZoom: 5 + } + } + } + }, + // MDT + MDT: { + url: "https://servicios.idee.es/wmts/mdt?service=WMTS&request=GetTile&version=1.0.0&Format=image/png&layer={variant}" + completeWMTS, + options: { + attribution: "Infraestructura de Datos Espaciales de España (IDEE)", + variant: "EL.GridCoverage", + bounds: [ + [22.173559281306314, -47.0716243806546], + [66.88067635831743, + 40.8749629405498 + ] + ] + }, + variants: { + Elevaciones: {}, + Relieve: "Relieve", + CurvasNivel: { + url: "http://www.ign.es/wms-inspire/mdt?", + options: { + layers: "EL.ContourLine", + transparent: true, + format: "image/png", + minZoom: 12 + } + } + } + }, + // Mapa Topografico Nacional + MTN: { + url: "https://ign.es/wmts/mapa-raster?service=WMTS&request=GetTile&version=1.0.0&Format=image/jpeg&layer=MTN&style=default" + completeWMTS, + options: { + attribution: "{attribution.MDT}", + minZoom: 4, + bounds: [ + [22.173559281306314, -47.0716243806546], + [66.88067635831743, + 40.8749629405498 + ] + ] + } + }, + // Plan Nacional de Ortofotografia Aerea + PNOA: { + url: "https://www.ign.es/wmts/pnoa-ma?service=WMTS&request=GetTile&version=1.0.0&Format=image/png&layer=OI.OrthoimageCoverage" + completeWMTS, + options: { + attribution: "{attribution.MDT}", + minZoom: 4, + bounds: [ + [22.173559281306314, -47.0716243806546], + [66.88067635831743, + 40.8749629405498 + ] + ] + } + }, + // Ocupacion Suelo + OcupacionSuelo: { + url: "https://servicios.idee.es/wmts/ocupacion-suelo?service=WMTS&request=GetTile&version=1.0.0&Format=image/png&layer={variant}&style=default" + completeWMTS, + options: { + attribution: "CC BY 4.0 scne.es. Infraestructura de Datos Espaciales de España (IDEE)", + variant: "LC.LandCoverSurfaces" + }, + variants: { + Ocupacion: {}, + Usos: "LU.ExistingLandUse" + } + }, + // Light Detection and Ranging - LiDAR + LiDAR: { + url: "https://wmts-mapa-lidar.idee.es/lidar?service=WMTS&request=GetTile&version=1.0.0&Format=image/png&layer={variant}" + completeWMTS, + options: { + attribution: "{attribution.MDT}", + variant: "EL.GridCoverageDSM" + } + }, + //WMS Servers + Geofisica: { + url: "https://www.ign.es/wms-inspire/geofisica?", + options: { + layers: "Ultimos10dias", + format: "image/png", + transparent: true, + attribution: "{attribution.IGNBase}" + }, + // Selected + variants: { + Terremotos10dias: {}, + Terremotos30dias: "Ultimos30dias", + Terremotos365dias: "Ultimos365dias", + VigilanciaVolcanica: "VigilanciaVolcanica" + } + }, + CaminoDeSantiago: { + url: "https://www.ign.es/wms-inspire/camino-santiago?", + options: { + layers: "camino_frances", + format: "image/png", + transparent: true, + attribution: "CC BY 4.0 ign.es. Federación Española de Asociaciones de Amigos del Camino de Santiago (FEAACS)" + }, + variants: { + CaminoFrances: {}, + CaminosTuronensis: "caminos_turonensis", + CaminosGalicia: "caminos_galicia", + CaminosDelNorte: "caminos_norte", + CaminosAndaluces: "caminos_andaluces", + CaminosCentro: "caminos_centro", + CaminosEste: "caminos_este", + CaminosCatalanes: "caminos_catalanes", + CaminosSureste: "caminos_sureste", + CaminosInsulares: "caminos_insulares", + CaminosPiemonts: "caminos_piemonts", + CaminosTolosana: "caminos_tolosana", + CaminosPortugueses: "caminos_portugueses" + } + }, + Catastro: { + url: "https://ovc.catastro.meh.es/cartografia/INSPIRE/spadgcwms.aspx", + options: { + layers: "CP.CadastralParcel", + transparent: true, + minZoom: 15, + format: "image/png", + attribution: "Spanish General Directorate for Cadastre" + }, + variants: { + Catastro: { + url: "http://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx", + options: { + layers: "Catastro", + minZoom: 1, + transparent: false + } + }, + Parcela: { + url: "http://ovc.catastro.meh.es/Cartografia/WMS/ServidorWMS.aspx", + options: { + layers: "PARCELA", + minZoom: 15 + } + }, + CadastralParcel: {}, + CadastralZoning: "CP.CadastralZoning", + Address: "AD.Address", + Building: "BU.Building" + } + }, + RedTransporte: { + url: "https://servicios.idee.es/wms-inspire/transportes", + options: { + layers: "TN.RoadTransportNetwork.RoadLink", + transparent: true, + format: "image/png", + attribution: "Sistema Geográfico Nacional SCNE" + }, + variants: { + // Selected, there are more, feel free to contribute + Carreteras: {}, + Ferroviario: "TN.RailTransportNetwork.RailwayLink", + Aerodromo: "TN.AirTransportNetwork.AerodromeArea", + AreaServicio: "TN.RoadTransportNetwork.RoadServiceArea", + EstacionesFerroviario: "TN.RailTransportNetwork.RailwayStationArea", + Puertos: "TN.WaterTransportNetwork.PortArea" + } + }, + Cartociudad: { + url: "https://www.cartociudad.es/wms-inspire/direcciones-ccpp", + options: { + attribution: "CC BY 4.0 scne.es Cartociudad", + layers: "codigo-postal", + transparent: true, + minZoom: 14, + format: "image/png" + }, + variants: { + CodigosPostales: {}, + Direcciones: { + options: { + layers: "AD.Address", + minZoom: 15 + } + } + } + }, + NombresGeograficos: { + url: "https://www.ign.es/wms-inspire/ngbe?", + options: { + layers: "GN.GeographicalNames", + format: "image/png", + transparent: true, + attribution: "{attribution.IGNBase}", + minZoom: 6 + } + }, + UnidadesAdm: { + url: "https://www.ign.es/wms-inspire/unidades-administrativas?", + options: { + layers: "AU.AdministrativeBoundary", + format: "image/png", + transparent: true, + attribution: "{attribution.IGNBase}" + }, + variants: { + Limites: "AU.AdministrativeBoundary", + Unidades: "AU.AdministrativeUnit" + } + }, + Hidrografia: { + url: "https://servicios.idee.es/wms-inspire/hidrografia?", + options: { + layers: "HY.PhysicalWaters.Waterbodies", + format: "image/png", + transparent: true, + attribution: "CC BY 4.0 scne.es SCNE" + }, + // Selected, there are more, feel free to contribute + variants: { + MasaAgua: {}, + Cuencas: { + url: "https://wms.mapama.gob.es/sig/Agua/CuencasCauces/wms.aspx?", + options: { + attribution: "Ministerio para la Transición Ecológica y el Reto Demográfico", + layers: "HY.PhysicalWaters.Catchments" + } + }, + Subcuencas: { + url: "https://wms.mapama.gob.es/sig/Agua/SubcuencasCauces/wms.aspx?", + options: { + attribution: "Ministerio para la Transición Ecológica y el Reto Demográfico", + layers: "HY.PhysicalWaters.Catchments" + } + } + } + }, + Militar: { + url: "http://wms-defensa.idee.es/mapas?", + options: { + layers: "CEGET_1M", + format: "image/png", + transparent: true, + attribution: "Centro Geográfico del Ejército de Tierra (CEGET)" + }, + variants: { + CEGET1M: {}, + CEGETM7814: "CEGET_M7814", + CEGETM7815: "CEGET_M7815", + CEGETM682: "ceget_M682", + CECAF1M: "cecaf_cnv_1M" + } + }, + ADIF: { + url: "http://ideadif.adif.es/services/wms?", + options: { + layers: "TN.RailTransportNetwork.RailwayLink", + format: "image/png", + transparent: true, + attribution: "© ADIF" + }, + variants: { + Vias: {}, + Nodos: "TN.RailTransportNetwork.RailwayNode", + Estaciones: "TN.RailTransportNetwork.RailwayStationNode" + } + }, + LimitesMaritimos: { + url: "http://ideihm.covam.es/ihm-inspire/wms-unidadesmaritimas?", + options: { + layers: "AU.MaritimeBoundary", + format: "image/png", + transparent: true, + attribution: "© Instituto Hidrográfico de la Marina" + }, + variants: { + LimitesMaritimos: {}, + LineasBase: "AU.Baseline" + } + }, + Copernicus: { + url: "https://servicios.idee.es/wms/copernicus-landservice-spain?", + options: { + layers: "CoperPanEuropean", + format: "image/png", + transparent: true, + attribution: "{attribution.IGNBase}" + }, + variants: { + LandCover: {}, + Forest: "HRLForestTCD2015", + ForestLeaf: "HRLForestDLT2015", + WaterWet: "HRLWaterWetT2015", + SoilSeal: "HRLImpervioDens2015", + GrassLand: "HRLGrassLand2015", + Local: "Local", + RiparianGreen: "Copernicus_RZ_GLE", + RiparianLandCover: "Copernicus_RZ_LCLU", + Natura2k: "N2k_LCLU_2012", + UrbanAtlas: { + options: { + layers: "Urban_Atlas_2012", + minZoom: 8 + } + } + } + }, + ParquesNaturales: { + url: "http://sigred.oapn.es/geoserver/LimitesParquesNacionalesZPP/wms?", + options: { + layers: "view_red_oapn_limite_pn", + format: "image/png", + transparent: true, + attribution: "Ministerio para la Transición Ecológica y el Reto Demográfico" + }, + variants: { + Limites: {}, + ZonasPerifericas: "view_red_oapn_zpp" + } + } }; - -// Adapted from https://github.com/leaflet-extras/leaflet-providers +// Adapted from https://github.com/leaflet-extras/leaflet-providers // Copyright (c) 2013 Leaflet Providers contributors All rights reserved. // BSD 2-Clause "Simplified" License - function LPESP_composenames (arg, - options) { - var providers = providersESP; - 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 - }; - if (variantName){ - provider.options.providerName = providerName+'.'+variantName; - } else { - provider.options.providerName = providerName; - } - - // 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]; - //Guess WMS or WMTS - var finalurl = variant.url || - provider.url; - //According to template Tiles uses {x} while WMS not. - var wmts = finalurl.includes("{x}"); - - var variantOptions; - if (typeof variant === 'string') { - // Depending on WMTS or Tiles - if (wmts) { - variantOptions = { - variant: variant - }; - } else { - variantOptions = { - layers: 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 - function attributionReplacer (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); - var providerend = { - url: provider.url, - options: layerOpts - }; - return providerend; - -}; -L.tileLayer.providerESP = function ( - name, opts) { - var newprov = LPESP_composenames(name, - opts); - var nameurl = newprov.url; - if (nameurl.includes("{x}")) { - return L.tileLayer(newprov.url, - newprov.options); - } else { - return L.tileLayer.wms(newprov.url, - newprov.options); - } -}; \ No newline at end of file +function providerOpts(arg, options) { + var providers = providersESP; + 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 + }; + if (variantName) { + provider.options.providerName = providerName + '.' + variantName; + } else { + provider.options.providerName = providerName; + } + // 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]; + //Guess WMS or WMTS + var finalurl = variant.url || provider.url; + //According to template Tiles uses {x} while WMS not. + var wmts = finalurl.includes("{x}"); + var variantOptions; + if (typeof variant === 'string') { + // Depending on WMTS or Tiles + if (wmts) { + variantOptions = { + variant: variant + }; + } else { + variantOptions = { + layers: 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 + function attributionReplacer(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); + var providerend = { + url: provider.url, + options: layerOpts + }; + return providerend; +} +L.tileLayer.providerESP = function (name, opts) { + var newprov = providerOpts(name, opts); + var nameurl = newprov.url; + if (nameurl.includes("{x}")) { + return L.tileLayer(newprov.url, newprov.options); + } else { + return L.tileLayer.wms(newprov.url, newprov.options); + } +} \ No newline at end of file