From 2a608d15930b5dcc49540f330aab0d781a683577 Mon Sep 17 00:00:00 2001 From: Joachim Ungar Date: Wed, 11 Sep 2024 07:57:54 +0200 Subject: [PATCH 1/3] fixed deprecated WMTS endpoints and added recent S2Cloudless versions --- mapchete/static/index.html | 46 +++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/mapchete/static/index.html b/mapchete/static/index.html index b836fa03..07c64a39 100644 --- a/mapchete/static/index.html +++ b/mapchete/static/index.html @@ -65,7 +65,7 @@ // Terrain light var options = extend(defaults, { - url: "https://s2maps-tiles.eu/wmts/", + url: "https://tiles.maps.eox.at/wmts/", name: "EOX::Maps Terrain Light", {% if is_mercator %} layer: 'terrain-light_3857', @@ -78,9 +78,39 @@ var terrain_light_wmts_layer = new OpenLayers.Layer.WMTS(options); map.addLayer(terrain_light_wmts_layer); + // Sentinel-2 Cloudless 2023 + var options = extend(defaults, { + url: "https://tiles.maps.eox.at/wmts/", + name: "Sentinel-2 Cloudless 2023", + {% if is_mercator %} + layer: 's2cloudless-2023_3857', + {% else %} + layer: 's2cloudless-2023', + {% endif %} + format: 'image/jpeg', + isBaseLayer: true, + }); + var s2cloudless2023_wmts_layer = new OpenLayers.Layer.WMTS(options); + map.addLayer(s2cloudless2023_wmts_layer); + + // Sentinel-2 Cloudless 2022 + var options = extend(defaults, { + url: "https://tiles.maps.eox.at/wmts/", + name: "Sentinel-2 Cloudless 2022", + {% if is_mercator %} + layer: 's2cloudless-2022_3857', + {% else %} + layer: 's2cloudless-2022', + {% endif %} + format: 'image/jpeg', + isBaseLayer: true, + }); + var s2cloudless2022_wmts_layer = new OpenLayers.Layer.WMTS(options); + map.addLayer(s2cloudless2022_wmts_layer); + // Sentinel-2 Cloudless 2021 var options = extend(defaults, { - url: "https://s2maps-tiles.eu/wmts/", + url: "https://tiles.maps.eox.at/wmts/", name: "Sentinel-2 Cloudless 2021", {% if is_mercator %} layer: 's2cloudless-2021_3857', @@ -95,7 +125,7 @@ // Sentinel-2 Cloudless 2020 var options = extend(defaults, { - url: "https://s2maps-tiles.eu/wmts/", + url: "https://tiles.maps.eox.at/wmts/", name: "Sentinel-2 Cloudless 2020", {% if is_mercator %} layer: 's2cloudless-2020_3857', @@ -110,7 +140,7 @@ // Sentinel-2 Cloudless 2019 var options = extend(defaults, { - url: "https://s2maps-tiles.eu/wmts/", + url: "https://tiles.maps.eox.at/wmts/", name: "Sentinel-2 Cloudless 2019", {% if is_mercator %} layer: 's2cloudless-2019_3857', @@ -125,7 +155,7 @@ // Sentinel-2 Cloudless 2018 var options = extend(defaults, { - url: "https://s2maps-tiles.eu/wmts/", + url: "https://tiles.maps.eox.at/wmts/", name: "Sentinel-2 Cloudless 2018", {% if is_mercator %} layer: 's2cloudless-2018_3857', @@ -140,7 +170,7 @@ // OSM var options = extend(defaults, { - url: "https://s2maps-tiles.eu/wmts/", + url: "https://tiles.maps.eox.at/wmts/", name: "OpenStreetMap", {% if is_mercator %} layer: 'osm_3857', @@ -155,7 +185,7 @@ // Coastline var options = extend(defaults, { - url: "https://s2maps-tiles.eu/wmts/", + url: "https://tiles.maps.eox.at/wmts/", name: "EOX::Maps Coastline", {% if is_mercator %} layer: 'coastline_3857', @@ -184,7 +214,7 @@ // Overlay var options = extend(defaults, { - url: "https://s2maps-tiles.eu/wmts/", + url: "https://tiles.maps.eox.at/wmts/", name: "EOX::Maps Base Overlay", {% if is_mercator %} layer: 'overlay_base_3857', From 8e1199ccac07bf44e28201ccaf1d606295a3f900 Mon Sep 17 00:00:00 2001 From: Joachim Ungar Date: Wed, 11 Sep 2024 08:38:30 +0200 Subject: [PATCH 2/3] adapt to Fiona changing error messages --- mapchete/io/vector.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mapchete/io/vector.py b/mapchete/io/vector.py index 559c4dda..e2593ce9 100644 --- a/mapchete/io/vector.py +++ b/mapchete/io/vector.py @@ -76,7 +76,9 @@ def fiona_read(path, mode="r", **kwargs): ): if i in str(repr(exc)): raise FileNotFoundError(f"path {str(path)} does not exist") - else: # pragma: no cover + else: + if not path.exists(): + raise FileNotFoundError(f"path {str(path)} does not exist") raise From dee3d243e2decd50b5e3c64d3bf13b347026124a Mon Sep 17 00:00:00 2001 From: Joachim Ungar Date: Wed, 11 Sep 2024 09:03:02 +0200 Subject: [PATCH 3/3] account for potential exceptions during exists check --- mapchete/io/vector.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/mapchete/io/vector.py b/mapchete/io/vector.py index e2593ce9..29391d0e 100644 --- a/mapchete/io/vector.py +++ b/mapchete/io/vector.py @@ -68,18 +68,27 @@ def fiona_read(path, mode="r", **kwargs): logger.debug("reading %s with GDAL options %s", str(path), env.options) with fiona.open(str(path), mode=mode, **kwargs) as src: yield src - except DriverError as exc: + except DriverError as fiona_exception: + # look for hints from Fiona that the file does not exist for i in ( "does not exist in the file system", "No such file or directory", "specified key does not exist.", ): - if i in str(repr(exc)): - raise FileNotFoundError(f"path {str(path)} does not exist") + if i in str(repr(fiona_exception)): # pragma: no cover + break + # if there are no hints, investigate further else: - if not path.exists(): - raise FileNotFoundError(f"path {str(path)} does not exist") - raise + # if file exists or exists check fails, raise original Fiona exception + try: + exists = path.exists() + except Exception: # pragma: no cover + raise fiona_exception + if exists: + raise fiona_exception + + # file does not exist + raise FileNotFoundError(f"path {str(path)} does not exist") @contextmanager