From 66fcc2e9f7252f7ec12b49dec15741a9c2f29ede Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Wed, 25 Nov 2026 14:21:45 +0100 Subject: [PATCH 01/24] feat(basemap): geology sources registry Co-Authored-By: Claude Opus 5.5 --- pyproject.toml | 1 + .../basemap/basemap_providers.py | 25 +++++ .../basemap/geology_registry.py | 106 ++++++++++++++++++ .../basemap/geology_sources.json | 65 +++++++++++ tests/test_basemap_geology.py | 92 +++++++++++++++ 5 files changed, 289 insertions(+) create mode 100644 src/opengeodeweb_back/basemap/geology_registry.py create mode 100644 src/opengeodeweb_back/basemap/geology_sources.json create mode 100644 tests/test_basemap_geology.py diff --git a/pyproject.toml b/pyproject.toml index 8127282a..89fbcfdb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,4 +35,5 @@ where = ["src"] "opengeodeweb_back.routes.create.schemas" = ["*.json"] "opengeodeweb_back.routes.crs.schemas" = ["*.json"] "opengeodeweb_back.routes.basemap.schemas" = ["*.json"] +"opengeodeweb_back.basemap" = ["*.json"] "opengeodeweb_back" = ["py.typed", "schema_definitions.json"] diff --git a/src/opengeodeweb_back/basemap/basemap_providers.py b/src/opengeodeweb_back/basemap/basemap_providers.py index 5f451fc8..44db6f18 100644 --- a/src/opengeodeweb_back/basemap/basemap_providers.py +++ b/src/opengeodeweb_back/basemap/basemap_providers.py @@ -1,6 +1,7 @@ from __future__ import annotations # Standard library imports +import math import os from dataclasses import dataclass from typing import TYPE_CHECKING @@ -18,6 +19,17 @@ class Source: url_template: str max_zoom: int attribution: str + # Scale window where the source is used, in scale denominators: geology sources only + min_scale: float = 0.0 + max_scale: float = math.inf + # Scale of the data, geology sources only: the most detailed source is tried first + source_scale: float | None = None + # Web Mercator extent the source covers, None for the whole world + area_3857: tuple[float, float, float, float] | None = None + # How the server says it has no data: a 404, a transparent tile or a plain colour tile + empty_tile: str = "404" + # WMS only: the CRS of the GetMap bounding box + wms_crs: str | None = None _GEOPLATEFORME = ( @@ -66,6 +78,19 @@ class Source: } +def _geology_sources() -> dict[str, Source]: + # Imported here: the registry builds Source objects of this module + from opengeodeweb_back.basemap import geology_registry # noqa: PLC0415 + + return geology_registry.load() + + +_GEOLOGY = _geology_sources() +SOURCES.update(_GEOLOGY) +# The fallback order of the geology map, the most detailed first +GEOLOGY_SOURCES: tuple[str, ...] = tuple(_GEOLOGY) + + def url_template(source: str) -> str: # Local servers for tests: one variable per source, else one for all where {source} is replaced template = os.environ.get(f"BASEMAP_TILE_URL_{source.upper()}") diff --git a/src/opengeodeweb_back/basemap/geology_registry.py b/src/opengeodeweb_back/basemap/geology_registry.py new file mode 100644 index 00000000..4115a13e --- /dev/null +++ b/src/opengeodeweb_back/basemap/geology_registry.py @@ -0,0 +1,106 @@ +from __future__ import annotations + +# Standard library imports +import json +import re +from pathlib import Path +from typing import Any + +# Third party imports +import opengeode_geosciences as og_geosciences + +# Local application imports +from opengeodeweb_back.basemap.basemap_providers import Source +from opengeodeweb_back.crs.crs_functions import convert_xy_corners + +REGISTRY_PATH = Path(__file__).parent / "geology_sources.json" +ID_PREFIX = "geology_" +PROTOCOLS = ("wmts", "xyz", "wms") +COLOUR = re.compile(r"#[0-9a-f]{6}") +# Web Mercator stops short of the poles +MAX_LATITUDE = 85.05 +REQUIRED = ( + "id", + "name", + "protocol", + "url", + "attribution", + "status", + "min_scale", + "max_scale", + "source_scale", +) +WGS84 = og_geosciences.GeographicCoordinateSystemInfo("EPSG", "4326", "WGS 84") +WEB_MERCATOR = og_geosciences.GeographicCoordinateSystemInfo( + "EPSG", "3857", "WGS 84 / Pseudo-Mercator" +) + + +class RegistryError(ValueError): + pass + + +def _area_3857(area: list[float] | None) -> tuple[float, float, float, float] | None: + if area is None: + return None + lon_min, lat_min, lon_max, lat_max = area + clamped = ( + lon_min, + max(lat_min, -MAX_LATITUDE), + lon_max, + min(lat_max, MAX_LATITUDE), + ) + corners = convert_xy_corners(clamped, WGS84, WEB_MERCATOR) + xs = [x for x, _ in corners] + ys = [y for _, y in corners] + return (min(xs), min(ys), max(xs), max(ys)) + + +def _check(entry: dict[str, Any]) -> None: + name = entry.get("id", "?") + missing = [key for key in REQUIRED if entry.get(key) is None] + if missing: + msg = f"Geology source {name}: missing {', '.join(missing)}" + raise RegistryError(msg) + if not str(name).startswith(ID_PREFIX): + msg = f"Geology source {name}: the id must start with {ID_PREFIX}" + raise RegistryError(msg) + if entry["protocol"] not in PROTOCOLS: + msg = f"Geology source {name}: unknown protocol {entry['protocol']}" + raise RegistryError(msg) + empty_tile = entry.get("empty_tile", "404") + if empty_tile not in ("404", "transparent") and not COLOUR.fullmatch(empty_tile): + msg = f"Geology source {name}: empty_tile must be 404, transparent or #rrggbb" + raise RegistryError(msg) + if entry["min_scale"] >= entry["max_scale"]: + msg = f"Geology source {name}: min_scale must be below max_scale" + raise RegistryError(msg) + + +def _source(entry: dict[str, Any]) -> Source: + return Source( + url_template=entry["url"], + max_zoom=entry.get("max_zoom") or 0, + attribution=entry["attribution"], + min_scale=entry["min_scale"], + max_scale=entry["max_scale"], + source_scale=entry["source_scale"], + area_3857=_area_3857(entry.get("area")), + empty_tile=entry.get("empty_tile", "404"), + ) + + +def load(path: Path = REGISTRY_PATH) -> dict[str, Source]: + """The verified geology sources by id, the most detailed first.""" + entries: list[dict[str, Any]] = json.loads(path.read_text(encoding="utf-8")) + seen: set[str] = set() + for entry in entries: + _check(entry) + if entry["id"] in seen: + msg = f"Geology source {entry['id']}: duplicate id" + raise RegistryError(msg) + seen.add(entry["id"]) + verified = [entry for entry in entries if entry["status"] == "verified"] + # Stable: sources of the same scale keep the registry order + verified.sort(key=lambda entry: entry["source_scale"]) + return {entry["id"]: _source(entry) for entry in verified} diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json new file mode 100644 index 00000000..3d154107 --- /dev/null +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -0,0 +1,65 @@ +[ + { + "id": "geology_brgm_50k", + "name": "BRGM 1/50 000", + "provider": "BRGM via Géoplateforme", + "area": [-12.2064, 40.681, 11.894, 52.1672], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wmts", + "url": "https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=BRGM_SCAN_D_GEOL50&STYLE=normal&TILEMATRIXSET=PM_0_15&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/jpeg", + "layers": "BRGM_SCAN_D_GEOL50", + "styles": "normal", + "format": "image/jpeg", + "supported_crs": ["EPSG:3857"], + "max_zoom": 15, + "empty_tile": "#ffffff", + "licence": "Licence Ouverte Etalab 2.0", + "attribution": "© BRGM", + "status": "verified" + }, + { + "id": "geology_brgm_250k", + "name": "BRGM 1/250 000", + "provider": "BRGM via Géoplateforme", + "area": [-6.20495, 41.9671, 12.2874, 51.2917], + "level": "N2", + "source_scale": 250000, + "min_scale": 80000, + "max_scale": 400000, + "protocol": "wmts", + "url": "https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=BRGM_SCAN_F_GEOL250&STYLE=normal&TILEMATRIXSET=PM_0_14&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/jpeg", + "layers": "BRGM_SCAN_F_GEOL250", + "styles": "normal", + "format": "image/jpeg", + "supported_crs": ["EPSG:3857"], + "max_zoom": 14, + "empty_tile": "#ffffff", + "licence": "Licence Ouverte Etalab 2.0", + "attribution": "© BRGM", + "status": "verified" + }, + { + "id": "geology_brgm_1m", + "name": "BRGM 1/1 000 000", + "provider": "BRGM via Géoplateforme", + "area": [-5.86764, 41.1701, 11.0789, 51.1419], + "level": "N1", + "source_scale": 1000000, + "min_scale": 400000, + "max_scale": 100000000, + "protocol": "wmts", + "url": "https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=BRGM_SCAN_F_GEOL1M&STYLE=normal&TILEMATRIXSET=PM_0_11&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/jpeg", + "layers": "BRGM_SCAN_F_GEOL1M", + "styles": "normal", + "format": "image/jpeg", + "supported_crs": ["EPSG:3857"], + "max_zoom": 11, + "empty_tile": "#ffffff", + "licence": "Licence Ouverte Etalab 2.0", + "attribution": "© BRGM", + "status": "verified" + } +] diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py new file mode 100644 index 00000000..0a00779e --- /dev/null +++ b/tests/test_basemap_geology.py @@ -0,0 +1,92 @@ +from __future__ import annotations + +# Standard library imports +import json +import math +from typing import TYPE_CHECKING + +# Third party imports +import pytest + +# Local application imports +from opengeodeweb_back.basemap import basemap_providers, geology_registry + +if TYPE_CHECKING: + from pathlib import Path + +ENTRY = { + "id": "geology_test", + "name": "Test 1/50 000", + "provider": "Test", + "area": [-5.0, 41.0, 10.0, 51.0], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "xyz", + "url": "https://tiles.test/{z}/{x}/{y}.png", + "layers": None, + "styles": None, + "format": "image/png", + "supported_crs": ["EPSG:3857"], + "max_zoom": 15, + "empty_tile": "transparent", + "licence": "CC BY 4.0", + "attribution": "© Test", + "status": "verified", +} + + +def _registry(tmp_path: Path, *entries: dict[str, object]) -> Path: + path = tmp_path / "sources.json" + path.write_text(json.dumps(list(entries))) + return path + + +def test_registry_loads_verified_sources_most_detailed_first(tmp_path: Path) -> None: + coarse = {**ENTRY, "id": "geology_coarse", "source_scale": 1_000_000, "area": None} + unchecked = {**ENTRY, "id": "geology_unchecked", "status": "to_check"} + sources = geology_registry.load(_registry(tmp_path, coarse, ENTRY, unchecked)) + # The most detailed first; unverified sources are never used + assert list(sources) == ["geology_test", "geology_coarse"] + test = sources["geology_test"] + assert (test.min_scale, test.max_scale, test.source_scale) == (0, 80_000, 50_000) + assert test.empty_tile == "transparent" + assert sources["geology_coarse"].area_3857 is None + # The area is kept in Web Mercator, like the tile grid + assert test.area_3857 is not None + assert test.area_3857[0] == pytest.approx(-556_597.45, abs=1) + + +@pytest.mark.parametrize( + "change", + [ + {"id": "brgm"}, + {"protocol": "wfs"}, + {"empty_tile": "white"}, + {"min_scale": 90_000}, + {"url": None}, + {"source_scale": None}, + ], +) +def test_invalid_registry_entry_names_the_entry(tmp_path: Path, change: dict[str, object]) -> None: + with pytest.raises(geology_registry.RegistryError, match=r"geology_test|brgm"): + geology_registry.load(_registry(tmp_path, {**ENTRY, **change})) + + +def test_duplicate_registry_ids_are_rejected(tmp_path: Path) -> None: + with pytest.raises(geology_registry.RegistryError, match="geology_test"): + geology_registry.load(_registry(tmp_path, ENTRY, ENTRY)) + + +def test_shipped_registry_feeds_the_source_table() -> None: + scales = [ + basemap_providers.SOURCES[source].source_scale or 0 + for source in basemap_providers.GEOLOGY_SOURCES + ] + assert scales == sorted(scales) + for source in basemap_providers.GEOLOGY_SOURCES: + assert source.startswith("geology_") + assert source in basemap_providers.SOURCES + # The sources of the other maps keep the defaults: one source for the whole mosaic + assert basemap_providers.SOURCES["osm"].max_scale == math.inf From 8cb229c4ddc44d2795cfc220a4d6448c27cd05f8 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Wed, 25 Nov 2026 14:24:19 +0100 Subject: [PATCH 02/24] feat(basemap): serve wms and export sources as tiles Co-Authored-By: Claude Opus 5.5 --- .../basemap/basemap_tiles.py | 35 ++++++++++- .../basemap/geology_registry.py | 47 +++++++++++++- tests/test_basemap_geology.py | 61 ++++++++++++++++++- 3 files changed, 136 insertions(+), 7 deletions(-) diff --git a/src/opengeodeweb_back/basemap/basemap_tiles.py b/src/opengeodeweb_back/basemap/basemap_tiles.py index 7c69f468..505c775e 100644 --- a/src/opengeodeweb_back/basemap/basemap_tiles.py +++ b/src/opengeodeweb_back/basemap/basemap_tiles.py @@ -22,6 +22,7 @@ # Third party imports import certifi +import opengeode_geosciences as og_geosciences from PIL import Image # Local application imports @@ -32,6 +33,7 @@ USER_AGENT, url_template, ) +from opengeodeweb_back.crs.crs_functions import convert_xy_corners if TYPE_CHECKING: from collections.abc import Iterator @@ -127,6 +129,29 @@ def tile_range( return best +WGS84 = og_geosciences.GeographicCoordinateSystemInfo("EPSG", "4326", "WGS 84") +WEB_MERCATOR = og_geosciences.GeographicCoordinateSystemInfo( + "EPSG", "3857", "WGS 84 / Pseudo-Mercator" +) + + +def tile_bbox(source: str, z: int, x: int, y: int) -> str: + """BBOX of a GetMap covering tile z/x/y, in the CRS of the source WMS.""" + bounds = TileRange(z, x, x, y, y).bounds_3857() + crs = SOURCES[source].wms_crs + if crs is None or crs == "EPSG:3857": + return ",".join(str(value) for value in bounds) + # The CRS API converts the corners: no projection written here + corners = convert_xy_corners(bounds, WEB_MERCATOR, WGS84) + lons = [lon for lon, _ in corners] + lats = [lat for _, lat in corners] + lon_lat = (min(lons), min(lats), max(lons), max(lats)) + # WMS 1.3.0 reads EPSG:4326 latitude first + if crs == "EPSG:4326": + lon_lat = (lon_lat[1], lon_lat[0], lon_lat[3], lon_lat[2]) + return ",".join(str(value) for value in lon_lat) + + def _cache_folder() -> Path: default = Path(tempfile.gettempdir()) / "opengeodeweb_basemap_cache" return Path(os.environ.get("BASEMAP_CACHE_FOLDER", str(default))) @@ -163,7 +188,7 @@ def _write_cache(cached: Path, content: bytes) -> None: Path(temporary).unlink() -def _fetch_tile(source: str, z: int, x: int, y: int) -> bytes | None: +def _fetch_tile(source: str, z: int, x: int, y: int, bbox: str) -> bytes | None: # The template hash keeps tiles of an overridden URL apart template = url_template(source) template_hash = hashlib.sha256(template.encode()).hexdigest()[:12] @@ -172,7 +197,7 @@ def _fetch_tile(source: str, z: int, x: int, y: int) -> bytes | None: if cached_content is not None: return None if cached_content == MISSING_TILE else cached_content # Open tile servers ask every application to name itself - url = template.format(z=z, x=x, y=y) + url = template.format(z=z, x=x, y=y, bbox=bbox) request = urllib.request.Request( # noqa: S310 URL from the source table or the environment url, headers={"User-Agent": USER_AGENT} ) @@ -248,7 +273,11 @@ def _source_tiles( children: dict[tuple[int, int], list[tuple[int, int]]] = {} for x, y in tiles.tiles(): children.setdefault((x >> depth, y >> depth), []).append((x, y)) - futures = {parent: downloads.submit(_fetch_tile, source, z, *parent) for parent in children} + # PROJ runs through OpenGeode: the bounding boxes are converted here, not in the downloads + futures = { + parent: downloads.submit(_fetch_tile, source, z, *parent, tile_bbox(source, z, *parent)) + for parent in children + } done, _ = wait(futures.values(), timeout=max(0.0, deadline - time.monotonic())) images: dict[tuple[int, int], bytes | None] = {} for parent, future in futures.items(): diff --git a/src/opengeodeweb_back/basemap/geology_registry.py b/src/opengeodeweb_back/basemap/geology_registry.py index 4115a13e..59dd7ad2 100644 --- a/src/opengeodeweb_back/basemap/geology_registry.py +++ b/src/opengeodeweb_back/basemap/geology_registry.py @@ -15,8 +15,12 @@ REGISTRY_PATH = Path(__file__).parent / "geology_sources.json" ID_PREFIX = "geology_" -PROTOCOLS = ("wmts", "xyz", "wms") +PROTOCOLS = ("wmts", "xyz", "wms", "export") COLOUR = re.compile(r"#[0-9a-f]{6}") +# Web Mercator first: its tiles fall on the tile grid. Else longitude first, then latitude first +WMS_CRS_PREFERENCE = ("EPSG:3857", "CRS:84", "EPSG:4326") +# No tile grid caps a WMS: past this zoom its tiles are enlarged +WMS_MAX_ZOOM = 18 # Web Mercator stops short of the poles MAX_LATITUDE = 85.05 REQUIRED = ( @@ -75,18 +79,55 @@ def _check(entry: dict[str, Any]) -> None: if entry["min_scale"] >= entry["max_scale"]: msg = f"Geology source {name}: min_scale must be below max_scale" raise RegistryError(msg) + # A WMS without a usable CRS or an export without {bbox} is rejected, even unverified + _url(entry) + + +def _wms(entry: dict[str, Any]) -> tuple[str, str]: + """The GetMap template of a WMS entry, with its {bbox}, and the CRS it asks.""" + supported = entry.get("supported_crs") or [] + crs = next((crs for crs in WMS_CRS_PREFERENCE if crs in supported), None) + if crs is None: + msg = ( + f"Geology source {entry['id']}: the WMS serves none of {', '.join(WMS_CRS_PREFERENCE)}" + ) + raise RegistryError(msg) + query = ( + "SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap" + f"&LAYERS={entry['layers']}&STYLES={entry.get('styles') or ''}&CRS={crs}" + "&BBOX={bbox}&WIDTH=256&HEIGHT=256" + f"&FORMAT={entry['format']}&TRANSPARENT=TRUE" + ) + separator = "&" if "?" in entry["url"] else "?" + return f"{entry['url']}{separator}{query}", crs + + +def _url(entry: dict[str, Any]) -> tuple[str, str | None]: + """The tile URL template of an entry, and the CRS of its {bbox} when it has one.""" + if entry["protocol"] == "wms": + return _wms(entry) + if entry["protocol"] == "export": + # An ArcGIS MapServer export: a full template, asked in Web Mercator + if "{bbox}" not in entry["url"]: + msg = f"Geology source {entry['id']}: an export url needs a {{bbox}}" + raise RegistryError(msg) + return entry["url"], "EPSG:3857" + return entry["url"], None def _source(entry: dict[str, Any]) -> Source: + url_template, wms_crs = _url(entry) + bbox_protocol = entry["protocol"] in ("wms", "export") return Source( - url_template=entry["url"], - max_zoom=entry.get("max_zoom") or 0, + url_template=url_template, + max_zoom=entry.get("max_zoom") or (WMS_MAX_ZOOM if bbox_protocol else 0), attribution=entry["attribution"], min_scale=entry["min_scale"], max_scale=entry["max_scale"], source_scale=entry["source_scale"], area_3857=_area_3857(entry.get("area")), empty_tile=entry.get("empty_tile", "404"), + wms_crs=wms_crs, ) diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index 0a00779e..c01f625b 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -9,7 +9,7 @@ import pytest # Local application imports -from opengeodeweb_back.basemap import basemap_providers, geology_registry +from opengeodeweb_back.basemap import basemap_providers, basemap_tiles, geology_registry if TYPE_CHECKING: from pathlib import Path @@ -90,3 +90,62 @@ def test_shipped_registry_feeds_the_source_table() -> None: assert source in basemap_providers.SOURCES # The sources of the other maps keep the defaults: one source for the whole mosaic assert basemap_providers.SOURCES["osm"].max_scale == math.inf + + +WMS_ENTRY = { + **ENTRY, + "id": "geology_wms", + "protocol": "wms", + "url": "https://wms.test/geology", + "layers": "GEOLOGY", + "styles": "", + "format": "image/png", +} + + +def test_wms_source_asks_web_mercator_when_served(tmp_path: Path) -> None: + wms = geology_registry.load(_registry(tmp_path, WMS_ENTRY))["geology_wms"] + assert wms.wms_crs == "EPSG:3857" + assert wms.url_template.startswith("https://wms.test/geology?SERVICE=WMS&VERSION=1.3.0") + assert "REQUEST=GetMap&LAYERS=GEOLOGY&STYLES=&CRS=EPSG:3857&BBOX={bbox}" in wms.url_template + assert "WIDTH=256&HEIGHT=256&FORMAT=image/png&TRANSPARENT=TRUE" in wms.url_template + + +def test_wms_source_without_web_mercator_asks_crs84(tmp_path: Path) -> None: + entry = {**WMS_ENTRY, "supported_crs": ["EPSG:4326", "CRS:84"]} + assert geology_registry.load(_registry(tmp_path, entry))["geology_wms"].wms_crs == "CRS:84" + entry = {**WMS_ENTRY, "supported_crs": ["EPSG:2154"]} + with pytest.raises(geology_registry.RegistryError, match="geology_wms"): + geology_registry.load(_registry(tmp_path, entry)) + + +def test_tile_bbox_in_the_wms_crs(monkeypatch: pytest.MonkeyPatch) -> None: + half = basemap_tiles.HALF_WORLD + mercator = basemap_providers.Source("u", 15, "a", wms_crs="EPSG:3857") + degrees = basemap_providers.Source("u", 15, "a", wms_crs="CRS:84") + latitude_first = basemap_providers.Source("u", 15, "a", wms_crs="EPSG:4326") + monkeypatch.setitem(basemap_providers.SOURCES, "geology_m", mercator) + monkeypatch.setitem(basemap_providers.SOURCES, "geology_d", degrees) + monkeypatch.setitem(basemap_providers.SOURCES, "geology_l", latitude_first) + # Tile 1/1/0: the north-east quarter of the world + assert basemap_tiles.tile_bbox("geology_m", 1, 1, 0) == f"0.0,0.0,{half},{half}" + lon_min, lat_min, lon_max, lat_max = map( + float, basemap_tiles.tile_bbox("geology_d", 1, 1, 0).split(",") + ) + assert (lon_min, lat_min, lon_max) == pytest.approx((0, 0, 180)) + assert lat_max == pytest.approx(85.0511, abs=1e-3) + # WMS 1.3.0 reads EPSG:4326 latitude first + lat_min, lon_min, lat_max, lon_max = map( + float, basemap_tiles.tile_bbox("geology_l", 1, 1, 0).split(",") + ) + assert (lat_min, lon_min, lon_max) == pytest.approx((0, 0, 180)) + + +def test_export_source_keeps_its_template(tmp_path: Path) -> None: + template = "https://maps.test/server/rest/services/Geology/MapServer/export?bbox={bbox}&bboxSR=3857&size=256,256&f=image" + entry = {**ENTRY, "id": "geology_export", "protocol": "export", "url": template} + source = geology_registry.load(_registry(tmp_path, entry))["geology_export"] + assert (source.url_template, source.wms_crs) == (template, "EPSG:3857") + without_bbox = {**entry, "url": "https://maps.test/MapServer/export?f=image"} + with pytest.raises(geology_registry.RegistryError, match="geology_export"): + geology_registry.load(_registry(tmp_path, without_bbox)) From a0a45db03134eecd00df6de3a50fe3591209f395 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Wed, 25 Nov 2026 14:34:42 +0100 Subject: [PATCH 03/24] feat(basemap): empty tiles and rate limits of a source Co-Authored-By: Claude Opus 5.5 --- .../basemap/basemap_tiles.py | 108 ++++++++++++++---- .../basemap/geology_registry.py | 2 +- tests/test_basemap_geology.py | 105 ++++++++++++++++- 3 files changed, 191 insertions(+), 24 deletions(-) diff --git a/src/opengeodeweb_back/basemap/basemap_tiles.py b/src/opengeodeweb_back/basemap/basemap_tiles.py index 505c775e..9a7bd852 100644 --- a/src/opengeodeweb_back/basemap/basemap_tiles.py +++ b/src/opengeodeweb_back/basemap/basemap_tiles.py @@ -5,6 +5,7 @@ import hashlib import http.client import io +import logging import math import os import ssl @@ -23,7 +24,7 @@ # Third party imports import certifi import opengeode_geosciences as og_geosciences -from PIL import Image +from PIL import Image, ImageChops # Local application imports from opengeodeweb_back import geode_functions @@ -38,12 +39,20 @@ if TYPE_CHECKING: from collections.abc import Iterator +logger = logging.getLogger(__name__) + # Folder of a basemap data holding its tiles: only basemaps have one TILES_FOLDER = "tiles" HALF_WORLD = 20037508.342789244 DEFAULT_MAX_PIXELS = 2048 PNG_SIGNATURE = b"\x89PNG" JPEG_QUALITY = 90 +# Levels a JPEG may blur a plain colour by +JPEG_TOLERANCE = 3 +TOO_MANY_REQUESTS_RETRIES = 2 +MAX_RETRY_WAIT_SECONDS = 5.0 +# One warning per source and per minute: a broken server must not flood the log +WARNING_INTERVAL_SECONDS = 60.0 # Cached in place of a tile the server does not have, so it is not asked again MISSING_TILE = b"missing" FETCH_WORKERS = 8 @@ -59,6 +68,7 @@ _HOST_LIMITS: dict[str, threading.Semaphore] = {} _HOST_LIMITS_LOCK = threading.Lock() +_LAST_WARNINGS: dict[str, float] = {} def _host_limit(url: str) -> threading.Semaphore: @@ -188,6 +198,57 @@ def _write_cache(cached: Path, content: bytes) -> None: Path(temporary).unlink() +def is_empty(content: bytes, empty_tile: str) -> bool: + """Whether a served tile is the image the server sends where it has no data.""" + if empty_tile == "404": + return False + try: + with Image.open(io.BytesIO(content)) as image: + if empty_tile == "transparent": + # No bounding box: every pixel has a zero alpha + return image.convert("RGBA").getchannel("A").getbbox() is None + rgb = image.convert("RGB") + except OSError: # UnidentifiedImageError included + return False + colour = tuple(int(empty_tile[i : i + 2], 16) for i in (1, 3, 5)) + difference = ImageChops.difference(rgb, Image.new("RGB", rgb.size, colour)) + # JPEG blurs a plain colour by a few levels: only larger differences count + beyond = difference.point(lambda level: 255 if level > JPEG_TOLERANCE else 0) + return beyond.getbbox() is None + + +def _warn_failure(source: str, reason: str) -> None: + now = time.monotonic() + with _HOST_LIMITS_LOCK: + if now - _LAST_WARNINGS.get(source, -math.inf) < WARNING_INTERVAL_SECONDS: + return + _LAST_WARNINGS[source] = now + logger.warning("Basemap source %s failed (%s): the next source is used", source, reason) + + +def _retry_wait(error: urllib.error.HTTPError) -> float: + try: + wait_seconds = float(error.headers.get("Retry-After", "1")) + except ValueError: # an HTTP date: wait the most + wait_seconds = MAX_RETRY_WAIT_SECONDS + return min(max(wait_seconds, 0.0), MAX_RETRY_WAIT_SECONDS) + + +def _download(url: str) -> bytes: + # Open tile servers ask every application to name itself + request = urllib.request.Request( # noqa: S310 URL from the source table or the environment + url, headers={"User-Agent": USER_AGENT} + ) + with ( + _host_limit(url), + urllib.request.urlopen( # noqa: S310 + request, timeout=FETCH_TIMEOUT_SECONDS, context=SSL_CONTEXT + ) as response, + ): + content: bytes = response.read() + return content + + def _fetch_tile(source: str, z: int, x: int, y: int, bbox: str) -> bytes | None: # The template hash keeps tiles of an overridden URL apart template = url_template(source) @@ -196,30 +257,33 @@ def _fetch_tile(source: str, z: int, x: int, y: int, bbox: str) -> bytes | None: cached_content = _read_cache(cached) if cached_content is not None: return None if cached_content == MISSING_TILE else cached_content - # Open tile servers ask every application to name itself url = template.format(z=z, x=x, y=y, bbox=bbox) - request = urllib.request.Request( # noqa: S310 URL from the source table or the environment - url, headers={"User-Agent": USER_AGENT} - ) - try: - with ( - _host_limit(url), - urllib.request.urlopen( # noqa: S310 - request, timeout=FETCH_TIMEOUT_SECONDS, context=SSL_CONTEXT - ) as response, - ): - content: bytes = response.read() - except urllib.error.HTTPError as error: - error.close() - # Outside its area (the IGN outside France) a server answers 404: unlike a timeout or a - # network error, asking again would give the same answer - if error.code == HTTPStatus.NOT_FOUND: - _write_cache(cached, MISSING_TILE) - return None - except DOWNLOAD_ERRORS: - return None + content = b"" + for attempt in range(TOO_MANY_REQUESTS_RETRIES + 1): + try: + content = _download(url) + break + except urllib.error.HTTPError as error: + error.close() + if error.code == HTTPStatus.TOO_MANY_REQUESTS and attempt < TOO_MANY_REQUESTS_RETRIES: + time.sleep(_retry_wait(error)) + continue + # Outside its area (the IGN outside France) a server answers 404: unlike a timeout or a + # network error, asking again would give the same answer + if error.code == HTTPStatus.NOT_FOUND: + _write_cache(cached, MISSING_TILE) + else: + _warn_failure(source, f"HTTP {error.code}") + return None + except DOWNLOAD_ERRORS as error: + _warn_failure(source, type(error).__name__) + return None if not _is_image(content): return None + # Where a server has no data it may send a plain tile instead of a 404: missing as well + if is_empty(content, SOURCES[source].empty_tile): + _write_cache(cached, MISSING_TILE) + return None _write_cache(cached, content) return content diff --git a/src/opengeodeweb_back/basemap/geology_registry.py b/src/opengeodeweb_back/basemap/geology_registry.py index 59dd7ad2..58e4f5cb 100644 --- a/src/opengeodeweb_back/basemap/geology_registry.py +++ b/src/opengeodeweb_back/basemap/geology_registry.py @@ -107,7 +107,7 @@ def _url(entry: dict[str, Any]) -> tuple[str, str | None]: if entry["protocol"] == "wms": return _wms(entry) if entry["protocol"] == "export": - # An ArcGIS MapServer export: a full template, asked in Web Mercator + # A map server export: a full template, asked in Web Mercator if "{bbox}" not in entry["url"]: msg = f"Geology source {entry['id']}: an export url needs a {{bbox}}" raise RegistryError(msg) diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index c01f625b..085b30b8 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -1,12 +1,17 @@ from __future__ import annotations # Standard library imports +import io import json import math -from typing import TYPE_CHECKING +import urllib.error +import urllib.request +from email.message import Message +from typing import TYPE_CHECKING, Self # Third party imports import pytest +from PIL import Image # Local application imports from opengeodeweb_back.basemap import basemap_providers, basemap_tiles, geology_registry @@ -149,3 +154,101 @@ def test_export_source_keeps_its_template(tmp_path: Path) -> None: without_bbox = {**entry, "url": "https://maps.test/MapServer/export?f=image"} with pytest.raises(geology_registry.RegistryError, match="geology_export"): geology_registry.load(_registry(tmp_path, without_bbox)) + + +WHOLE_WORLD = basemap_tiles.TileRange(1, 0, 1, 0, 1) + + +def _image(mode: str, colour: tuple[int, ...], image_format: str) -> bytes: + output = io.BytesIO() + Image.new(mode, (256, 256), colour).save(output, format=image_format) + return output.getvalue() + + +def test_empty_tiles() -> None: + white = _image("RGB", (255, 255, 255), "JPEG") + clear = _image("RGBA", (0, 0, 0, 0), "PNG") + coloured = _image("RGB", (200, 120, 40), "PNG") + # The Géoplateforme answers a plain white JPEG outside its maps + assert basemap_tiles.is_empty(white, "#ffffff") + assert not basemap_tiles.is_empty(coloured, "#ffffff") + assert basemap_tiles.is_empty(clear, "transparent") + assert not basemap_tiles.is_empty(coloured, "transparent") + # A 404 source never reads its tiles + assert not basemap_tiles.is_empty(white, "404") + + +class _Answer: + def __init__(self, content: bytes) -> None: + self.content = content + + def __enter__(self) -> Self: + return self + + def __exit__(self, *_args: object) -> None: + pass + + def read(self) -> bytes: + return self.content + + +def _source(monkeypatch: pytest.MonkeyPatch, tmp_path: Path, **fields: object) -> None: + monkeypatch.setenv("BASEMAP_CACHE_FOLDER", str(tmp_path)) + monkeypatch.delenv("BASEMAP_TILE_URL", raising=False) + source = basemap_providers.Source("https://tiles.test/{z}/{x}/{y}.png", 15, "a", **fields) + monkeypatch.setitem(basemap_providers.SOURCES, "geology_t", source) + + +def test_empty_tile_is_missing_and_not_asked_again( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + _source(monkeypatch, tmp_path, empty_tile="#ffffff") + white = _image("RGB", (255, 255, 255), "JPEG") + calls: list[str] = [] + + def answer(request: urllib.request.Request, **_kwargs: object) -> _Answer: + calls.append(request.full_url) + return _Answer(white) + + monkeypatch.setattr(urllib.request, "urlopen", answer) + assert not any(basemap_tiles.fetch_tiles("geology_t", WHOLE_WORLD).values()) + basemap_tiles.fetch_tiles("geology_t", WHOLE_WORLD) + assert len(calls) == 4 + + +def _too_many_requests(url: str) -> urllib.error.HTTPError: + headers = Message() + headers["Retry-After"] = "0" + return urllib.error.HTTPError(url, 429, "Too Many Requests", headers, io.BytesIO()) + + +def test_too_many_requests_waits_then_retries( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + _source(monkeypatch, tmp_path) + tile = _image("RGB", (200, 120, 40), "PNG") + refused: set[str] = set() + + def once_refused(request: urllib.request.Request, **_kwargs: object) -> _Answer: + if request.full_url not in refused: + refused.add(request.full_url) + raise _too_many_requests(request.full_url) + return _Answer(tile) + + monkeypatch.setattr(urllib.request, "urlopen", once_refused) + assert all(basemap_tiles.fetch_tiles("geology_t", WHOLE_WORLD).values()) + + +def test_persistent_too_many_requests_is_a_missing_tile( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path, caplog: pytest.LogCaptureFixture +) -> None: + _source(monkeypatch, tmp_path) + + def always_refused(request: urllib.request.Request, **_kwargs: object) -> _Answer: + raise _too_many_requests(request.full_url) + + monkeypatch.setattr(urllib.request, "urlopen", always_refused) + assert not any(basemap_tiles.fetch_tiles("geology_t", WHOLE_WORLD).values()) + # Not cached: the server may answer later + assert not any(path.is_file() for path in tmp_path.rglob("*")) + assert "geology_t" in caplog.text From 817f58b76e90402e6e1bffea7084be5711e521b6 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Wed, 25 Nov 2026 14:37:43 +0100 Subject: [PATCH 04/24] feat(basemap): fill the geology layer tile by tile Co-Authored-By: Claude Opus 5.5 --- .../basemap/basemap_tiles.py | 76 +++++++++++-- tests/test_basemap_geology.py | 106 ++++++++++++++++++ 2 files changed, 175 insertions(+), 7 deletions(-) diff --git a/src/opengeodeweb_back/basemap/basemap_tiles.py b/src/opengeodeweb_back/basemap/basemap_tiles.py index 9a7bd852..7d6be563 100644 --- a/src/opengeodeweb_back/basemap/basemap_tiles.py +++ b/src/opengeodeweb_back/basemap/basemap_tiles.py @@ -44,6 +44,10 @@ # Folder of a basemap data holding its tiles: only basemaps have one TILES_FOLDER = "tiles" HALF_WORLD = 20037508.342789244 +# Radius of the Web Mercator sphere: HALF_WORLD = pi * EARTH_RADIUS +EARTH_RADIUS = 6_378_137.0 +# Scale denominator of a zoom 0 tile at the equator, for 0.28 mm screen pixels (OGC) +EQUATOR_SCALE_AT_ZOOM_0 = 559_082_264.0 DEFAULT_MAX_PIXELS = 2048 PNG_SIGNATURE = b"\x89PNG" JPEG_QUALITY = 90 @@ -108,6 +112,25 @@ def tiles(self) -> list[tuple[int, int]]: ] +def tile_scale(z: int, y: int) -> float: + """Scale denominator at the centre of tile row y: finer away from the equator.""" + center_y = HALF_WORLD - (y + 0.5) * _tile_span(z) + # Web Mercator stretches the ground by 1 / cos(latitude) = cosh(y / R) + return EQUATOR_SCALE_AT_ZOOM_0 / (1 << z) / math.cosh(center_y / EARTH_RADIUS) + + +def eligible(source: str, z: int, tile: tuple[int, int]) -> bool: + """Whether the scale window and the area of a source hold the tile.""" + settings = SOURCES[source] + if not settings.min_scale <= tile_scale(z, tile[1]) < settings.max_scale: + return False + if settings.area_3857 is None: + return True + x_min, y_min, x_max, y_max = TileRange(z, tile[0], tile[0], tile[1], tile[1]).bounds_3857() + area_x_min, area_y_min, area_x_max, area_y_max = settings.area_3857 + return x_min < area_x_max and area_x_min < x_max and y_min < area_y_max and area_y_min < y_max + + def _range_at(bounds_3857: tuple[float, float, float, float], z: int) -> TileRange: span = _tile_span(z) last = (1 << z) - 1 @@ -329,13 +352,17 @@ def _downloads(workers: int) -> Iterator[ThreadPoolExecutor]: def _source_tiles( - source: str, tiles: TileRange, downloads: ThreadPoolExecutor, deadline: float + source: str, + tiles: TileRange, + downloads: ThreadPoolExecutor, + deadline: float, + wanted: list[tuple[int, int]] | None = None, ) -> dict[tuple[int, int], bytes | None]: # Past its max zoom a source has no tile: its parent tiles are enlarged instead depth = max(0, tiles.z - SOURCES[source].max_zoom) z = tiles.z - depth children: dict[tuple[int, int], list[tuple[int, int]]] = {} - for x, y in tiles.tiles(): + for x, y in wanted or tiles.tiles(): children.setdefault((x >> depth, y >> depth), []).append((x, y)) # PROJ runs through OpenGeode: the bounding boxes are converted here, not in the downloads futures = { @@ -369,10 +396,37 @@ def _first_served( return None +def _each_tile_served( + layer: tuple[str, ...], tiles: TileRange, downloads: ThreadPoolExecutor, deadline: float +) -> dict[str, dict[tuple[int, int], bytes | None]]: + """Each tile from the first source serving it, the sources in the layer order.""" + missing = set(tiles.tiles()) + served: dict[str, dict[tuple[int, int], bytes | None]] = {} + for source in layer: + wanted = sorted(tile for tile in missing if eligible(source, tiles.z, tile)) + if not wanted: + continue + images = _source_tiles(source, tiles, downloads, deadline, wanted) + found: dict[tuple[int, int], bytes | None] = { + tile: content for tile, content in images.items() if content is not None + } + if found: + served[source] = found + missing -= found.keys() + if not missing: + break + return served + + +def _filled_tile_by_tile(layer: tuple[str, ...]) -> bool: + # Geology sources have a scale window: each tile takes its own source + return any(math.isfinite(SOURCES[source].max_scale) for source in layer) + + def fetch_layers( layers: list[tuple[str, ...]], tiles: TileRange ) -> dict[str, dict[tuple[int, int], bytes | None]]: - """The tiles of the first source serving any in each layer, by source. + """The tiles of each layer by source: the first source serving any, or tile by tile. Every layer at once: the slowest server sets the wait, not the sum of them. """ @@ -381,10 +435,18 @@ def fetch_layers( _downloads(FETCH_WORKERS * max(1, len(layers))) as downloads, ThreadPoolExecutor(max(1, len(layers))) as executor, ): - served = executor.map( - lambda layer: _first_served(layer, tiles, downloads, deadline), layers - ) - return dict(item for item in served if item is not None) + + def fetch(layer: tuple[str, ...]) -> dict[str, dict[tuple[int, int], bytes | None]]: + if _filled_tile_by_tile(layer): + return _each_tile_served(layer, tiles, downloads, deadline) + first = _first_served(layer, tiles, downloads, deadline) + return {} if first is None else dict([first]) + + return { + source: images + for served in executor.map(fetch, layers) + for source, images in served.items() + } def _extension(content: bytes) -> str: diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index 085b30b8..8e5041b4 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -1,6 +1,7 @@ from __future__ import annotations # Standard library imports +import dataclasses import io import json import math @@ -252,3 +253,108 @@ def always_refused(request: urllib.request.Request, **_kwargs: object) -> _Answe # Not cached: the server may answer later assert not any(path.is_file() for path in tmp_path.rglob("*")) assert "geology_t" in caplog.text + + +HALF = basemap_tiles.HALF_WORLD + + +def test_tile_scale_follows_zoom_and_latitude() -> None: + # At the equator, zoom 9 is about 1/1 000 000 + assert basemap_tiles.tile_scale(9, 255) == pytest.approx(1_091_958, rel=0.01) + # One zoom more halves the scale + assert basemap_tiles.tile_scale(10, 511) == pytest.approx(545_979, rel=0.01) + # At 60° north the ground is twice as small on the screen + assert basemap_tiles.tile_scale(9, 148) == pytest.approx(1_091_958 / 2, rel=0.02) + + +def _two_sources(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: + monkeypatch.setenv("BASEMAP_CACHE_FOLDER", str(tmp_path)) + monkeypatch.delenv("BASEMAP_TILE_URL", raising=False) + # A detailed national source on the west half of the world, then a coarse continental one + national = basemap_providers.Source( + "https://national.test/{z}/{x}/{y}.png", + 15, + "© National", + min_scale=0, + max_scale=1e12, + source_scale=50_000, + area_3857=(-HALF, -HALF, 0.0, HALF), + empty_tile="transparent", + ) + continental = basemap_providers.Source( + "https://continental.test/{z}/{x}/{y}.png", + 15, + "© Continental", + min_scale=0, + max_scale=1e12, + source_scale=1_000_000, + empty_tile="transparent", + ) + monkeypatch.setitem(basemap_providers.SOURCES, "geology_national", national) + monkeypatch.setitem(basemap_providers.SOURCES, "geology_continental", continental) + tile = _image("RGB", (200, 120, 40), "PNG") + monkeypatch.setattr(urllib.request, "urlopen", lambda *_a, **_k: _Answer(tile)) + + +def test_each_tile_takes_the_first_source_serving_it( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + _two_sources(monkeypatch, tmp_path) + images = basemap_tiles.fetch_layers([("geology_national", "geology_continental")], WHOLE_WORLD) + # The west column from the national source, the east one from the continental source + assert sorted(images["geology_national"]) == [(0, 0), (0, 1)] + assert sorted(images["geology_continental"]) == [(1, 0), (1, 1)] + + +def test_a_failing_source_leaves_its_tiles_to_the_next( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + _two_sources(monkeypatch, tmp_path) + tile = _image("RGB", (200, 120, 40), "PNG") + + def national_down(request: urllib.request.Request, **_kwargs: object) -> _Answer: + if "national" in request.full_url: + raise TimeoutError + return _Answer(tile) + + monkeypatch.setattr(urllib.request, "urlopen", national_down) + images = basemap_tiles.fetch_layers([("geology_national", "geology_continental")], WHOLE_WORLD) + assert list(images) == ["geology_continental"] + assert len(images["geology_continental"]) == 4 + + +def test_out_of_scale_source_is_not_asked(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: + _two_sources(monkeypatch, tmp_path) + detailed = basemap_providers.SOURCES["geology_national"] + monkeypatch.setitem( + basemap_providers.SOURCES, + "geology_national", + dataclasses.replace(detailed, max_scale=80_000), + ) + # A whole world view is far coarser than 1/80 000: the continental source alone fills it + images = basemap_tiles.fetch_layers([("geology_national", "geology_continental")], WHOLE_WORLD) + assert list(images) == ["geology_continental"] + + +def test_tiles_without_a_source_stay_empty(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: + _two_sources(monkeypatch, tmp_path) + # No world fallback: the east column is left out, and the Viewer shows it transparent + images = basemap_tiles.fetch_layers([("geology_national",)], WHOLE_WORLD) + assert sorted(images["geology_national"]) == [(0, 0), (0, 1)] + + +def test_layers_without_scale_windows_keep_one_source_per_mosaic( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + _two_sources(monkeypatch, tmp_path) + monkeypatch.setitem( + basemap_providers.SOURCES, + "first", + basemap_providers.Source("https://a.test/{z}/{x}/{y}.png", 15, "a"), + ) + monkeypatch.setitem( + basemap_providers.SOURCES, + "second", + basemap_providers.Source("https://b.test/{z}/{x}/{y}.png", 15, "b"), + ) + assert list(basemap_tiles.fetch_layers([("first", "second")], WHOLE_WORLD)) == ["first"] From f14306e8100b758b6c147f5be55ea66054329ee3 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Wed, 25 Nov 2026 14:40:16 +0100 Subject: [PATCH 05/24] feat(basemap): geology map Co-Authored-By: Claude Opus 5.5 --- opengeodeweb_back_schemas.json | 1 + opengeodeweb_back_typed_schemas.d.ts | 2 +- .../basemap/basemap_providers.py | 7 ++++ .../routes/basemap/schemas/build.json | 1 + .../routes/basemap/schemas/build.py | 1 + tests/test_basemap.py | 32 ++++++++++++++++++- 6 files changed, 42 insertions(+), 2 deletions(-) diff --git a/opengeodeweb_back_schemas.json b/opengeodeweb_back_schemas.json index b4f5b660..78e598ba 100644 --- a/opengeodeweb_back_schemas.json +++ b/opengeodeweb_back_schemas.json @@ -53,6 +53,7 @@ "enum": [ "satellite", "plan", + "geology", "routes" ] } diff --git a/opengeodeweb_back_typed_schemas.d.ts b/opengeodeweb_back_typed_schemas.d.ts index 129ec1d3..5271f36d 100644 --- a/opengeodeweb_back_typed_schemas.d.ts +++ b/opengeodeweb_back_typed_schemas.d.ts @@ -29,7 +29,7 @@ export interface Bounds { y_min: number; } -export type Map = "satellite" | "plan" | "routes"; +export type Map = "satellite" | "plan" | "geology" | "routes"; export interface BasemapBuildResponse { attribution: string; diff --git a/src/opengeodeweb_back/basemap/basemap_providers.py b/src/opengeodeweb_back/basemap/basemap_providers.py index 44db6f18..e6f2e77f 100644 --- a/src/opengeodeweb_back/basemap/basemap_providers.py +++ b/src/opengeodeweb_back/basemap/basemap_providers.py @@ -89,6 +89,13 @@ def _geology_sources() -> dict[str, Source]: SOURCES.update(_GEOLOGY) # The fallback order of the geology map, the most detailed first GEOLOGY_SOURCES: tuple[str, ...] = tuple(_GEOLOGY) +# Under the roads: they stay readable over the geology. One layer filled tile by tile +MAPS = { + "satellite": MAPS["satellite"], + "plan": MAPS["plan"], + "geology": (GEOLOGY_SOURCES,), + "routes": MAPS["routes"], +} def url_template(source: str) -> str: diff --git a/src/opengeodeweb_back/routes/basemap/schemas/build.json b/src/opengeodeweb_back/routes/basemap/schemas/build.json index e1f4c6e1..32146503 100644 --- a/src/opengeodeweb_back/routes/basemap/schemas/build.json +++ b/src/opengeodeweb_back/routes/basemap/schemas/build.json @@ -14,6 +14,7 @@ "enum": [ "satellite", "plan", + "geology", "routes" ] } diff --git a/src/opengeodeweb_back/routes/basemap/schemas/build.py b/src/opengeodeweb_back/routes/basemap/schemas/build.py index b798c0cd..61bc5c6f 100644 --- a/src/opengeodeweb_back/routes/basemap/schemas/build.py +++ b/src/opengeodeweb_back/routes/basemap/schemas/build.py @@ -22,6 +22,7 @@ def __post_init__(self) -> None: class Map(Enum): + GEOLOGY = "geology" PLAN = "plan" ROUTES = "routes" SATELLITE = "satellite" diff --git a/tests/test_basemap.py b/tests/test_basemap.py index 80498a20..3cc89dd6 100644 --- a/tests/test_basemap.py +++ b/tests/test_basemap.py @@ -366,6 +366,31 @@ def test_build_route_skips_sources_without_tiles( assert not (tiles_path / "ign_roads").exists() +def test_build_route_geology_tile_by_tile( + client: FlaskClient, monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + # Only the BRGM 1/50 000 serves tiles: Paris is far more detailed than its other maps + _serve(monkeypatch, tmp_path / "cache", (tmp_path / "none").as_uri() + "/{z}/{x}/{y}.png") + monkeypatch.setenv("BASEMAP_TILE_URL_EOX_S2CLOUDLESS_2016", ANY_TILE.as_uri()) + monkeypatch.setenv("BASEMAP_TILE_URL_GEOLOGY_BRGM_50K", ANY_TILE.as_uri()) + response = _build(client, maps=["satellite", "geology"]) + assert response.status_code == 200 + body = response.get_json() + assert body["maps"][-1] == {"map": "geology", "sources": ["geology_brgm_50k"]} + assert "© BRGM" in body["attribution"] + + +def test_build_route_geology_outside_every_source( + client: FlaskClient, monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + # No geological survey serves the zone: the geology map is left out, the satellite stays + _serve(monkeypatch, tmp_path / "cache", (tmp_path / "none").as_uri() + "/{z}/{x}/{y}.png") + monkeypatch.setenv("BASEMAP_TILE_URL_EOX_S2CLOUDLESS_2016", ANY_TILE.as_uri()) + response = _build(client, maps=["satellite", "geology"]) + assert response.status_code == 200 + assert [entry["map"] for entry in response.get_json()["maps"]] == ["satellite"] + + def test_padding_is_in_metres() -> None: padded = blueprint_basemap.padded((5.0, 7.0, 5.0, 7.0)) assert padded[2] - padded[0] >= 1_000.0 @@ -391,8 +416,13 @@ def test_url_template_from_the_source_table(monkeypatch: pytest.MonkeyPatch) -> def test_maps_from_the_bottom_up() -> None: - # Whatever the requested order: satellite, plan, then routes + # Whatever the requested order: satellite, plan, geology, then routes assert basemap_providers.sorted_maps(["routes", "satellite"]) == ["satellite", "routes"] + assert basemap_providers.sorted_maps(["routes", "geology", "plan"]) == [ + "plan", + "geology", + "routes", + ] assert basemap_providers.max_zoom(["eox_s2cloudless_2016", "ign_roads"]) == 18 assert basemap_providers.max_zoom(["eox_overlay", "ign_orthophotos"]) == 19 From 83c4a56a098ebca0a124527c660c593e98e44e78 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Wed, 25 Nov 2026 15:29:07 +0100 Subject: [PATCH 06/24] feat(basemap): geology sources of the first lot Co-Authored-By: Claude Opus 5.5 --- pytest.ini | 5 +- .../basemap/geology_sources.json | 499 +++++++++++++++++- tests/test_basemap_geology.py | 31 ++ 3 files changed, 526 insertions(+), 9 deletions(-) diff --git a/pytest.ini b/pytest.ini index b5a5096b..a85ea7f0 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,5 @@ [pytest] -addopts = --ignore=src/opengeodeweb_back/ \ No newline at end of file +# Network tests reach the real tile servers: run them by hand with -m network +addopts = --ignore=src/opengeodeweb_back/ -m "not network" +markers = + network: reaches the real tile servers, not run in CI diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index 3d154107..3d67710a 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -3,7 +3,12 @@ "id": "geology_brgm_50k", "name": "BRGM 1/50 000", "provider": "BRGM via Géoplateforme", - "area": [-12.2064, 40.681, 11.894, 52.1672], + "area": [ + -12.2064, + 40.681, + 11.894, + 52.1672 + ], "level": "N3", "source_scale": 50000, "min_scale": 0, @@ -13,7 +18,9 @@ "layers": "BRGM_SCAN_D_GEOL50", "styles": "normal", "format": "image/jpeg", - "supported_crs": ["EPSG:3857"], + "supported_crs": [ + "EPSG:3857" + ], "max_zoom": 15, "empty_tile": "#ffffff", "licence": "Licence Ouverte Etalab 2.0", @@ -24,17 +31,24 @@ "id": "geology_brgm_250k", "name": "BRGM 1/250 000", "provider": "BRGM via Géoplateforme", - "area": [-6.20495, 41.9671, 12.2874, 51.2917], + "area": [ + -6.20495, + 41.9671, + 12.2874, + 51.2917 + ], "level": "N2", "source_scale": 250000, - "min_scale": 80000, + "min_scale": 0, "max_scale": 400000, "protocol": "wmts", "url": "https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=BRGM_SCAN_F_GEOL250&STYLE=normal&TILEMATRIXSET=PM_0_14&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/jpeg", "layers": "BRGM_SCAN_F_GEOL250", "styles": "normal", "format": "image/jpeg", - "supported_crs": ["EPSG:3857"], + "supported_crs": [ + "EPSG:3857" + ], "max_zoom": 14, "empty_tile": "#ffffff", "licence": "Licence Ouverte Etalab 2.0", @@ -45,21 +59,490 @@ "id": "geology_brgm_1m", "name": "BRGM 1/1 000 000", "provider": "BRGM via Géoplateforme", - "area": [-5.86764, 41.1701, 11.0789, 51.1419], + "area": [ + -5.86764, + 41.1701, + 11.0789, + 51.1419 + ], "level": "N1", "source_scale": 1000000, - "min_scale": 400000, + "min_scale": 0, "max_scale": 100000000, "protocol": "wmts", "url": "https://data.geopf.fr/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=BRGM_SCAN_F_GEOL1M&STYLE=normal&TILEMATRIXSET=PM_0_11&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&FORMAT=image/jpeg", "layers": "BRGM_SCAN_F_GEOL1M", "styles": "normal", "format": "image/jpeg", - "supported_crs": ["EPSG:3857"], + "supported_crs": [ + "EPSG:3857" + ], "max_zoom": 11, "empty_tile": "#ffffff", "licence": "Licence Ouverte Etalab 2.0", "attribution": "© BRGM", "status": "verified" + }, + { + "id": "geology_egdi_1m", + "name": "EGDI 1/1 000 000 (Europe)", + "provider": "EuroGeoSurveys (EGDI), service hosted by Geological Survey of Slovenia (GeoZS)", + "area": [ + -56.296504, + 24.931501, + 53.104653, + 72.1479 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://geoserver.geo-zs.si/egdi-surface-geology/gsmlp/wms", + "layers": "GeologicUnitView_Lithology", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "empty_tile": "transparent", + "licence": "Creative Commons BY 4.0 (https://creativecommons.org/licenses/by/4.0/), per EGDI metadata record 5729ffdf-2558-48fc-a5d2-645a0a010855", + "attribution": "EGDI 1:1M Surface Geology © EuroGeoSurveys and the European geological surveys, CC BY 4.0; Malta: Continental Shelf Department, Ministry for Transport and Infrastructure", + "status": "to_check", + "notes": "Vérifié (CC BY 4.0, pas de données en Croatie) ; en attente de la décision : repli européen ou retrait." + }, + { + "id": "geology_bgs_625k", + "name": "BGS 1/625 000", + "provider": "British Geological Survey", + "area": [ + -8.648463, + 49.863792, + 1.767673, + 60.861176 + ], + "level": "N1", + "source_scale": 625000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://ogc.bgs.ac.uk/cgi-bin/BGS_Bedrock_and_Superficial_Geology/wms", + "layers": "GBR_BGS_625k_BLS", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "empty_tile": "transparent", + "licence": "Open Government Licence v3.0 (https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/)", + "attribution": "Contains British Geological Survey materials © UKRI 2026", + "status": "verified" + }, + { + "id": "geology_bgs_50k", + "name": "BGS 1/50 000", + "provider": "British Geological Survey", + "area": [ + -8.344021, + 49.846369, + 2.697705, + 60.866269 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://map.bgs.ac.uk/arcgis/services/BGS_Detailed_Geology/MapServer/WMSServer", + "layers": "BGS.50k.Bedrock,BGS.50k.Superficial.deposits", + "styles": ",", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "empty_tile": "transparent", + "licence": "Open Government Licence v3.0 (https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/)", + "attribution": "Contains British Geological Survey materials © UKRI 2026", + "status": "verified" + }, + { + "id": "geology_igme_1m", + "name": "IGME 1/1 000 000 (Spain)", + "provider": "Instituto Geológico y Minero de España (IGME-CSIC)", + "area": [ + -22.719066, + 26.602222, + 6.256604, + 44.659923 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://mapas.igme.es/gis/services/Cartografia_Geologica/IGME_Geologico_1M/MapServer/WMSServer", + "layers": "0,2", + "styles": ",", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "empty_tile": "transparent", + "licence": "Licencia de uso IGME 2022 (free licence for commercial and non-commercial use), https://info.igme.es/media/Pdfs/LicUsoIGME_GENERICA_EN_2022.pdf", + "attribution": "Origen de los datos: © CN Instituto Geológico y Minero de España (IGME)", + "status": "verified" + }, + { + "id": "geology_igme_geode_50k", + "name": "IGME GEODE 1/50 000 (Spain)", + "provider": "Instituto Geológico y Minero de España (IGME-CSIC)", + "area": [ + -18.161186, + 27.637739, + 4.327781, + 43.792384 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://mapas.igme.es/gis/services/Cartografia_Geologica/IGME_Geode_50/MapServer/WMSServer", + "layers": "1,2", + "styles": ",", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "empty_tile": "transparent", + "licence": "Licencia de uso IGME 2022 (free licence for commercial and non-commercial use), https://info.igme.es/media/Pdfs/LicUsoIGME_GENERICA_EN_2022.pdf", + "attribution": "Origen de los datos: © CN Instituto Geológico y Minero de España (IGME)", + "status": "verified" + }, + { + "id": "geology_igme_magna_50k", + "name": "IGME MAGNA 1/50 000 (Spain)", + "provider": "Instituto Geológico y Minero de España (IGME-CSIC)", + "area": [ + -18.208334, + 27.608334, + 4.331386, + 43.833319 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://mapas.igme.es/gis/services/Cartografia_Geologica/IGME_MAGNA_50/MapServer/WMSServer", + "layers": "0,2", + "styles": ",", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "empty_tile": "transparent", + "licence": "Licencia de uso IGME 2022, https://info.igme.es/media/Pdfs/LicUsoIGME_GENERICA_EN_2022.pdf, plus service AccessConstraints", + "attribution": "Origen de los datos: © CN Instituto Geológico y Minero de España (IGME)", + "status": "to_check", + "notes": "Technically OK (tile tests pass). Licence unclear: capabilities AccessConstraints say 'No está permitido implementar un servicio de valor añadido no gratuito sin establecer contacto con el IGME' (a paid value-added service needs contacting IGME), which narrows the generic licence. Redundant with GEODE 50k (same data, seamless); keep GEODE unless IGME confirms in writing." + }, + { + "id": "geology_igme_200k", + "name": "IGME 1/200 000 (Spain)", + "provider": "Instituto Geológico y Minero de España (IGME-CSIC)", + "area": [ + -10.086399, + 35.804852, + 4.90577, + 44.134668 + ], + "level": "N2", + "source_scale": 200000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://mapas.igme.es/gis/services/Cartografia_Geologica/IGME_Geologico_200/MapServer/WMSServer", + "layers": "0,2", + "styles": ",", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "empty_tile": "transparent", + "licence": "Licencia de uso IGME 2022 (free licence for commercial and non-commercial use), https://info.igme.es/media/Pdfs/LicUsoIGME_GENERICA_EN_2022.pdf", + "attribution": "Origen de los datos: © CN Instituto Geológico y Minero de España (IGME)", + "status": "to_check", + "notes": "Licence OK. Coverage is a patchwork of published sheets only (layer 9 'Límite hojas disponibles'): Sierra Nevada/Granada, Madrid and Zaragoza tiles are empty; Pozoblanco and León tiles render. A partial N2 would leave holes inside the declared area. Use only if the registry can tolerate holes, or derive area from the sheet-limit layer. No EPSG:3857 in capabilities (CRS:84 used)." + }, + { + "id": "geology_usgs_sgmc", + "name": "USGS State Geologic Map Compilation (SGMC)", + "provider": "U.S. Geological Survey", + "area": [ + -129.57, + 22.4, + -64.98, + 50.78 + ], + "level": "N1", + "source_scale": 500000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wmts", + "url": "https://mrdata.usgs.gov/mapcache/wmts/1.0.0/sgmc2/default/GoogleMapsCompatible/{z}/{y}/{x}.png", + "layers": "sgmc2", + "styles": "default", + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "U.S. Public Domain: \"USGS-authored or produced data and information are considered to be in the U.S. Public Domain.\" (https://www.usgs.gov/information-policies-and-instructions/copyrights-and-credits). Data release metadata (doi:10.5066/F7WH2N65) use constraint: \"Acknowledgment of the U.S. Geological Survey would be appreciated in products derived from these data. User specifically agrees not to misrepresent the data, nor to imply that changes made were approved or endorsed by the U.S. Geological Survey.\" No restriction on commercial use or caching.", + "attribution": "Geology: U.S. Geological Survey, State Geologic Map Compilation (Horton et al., 2017)", + "status": "verified" + }, + { + "id": "geology_usgs_alaska", + "name": "USGS Geologic Map of Alaska (SIM 3340)", + "provider": "U.S. Geological Survey", + "area": [ + -180.0, + 51.0, + -129.0, + 72.0 + ], + "level": "N1", + "source_scale": 1584000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wmts", + "url": "https://mrdata.usgs.gov/mapcache/wmts/1.0.0/sim3340/default/GoogleMapsCompatible/{z}/{y}/{x}.png", + "layers": "sim3340", + "styles": "default", + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "U.S. Public Domain: \"USGS-authored or produced data and information are considered to be in the U.S. Public Domain.\" (https://www.usgs.gov/information-policies-and-instructions/copyrights-and-credits). WMS capabilities: Fees none, AccessConstraints none. No restriction on commercial use or caching.", + "attribution": "Geology: U.S. Geological Survey, Geologic Map of Alaska (Wilson et al., 2015, SIM 3340)", + "status": "verified" + }, + { + "id": "geology_usgs_hawaii", + "name": "USGS Geologic Map of the State of Hawaii", + "provider": "U.S. Geological Survey", + "area": [ + -160.25, + 18.9, + -154.8, + 22.24 + ], + "level": "N2", + "source_scale": 100000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wmts", + "url": "https://mrdata.usgs.gov/mapcache/wmts/1.0.0/higeol/default/GoogleMapsCompatible/{z}/{y}/{x}.png", + "layers": "higeol", + "styles": "default", + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "U.S. Public Domain: \"USGS-authored or produced data and information are considered to be in the U.S. Public Domain.\" (https://www.usgs.gov/information-policies-and-instructions/copyrights-and-credits). WMS capabilities (services/hi): Fees none, AccessConstraints none. No restriction on commercial use or caching.", + "attribution": "Geology: U.S. Geological Survey, Geologic Map of the State of Hawai'i (Sherrod et al., 2007, OFR 2007-1089)", + "status": "verified" + }, + { + "id": "geology_usgs_puerto_rico", + "name": "USGS Geology of Puerto Rico (OFR 98-38)", + "provider": "U.S. Geological Survey", + "area": [ + -67.3, + 17.9, + -65.5, + 18.6 + ], + "level": "N2", + "source_scale": 100000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wmts", + "url": "https://mrdata.usgs.gov/mapcache/wmts/1.0.0/prgeol/default/GoogleMapsCompatible/{z}/{y}/{x}.png", + "layers": "prgeol", + "styles": "default", + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "U.S. Public Domain: \"USGS-authored or produced data and information are considered to be in the U.S. Public Domain.\" (https://www.usgs.gov/information-policies-and-instructions/copyrights-and-credits). WMS capabilities (services/pr): Fees none, AccessConstraints none. No restriction on commercial use or caching.", + "attribution": "Geology: U.S. Geological Survey, Open-File Report 98-38 (Bawiec, 1998)", + "status": "verified" + }, + { + "id": "geology_ga_1m", + "name": "Geoscience Australia 1/1 000 000", + "provider": "Geoscience Australia", + "area": [ + 72.577237, + -54.777736, + 167.998035, + -9.17848 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "xyz", + "url": "https://services.ga.gov.au/gis/rest/services/GA_Surface_Geology/MapServer/tile/{z}/{y}/{x}", + "layers": null, + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 14, + "empty_tile": "transparent", + "licence": "Creative Commons Attribution 4.0 International (CC BY 4.0), https://creativecommons.org/licenses/by/4.0/legalcode ; GA copyright notice https://www.ga.gov.au/copyright", + "attribution": "© Commonwealth of Australia (Geoscience Australia) 2016, CC BY 4.0", + "status": "verified" + }, + { + "id": "geology_ga_1m_wms", + "name": "Geoscience Australia 1/1 000 000 (WMS)", + "provider": "Geoscience Australia", + "area": [ + 72.577237, + -54.777736, + 167.998035, + -9.17848 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://services.ga.gov.au/gis/services/GA_Surface_Geology/MapServer/WMSServer", + "layers": "AUS_GA_2500k_GUPoly_Lithostratigraphy,AUS_GA_2500k_Contacts,AUS_GA_2500k_Faults,AUS_GA_1M_GUPoly_Lithostratigraphy,AUS_GA_1M_Contacts,AUS_GA_1M_Faults", + "styles": ",,,,,", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Creative Commons Attribution 4.0 International (CC BY 4.0), https://creativecommons.org/licenses/by/4.0/legalcode (WMS AccessConstraints + https://www.ga.gov.au/copyright)", + "attribution": "© Commonwealth of Australia (Geoscience Australia) 2016, CC BY 4.0", + "status": "to_check", + "notes": "Doublon WMS de geology_ga_1m (tuiles), gardé comme repli possible : non chargé." + }, + { + "id": "geology_gsj_200k", + "name": "GSJ 1/200 000", + "provider": "Geological Survey of Japan, AIST", + "area": [ + 122.924639, + 20.412746, + 153.997258, + 45.567699 + ], + "level": "N2", + "source_scale": 200000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "xyz", + "url": "https://gbank.gsj.jp/seamless/v2/api/1.3.1/tiles/{z}/{y}/{x}.png", + "layers": null, + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 13, + "empty_tile": "transparent", + "licence": "Public Data License / Government of Japan Standard Terms of Use (version 2.0), compatible with CC BY 4.0; commercial use allowed. https://www.gsj.jp/license/license.html , https://gbank.gsj.jp/seamless/agreement.html", + "attribution": "Seamless Digital Geological Map of Japan V2 1:200,000 (© Geological Survey of Japan, AIST), https://gbank.gsj.jp/seamless/", + "status": "verified" + }, + { + "id": "geology_gsj_200k_wms", + "name": "GSJ 1/200 000 (WMS)", + "provider": "Geological Survey of Japan, AIST", + "area": [ + 122.924639, + 20.412746, + 153.997258, + 45.567699 + ], + "level": "N2", + "source_scale": 200000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://ows.gsj.jp/ows/seamlessv2", + "layers": "seamlessV2_poly,seamlessV2_line", + "styles": ",", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "EPSG:4326" + ], + "max_zoom": 13, + "empty_tile": "transparent", + "licence": "Public Data License / Government of Japan Standard Terms of Use (version 2.0), compatible with CC BY 4.0; commercial use allowed. https://www.gsj.jp/license/license.html , https://gbank.gsj.jp/owscontents/license.html", + "attribution": "Seamless Digital Geological Map of Japan V2 1:200,000 (© Geological Survey of Japan, AIST), https://gbank.gsj.jp/seamless/", + "status": "to_check", + "notes": "Doublon WMS de geology_gsj_200k (tuiles), gardé comme repli possible : non chargé." + }, + { + "id": "geology_gsj_1m", + "name": "GSJ 1/1 000 000", + "provider": "Geological Survey of Japan, AIST", + "area": [ + 122.943, + 20.4539, + 153.994, + 45.5541 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "xyz", + "url": "https://ows.gsj.jp/tilemap/geologicmap/wmts/1.0.0/JPN_GSJ_1M_Combined_BLT_SLT_BA/default/EPSG900913/{z}/{y}/{x}.png", + "layers": null, + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 17, + "empty_tile": "transparent", + "licence": "Unclear: GSJ site licence (Government of Japan Standard Terms of Use 2.0, commercial OK, https://www.gsj.jp/license/license.html) vs WMS capabilities AccessConstraints 'personal, teaching, research or non-commercial use'", + "attribution": "1:1,000,000 Geological Map of Japan, 3rd ed. (© Geological Survey of Japan, AIST)", + "status": "to_check", + "notes": "Technically OK: WMTS REST template from https://ows.gsj.jp/tilemap/geologicmap/wmts/1.0.0/WMTSCapabilities.xml, TileMatrixSet EPSG900913 = Google grid 256 px, TileMatrix ids are zero-padded '00'..'18' but unpadded z works too (z=5 and z=05 return identical bytes). Tiles served to z17 at the test site (z18 fully transparent). Tiles are slightly translucent (alpha ~214-255). Outside coverage: 256x256 fully transparent PNG. to_check because the sibling WMS (https://ows.gsj.jp/ows/GSJ_Combined_Bedrock_and_Superficial_Geology_and_Age/wms) GetCapabilities AccessConstraints says 'available for free download for your personal, teaching, research or non-commercial use' (legacy OneGeology wording), contradicting the GSJ site-wide licence; ask GSJ (publish@gsj.jp) which applies. Redundant with geology_gsj_200k for display anyway." } ] diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index 8e5041b4..fa968e5d 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -358,3 +358,34 @@ def test_layers_without_scale_windows_keep_one_source_per_mosaic( basemap_providers.Source("https://b.test/{z}/{x}/{y}.png", 15, "b"), ) assert list(basemap_tiles.fetch_layers([("first", "second")], WHOLE_WORLD)) == ["first"] + + +# A tile with data of every shipped geology source, z/x/y in Web Mercator +KNOWN_TILES = { + "geology_brgm_50k": (13, 4164, 2922), + "geology_brgm_250k": (10, 518, 352), + "geology_brgm_1m": (8, 129, 88), + "geology_bgs_50k": (13, 4055, 2657), + "geology_bgs_625k": (8, 126, 83), + "geology_igme_geode_50k": (13, 4018, 3185), + "geology_igme_1m": (7, 62, 49), + "geology_usgs_sgmc": (12, 850, 1554), + "geology_usgs_alaska": (10, 91, 267), + "geology_usgs_hawaii": (10, 70, 455), + "geology_usgs_puerto_rico": (10, 322, 459), + "geology_ga_1m": (10, 921, 627), + "geology_gsj_200k": (10, 907, 402), +} + + +@pytest.mark.network +@pytest.mark.parametrize("source", basemap_providers.GEOLOGY_SOURCES) +def test_shipped_source_serves_a_tile( + source: str, monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + monkeypatch.setenv("BASEMAP_CACHE_FOLDER", str(tmp_path)) + monkeypatch.delenv("BASEMAP_TILE_URL", raising=False) + z, x, y = KNOWN_TILES[source] + content = basemap_tiles.fetch_tiles(source, basemap_tiles.TileRange(z, x, x, y, y))[(x, y)] + assert content is not None + assert not basemap_tiles.is_empty(content, "transparent") From 06005351b36386a3de05d7481ba852fd8e78b2be Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Wed, 25 Nov 2026 15:44:26 +0100 Subject: [PATCH 07/24] fix(basemap): drop geology sources with an uncertain licence Co-Authored-By: Claude Opus 5.5 --- src/opengeodeweb_back/basemap/geology_sources.json | 12 ++++++++---- tests/test_basemap_geology.py | 4 ---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index 3d67710a..34101011 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -140,7 +140,8 @@ "empty_tile": "transparent", "licence": "Open Government Licence v3.0 (https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/)", "attribution": "Contains British Geological Survey materials © UKRI 2026", - "status": "verified" + "status": "to_check", + "notes": "Licence incertaine : l'ancien texte des capabilities interdit de « set up a service selling on this material » sans licence, la page actuelle dit OGL v3. Exclu tant que le BGS ne confirme pas." }, { "id": "geology_bgs_50k", @@ -169,7 +170,8 @@ "empty_tile": "transparent", "licence": "Open Government Licence v3.0 (https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/)", "attribution": "Contains British Geological Survey materials © UKRI 2026", - "status": "verified" + "status": "to_check", + "notes": "Licence incertaine : une ancienne fiche de métadonnées BGS dit « personal, non-commercial use only », les capabilities disent OGL v3. Exclu tant que le BGS ne confirme pas." }, { "id": "geology_igme_1m", @@ -197,7 +199,8 @@ "empty_tile": "transparent", "licence": "Licencia de uso IGME 2022 (free licence for commercial and non-commercial use), https://info.igme.es/media/Pdfs/LicUsoIGME_GENERICA_EN_2022.pdf", "attribution": "Origen de los datos: © CN Instituto Geológico y Minero de España (IGME)", - "status": "verified" + "status": "to_check", + "notes": "Licence incertaine : la licence IGME 2022 autorise l'usage commercial, mais exige que les produits dérivés « ne remplacent pas ceux offerts par l'IGME ». Exclu tant que l'IGME ne confirme pas." }, { "id": "geology_igme_geode_50k", @@ -226,7 +229,8 @@ "empty_tile": "transparent", "licence": "Licencia de uso IGME 2022 (free licence for commercial and non-commercial use), https://info.igme.es/media/Pdfs/LicUsoIGME_GENERICA_EN_2022.pdf", "attribution": "Origen de los datos: © CN Instituto Geológico y Minero de España (IGME)", - "status": "verified" + "status": "to_check", + "notes": "Licence incertaine : même clause IGME (« ne pas remplacer les produits de l'IGME »). Exclu tant que l'IGME ne confirme pas." }, { "id": "geology_igme_magna_50k", diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index fa968e5d..258faa87 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -365,10 +365,6 @@ def test_layers_without_scale_windows_keep_one_source_per_mosaic( "geology_brgm_50k": (13, 4164, 2922), "geology_brgm_250k": (10, 518, 352), "geology_brgm_1m": (8, 129, 88), - "geology_bgs_50k": (13, 4055, 2657), - "geology_bgs_625k": (8, 126, 83), - "geology_igme_geode_50k": (13, 4018, 3185), - "geology_igme_1m": (7, 62, 49), "geology_usgs_sgmc": (12, 850, 1554), "geology_usgs_alaska": (10, 91, 267), "geology_usgs_hawaii": (10, 70, 455), From 3591f8460e7c8df92daee4fca06bce99824c4bc8 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Wed, 25 Nov 2026 15:49:51 +0100 Subject: [PATCH 08/24] feat(basemap): egdi as the european geology fallback Co-Authored-By: Claude Opus 5.5 --- src/opengeodeweb_back/basemap/geology_sources.json | 3 +-- tests/test_basemap_geology.py | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index 34101011..7acbc384 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -110,8 +110,7 @@ "empty_tile": "transparent", "licence": "Creative Commons BY 4.0 (https://creativecommons.org/licenses/by/4.0/), per EGDI metadata record 5729ffdf-2558-48fc-a5d2-645a0a010855", "attribution": "EGDI 1:1M Surface Geology © EuroGeoSurveys and the European geological surveys, CC BY 4.0; Malta: Continental Shelf Department, Ministry for Transport and Infrastructure", - "status": "to_check", - "notes": "Vérifié (CC BY 4.0, pas de données en Croatie) ; en attente de la décision : repli européen ou retrait." + "status": "verified" }, { "id": "geology_bgs_625k", diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index 258faa87..ee8bf888 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -365,6 +365,7 @@ def test_layers_without_scale_windows_keep_one_source_per_mosaic( "geology_brgm_50k": (13, 4164, 2922), "geology_brgm_250k": (10, 518, 352), "geology_brgm_1m": (8, 129, 88), + "geology_egdi_1m": (7, 67, 42), "geology_usgs_sgmc": (12, 850, 1554), "geology_usgs_alaska": (10, 91, 267), "geology_usgs_hawaii": (10, 70, 455), From 472b4d4f513966bb0fc82c0f84d5bd542f05a3fc Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Wed, 25 Nov 2026 15:08:06 +0000 Subject: [PATCH 09/24] Apply prepare changes --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5c24d6ce..597e5178 100644 --- a/requirements.txt +++ b/requirements.txt @@ -84,4 +84,3 @@ werkzeug==3.1.8 # flask # flask-cors -opengeodeweb-microservice==1.*,>=1.4.0 From 165c97f0b08798db395de10b604d6dcb03288c18 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Wed, 25 Nov 2026 16:30:29 +0100 Subject: [PATCH 10/24] feat(basemap): geology sources of europe, canada and australian states Co-Authored-By: Claude Opus 5.5 --- .../basemap/geology_sources.json | 1536 +++++++++++++++++ tests/test_basemap_geology.py | 18 + 2 files changed, 1554 insertions(+) diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index 7acbc384..0330e73c 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -547,5 +547,1541 @@ "attribution": "1:1,000,000 Geological Map of Japan, 3rd ed. (© Geological Survey of Japan, AIST)", "status": "to_check", "notes": "Technically OK: WMTS REST template from https://ows.gsj.jp/tilemap/geologicmap/wmts/1.0.0/WMTSCapabilities.xml, TileMatrixSet EPSG900913 = Google grid 256 px, TileMatrix ids are zero-padded '00'..'18' but unpadded z works too (z=5 and z=05 return identical bytes). Tiles served to z17 at the test site (z18 fully transparent). Tiles are slightly translucent (alpha ~214-255). Outside coverage: 256x256 fully transparent PNG. to_check because the sibling WMS (https://ows.gsj.jp/ows/GSJ_Combined_Bedrock_and_Superficial_Geology_and_Age/wms) GetCapabilities AccessConstraints says 'available for free download for your personal, teaching, research or non-commercial use' (legacy OneGeology wording), contradicting the GSJ site-wide licence; ask GSJ (publish@gsj.jp) which applies. Redundant with geology_gsj_200k for display anyway." + }, + { + "id": "geology_swisstopo_ga25", + "name": "Geological Atlas of Switzerland 1:25 000 (GA25)", + "provider": "swisstopo (Federal Office of Topography)", + "area": [ + 5.140242, + 45.398181, + 11.47757, + 48.230651 + ], + "level": "N3", + "source_scale": 25000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wmts", + "url": "https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.geologie-geologischer_atlas/default/current/3857/{z}/{x}/{y}.png", + "layers": "ch.swisstopo.geologie-geologischer_atlas", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "opendata.swiss 'Open use. Must provide the source.' (terms_by) https://opendata.swiss/terms-of-use#terms_by ; swisstopo OGD terms https://www.swisstopo.admin.ch/en/terms-of-use-free-geodata-and-geoservices ; FSDI general terms (fair use) https://www.geo.admin.ch/en/general-terms-of-use-fsdi", + "attribution": "© swisstopo", + "status": "verified" + }, + { + "id": "geology_swisstopo_swissgeocover2d", + "name": "swissGEOCOVER2D geological vector datasets 1:25 000 (bedrock + unconsolidated + surfaces + lines + tectonic lines)", + "provider": "swisstopo (Federal Office of Topography)", + "area": [ + 5.140242, + 45.398181, + 11.47757, + 48.230651 + ], + "level": "N3", + "source_scale": 25000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://wms.geo.admin.ch/", + "layers": "ch.swisstopo.geologie-swissgeocover2d_bedrock,ch.swisstopo.geologie-swissgeocover2d_unconsolidated,ch.swisstopo.geologie-swissgeocover2d_surfaces,ch.swisstopo.geologie-swissgeocover2d_lines,ch.swisstopo.geologie-swissgeocover2d_tecto_lines", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "opendata.swiss 'Open use. Must provide the source.' (terms_by) https://opendata.swiss/terms-of-use#terms_by (datasets geologische-vektordatensatze-geocover-bedrock / -unconsolidated-deposits / -geological-surfaces / -tectonic-lines) ; swisstopo OGD terms https://www.swisstopo.admin.ch/en/terms-of-use-free-geodata-and-geoservices", + "attribution": "© swisstopo", + "status": "verified" + }, + { + "id": "geology_swisstopo_geocover_legacy", + "name": "GeoCover - Vector Datasets (legacy WMTS)", + "provider": "swisstopo (Federal Office of Topography)", + "area": [ + 5.140242, + 45.398181, + 11.47757, + 48.230651 + ], + "level": "N3", + "source_scale": 25000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wmts", + "url": "https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.geologie-geocover/default/current/3857/{z}/{x}/{y}.png", + "layers": "ch.swisstopo.geologie-geocover", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 16, + "empty_tile": "transparent", + "licence": "geocat.ch 2467ab13-e794-4c13-8c55-59fe276398c5: 'Freie Nutzung. Quellenangabe ist Pflicht.' NonCommercialAllowed-CommercialAllowed-ReferenceRequired", + "attribution": "© swisstopo", + "status": "to_check", + "notes": "Licence is fine and tiles work: z7-z16, 0.2 s. It is not verified because the swisstopo legend says the layer leaves map.geo.admin.ch on 16 December 2026 and the WMTS may follow. Use geology_swisstopo_swissgeocover2d instead. TileMatrixSet 3857_16: z17 and above return HTTP 400 'Unsupported zoom level'." + }, + { + "id": "geology_swisstopo_gk500", + "name": "Geological Map of Switzerland 1:500 000 (GK500-Geol)", + "provider": "swisstopo (Federal Office of Topography)", + "area": [ + 5.140242, + 45.398181, + 11.47757, + 48.230651 + ], + "level": "N2", + "source_scale": 500000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wmts", + "url": "https://wmts.geo.admin.ch/1.0.0/ch.swisstopo.geologie-geologische_karte/default/current/3857/{z}/{x}/{y}.png", + "layers": "ch.swisstopo.geologie-geologische_karte", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "opendata.swiss 'Open use' (terms_open) for dataset 'GeoMaps 500 Raster' https://opendata.swiss/terms-of-use#terms_open ; swisstopo OGD terms https://www.swisstopo.admin.ch/en/terms-of-use-free-geodata-and-geoservices", + "attribution": "© swisstopo", + "status": "verified" + }, + { + "id": "geology_sgids_gm50", + "name": "Geologická mapa SR 1:50 000 (Geological Map of the Slovak Republic 1:50 000)", + "provider": "ŠGÚDŠ - State Geological Institute of Dionýz Štúr", + "area": [ + 16.6, + 47.5, + 22.8, + 49.9 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://ags.geology.sk/arcgis/services/WebServices/GM50/MapServer/WMSServer", + "layers": "0,1", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Creative Commons BY 4.0 International (https://www.geology.sk/service-sharing/?lang=en ; https://creativecommons.org/licenses/by/4.0/)", + "attribution": "© State Geological Institute of Dionýz Štúr (ŠGÚDŠ) - Geological map of Slovakia 1:50 000", + "status": "to_check", + "notes": "Licence incertaine : CC BY 4.0 affiché pour les téléchargements, les services ne citent que « copyright ŠGÚDŠ ». Exclu tant que le ŠGÚDŠ ne confirme pas." + }, + { + "id": "geology_sgids_gm200", + "name": "Prehľadná geologická mapa SR 1:200 000 (Overview Geological Map of the Slovak Republic)", + "provider": "ŠGÚDŠ - State Geological Institute of Dionýz Štúr", + "area": [ + 16.6, + 47.5, + 22.8, + 49.9 + ], + "level": "N2", + "source_scale": 200000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://ags.geology.sk/arcgis/services/WebServices/GM200/MapServer/WMSServer", + "layers": "0,1", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 16, + "empty_tile": "transparent", + "licence": "Creative Commons BY 4.0 International (https://www.geology.sk/service-sharing/?lang=en ; https://creativecommons.org/licenses/by/4.0/)", + "attribution": "© State Geological Institute of Dionýz Štúr (ŠGÚDŠ) - BEZÁK, V. et al.: Comprehensive geological map of the Slovak Republic 1:200 000, 2008", + "status": "to_check", + "notes": "Même doute de licence que geology_sgids_gm50." + }, + { + "id": "geology_sgids_gm500", + "name": "Geologická mapa Západných Karpát a priľahlých území 1:500 000 (Geological map of the Western Carpathians and adjacent areas)", + "provider": "ŠGÚDŠ - State Geological Institute of Dionýz Štúr", + "area": [ + 15.423519, + 47.261998, + 23.118449, + 50.496025 + ], + "level": "N1", + "source_scale": 500000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://ags.geology.sk/arcgis/services/WebServices/GM500/MapServer/WMSServer", + "layers": "0,1", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 14, + "empty_tile": "transparent", + "licence": "Creative Commons BY 4.0 International (https://www.geology.sk/service-sharing/?lang=en ; https://creativecommons.org/licenses/by/4.0/)", + "attribution": "© State Geological Institute of Dionýz Štúr (ŠGÚDŠ) - LEXA, J. et al.: Geological map of the Western Carpathians and adjacent areas 1:500 000, 2008", + "status": "to_check", + "notes": "Même doute de licence que geology_sgids_gm50." + }, + { + "id": "geology_bgr_guek250", + "name": "Geologische Übersichtskarte der Bundesrepublik Deutschland 1:250 000 (GÜK250)", + "provider": "BGR - Bundesanstalt für Geowissenschaften und Rohstoffe", + "area": [ + 5.562778, + 47.141228, + 15.575523, + 55.08509 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://services.bgr.de/wms/geologie/guek250/", + "layers": "1,2", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "EPSG:4326" + ], + "max_zoom": 14, + "empty_tile": "transparent", + "licence": "Contradictory: BGR General Standard Terms and Conditions https://www.bgr.bund.de/AGB_en (capabilities AccessConstraints) vs GeoNutzV https://sg.geodatenzentrum.de/web_public/gdz/lizenz/geonutzv.pdf (metadata record)", + "attribution": "Datenquelle: GÜK250 (WMS), (c) BGR, Hannover, 2019", + "status": "to_check", + "notes": "LICENCE CONFLICT. The capabilities and the metadata useConstraints point to the BGR AGB/GSTC. GSTC Art. 3(1) says: 'The rights which are not transferred include in particular the right to make accessible to the public'. Art. 3(5) says: 'All other use not expressly specified above, requires special written agreement'. The same CSW record (0f2e1b5b-...) also says the data may be used under GeoNutzV. GeoNutzV §2(1) allows 'kommerzieller und nicht kommerzieller Nutzung'. That is a contradiction, so ask BGR. Technically OK. Server scale limits: Min 1:34,124, Max 1:545,979, so it draws only at about z11-z14; z8 and z10 return empty transparent tiles. Layer 1 = Basislayer_Genese, 2 = Überlagerungslayer_Genese (also 4/5 Petrographie, 7/8 Stratigraphie). 0.2-0.35 s per tile." + }, + { + "id": "geology_bgr_gk1000", + "name": "Geologische Karte der Bundesrepublik Deutschland 1:1 000 000 (GK1000, INSPIRE)", + "provider": "BGR - Bundesanstalt für Geowissenschaften und Rohstoffe", + "area": [ + 5.384608, + 47.066883, + 15.745689, + 55.17185 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://services.bgr.de/wms/inspire_ge/gk1000/", + "layers": "1", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "EPSG:4326" + ], + "max_zoom": 12, + "empty_tile": "transparent", + "licence": "Contradictory: BGR General Standard Terms and Conditions https://www.bgr.bund.de/AGB_en vs GeoNutzV (metadata record 1C60DDA9-...)", + "attribution": "GK1000-INSPIRE, (c) BGR Hannover, 2016", + "status": "to_check", + "notes": "Same AGB vs GeoNutzV conflict as geology_bgr_guek250. The INSPIRE service is used because it has no scale limits; z6-z8 draw. The classic https://services.bgr.de/wms/geologie/gk1000/ draws only at about z9-z10 (Min 1:472,470, Max 1:1,889,881). Slow at small scale: z6 9.6 s, z7 7.6 s (app timeout 10 s); z8 0.33 s. Layer 1 = GE.GeologicUnit.AgeOfRocks." + }, + { + "id": "geology_hgi_gk300", + "name": "Geološka karta Republike Hrvatske 1:300 000 (INSPIRE WMS)", + "provider": "HGI-CGS - Hrvatski geološki institut", + "area": [ + 13.48984458, + 42.38732698, + 19.44725221, + 46.55502178 + ], + "level": "N2", + "source_scale": 300000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://transformiraj.nipp.hr/ows/services/org.2.abf7ddc6-7578-4070-a9db-c291a42e55c6_wms", + "layers": "GE.GeologicUnit.AgeOfRocks", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "EPSG:4326" + ], + "max_zoom": 14, + "empty_tile": "transparent", + "licence": "Unknown: capabilities Fees 'conditionsUnknown', AccessConstraints 'otherRestrictions'; dataset metadata 'conditions to access and use unknown' (INSPIRE ConditionsApplyingToAccessAndUse/conditionsUnknown)", + "attribution": "© Hrvatski geološki institut (HGI-CGS)", + "status": "to_check", + "notes": "No licence is stated anywhere, and data.gov.hr has license_id null for both packages. The service runs on the national NIPP transformation platform (transformiraj.nipp.hr, Državna geodetska uprava), but its abstract says HGI operates and maintains it. The old HGI link http://webgis.hgi-cgs.hr/gk300/ is dead (NXDOMAIN). Technically OK: z7-z13 draw, 0.14-0.6 s; mid-ocean gives a transparent tile." + }, + { + "id": "geology_ngu_n50", + "name": "Norway bedrock 1:50 000 (Berggrunn N50, main rock types)", + "provider": "NGU - Geological Survey of Norway", + "area": [ + -2.56007, + 57.0881, + 33.0201, + 71.8912 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://geo.ngu.no/mapserver/BerggrunnWMS3", + "layers": "Berggrunn_lokal_hovedbergarter_fullzoom", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Norsk lisens for offentlige data (NLOD) 1.0 - https://data.norge.no/nlod/no/1.0 (Geonorge metadata of Berggrunn WMS3, uuid 51243d4e-e86e-474b-baf8-b7ccfb59fe8e)", + "attribution": "Inneholder data under Norsk lisens for offentlige data (NLOD) tilgjengeliggjort av Norges geologiske undersøkelse (NGU)", + "status": "verified" + }, + { + "id": "geology_ngu_n250", + "name": "Norway bedrock 1:250 000 (Berggrunn N250, main rock types)", + "provider": "NGU - Geological Survey of Norway", + "area": [ + -2.56007, + 57.0881, + 33.0201, + 71.8912 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://geo.ngu.no/mapserver/BerggrunnWMS3", + "layers": "Berggrunn_regional_hovedbergarter", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Norsk lisens for offentlige data (NLOD) 1.0 - https://data.norge.no/nlod/no/1.0 (Geonorge metadata of Berggrunn WMS3, uuid 51243d4e-e86e-474b-baf8-b7ccfb59fe8e)", + "attribution": "Inneholder data under Norsk lisens for offentlige data (NLOD) tilgjengeliggjort av Norges geologiske undersøkelse (NGU)", + "status": "verified" + }, + { + "id": "geology_ngu_n1350", + "name": "Norway bedrock 1:1 350 000 (Berggrunn N1350, main rock types)", + "provider": "NGU - Geological Survey of Norway", + "area": [ + -2.56007, + 57.0881, + 33.0201, + 71.8912 + ], + "level": "N1", + "source_scale": 1350000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://geo.ngu.no/mapserver/BerggrunnWMS3", + "layers": "Berggrunn_nasjonal_hovedbergarter", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Norsk lisens for offentlige data (NLOD) 1.0 - https://data.norge.no/nlod/no/1.0 (Geonorge metadata of Berggrunn WMS3, uuid 51243d4e-e86e-474b-baf8-b7ccfb59fe8e)", + "attribution": "Inneholder data under Norsk lisens for offentlige data (NLOD) tilgjengeliggjort av Norges geologiske undersøkelse (NGU)", + "status": "verified" + }, + { + "id": "geology_gtk_200k", + "name": "Bedrock of Finland 1:200 000 (lithological units)", + "provider": "GTK - Geological Survey of Finland", + "area": [ + 15.619292, + 59.352464, + 33.107505, + 70.094874 + ], + "level": "N2", + "source_scale": 200000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://gtkdata.gtk.fi/arcgis/services/Rajapinnat/GTK_Kalliopera_WMS/MapServer/WMSServer", + "layers": "Litologiset_yksik%C3%B6t_200k25132", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "GTK Open Licence (CC BY 4.0) - https://www.gtk.fi/en/open-licence/ ; product licence type from https://www.gtk.fi/app/uploads/2026/11/gtk_paikkatietoaineistot_hinnasto_price_list_for_digital_data_products_2026_11_23.pdf", + "attribution": "Bedrock of Finland 1:200 000 © Geological Survey of Finland (GTK), CC BY 4.0", + "status": "verified" + }, + { + "id": "geology_gtk_1m", + "name": "Bedrock of Finland 1:1 000 000 (rock associations)", + "provider": "GTK - Geological Survey of Finland", + "area": [ + 15.619292, + 59.352464, + 33.107505, + 70.094874 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://gtkdata.gtk.fi/arcgis/services/Rajapinnat/GTK_Kalliopera_WMS/MapServer/WMSServer", + "layers": "kalliopera_1m_kivilajiseurueet", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "GTK Open Licence (CC BY 4.0) - https://www.gtk.fi/en/open-licence/ ; product licence type from https://www.gtk.fi/app/uploads/2026/11/gtk_paikkatietoaineistot_hinnasto_price_list_for_digital_data_products_2026_11_23.pdf", + "attribution": "Bedrock of Finland 1:1 000 000 © Geological Survey of Finland (GTK), CC BY 4.0", + "status": "verified" + }, + { + "id": "geology_sgu_50k_250k", + "name": "Sweden bedrock 1:50 000-1:250 000 (geological units)", + "provider": "SGU - Geological Survey of Sweden", + "area": [ + 8.643886, + 55.164931, + 25.48694, + 69.14879 + ], + "level": "N2", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://maps3.sgu.se/geoserver/wms", + "layers": "berg:SE.GOV.SGU.BERG.GEOLOGISK_ENHET.YTA.50K", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Creative Commons Zero (CC0 1.0) - https://www.sgu.se/en/products/geological-data/about-sgus-geological-data/license-terms-for-sgus-geological-data/", + "attribution": "Geological Survey of Sweden (SGU), CC0", + "status": "verified" + }, + { + "id": "geology_sgu_1m", + "name": "Sweden bedrock 1:1 000 000 (lithology)", + "provider": "SGU - Geological Survey of Sweden", + "area": [ + 10.030101, + 54.980461, + 24.219509, + 69.061768 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://maps3.sgu.se/geoserver/wms", + "layers": "inspire:GE.GeologicUnit.SGU.Bedrock_1M.Lithology.Polygon", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Creative Commons Zero (CC0 1.0) - https://www.sgu.se/en/products/geological-data/about-sgus-geological-data/license-terms-for-sgus-geological-data/", + "attribution": "Geological Survey of Sweden (SGU), CC0", + "status": "verified" + }, + { + "id": "geology_gsi_100k", + "name": "Ireland bedrock geology 1:100 000", + "provider": "GSI - Geological Survey Ireland", + "area": [ + -10.902858, + 51.399901, + -5.875165, + 55.449228 + ], + "level": "N3", + "source_scale": 100000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://gsi.geodata.gov.ie/server/services/Bedrock/IE_GSI_Bedrock_Geology_Datasets_100K_IE26_ITM/MapServer/WMSServer", + "layers": "IE_GSI_Bedrock_Geology_100K_IE26_ITM", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 14, + "empty_tile": "transparent", + "licence": "CC BY 4.0 - https://creativecommons.org/licenses/by/4.0/ (WMS AccessConstraints + https://gsi.ie/data-and-maps/ \"GSI Data Licence Agreement\")", + "attribution": "Contains Irish Public Sector Data (Geological Survey Ireland) licensed under a Creative Commons Attribution 4.0 International (CC BY 4.0) licence", + "status": "verified" + }, + { + "id": "geology_spw_wallonie_25k", + "name": "Geological map of Wallonia 1:25 000 (lithostratigraphic units)", + "provider": "SPW - Service géologique de Wallonie", + "area": [ + 3.175739, + 49.488512, + 6.23113, + 50.824268 + ], + "level": "N3", + "source_scale": 25000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://geoservices.wallonie.be/arcgis/services/SOL_SOUS_SOL/CARTE_GEOLOGIQUE_SIMPLE/MapServer/WMSServer", + "layers": "2", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 16, + "empty_tile": "transparent", + "licence": "CC BY 4.0 (data, Metawal record 5bb1c85c-abe1-46b3-9af6-489ab95cd0cb https://geodata.wallonie.be/id/5bb1c85c-abe1-46b3-9af6-489ab95cd0cb) + SPW visualisation-service conditions v1.1 https://geoportail.wallonie.be/files/documents/ConditionsSPW/LicServicesSPW.pdf", + "attribution": "Source : Service public de Wallonie (SPW) - Carte géologique de Wallonie (CGEOL_SIMPLE), CC BY 4.0", + "status": "verified" + }, + { + "id": "geology_spw_wallonie_n2", + "name": "Geological map of Wallonia (small-scale view)", + "provider": "SPW - Service géologique de Wallonie", + "area": [ + 3.175734, + 49.488512, + 6.23113, + 50.824476 + ], + "level": "N2", + "source_scale": 25000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://geoservices.wallonie.be/arcgis/services/SOL_SOUS_SOL/CARTE_GEOLOGIQUE_SIMPLE/MapServer/WMSServer", + "layers": "1,2", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 16, + "empty_tile": "transparent", + "licence": "CC BY 4.0 (data, Metawal record 5bb1c85c-abe1-46b3-9af6-489ab95cd0cb https://geodata.wallonie.be/id/5bb1c85c-abe1-46b3-9af6-489ab95cd0cb) + SPW visualisation-service conditions v1.1 https://geoportail.wallonie.be/files/documents/ConditionsSPW/LicServicesSPW.pdf", + "attribution": "Source : Service public de Wallonie (SPW) - Carte géologique de Wallonie (CGEOL_SIMPLE), CC BY 4.0", + "status": "verified" + }, + { + "id": "geology_dov_tertiair_50k", + "name": "Flanders Tertiary geological map 1:50 000", + "provider": "Departement Omgeving (Vlaamse overheid) - Databank Ondergrond Vlaanderen (DOV)", + "area": [ + 2.528904, + 50.673935, + 5.935354, + 51.504963 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://www.dov.vlaanderen.be/geoserver/wms", + "layers": "neo_paleo:tertiair_50k", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Modellicentie voor gratis hergebruik (Flemish free re-use model licence, CC BY compatible) - https://www.vlaanderen.be/digitaal-vlaanderen/onze-oplossingen/open-data/voorwaarden-voor-het-hergebruik-van-overheidsinformatie/modellicentie-gratis-hergebruik ; metadata https://metadata.vlaanderen.be/srv/api/records/E965C068-A1BE-43C3-AD0B-34BC44FE1D2C", + "attribution": "Bron: Dept Omgeving", + "status": "to_check", + "notes": "Licence ouverte, mais carte du Tertiaire sous la couverture quaternaire, pas de la géologie de surface : incohérente à la frontière wallonne." + }, + { + "id": "geology_geosphere_geofast_50k", + "name": "Austria GEOFAST geological maps 1:50 000", + "provider": "GeoSphere Austria", + "area": [ + 9.830706, + 46.496621, + 17.08705, + 49.02196 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://gis.geosphere.at/images/services/geologie/karte_geofast_50/ImageServer/WMSServer", + "layers": "0", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 17, + "empty_tile": "transparent", + "licence": "CC BY 4.0 - https://creativecommons.org/licenses/by/4.0/ (WMS AccessConstraints and REST copyrightText \"©GeoSphere Austria / CC BY 4.0\"); printed GEOFAST sheets credit the topographic base \"© BEV - Bundesamtes für Eich- und Vermessungswesen CC BY 4.0\"", + "attribution": "© GeoSphere Austria, CC BY 4.0; Topografie © BEV, CC BY 4.0", + "status": "verified" + }, + { + "id": "geology_geosphere_500k", + "name": "Geological map of Austria 1:500 000", + "provider": "GeoSphere Austria", + "area": [ + 9.530807, + 46.372306, + 17.160717, + 49.020709 + ], + "level": "N1", + "source_scale": 500000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://gis.geosphere.at/maps/services/geologie/karte_500/MapServer/WMSServer", + "layers": "0", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "CC BY 4.0 (WMS AccessConstraints \"©GeoSphere Austria / CC BY 4.0\")", + "attribution": "© GeoSphere Austria, CC BY 4.0", + "status": "to_check", + "notes": "to_check: technical only. Capabilities fetched OK (layer 0 \"Geologische Einheiten\"), but every GetMap returned HTTP 500 then 503 (\"No server is available\") - the whole /maps/ instance was down. Retest; licence text itself is fine." + }, + { + "id": "geology_lneg_50k", + "name": "Geological map of Portugal 1:50 000 (raster mosaic)", + "provider": "LNEG - Laboratório Nacional de Energia e Geologia", + "area": [ + -9.68237, + 36.943011, + -6.196717, + 42.189552 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://sig.lneg.pt/server/services/CGP50k/MapServer/WMSServer", + "layers": "2", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "unclear - see notes", + "attribution": "LNEG - Carta Geológica de Portugal 1:50 000", + "status": "to_check", + "notes": "to_check: dataset metadata (EGDI/dados.gov.pt) says CC BY 4.0, but the LNEG geoPortal Legal Notice (https://geoportal.lneg.pt/en/legal_notice/) states \"its use for commercial or offensive purposes is prohibited\". Contradiction -> do not ship until LNEG confirms in writing. WMS AccessConstraints empty. Tech: layer \"2\" (Image of mosaic group \"Geologia\", MaxScaleDenominator 1.89M) draws at z13 Lisbon in 0.57 s; scanned sheets with topography; coverage = published sheets only." + }, + { + "id": "geology_lneg_500k", + "name": "Geological map of Portugal 1:500 000", + "provider": "LNEG - Laboratório Nacional de Energia e Geologia", + "area": [ + -9.569808, + 36.942051, + -6.168756, + 42.157365 + ], + "level": "N2", + "source_scale": 500000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://sig.lneg.pt/server/services/CGP500k/MapServer/WMSServer", + "layers": "2", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "unclear - see notes", + "attribution": "LNEG - Carta Geológica de Portugal 1:500 000", + "status": "to_check", + "notes": "to_check: dataset metadata (EGDI/dados.gov.pt) says CC BY 4.0, but the LNEG geoPortal Legal Notice (https://geoportal.lneg.pt/en/legal_notice/) states \"its use for commercial or offensive purposes is prohibited\". Contradiction -> do not ship until LNEG confirms in writing. WMS AccessConstraints empty. Tech: layer \"2\" Geologia do Continente, z9 OK 0.75 s." + }, + { + "id": "geology_lneg_1m", + "name": "Geological map of Portugal 1:1 000 000", + "provider": "LNEG - Laboratório Nacional de Energia e Geologia", + "area": [ + -9.575005, + 36.948019, + -6.172037, + 42.15433 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://sig.lneg.pt/server/services/CGP1M/MapServer/WMSServer", + "layers": "Unidades_Geológicas421", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "unclear - see notes", + "attribution": "LNEG - Carta Geológica de Portugal 1:1 000 000", + "status": "to_check", + "notes": "to_check: dataset metadata (EGDI/dados.gov.pt) says CC BY 4.0, but the LNEG geoPortal Legal Notice (https://geoportal.lneg.pt/en/legal_notice/) states \"its use for commercial or offensive purposes is prohibited\". Contradiction -> do not ship until LNEG confirms in writing. WMS AccessConstraints empty. Tech: layer name has non-ASCII \"ó\" (URL-encode); z7 OK 0.65 s. Islands (Azores/Madeira) are separate layers of the same service." + }, + { + "id": "geology_ispra_carg_50k", + "name": "Italy CARG geological map 1:50 000 (geological units)", + "provider": "ISPRA - Servizio Geologico d'Italia", + "area": [ + 6.626458, + 37.198892, + 18.665947, + 47.199204 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://sinacloud.isprambiente.it/arcgisgeo/services/geo/SGI_ISPRA_Geologia25k/MapServer/WMSServer", + "layers": "0", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "unclear - see notes", + "attribution": "Servizio Geologico d'Italia - ISPRA", + "status": "to_check", + "notes": "to_check: ISPRA geo services carry no licence in capabilities; the sibling ISPRA raster service (sgi2 geo_100k_italia) AccessConstraints say \"L'uso dei dati per altri fini che non siano la semplice visualizzazione e' soggetto alla legge e deve esserne richiesto l'uso al Servizio Geologico d'Italia\", while the ISPRA site copyright page says CC BY 4.0 unless stated otherwise. Contradiction -> ask ISPRA. Tech: layer \"0\" Unità geologiche (CARG database rendered at 1:25k), MaxScaleDenominator 236235 -> z12+; partial coverage (only CARG sheets loaded: Florence z13 transparent, L'Aquila and Bergamo OK). ~0.6 s/tile." + }, + { + "id": "geology_ispra_100k", + "name": "Italy geological map 1:100 000 (geological units)", + "provider": "ISPRA - Servizio Geologico d'Italia", + "area": [ + 6.455743, + 35.215271, + 19.614583, + 47.137533 + ], + "level": "N2", + "source_scale": 100000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://sinacloud.isprambiente.it/arcgisgeo/services/servizi/geologica100k/MapServer/WMSServer", + "layers": "0", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "unclear - see notes", + "attribution": "Servizio Geologico d'Italia - ISPRA", + "status": "to_check", + "notes": "to_check: ISPRA geo services carry no licence in capabilities; the sibling ISPRA raster service (sgi2 geo_100k_italia) AccessConstraints say \"L'uso dei dati per altri fini che non siano la semplice visualizzazione e' soggetto alla legge e deve esserne richiesto l'uso al Servizio Geologico d'Italia\", while the ISPRA site copyright page says CC BY 4.0 unless stated otherwise. Contradiction -> ask ISPRA. Tech: MaxScaleDenominator 472470 -> transparent at z10, draws z11+; first z11 tile took 11.9 s (cold cache) then 0.5 s at z12 - risky vs 10 s timeout." + }, + { + "id": "geology_cgs_geocr50", + "name": "Geological map of the Czech Republic 1:50 000 (GEOCR50)", + "provider": "ČGS - Czech Geological Survey", + "area": [ + 11.939305, + 48.23201, + 18.957832, + 51.354768 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://mapy.geology.cz/arcgis/services/Geologie/geologicka_mapa50/MapServer/WMSServer", + "layers": "0", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "WMS AccessConstraints \"CC BY 4.0\" - unconfirmed, see notes", + "attribution": "(CC BY 4.0) Czech Geological Survey", + "status": "to_check", + "notes": "to_check: WMS AccessConstraints of geologicka_mapa50 say \"CC BY 4.0\", but the CGS copyright page (https://cgs.gov.cz/en/copyright) says website material needs written permission and grants CC BY 4.0 explicitly only for INSPIRE dataset downloads; the GEOCR50 dataset metadata (EGDI) says \"Copyright (All Rights Reserved)\" and refers to a licence agreement; CGS sells GEOCR50 data under a price list. Ask data@geology.cz. Tech: no EPSG:3857 -> CRS:84; layer 0 \"Horniny GeoČR50\" draws z13 Prague 0.32 s; no max-scale limit." + }, + { + "id": "geology_cgs_500k", + "name": "Geological map of the Czech Republic 1:500 000", + "provider": "ČGS - Czech Geological Survey", + "area": [ + 11.939436, + 48.23201, + 18.957832, + 51.354281 + ], + "level": "N1", + "source_scale": 500000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://mapy.geology.cz/arcgis/services/Geologie/geologicka_mapa500/MapServer/WMSServer", + "layers": "0", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "WMS AccessConstraints \"Copyright\" - not an open licence", + "attribution": "Czech Geological Survey", + "status": "to_check", + "notes": "to_check: AccessConstraints just \"Copyright\"; same CGS licence ambiguity as geology_cgs_geocr50. Tech: layer 0 \"Horniny\", z8 OK 0.41 s, CRS:84." + }, + { + "id": "geology_pgi_smgp_50k", + "name": "Detailed Geological Map of Poland 1:50 000 (SMGP)", + "provider": "PIG-PIB - Polish Geological Institute", + "area": [ + 13.875912, + 48.960363, + 24.644569, + 55.00204 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://cbdgmapa.pgi.gov.pl/arcgis/services/kartografia/smgp50k/MapServer/WMSServer", + "layers": "0", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "no explicit licence - see notes", + "attribution": "Państwowy Instytut Geologiczny - PIB", + "status": "to_check", + "notes": "to_check: WMS AccessConstraints empty; PIG-PIB metadata of SMGP sheets only use the INSPIRE codelist values \"Brak ograniczeń w publicznym dostępie\" / \"Brak warunków dostępu i użytkowania\" (noConditionsApply) - no named licence, nothing explicit on commercial redistribution or caching; geological information in Poland is governed by the Geological and Mining Law. Ask PIG-PIB for an explicit licence. Tech: layer 0 \"SMGP50k - wydzielenia geologiczne\", MaxScaleDenominator 94494 -> z13+ only (z12 transparent); Tatra/Zakopane z13 OK 0.53 s." + }, + { + "id": "geology_pgi_mgp_500k", + "name": "Geological Map of Poland 1:500 000 (Quaternary)", + "provider": "PIG-PIB - Polish Geological Institute", + "area": [ + 13.756915, + 49.048429, + 24.776311, + 55.923228 + ], + "level": "N2", + "source_scale": 500000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://cbdgmapa.pgi.gov.pl/arcgis/services/kartografia/mgp500k_2022/MapServer/WMSServer", + "layers": "11", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 13, + "empty_tile": "transparent", + "licence": "no explicit licence - see notes", + "attribution": "Państwowy Instytut Geologiczny - PIB", + "status": "to_check", + "notes": "to_check: WMS AccessConstraints empty; PIG-PIB metadata of SMGP sheets only use the INSPIRE codelist values \"Brak ograniczeń w publicznym dostępie\" / \"Brak warunków dostępu i użytkowania\" (noConditionsApply) - no named licence, nothing explicit on commercial redistribution or caching; geological information in Poland is governed by the Geological and Mining Law. Ask PIG-PIB for an explicit licence. Tech: layer 11 \"MGP500k - wydzielenia geologiczne czwartorzędu\" (surface Quaternary; layer 1 = sub-Cenozoic), MinScaleDenominator 94494 -> transparent from z13; z9 OK 0.46 s." + }, + { + "id": "geology_geus_25k", + "name": "Denmark surface geology (jordartskort) 1:25 000", + "provider": "GEUS - Geological Survey of Denmark and Greenland", + "area": [ + 8.015796, + 54.443147, + 15.576004, + 57.761365 + ], + "level": "N3", + "source_scale": 25000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://data.geus.dk/arcgis/services/Denmark/Jordartskort_25000/MapServer/WMSServer", + "layers": "Jordartskort", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "GEUS terms for free data 2014-06-20 (not open)", + "attribution": "GEUS", + "status": "to_check", + "notes": "to_check (likely excluded): WMS AccessConstraints empty; GEUS terms for free data (https://data.geus.dk/geusmap/terms_20140620.pdf) grant use \"til eget brug\" only and say \"Kunden har ikke ret til at kopiere, offentliggøre, videresælge, udlåne eller udleje eksemplarer af hele eller dele af Dataleverancen ... med mindre GEUS giver forudgående skriftligt samtykke\". Not compatible with tile caching/redistribution. Tech: no EPSG:3857; z13 Aarhus area 0.31 s but only 35% opaque (coverage gaps / water)." + }, + { + "id": "geology_geus_200k", + "name": "Denmark surface geology (jordartskort) 1:200 000", + "provider": "GEUS - Geological Survey of Denmark and Greenland", + "area": [ + 8.015044, + 54.442878, + 15.579855, + 57.761269 + ], + "level": "N2", + "source_scale": 200000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://data.geus.dk/arcgis/services/Denmark/Jordartskort_200000/MapServer/WMSServer", + "layers": "Jordart_200000", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "GEUS terms for free data 2014-06-20 (not open)", + "attribution": "GEUS", + "status": "to_check", + "notes": "to_check (likely excluded): WMS AccessConstraints empty; GEUS terms for free data (https://data.geus.dk/geusmap/terms_20140620.pdf) grant use \"til eget brug\" only and say \"Kunden har ikke ret til at kopiere, offentliggøre, videresælge, udlåne eller udleje eksemplarer af hele eller dele af Dataleverancen ... med mindre GEUS giver forudgående skriftligt samtykke\". Not compatible with tile caching/redistribution. Tech: z9 OK 0.42 s." + }, + { + "id": "geology_gsc_canada_5m", + "name": "Geological map of Canada (1860A)", + "provider": "Natural Resources Canada – Geological Survey of Canada", + "area": [ + -177.062, + 32.806, + -8.758, + 84.11 + ], + "level": "N1", + "source_scale": 5000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://maps-cartes.services.geo.ca/server_serveur/services/NRCan/geological_map_canada_wheeler_en/MapServer/WMSServer", + "layers": "0", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Open Government Licence – Canada, https://open.canada.ca/en/open-government-licence-canada", + "attribution": "Geological Survey of Canada, Natural Resources Canada (Wheeler et al. 1996, Map 1860A). Contains information licensed under the Open Government Licence – Canada.", + "status": "verified" + }, + { + "id": "geology_gsc_cgmc_250k", + "name": "Canada Geological Map Compilation (lithology)", + "provider": "Natural Resources Canada – Geological Survey of Canada", + "area": [ + -173.455, + 35.838, + -12.017, + 83.775 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://maps-cartes.services.geo.ca/server_serveur/services/NRCan/cdn_geol_compil_en/MapServer/WMSServer", + "layers": "0", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Open Government Licence – Canada, https://open.canada.ca/en/open-government-licence-canada", + "attribution": "Canada Geological Map Compilation, Geological Survey of Canada, Natural Resources Canada. Contains information licensed under the Open Government Licence – Canada.", + "status": "to_check", + "notes": "Technically OK, and the open.canada.ca record d4f80bd3-17e3-a7e8-4bfe-d22a430678d5 says OGL-Canada, 'unrestricted'. to_check because CGMC is a derivative of provincial survey maps (record: 'sourced from provincial, territorial, and other geological survey organizations'). OGL-Canada excludes 'third party rights the Information Provider is not authorized to license'. The Ontario source's own terms forbid commercial use and 'the creation of value-added products'. Confirm with NRCan that CGMC is cleared for commercial reuse. Raster layer with about 250 m pixels (blocky from z12), 35 generalized lithology classes, source scales 1:30k to 1:5M. EPSG:3857 works but is not advertised." + }, + { + "id": "geology_ogs_ontario_250k", + "name": "Bedrock geology of Ontario 1:250 000 (MRD126)", + "provider": "Ontario Geological Survey", + "area": [ + -95.154, + 41.677, + -74.32, + 56.859 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://ws.lioservices.lrc.gov.on.ca/arcgis2/services/GeologyOntario/GeologyOntario_Map/MapServer/WMSServer", + "layers": "3", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Ministry Terms of Use, http://www.geologyontario.mndm.gov.on.ca/terms_of_use.html (NOT an open licence)", + "attribution": "Ontario Geological Survey, © King's Printer for Ontario", + "status": "to_check", + "notes": "REJECT unless written permission is obtained. data.ontario.ca lists licence 'ministry-tou', not OGL-Ontario. The terms say: 'Any substantial reproduction of the Content or any commercial use of all or part of the Content is prohibited without the prior written permission of the Ministry... Commercial use includes commercial distribution of the Content ... and the creation of value-added products using the Content.' Technically OK: WMS 1.3.0, layer 3 'Bedrock Geology', MaxScaleDenominator 18.9M, fast (~0.5 s)." + }, + { + "id": "geology_bcgs_bc_50k", + "name": "British Columbia Digital Geology – Bedrock Geology", + "provider": "British Columbia Geological Survey", + "area": [ + -139.178, + 47.604, + -110.353, + 60.594 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://openmaps.gov.bc.ca/geo/pub/WHSE_MINERAL_TENURE.GEOL_BEDROCK_UNIT_POLY_SVW/ows", + "layers": "pub:WHSE_MINERAL_TENURE.GEOL_BEDROCK_UNIT_POLY_SVW", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Open Government Licence – British Columbia, https://www2.gov.bc.ca/gov/content/data/policy-standards/data-policies/open-data/open-government-licence-bc", + "attribution": "British Columbia Geological Survey. Contains information licensed under the Open Government Licence – British Columbia.", + "status": "verified" + }, + { + "id": "geology_mrnf_quebec_regional", + "name": "SIGEOM – Géologie régionale du Québec", + "provider": "Ministère des Ressources naturelles et des Forêts du Québec (SIGEOM)", + "area": [ + -85.0, + 40.0, + -50.0, + 65.0 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://servicesvectoriels.atlas.gouv.qc.ca/IDS_SGM_WMS/service.svc/get", + "layers": "SGM:Geologie_regionale", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Licence du gouvernement ouvert – Québec = CC BY 4.0, https://creativecommons.org/licenses/by/4.0/deed.fr", + "attribution": "Ministère des Ressources naturelles et des Forêts du Québec (SIGEOM)", + "status": "to_check", + "notes": "The licence is fine. Capabilities AccessConstraints: 'Licence du gouvernement ouvert - Québec (https://creativecommons.org/licenses/by/4.0/deed.fr)', Fees 'Données ouvertes'. Données Québec datasets are cc-by. BLOCKER: the service supports only WMS 1.1.1. VERSION=1.3.0 returns ServiceException 'Value 1.3.0 provided for a parameter version is invalid'. WMS 1.1.1 GetMap with SRS=EPSG:3857 renders correctly near Rouyn-Noranda (lon -79.0, lat 48.24) at z8 and z13. Capabilities take ~50 s. The source scale of 'Géologie régionale' (1:250k assumed) is not stated in the capabilities. N1 alternative: 'SGM:Geologie_generale' at 1:2M." + }, + { + "id": "geology_sgb_brazil_1m", + "name": "Carta Geológica do Brasil ao Milionésimo – Unidades Litoestratigráficas", + "provider": "Serviço Geológico do Brasil (SGB/CPRM)", + "area": [ + -73.992, + -33.751, + -34.79, + 5.283 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://geoservicos.sgb.gov.br/geoserver/ows", + "layers": "geosgb:litoestratigrafia_1m", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "unknown", + "attribution": "Serviço Geológico do Brasil – SGB/CPRM", + "status": "to_check", + "notes": "No licence text found. Capabilities give Fees NONE and AccessConstraints NONE, which is not a licence. No terms page found on sgb.gov.br or geosgb. The service itself works: GeoServer WMS 1.3.0. Response time is ~10 s at z5 (at the app's 10 s limit), ~3-6 s at z6 and ~1 s from z8. Other layers: litoestratigrafia_250k/100k/50k/25k, patchy coverage (transparent at Quadrilátero Ferrífero z8-z12)." + }, + { + "id": "geology_sgc_colombia_500k", + "name": "Atlas Geológico de Colombia 2023 – Unidades Cronoestratigráficas", + "provider": "Servicio Geológico Colombiano", + "area": [ + -84.764, + -6.989, + -60.892, + 16.167 + ], + "level": "N2", + "source_scale": 500000, + "min_scale": 0, + "max_scale": 1000000, + "protocol": "wms", + "url": "https://srvags.sgc.gov.co/arcgis/services/Mapa_Geologico_Colombia/Mapa_Geologico_Colombia_V2023/MapServer/WMSServer", + "layers": "3", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "SGC Términos generales y condiciones para el uso de la información, https://www2.sgc.gov.co/sgc/mapas/Documents/CondGenTermLicUso.pdf (restrictive)", + "attribution": "Servicio Geológico Colombiano", + "status": "to_check", + "notes": "Licence contradicts commercial use. SGC general terms grant a non-exclusive, non-transferable use licence for a specific purpose. They also say the licensee shall not commercialize or exchange the data without written authorization from SGC (read in web search summary; PDF not fetched directly). Technically OK: ArcGIS WMS 1.3.0, WMS layer '3' = 'Unidades Cronoestratigráficas', 1:500k, GetMap 1-2 s. EPSG:3857 works but is not advertised. Test site Bogotá (lon -74.07, lat 4.6), good tile z9/150/249." + }, + { + "id": "geology_gsnsw_seamless", + "name": "NSW Seamless Geology", + "provider": "Geological Survey of New South Wales (DPIRD)", + "area": [ + 140.96, + -37.57, + 159.26, + -28.07 + ], + "level": "N2", + "source_scale": 100000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://gs-seamless.geoscience.nsw.gov.au/geoserver/ows", + "layers": "geology:nsw_surface_no_hillshade", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Creative Commons Attribution 3.0 Australia (data.gov.au record 'NSW Seamless Geology', license_url http://creativecommons.org/licenses/by/3.0/au/); Data.NSW record: 'cc-by Creative Commons Attribution'; WMS AccessConstraints 'none', Fees 'none'", + "attribution": "NSW Seamless Geology © Geological Survey of New South Wales, Department of Primary Industries and Regional Development, CC BY 3.0 AU", + "status": "verified" + }, + { + "id": "geology_gsq_detailed_100k", + "name": "Queensland detailed surface geology 1:100k", + "provider": "Geological Survey of Queensland", + "area": [ + 137.995, + -29.5, + 153.639, + -9.0 + ], + "level": "N2", + "source_scale": 100000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://spatial-gis.information.qld.gov.au/arcgis/services/GeoscientificInformation/GeologyDetailed/MapServer/WMSServer", + "layers": "Detailed_surface_geology47720,Detailed_faults_and_shear_zones17471", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Creative Commons Attribution 4.0 International (WMS AccessConstraints: 'This service is free to use and is licensed under a Creative Commons - Attribution 4.0 International licence.'; data.qld.gov.au 'Queensland geology detailed web map service' = CC-BY-4.0, https://creativecommons.org/licenses/by/4.0/)", + "attribution": "© State of Queensland (Department of Natural Resources and Mines, Manufacturing and Regional and Rural Development) 2026", + "status": "verified" + }, + { + "id": "geology_gsv_seamless_50k", + "name": "Victoria Seamless Geology 1:50k", + "provider": "Geological Survey of Victoria (DEECA)", + "area": [ + 140.97, + -38.86, + 149.5, + -35.93 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://opendata.maps.vic.gov.au/geoserver/wms", + "layers": "open-data-platform:sg_geological_unit_50k", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "DataVic: Creative Commons Attribution 4.0 International (https://creativecommons.org/licenses/by/4.0/); BUT ISO metadata useLimitation contradicts it", + "attribution": "Seamless Geology © State of Victoria (Geological Survey of Victoria), CC BY 4.0", + "status": "to_check", + "notes": "TO_CHECK: Metashare ISO record b16d9cce-8613-5e05-acc0-1aa60d37a2ab has MD_LegalConstraints 'Creative Commons CC-BY-4.0' but also useLimitation: 'The data is subject to Crown copyright (State of Victoria) and interested parties are required to enter into a licence agreement. Subject to licence conditions'. Ask GSV/DataVic to confirm CC BY 4.0 applies to WMS tile caching. Technically fine: tiles at Ballarat z10-16 1.2-2.6 s; z6 20 s and z8 15 s (only relevant if shown below N3 range). Default style sg_geology_stratigraphy; alternative style open-data-platform:sg_geology_age. Outside Victoria: transparent 1784-byte PNG." + }, + { + "id": "geology_gsv_seamless_250k", + "name": "Victoria Seamless Geology 1:250k", + "provider": "Geological Survey of Victoria (DEECA)", + "area": [ + 140.96, + -39.16, + 149.98, + -33.98 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://opendata.maps.vic.gov.au/geoserver/wms", + "layers": "open-data-platform:sg_geological_unit_250k", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "DataVic: Creative Commons Attribution 4.0 International (https://creativecommons.org/licenses/by/4.0/); BUT ISO metadata useLimitation contradicts it", + "attribution": "Seamless Geology © State of Victoria (Geological Survey of Victoria), CC BY 4.0", + "status": "to_check", + "notes": "TO_CHECK: same contradiction as the 1:50k layer (ISO record d6f410a9-57a4-5414-9c22-0360328a02ef: 'subject to Crown copyright (State of Victoria) and interested parties are required to enter into a licence agreement. Subject to licence conditions'). Tiles at Ballarat z8-12: 1.5-4 s, opaque, thousands of colours." + }, + { + "id": "geology_gns_qmap_250k", + "name": "QMAP Geological Map of New Zealand 1:250k", + "provider": "GNS Science", + "area": [ + 166.18, + -49.54, + 180.0, + -31.93 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://maps.gns.cri.nz/geology/wms", + "layers": "NZL_GNS_250K_seamless_qmap_geological_map_current_view", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Conflicting: WMS AccessConstraints = CC BY 3.0 NZ; GNS 'using our geological maps' page = CC BY 4.0 'unless stated otherwise'; GNS Data Portal Terms (data.gns.cri.nz/mapservice/Content/Terms_1.html) = personal, non-transferable licence forbidding sublicensing/redistribution", + "attribution": "QMAP Geological Map of New Zealand 1:250 000 © GNS Science", + "status": "to_check", + "notes": "TO_CHECK: capabilities say 'Copyright GNS Science 2014. These map data are released free under the Creative Commons Attribution 3.0 New Zealand (CC-BY 3.0) Licence', but the GNS Science Data Portal Terms of Access and Use grant 'a personal, non -exclusive, non-assignable, non-transferable licence' and 'You may not: transfer or sublicense the Products publish or provide copies of all or any substantial part of any of the Products to any other parties, without prior written permission from GNS Science; or on-sell the Products'. Ask GNS which applies to maps.gns.cri.nz WMS tiles. Technically fine: Wellington z12-18 and Pukekohe z11 1.1-1.7 s; z5 15 s, z7 7 s (below N2 range). bbox spans the antimeridian in caps (Chatham Is.); area here excludes Chathams. This is the 2013-era seamless QMAP; the 4th edition (2023) is on gis.gns.cri.nz ArcGIS WMS but without EPSG:3857 (CRS:84/EPSG:4326 only) and with topographic layers credited to LINZ/NIWA." + }, + { + "id": "geology_gswa_500k", + "name": "Western Australia interpreted bedrock geology 1:500k", + "provider": "Geological Survey of Western Australia (DEMIRS) via SLIP", + "area": [ + 112.92, + -35.19, + 129.0, + -13.69 + ], + "level": "N2", + "source_scale": 500000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://public-services.slip.wa.gov.au/public/services/SLIP_Public_Services/Geology_and_Soils_Map/MapServer/WMSServer", + "layers": "16", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Conflicting: data.wa.gov.au DMIRS-016 = CC BY 4.0; SLIP service copyrightText = 'SLIP Transaction - Personal Use Licence' (non-commercial)", + "attribution": "1:500 000 State interpreted bedrock geology (DMIRS-016) © Geological Survey of Western Australia", + "status": "to_check", + "notes": "TO_CHECK: the MapServer copyrightText says 'by opening, viewing or using this data, you agree to only use this data for your personal and non-commercial use. You are not permitted to, in any form, reproduce, distribute, commercialise or create derivative works of this data without the data custodians prior written permission.' This contradicts the CC BY 4.0 catalogue record -> do not ship until DEMIRS/Landgate confirm. Interpreted BEDROCK (not surface) geology. Technically fine: Kalgoorlie z6-12 0.4-1.5 s. Layer 18 = '1:100 000 Interpreted Bedrock Geology (DMIRS-038)' (MaxScaleDenominator 1889880, partial coverage) is the N3-ish companion, same licence issue. GSWA's own geossdi.dmp.wa.gov.au answers with a bot/login proxy page." + }, + { + "id": "geology_gssa_geologic_units", + "name": "South Australia geologic units (GeoSciML portrayal)", + "provider": "Geological Survey of South Australia (Department for Energy and Mining)", + "area": [ + 128.5, + -44.5, + 141.5, + -25.5 + ], + "level": "N2", + "source_scale": 100000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://sarigdata.pir.sa.gov.au/geoserver/ows", + "layers": "gsmlp:GeologicUnitView", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Creative Commons Attribution 4.0 International (WMS AccessConstraints: 'This product is released under the Creative Commons Attribution 4.0 International Public License (CC BY 4.0)'; GSSA data services page: 'GSSA data services are open government services and licenced under Creative Commons')", + "attribution": "© Department for Energy and Mining, South Australia (Geological Survey of South Australia), CC BY 4.0", + "status": "to_check", + "notes": "TO_CHECK (performance, not licence): every GetMap took 31-34 s (z6-z14, two separate runs) -> exceeds the app's 10 s per-tile budget. z6/z8 returned fully transparent (likely scale-dependent rendering); z10-14 near Port Augusta (138.60,-32.50) opaque with 800-3000 colours. Source scale of the underlying compilation not stated in caps (100000 is a guess -> confirm). Licence text itself looks clean. Alternative services.sarig.sa.gov.au/vector/geology/wms has time-slice solid geology and 7M surface geology only; its GetCapabilities took 29 s." + }, + { + "id": "geology_mrt_tas_25k", + "name": "Tasmania geological polygons 1:25k", + "provider": "Mineral Resources Tasmania via theLIST", + "area": [ + 143.52, + -43.9, + 148.87, + -39.29 + ], + "level": "N3", + "source_scale": 25000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://services.thelist.tas.gov.au/arcgis/services/Public/GeologicalAndSoils/MapServer/WMSServer", + "layers": "Geological_Polygons_25K3024,Geological_Lines_25K57378", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Not stated: WMS Fees/AccessConstraints empty, MapServer copyrightText empty; no licence text found", + "attribution": "Mineral Resources Tasmania, theLIST © State of Tasmania", + "status": "to_check", + "notes": "TO_CHECK: (1) no licence text found anywhere on the service; (2) the default style renders polygon OUTLINES only (no unit colour fill, 4-10 colours per tile, ~45% opaque) -> not usable as a colour geology basemap. Scale-limited: 25K polygons MaxScaleDenominator 330729 (z11+), 250K polygons 500000 (z11+). Tested at Queenstown (145.55,-42.08) z11-16, 1.1-2.1 s." + }, + { + "id": "geology_kigam_50k", + "name": "Korea geological map 1:50k", + "provider": "Korea Institute of Geoscience and Mineral Resources (KIGAM)", + "area": [ + 124.61, + 33.11, + 131.87, + 38.61 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://data.kigam.re.kr/mgeo/geoserver/wms", + "layers": "geoOpen:L_50K_Geology_Map", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Unknown: WMS AccessConstraints 'NONE', Fees 'NONE'; no KOGL type found for the dataset", + "attribution": "Korea Institute of Geoscience and Mineral Resources (KIGAM)", + "status": "to_check", + "notes": "TO_CHECK: KIGAM's documented route is the 'Geo Big Data Open Platform' Open API, issued per applicant after approval (affiliation, domain, purpose). The open GeoServer endpoint answers without a key but no licence (KOGL type 1 vs 2/4) was found; commercial use unconfirmed. Not all 1:50k sheets published (gaps). Tiles at Gyeongju (129.21,35.84) z10-14: 3.6-6.7 s (close to the 10 s budget); GetCapabilities 13 s. Ocean: transparent 1784-byte PNG." + }, + { + "id": "geology_kigam_250k", + "name": "Korea geological map 1:250k", + "provider": "Korea Institute of Geoscience and Mineral Resources (KIGAM)", + "area": [ + 124.58, + 33.0, + 131.87, + 39.0 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://data.kigam.re.kr/mgeo/geoserver/wms", + "layers": "geoOpen:L_250K_Geology_Map", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 18, + "empty_tile": "transparent", + "licence": "Unknown: WMS AccessConstraints 'NONE', Fees 'NONE'; no KOGL type found for the dataset", + "attribution": "Korea Institute of Geoscience and Mineral Resources (KIGAM)", + "status": "to_check", + "notes": "TO_CHECK: same licence gap as the 1:50k layer. Tiles at Gyeongju z9 12.3 s (over budget), z11 4.4 s." } ] diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index ee8bf888..3ddda85a 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -372,6 +372,24 @@ def test_layers_without_scale_windows_keep_one_source_per_mosaic( "geology_usgs_puerto_rico": (10, 322, 459), "geology_ga_1m": (10, 921, 627), "geology_gsj_200k": (10, 907, 402), + "geology_swisstopo_ga25": (13, 4274, 2892), + "geology_swisstopo_swissgeocover2d": (13, 4274, 2892), + "geology_swisstopo_gk500": (10, 534, 361), + "geology_ngu_n50": (13, 4340, 2383), + "geology_ngu_n250": (10, 527, 295), + "geology_ngu_n1350": (7, 66, 36), + "geology_gtk_200k": (11, 1189, 562), + "geology_gtk_1m": (7, 73, 34), + "geology_sgu_50k_250k": (11, 1108, 583), + "geology_sgu_1m": (7, 69, 35), + "geology_gsi_100k": (12, 1943, 1333), + "geology_spw_wallonie_25k": (13, 4206, 2761), + "geology_spw_wallonie_n2": (11, 1051, 690), + "geology_geosphere_geofast_50k": (13, 4355, 2872), + "geology_gsc_canada_5m": (8, 70, 90), + "geology_bcgs_bc_50k": (12, 678, 1377), + "geology_gsnsw_seamless": (10, 936, 612), + "geology_gsq_detailed_100k": (10, 928, 570), } From 4120a2880ebcf74d28a91bca8dbc860b95c12320 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Wed, 25 Nov 2026 16:35:03 +0100 Subject: [PATCH 11/24] =?UTF-8?q?feat(basemap):=20wms=201.1.1=20geology=20?= =?UTF-8?q?sources,=20qu=C3=A9bec=20regional=20geology?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../basemap/geology_registry.py | 34 ++++++++++++++----- .../basemap/geology_sources.json | 8 +++-- tests/test_basemap_geology.py | 17 ++++++++++ 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/src/opengeodeweb_back/basemap/geology_registry.py b/src/opengeodeweb_back/basemap/geology_registry.py index 58e4f5cb..15216b67 100644 --- a/src/opengeodeweb_back/basemap/geology_registry.py +++ b/src/opengeodeweb_back/basemap/geology_registry.py @@ -19,6 +19,9 @@ COLOUR = re.compile(r"#[0-9a-f]{6}") # Web Mercator first: its tiles fall on the tile grid. Else longitude first, then latitude first WMS_CRS_PREFERENCE = ("EPSG:3857", "CRS:84", "EPSG:4326") +# WMS 1.1.1 has no CRS:84, and older servers name Web Mercator EPSG:900913 +WMS_1_1_1_CRS_PREFERENCE = ("EPSG:3857", "EPSG:900913", "EPSG:4326") +WMS_VERSIONS = ("1.3.0", "1.1.1") # No tile grid caps a WMS: past this zoom its tiles are enlarged WMS_MAX_ZOOM = 18 # Web Mercator stops short of the poles @@ -84,22 +87,37 @@ def _check(entry: dict[str, Any]) -> None: def _wms(entry: dict[str, Any]) -> tuple[str, str]: - """The GetMap template of a WMS entry, with its {bbox}, and the CRS it asks.""" + """The GetMap template of a WMS entry, with its {bbox}, and the CRS its bbox is written in.""" + version = entry.get("wms_version", "1.3.0") + if version not in WMS_VERSIONS: + msg = f"Geology source {entry['id']}: unknown WMS version {version}" + raise RegistryError(msg) + preference = WMS_CRS_PREFERENCE if version == "1.3.0" else WMS_1_1_1_CRS_PREFERENCE supported = entry.get("supported_crs") or [] - crs = next((crs for crs in WMS_CRS_PREFERENCE if crs in supported), None) + crs = next((crs for crs in preference if crs in supported), None) if crs is None: - msg = ( - f"Geology source {entry['id']}: the WMS serves none of {', '.join(WMS_CRS_PREFERENCE)}" - ) + msg = f"Geology source {entry['id']}: the WMS serves none of {', '.join(preference)}" raise RegistryError(msg) + # WMS 1.1.1 names the CRS parameter SRS + crs_parameter = "CRS" if version == "1.3.0" else "SRS" query = ( - "SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap" - f"&LAYERS={entry['layers']}&STYLES={entry.get('styles') or ''}&CRS={crs}" + f"SERVICE=WMS&VERSION={version}&REQUEST=GetMap" + f"&LAYERS={entry['layers']}&STYLES={entry.get('styles') or ''}&{crs_parameter}={crs}" "&BBOX={bbox}&WIDTH=256&HEIGHT=256" f"&FORMAT={entry['format']}&TRANSPARENT=TRUE" ) separator = "&" if "?" in entry["url"] else "?" - return f"{entry['url']}{separator}{query}", crs + return f"{entry['url']}{separator}{query}", _bbox_crs(crs, version) + + +def _bbox_crs(crs: str, version: str) -> str: + """How the tile bbox is written: Web Mercator, longitude first, or latitude first.""" + if crs == "EPSG:900913": + return "EPSG:3857" + # Only WMS 1.3.0 follows the latitude first axis order of EPSG:4326 + if crs == "EPSG:4326" and version == "1.1.1": + return "CRS:84" + return crs def _url(entry: dict[str, Any]) -> tuple[str, str | None]: diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index 0330e73c..7ede54e3 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -1706,14 +1706,16 @@ "styles": "", "format": "image/png", "supported_crs": [ - "EPSG:3857" + "EPSG:3857", + "EPSG:900913", + "EPSG:4326" ], "max_zoom": 18, "empty_tile": "transparent", "licence": "Licence du gouvernement ouvert – Québec = CC BY 4.0, https://creativecommons.org/licenses/by/4.0/deed.fr", "attribution": "Ministère des Ressources naturelles et des Forêts du Québec (SIGEOM)", - "status": "to_check", - "notes": "The licence is fine. Capabilities AccessConstraints: 'Licence du gouvernement ouvert - Québec (https://creativecommons.org/licenses/by/4.0/deed.fr)', Fees 'Données ouvertes'. Données Québec datasets are cc-by. BLOCKER: the service supports only WMS 1.1.1. VERSION=1.3.0 returns ServiceException 'Value 1.3.0 provided for a parameter version is invalid'. WMS 1.1.1 GetMap with SRS=EPSG:3857 renders correctly near Rouyn-Noranda (lon -79.0, lat 48.24) at z8 and z13. Capabilities take ~50 s. The source scale of 'Géologie régionale' (1:250k assumed) is not stated in the capabilities. N1 alternative: 'SGM:Geologie_generale' at 1:2M." + "status": "verified", + "wms_version": "1.1.1" }, { "id": "geology_sgb_brazil_1m", diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index 3ddda85a..71691356 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -125,6 +125,22 @@ def test_wms_source_without_web_mercator_asks_crs84(tmp_path: Path) -> None: geology_registry.load(_registry(tmp_path, entry)) +def test_wms_1_1_1_source_asks_srs(tmp_path: Path) -> None: + entry = {**WMS_ENTRY, "wms_version": "1.1.1", "supported_crs": ["EPSG:900913"]} + wms = geology_registry.load(_registry(tmp_path, entry))["geology_wms"] + assert "VERSION=1.1.1&REQUEST=GetMap" in wms.url_template + assert "&SRS=EPSG:900913&BBOX={bbox}" in wms.url_template + # The old name of Web Mercator: same bounding box + assert wms.wms_crs == "EPSG:3857" + entry = {**entry, "supported_crs": ["EPSG:4326"]} + wms = geology_registry.load(_registry(tmp_path, entry))["geology_wms"] + assert "&SRS=EPSG:4326&BBOX={bbox}" in wms.url_template + # WMS 1.1.1 reads EPSG:4326 longitude first, like CRS:84 + assert wms.wms_crs == "CRS:84" + with pytest.raises(geology_registry.RegistryError, match="geology_wms"): + geology_registry.load(_registry(tmp_path, {**entry, "wms_version": "1.0.0"})) + + def test_tile_bbox_in_the_wms_crs(monkeypatch: pytest.MonkeyPatch) -> None: half = basemap_tiles.HALF_WORLD mercator = basemap_providers.Source("u", 15, "a", wms_crs="EPSG:3857") @@ -388,6 +404,7 @@ def test_layers_without_scale_windows_keep_one_source_per_mosaic( "geology_geosphere_geofast_50k": (13, 4355, 2872), "geology_gsc_canada_5m": (8, 70, 90), "geology_bcgs_bc_50k": (12, 678, 1377), + "geology_mrnf_quebec_regional": (13, 2298, 2841), "geology_gsnsw_seamless": (10, 936, 612), "geology_gsq_detailed_100k": (10, 928, 570), } From 1679c16eaa5b9c8ed3b84ee8fbbf6609661e7956 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 26 Nov 2026 13:28:31 +0100 Subject: [PATCH 12/24] feat(basemap): brgm harmonised 1:50 000 geology first in france The scanned 1:50 000 sheets have gaps (3.0E 45.5N) and few 1:250 000 sheets exist: there the tiles fell back to the 1:1 000 000 map, enlarged eight times. BD Charm-50 is continuous over metropolitan France: it is tried before the scans, up to zoom 16 where the layer stops rendering. Co-Authored-By: Claude Opus 5.5 --- .../basemap/geology_sources.json | 37 ++++++++++++++++++- tests/test_basemap_geology.py | 2 + 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index 7ede54e3..a83fc036 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -1,4 +1,35 @@ [ + { + "id": "geology_brgm_charm50", + "name": "BRGM 1/50 000 harmonised (BD Charm-50)", + "provider": "BRGM", + "area": [ + -5.50071, + 41.2448, + 11.0344, + 51.1211 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://geoservices.brgm.fr/geologie", + "layers": "SCAN_H_GEOL50_SCAN", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 16, + "empty_tile": "transparent", + "licence": "Open data, no conditions apply to access and use (BRGM metadata record 94636790-8615-11dc-9e02-0050568151b7, geocatalogue.fr)", + "attribution": "© BRGM", + "status": "verified", + "notes": "Vectorised and harmonised 1:50 000 maps: continuous over metropolitan France, unlike the scanned sheets of geology_brgm_50k, which have gaps (e.g. 3.0E 45.5N). Listed before it so it is tried first. The layer renders from 1:9 000 to 1:251 000 (WMS ScaleDenominator): tiles are empty past zoom 16, so max_zoom is 16." + }, { "id": "geology_brgm_50k", "name": "BRGM 1/50 000", @@ -25,7 +56,8 @@ "empty_tile": "#ffffff", "licence": "Licence Ouverte Etalab 2.0", "attribution": "© BRGM", - "status": "verified" + "status": "verified", + "notes": "Scanned paper sheets (BD Scan-Géol-50): sheets missing from the scan leave white gaps (e.g. 3.0E 45.5N). Fallback behind geology_brgm_charm50." }, { "id": "geology_brgm_250k", @@ -53,7 +85,8 @@ "empty_tile": "#ffffff", "licence": "Licence Ouverte Etalab 2.0", "attribution": "© BRGM", - "status": "verified" + "status": "verified", + "notes": "Few 1:250 000 sheets exist: the tiles are white (no data) over most of France, e.g. Clermont-Ferrand, Orléans and 3.0E 45.5N. There, the tiles fall back to geology_brgm_1m." }, { "id": "geology_brgm_1m", diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index 71691356..10cc1269 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -378,6 +378,8 @@ def test_layers_without_scale_windows_keep_one_source_per_mosaic( # A tile with data of every shipped geology source, z/x/y in Web Mercator KNOWN_TILES = { + # 3.0E 45.5N: a gap of the scanned 1:50 000 sheets, served by the harmonised maps + "geology_brgm_charm50": (13, 4164, 2930), "geology_brgm_50k": (13, 4164, 2922), "geology_brgm_250k": (10, 518, 352), "geology_brgm_1m": (8, 129, 88), From 14d01166c823fe0e8d953d842b39ac09c50a7ac1 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 26 Nov 2026 13:51:22 +0100 Subject: [PATCH 13/24] feat(basemap): egdi geology asked up to zoom 13 A 1:1 000 000 map draws no more detail past zoom 13: deeper tiles are enlarged instead. Half the WMS requests to this slow server, which timed out under load (3 of 24 tiles in Spain). Co-Authored-By: Claude Opus 5.5 --- src/opengeodeweb_back/basemap/geology_sources.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index a83fc036..7c9c9cde 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -140,10 +140,12 @@ "CRS:84", "EPSG:4326" ], + "max_zoom": 13, "empty_tile": "transparent", "licence": "Creative Commons BY 4.0 (https://creativecommons.org/licenses/by/4.0/), per EGDI metadata record 5729ffdf-2558-48fc-a5d2-645a0a010855", "attribution": "EGDI 1:1M Surface Geology © EuroGeoSurveys and the European geological surveys, CC BY 4.0; Malta: Continental Shelf Department, Ministry for Transport and Infrastructure", - "status": "verified" + "status": "verified", + "notes": "A 1:1 000 000 map: past zoom 13 the server draws no more detail. Capping the zoom halves the WMS requests to this slow server (about 0.5 to 3 s per tile, and 10 s timeouts under load, e.g. 3 of 24 tiles in Spain). No Croatian units: tiles over Croatia are empty." }, { "id": "geology_bgs_625k", From 7b6521c37dbdfa8d3ba4ce5d56e473cd8dd29acc Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 26 Nov 2026 14:06:28 +0100 Subject: [PATCH 14/24] feat(basemap): yukon and saskatchewan geology Yukon bedrock compilation (OGL - Yukon) and Saskatchewan bedrock geology at 1:250 000 and 1:1 000 000 (Unrestricted Use Data Licence, commercial use allowed). New Brunswick and Nova Scotia are listed to check: no licence is named for their bedrock maps. Co-Authored-By: Claude Opus 5.5 --- .../basemap/geology_sources.json | 142 ++++++++++++++++++ tests/test_basemap_geology.py | 3 + 2 files changed, 145 insertions(+) diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index 7c9c9cde..a26207a2 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -1602,6 +1602,148 @@ "status": "to_check", "notes": "to_check (likely excluded): WMS AccessConstraints empty; GEUS terms for free data (https://data.geus.dk/geusmap/terms_20140620.pdf) grant use \"til eget brug\" only and say \"Kunden har ikke ret til at kopiere, offentliggøre, videresælge, udlåne eller udleje eksemplarer af hele eller dele af Dataleverancen ... med mindre GEUS giver forudgående skriftligt samtykke\". Not compatible with tile caching/redistribution. Tech: z9 OK 0.42 s." }, + { + "id": "geology_ygs_yukon_bedrock", + "name": "Yukon bedrock geology compilation", + "provider": "Yukon Geological Survey", + "area": [ + -141.01, + 59.99, + -123.8, + 69.65 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "xyz", + "url": "https://deptweb.gov.yk.ca/prod/rest/services/YGS_BedrockGeology/BedrockGeology_cache/MapServer/tile/{z}/{y}/{x}", + "layers": null, + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 16, + "empty_tile": "transparent", + "licence": "Open Government Licence - Yukon (https://open.yukon.ca/data/open-government-licence-yukon): commercial or non-commercial reuse with attribution; licence of the 'Bedrock geology' dataset on open.yukon.ca and of the ArcGIS layer metadata", + "attribution": "Contains information licensed under the Open Government Licence - Yukon. Yukon Geological Survey", + "status": "verified", + "notes": "Compilation of the detailed maps and regional compilations of the YGS and the GSC, 1999-2023. Cached service BedrockGeology_cache (1:37M to 1:9 000, z0-z16); the other service Bedrock_Geology__Tiles stops at 1:1.1M (z8). Mixed cache: JPEG where full, transparent PNG outside the data. The general yukon.ca copyright page restricts commercial reuse of website material, but the dataset itself is published under the OGL - Yukon." + }, + { + "id": "geology_sgs_saskatchewan_250k", + "name": "Saskatchewan bedrock geology 1:250 000", + "provider": "Saskatchewan Geological Survey (Ministry of Energy and Resources)", + "area": [ + -110.01, + 48.99, + -101.36, + 60.01 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "export", + "url": "https://gis.saskatchewan.ca/arcgis/rest/services/Economy/Geology/MapServer/export?bbox={bbox}&bboxSR=3857&imageSR=3857&size=256,256&format=png32&transparent=true&layers=show:10&f=image", + "layers": "show:10", + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "empty_tile": "transparent", + "licence": "Government of Saskatchewan Standard Unrestricted Use Data Licence (Version 2.0), https://gisappl.saskatchewan.ca/Html5Ext/Resources/GOS_Standard_Unrestricted_Use_Data_Licence_v2.0.pdf: 'licence to use the Information, including for commercial purposes'; named in the service item licenseInfo", + "attribution": "Saskatchewan Geological Survey. Contains information licensed under the Government of Saskatchewan Standard Unrestricted Use Data Licence (Version 2.0)", + "status": "verified", + "notes": "ArcGIS MapServer Economy/Geology, layer 10 'Bedrock Geology 250K', exported in Web Mercator (the service CRS is EPSG:2957). 0.5-3 s per tile." + }, + { + "id": "geology_sgs_saskatchewan_1m", + "name": "Saskatchewan bedrock geology 1:1 000 000", + "provider": "Saskatchewan Geological Survey (Ministry of Energy and Resources)", + "area": [ + -110.01, + 48.99, + -101.36, + 60.01 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "export", + "url": "https://gis.saskatchewan.ca/arcgis/rest/services/Economy/Geology/MapServer/export?bbox={bbox}&bboxSR=3857&imageSR=3857&size=256,256&format=png32&transparent=true&layers=show:11&f=image", + "layers": "show:11", + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 13, + "empty_tile": "transparent", + "licence": "Government of Saskatchewan Standard Unrestricted Use Data Licence (Version 2.0), https://gisappl.saskatchewan.ca/Html5Ext/Resources/GOS_Standard_Unrestricted_Use_Data_Licence_v2.0.pdf: 'licence to use the Information, including for commercial purposes'; named in the service item licenseInfo", + "attribution": "Saskatchewan Geological Survey. Contains information licensed under the Government of Saskatchewan Standard Unrestricted Use Data Licence (Version 2.0)", + "status": "verified", + "notes": "Same service, layer 11 'Bedrock Geology 1M' (updated February 2021). Asked up to zoom 13: a 1:1 000 000 map draws no more detail." + }, + { + "id": "geology_nbgs_bedrock", + "name": "New Brunswick bedrock geology", + "provider": "New Brunswick Dept. of Natural Resources and Energy Development", + "area": [ + -69.06, + 44.6, + -63.77, + 48.07 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "export", + "url": "https://gis-erd-der.gnb.ca/server/rest/services/OpenData/NBGS_Bedrock_Geology/MapServer/export?bbox={bbox}&bboxSR=3857&imageSR=3857&size=256,256&format=png32&transparent=true&f=image", + "layers": null, + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "empty_tile": "transparent", + "licence": "Unstated for this dataset", + "attribution": "New Brunswick Dept. of Natural Resources and Energy Development", + "status": "to_check", + "notes": "TO_CHECK: technically fine (z7-z13, 0.5-1.3 s, real polygons). The service sits in the OpenData folder and New Brunswick has an Open Government Licence (OGL-Canada 2.0 based, https://www.gnb.ca/en/campaign/geonb/open-government-license.html), but neither the service item (licenseInfo empty) nor the geo.ca record (empty 'Use Limitations') names a licence for the bedrock geology. Ask the NBGS Geoscience Information Officer." + }, + { + "id": "geology_nsdnr_bedrock", + "name": "Nova Scotia bedrock geology (ME 2000-1)", + "provider": "Nova Scotia Department of Natural Resources and Renewables", + "area": [ + -66.4, + 43.35, + -59.6, + 47.1 + ], + "level": "N2", + "source_scale": 500000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "export", + "url": "https://dawson.novascotia.ca/arcgis/rest/services/Bedrock_Geologic_Units_p00001gb_UT83_Web_Map_MIL1/MapServer/export?bbox={bbox}&bboxSR=3857&imageSR=3857&size=256,256&format=png32&transparent=true&f=image", + "layers": null, + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "empty_tile": "transparent", + "licence": "Unclear: dataset licence agreement shipped with DP ME 43", + "attribution": "Nova Scotia Department of Natural Resources and Renewables", + "status": "to_check", + "notes": "TO_CHECK, not tested: the downloadable version (DP ME 43) comes with its own licence agreement that the user must accept; no open licence is named on the ArcGIS service. Read that agreement, or find the copy on data.novascotia.ca and its licence, before verifying." + }, { "id": "geology_gsc_canada_5m", "name": "Geological map of Canada (1860A)", diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index 10cc1269..0f45b240 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -404,6 +404,9 @@ def test_layers_without_scale_windows_keep_one_source_per_mosaic( "geology_spw_wallonie_25k": (13, 4206, 2761), "geology_spw_wallonie_n2": (11, 1051, 690), "geology_geosphere_geofast_50k": (13, 4355, 2872), + "geology_ygs_yukon_bedrock": (12, 511, 1172), + "geology_sgs_saskatchewan_250k": (12, 847, 1285), + "geology_sgs_saskatchewan_1m": (9, 105, 168), "geology_gsc_canada_5m": (8, 70, 90), "geology_bcgs_bc_50k": (12, 678, 1377), "geology_mrnf_quebec_regional": (13, 2298, 2841), From bf2927dde21d7180b5b028b30f3840b60e721312 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 26 Nov 2026 14:09:00 +0100 Subject: [PATCH 15/24] feat(basemap): estonia and northern ireland geology Estonian geological maps at 1:50 000 and 1:400 000 (Land Board open data licence, commercial use allowed) and GSNI maps at 1:10 000 and 1:250 000 (Open Government Licence). Co-Authored-By: Claude Opus 5.5 --- .../basemap/geology_sources.json | 116 ++++++++++++++++++ tests/test_basemap_geology.py | 4 + 2 files changed, 120 insertions(+) diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index a26207a2..78a082f1 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -1083,6 +1083,122 @@ "attribution": "Geological Survey of Sweden (SGU), CC0", "status": "verified" }, + { + "id": "geology_egt_estonia_50k", + "name": "Estonian geological base map 1:50 000 (Quaternary cover)", + "provider": "Geological Survey of Estonia (since 2025) / Estonian Land and Spatial Development Board", + "area": [ + 21.7, + 57.5, + 28.25, + 59.75 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://teenus.maaamet.ee/ows/wms-geoloogia", + "layers": "geol_pinnakate_pinnakatteeh_stratgen", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "EPSG:4326" + ], + "max_zoom": 16, + "empty_tile": "transparent", + "licence": "Republic of Estonia Land and Spatial Development Board open data licence 01.01.2025 (https://geoportaal.maaruum.ee/opendata-licence): 'use the data for commercial or non-commercial purposes and redistribute data', with a reference naming the licensor, the data title and its date; named in the geological base map metadata", + "attribution": "Geological base map 1:50 000: Republic of Estonia Land and Spatial Development Board", + "status": "verified", + "notes": "Layer 'Pinnakatte avamused (50k)' of the MapServer WMS (Quaternary deposits, the surface geology of Estonia). Mapped sheets only: unmapped areas are transparent. 0.4-0.5 s per tile. The bedrock layer geol_aluspohi_aluspohjaehitus_avamus also works but lies under the cover." + }, + { + "id": "geology_egt_estonia_400k", + "name": "Estonian geological map 1:400 000 (Quaternary cover)", + "provider": "Geological Survey of Estonia (since 2025) / Estonian Land and Spatial Development Board", + "area": [ + 21.7, + 57.5, + 28.25, + 59.75 + ], + "level": "N2", + "source_scale": 400000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://teenus.maaamet.ee/ows/geoloogia400k", + "layers": "G400_PINNAKATE_K", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:4326" + ], + "max_zoom": 14, + "empty_tile": "transparent", + "licence": "Republic of Estonia Land and Spatial Development Board open data licence 01.01.2025 (https://geoportaal.maaruum.ee/opendata-licence): 'use the data for commercial or non-commercial purposes and redistribute data', with a reference naming the licensor, the data title and its date; named in the geological base map metadata", + "attribution": "Geological map 1:400 000: Republic of Estonia Land and Spatial Development Board", + "status": "verified", + "notes": "Layer 'Pinnakatte kaart' of the 1:400 000 WMS; the service has no Web Mercator, so tiles are asked in EPSG:4326. Whole country, 0.4-0.7 s per tile." + }, + { + "id": "geology_gsni_10k", + "name": "GSNI 1:10 000 geology (bedrock and superficial)", + "provider": "Geological Survey of Northern Ireland", + "area": [ + -8.2, + 54.0, + -5.4, + 55.4 + ], + "level": "N3", + "source_scale": 10000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "export", + "url": "https://map.bgs.ac.uk/arcgis/rest/services/GeoIndex_GSNI/GSNI_Geology_Landsat_WMS/MapServer/export?bbox={bbox}&bboxSR=3857&imageSR=3857&size=256,256&format=png32&transparent=true&layers=show:5,6&f=image", + "layers": "show:5,6", + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "empty_tile": "transparent", + "licence": "Open Government Licence (https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/): 'The data is delivered under the terms of the Open Government Licence' (GSNI WMS page https://gsni.bgs.ac.uk/data-and-maps/wms-services.html)", + "attribution": "Contains Geological Survey of Northern Ireland materials © Crown Copyright 2026", + "status": "verified", + "notes": "ArcGIS MapServer GeoIndex_GSNI/GSNI_Geology_Landsat_WMS (hosted by the BGS), layers 5 'Superficial Geology (10k)' over 6 'Bedrock Geology (10k)', drawn from 1:250 000. Partial coverage (mapped areas only). Unlike the BGS Great Britain services (geology_bgs_*), the GSNI WMS page states the OGL without restriction." + }, + { + "id": "geology_gsni_250k", + "name": "GSNI 1:250 000 geology (bedrock and superficial)", + "provider": "Geological Survey of Northern Ireland", + "area": [ + -8.2, + 54.0, + -5.4, + 55.4 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "export", + "url": "https://map.bgs.ac.uk/arcgis/rest/services/GeoIndex_GSNI/GSNI_Geology_Landsat_WMS/MapServer/export?bbox={bbox}&bboxSR=3857&imageSR=3857&size=256,256&format=png32&transparent=true&layers=show:9,10&f=image", + "layers": "show:9,10", + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 15, + "empty_tile": "transparent", + "licence": "Open Government Licence (https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/): 'The data is delivered under the terms of the Open Government Licence' (GSNI WMS page https://gsni.bgs.ac.uk/data-and-maps/wms-services.html)", + "attribution": "Contains Geological Survey of Northern Ireland materials © Crown Copyright 2026", + "status": "verified", + "notes": "Same service, layers 9 'Superficial Geology (250k)' over 10 'Bedrock Geology (250k)': all of Northern Ireland. 0.2-0.6 s per tile." + }, { "id": "geology_gsi_100k", "name": "Ireland bedrock geology 1:100 000", diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index 0f45b240..4b544236 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -400,6 +400,10 @@ def test_layers_without_scale_windows_keep_one_source_per_mosaic( "geology_gtk_1m": (7, 73, 34), "geology_sgu_50k_250k": (11, 1108, 583), "geology_sgu_1m": (7, 69, 35), + "geology_egt_estonia_50k": (12, 2352, 1225), + "geology_egt_estonia_400k": (11, 1176, 612), + "geology_gsni_10k": (13, 3961, 2606), + "geology_gsni_250k": (11, 986, 651), "geology_gsi_100k": (12, 1943, 1333), "geology_spw_wallonie_25k": (13, 4206, 2761), "geology_spw_wallonie_n2": (11, 1051, 690), From c6cf7edee1a3b5c7ee73f4531c7e173ca1f8a99a Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 26 Nov 2026 14:32:54 +0100 Subject: [PATCH 16/24] feat(basemap): iceland geology Natural Science Institute of Iceland maps (CC BY 4.0): 1:600 000 bedrock and the two 1:100 000 sheets on its GeoServer. Hungary (SZTFH 1:100 000) and Israel (GSI 1:50 000) work but are listed to check: their terms contradict the metadata or are not stated. Co-Authored-By: Claude Opus 5.5 --- .../basemap/geology_sources.json | 140 ++++++++++++++++++ tests/test_basemap_geology.py | 3 + 2 files changed, 143 insertions(+) diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index 78a082f1..0972018e 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -147,6 +147,56 @@ "status": "verified", "notes": "A 1:1 000 000 map: past zoom 13 the server draws no more detail. Capping the zoom halves the WMS requests to this slow server (about 0.5 to 3 s per tile, and 10 s timeouts under load, e.g. 3 of 24 tiles in Spain). No Croatian units: tiles over Croatia are empty." }, + { + "id": "geology_sztfh_hungary_100k", + "name": "Hungary surface geology 1:100 000", + "provider": "SZTFH", + "area": [ + 16.1, + 45.7, + 22.95, + 48.6 + ], + "level": "N3", + "source_scale": 100000, + "min_scale": 0, + "max_scale": 250000, + "protocol": "export", + "url": "https://map.hugeo.hu/arcgis/rest/services/fdt100/fdt100_foldtan/MapServer/export?bbox={bbox}&bboxSR=3857&imageSR=3857&size=256,256&format=png32&transparent=true&layers=show:6,4,3&f=image", + "max_zoom": 15, + "empty_tile": "transparent", + "attribution": "© SZTFH, Magyarország földtani térképe 1:100 000 (Gyalog & Síkhegyi eds., 2005)", + "status": "to_check", + "licence": "Unclear: EGDI metadata 68ff6dfe-431c-4272-8659-67520a010e58 says 'no conditions apply', but the map.hugeo.hu terms ('Felhasználási feltételek') say the maps are SZTFH intellectual property and to contact SZTFH before any official use", + "notes": "TO_CHECK: technically fine. Layers 6 Földtan (units), 4 boundaries, 3 tectonics of fdt100/fdt100_foldtan; native EOV (EPSG:23700), the export reprojects to 3857 (the WMS offers no Web Mercator). First tile 4.3 s cold, then 0.3-1 s. The 1:500 000 service returns blank images. Ask SZTFH for written permission for commercial use.", + "layers": null, + "styles": null + }, + { + "id": "geology_gsi_israel_50k", + "name": "Israel geology 1:50 000", + "provider": "GSI - Geological Survey of Israel", + "area": [ + 34.19, + 29.48, + 35.95, + 33.34 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 100000, + "protocol": "xyz", + "url": "https://egozi.gsi.gov.il/arcgis/rest/services/Hosted/map50000lb111126/MapServer/tile/{z}/{y}/{x}", + "max_zoom": 16, + "empty_tile": "404", + "attribution": "© Geological Survey of Israel", + "status": "to_check", + "licence": "Not stated: no licence on the service, the portal item or any reachable GSI page", + "notes": "TO_CHECK: technically fine. Seamless merged 1:50 000 map, cached PNG tiles in Web Mercator; geology draws from z12 to about z16 (z11 and coarser show only the sheet key-map grid). 0.3-0.6 s per tile. The service name carries a date (map50000lb111126), so the URL will likely change on republication; the older Geo50K services need a token. empty_tile not tested outside Israel. The 1:200 000 map is only a FeatureServer / VectorTileServer. Ask GSI for its terms.", + "layers": null, + "styles": null + }, { "id": "geology_bgs_625k", "name": "BGS 1/625 000", @@ -1199,6 +1249,96 @@ "status": "verified", "notes": "Same service, layers 9 'Superficial Geology (250k)' over 10 'Bedrock Geology (250k)': all of Northern Ireland. 0.2-0.6 s per tile." }, + { + "provider": "Náttúrufræðistofnun Íslands (Natural Science Institute of Iceland)", + "protocol": "wms", + "url": "https://gis.natt.is/geoserver/ows", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84" + ], + "empty_tile": "transparent", + "licence": "CC BY 4.0 - https://creativecommons.org/licenses/by/4.0/ (https://www.natt.is/en/resources/open-data: \"The open data of the Natural Science Institute of Iceland is published under the CC BY 4.0\"; dataset metadata gatt.natt.is useConstraints link to that page; WMS AccessConstraints = https://www.natt.is/en/resources/open-data, Fees = no)", + "status": "verified", + "min_scale": 0, + "id": "geology_natt_iceland_600k", + "name": "Iceland bedrock geology 1:600 000", + "area": [ + -24.75, + 63.21, + -13.19, + 66.58 + ], + "level": "N2", + "source_scale": 600000, + "max_scale": 1500000, + "layers": "ni:ni_j600v_berg_2_jardlog_2utg_fl", + "max_zoom": 13, + "attribution": "Náttúrufræðistofnun Íslands, Jarðfræðikort af Íslandi 1:600 000, Berggrunnur, 2. útgáfa, CC BY 4.0", + "notes": "Bedrock units of the 2nd edition national map (metadata record {005FFDAD-69A1-4385-B16F-FD31B960FE33}); boundaries/faults are separate layers not included. Draws at all zooms (tested z3-z15), ~0.2-0.6 s per tile. The layer NATT:jardlog_en listed in GetCapabilities returns LayerNotDefined." + }, + { + "provider": "Náttúrufræðistofnun Íslands (Natural Science Institute of Iceland)", + "protocol": "wms", + "url": "https://gis.natt.is/geoserver/ows", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84" + ], + "empty_tile": "transparent", + "licence": "CC BY 4.0 - https://creativecommons.org/licenses/by/4.0/ (https://www.natt.is/en/resources/open-data: \"The open data of the Natural Science Institute of Iceland is published under the CC BY 4.0\"; dataset metadata gatt.natt.is useConstraints link to that page; WMS AccessConstraints = https://www.natt.is/en/resources/open-data, Fees = no)", + "status": "verified", + "min_scale": 0, + "id": "geology_natt_iceland_100k_west", + "name": "Iceland bedrock geology 1:100 000 - Western Volcanic Zone", + "area": [ + -21.05, + 64.19, + -19.63, + 65.1 + ], + "level": "N3", + "source_scale": 100000, + "max_scale": 250000, + "layers": "ni:ni_j100v_vesturgosbelti_berggrunnur_1utg_fl2", + "max_zoom": 16, + "attribution": "Náttúrufræðistofnun Íslands, Jarðfræðikort Vesturgosbelti 1:100 000 (berggrunnur), CC BY 4.0", + "notes": "Layer _fl2 (age-coloured, title 'berggrunnur aldurEN'): the sister layer ni:..._1utg_fl fails with a GeoServer style error (attribute 'jardmlandmberg' missing). Covers only the Western Volcanic Zone sheet (Þingvellir-Langjökull); glaciers are left blank (e.g. -20.3E 64.6N is Langjökull). ~0.2-0.4 s per tile. WMS on the shared Icelandic GeoServer (also ogc.gis.is); layer advertises EPSG:3057 and CRS:84, the root layer advertises EPSG:3857 which works." + }, + { + "provider": "Náttúrufræðistofnun Íslands (Natural Science Institute of Iceland)", + "protocol": "wms", + "url": "https://gis.natt.is/geoserver/ows", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84" + ], + "empty_tile": "transparent", + "licence": "CC BY 4.0 - https://creativecommons.org/licenses/by/4.0/ (https://www.natt.is/en/resources/open-data: \"The open data of the Natural Science Institute of Iceland is published under the CC BY 4.0\"; dataset metadata gatt.natt.is useConstraints link to that page; WMS AccessConstraints = https://www.natt.is/en/resources/open-data, Fees = no)", + "status": "verified", + "min_scale": 0, + "id": "geology_natt_iceland_100k_east", + "name": "Iceland bedrock geology 1:100 000 - East Iceland", + "area": [ + -14.78, + 64.58, + -13.43, + 65.41 + ], + "level": "N3", + "source_scale": 100000, + "max_scale": 250000, + "layers": "ni:ni_j100v_austurland_berggrunnur_1utg_fl", + "max_zoom": 16, + "attribution": "Náttúrufræðistofnun Íslands, Jarðfræðikort Austurland 1:100 000 (berggrunnur), CC BY 4.0", + "notes": "Covers only the East Iceland (Austurland) sheet. ~0.2-0.4 s per tile. Same GeoServer as geology_natt_iceland_600k." + }, { "id": "geology_gsi_100k", "name": "Ireland bedrock geology 1:100 000", diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index 4b544236..d50b0044 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -404,6 +404,9 @@ def test_layers_without_scale_windows_keep_one_source_per_mosaic( "geology_egt_estonia_400k": (11, 1176, 612), "geology_gsni_10k": (13, 3961, 2606), "geology_gsni_250k": (11, 986, 651), + "geology_natt_iceland_600k": (9, 225, 136), + "geology_natt_iceland_100k_west": (12, 1809, 1072), + "geology_natt_iceland_100k_east": (13, 3772, 2131), "geology_gsi_100k": (12, 1943, 1333), "geology_spw_wallonie_25k": (13, 4206, 2761), "geology_spw_wallonie_n2": (11, 1051, 690), From 14850caaabdcf4eb7b6e42c9a884fb437cc48ab6 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 26 Nov 2026 14:34:30 +0100 Subject: [PATCH 17/24] feat(basemap): argentina and mexico geology SEGEMAR 1:250 000 sheets and 1:2 500 000 national map (CC BY 4.0), and the INEGI rock map of Mexico (INEGI free use terms, commercial use allowed). INGEMMET (Peru) is listed to check: its terms name no commercial use, its national map is CC BY-NC-ND, and its server sends an incomplete TLS chain. Co-Authored-By: Claude Opus 5.5 --- .../basemap/geology_sources.json | 121 ++++++++++++++++++ tests/test_basemap_geology.py | 3 + 2 files changed, 124 insertions(+) diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index 0972018e..cd9fae29 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -2150,6 +2150,127 @@ "status": "verified", "wms_version": "1.1.1" }, + { + "id": "geology_segemar_250k", + "name": "SEGEMAR Unidades Geológicas 1:250 000", + "provider": "SEGEMAR (SIGAM)", + "area": [ + -72.99, + -53.0, + -57.0, + -21.78 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://sigam.segemar.gov.ar/geoserver217/wms", + "layers": "sigam:e250K_UnidadGeologica", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "empty_tile": "transparent", + "licence": "CC BY 4.0, https://creativecommons.org/licenses/by/4.0/ (SIGAM site footer https://sigam.segemar.gov.ar/: 'Esta obra cuyo autor es SEGEMAR está bajo una Licencia Creative Commons Atribución 4.0 Internacional'; WMS AccessConstraints: 'Por licencia de Creative Commons Argentina, la explotación de la obra autorizada por la licencia, será necesario reconocer la autoría')", + "attribution": "© SEGEMAR, CC BY 4.0", + "status": "verified", + "notes": "Hojas geológicas 1:250 000 (Carta Geológica, Ley 24.224), layer sigam:e250K_UnidadGeologica on the GeoServer path 'geoserver217' (the plain /geoserver/ path returns HTTP 500). Unpublished sheets are transparent gaps. Draws up to z16, about 1 s per tile." + }, + { + "id": "geology_segemar_2500k", + "name": "SEGEMAR Mapa Geológico de la República Argentina 1:2 500 000", + "provider": "SEGEMAR (SIGAM)", + "area": [ + -73.57, + -55.06, + -53.5, + -21.78 + ], + "level": "N1", + "source_scale": 2500000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://sigam.segemar.gov.ar/geoserver217/wms", + "layers": "sigam:e2.5M.UnidadesGeologicas", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 11, + "empty_tile": "transparent", + "licence": "CC BY 4.0, https://creativecommons.org/licenses/by/4.0/ (SIGAM site footer https://sigam.segemar.gov.ar/: 'Esta obra cuyo autor es SEGEMAR está bajo una Licencia Creative Commons Atribución 4.0 Internacional'; WMS AccessConstraints: 'Por licencia de Creative Commons Argentina, la explotación de la obra autorizada por la licencia, será necesario reconocer la autoría')", + "attribution": "© SEGEMAR, CC BY 4.0", + "status": "verified", + "notes": "Continuous national map at 1:2 500 000; its polygons also reach the Chilean side up to the Pacific. Area cut at 53.5W (the capabilities box spans the South Atlantic). Asked up to zoom 11: no more detail past it. 1.2-1.8 s per tile. Same WMS also has provincial 1:750k layers (e750K.Prov*Geol), not added." + }, + { + "id": "geology_inegi_rocas", + "name": "INEGI Geología (Rocas)", + "provider": "INEGI (Instituto Nacional de Estadística y Geografía)", + "area": [ + -119.883, + 13.4965, + -83.4961, + 33.7243 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://gaia.inegi.org.mx/NLB/tunnel/wms/wms61", + "layers": "c413", + "styles": "", + "format": "image/png", + "wms_version": "1.1.1", + "supported_crs": [ + "EPSG:3857", + "EPSG:900913", + "EPSG:4326" + ], + "empty_tile": "transparent", + "licence": "Términos de libre uso de la información del INEGI, https://www.inegi.org.mx/inegi/terminos.html: 'Puede explotar comercialmente la información, utilizándola como insumo para generar otros productos o servicios', with credit to INEGI; WMS Fees and AccessConstraints none", + "attribution": "Fuente: INEGI", + "status": "verified", + "notes": "Layer c413 'Rocas' of the Mapa Digital de México WMS (v6.1), national coverage. No layer abstract: source_scale 250000 is inferred from the polygon detail and from the INEGI 1:250 000 Continuo Nacional Geológico (made with the SGM), not confirmed. First tile up to 4.6 s, then 1.2-2.7 s. The SGM's own service (portal.sgm.gob.mx) answers 403 to direct clients." + }, + { + "id": "geology_ingemmet_50k", + "name": "INGEMMET Mapa Geológico Integrado 1:50 000", + "provider": "INGEMMET (GEOCATMIN)", + "area": [ + -81.5, + -18.35, + -68.83, + -2.98 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "xyz", + "url": "https://geocatmin.ingemmet.gob.pe/arcgis/rest/services/SERV_GEOLOGIA_50K_INTEGRADA/MapServer/tile/{z}/{y}/{x}", + "layers": null, + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 16, + "empty_tile": "404", + "licence": "Unclear: the GEOCATMIN terms allow use and derived works with a reference to INGEMMET but name no commercial use; the INGEMMET repository publishes the national geological map under CC BY-NC-ND 4.0", + "attribution": "© INGEMMET", + "status": "to_check", + "notes": "TO_CHECK: (1) licence contradiction above, ask INGEMMET; (2) the server sends an incomplete TLS chain: the app's certifi context fails with CERTIFICATE_VERIFY_FAILED (works with curl / the Windows store). Integrated map of 1057 1:50 000 sheets (August 2025), cached Web Mercator tiles, 1.0-1.5 s per tile; no-geology areas return a 190-byte transparent PNG." + }, { "id": "geology_sgb_brazil_1m", "name": "Carta Geológica do Brasil ao Milionésimo – Unidades Litoestratigráficas", diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index d50b0044..80f23e0e 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -417,6 +417,9 @@ def test_layers_without_scale_windows_keep_one_source_per_mosaic( "geology_gsc_canada_5m": (8, 70, 90), "geology_bcgs_bc_50k": (12, 678, 1377), "geology_mrnf_quebec_regional": (13, 2298, 2841), + "geology_segemar_250k": (10, 315, 608), + "geology_segemar_2500k": (6, 19, 38), + "geology_inegi_rocas": (8, 55, 111), "geology_gsnsw_seamless": (10, 936, 612), "geology_gsq_detailed_100k": (10, 928, 570), } From 50e8bb870b146a8ab0ad02f059087176bdf3c699 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 26 Nov 2026 14:40:06 +0100 Subject: [PATCH 18/24] feat(basemap): northern territory and alberta geology NTGS 1:250 000 mosaic and 1:2 500 000 map (CC BY 4.0) and AGS Map 600 bedrock geology of Alberta (OGL - Alberta). Newfoundland and Labrador GeoAtlas maps work but are listed to check: no licence is named and the GSNL disclaimer forbids digital copies to third parties. Co-Authored-By: Claude Opus 5.5 --- .../basemap/geology_sources.json | 175 ++++++++++++++++++ tests/test_basemap_geology.py | 3 + 2 files changed, 178 insertions(+) diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index cd9fae29..728b01e5 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -2000,6 +2000,122 @@ "status": "to_check", "notes": "TO_CHECK, not tested: the downloadable version (DP ME 43) comes with its own licence agreement that the user must accept; no open licence is named on the ArcGIS service. Read that agreement, or find the copy on data.novascotia.ca and its licence, before verifying." }, + { + "id": "geology_ags_1m", + "name": "AGS Bedrock Geology of Alberta 1:1 000 000 (Map 600)", + "provider": "Alberta Geological Survey (Alberta Energy Regulator)", + "area": [ + -120.0, + 48.99, + -110.0, + 60.0 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "xyz", + "url": "https://tiles.arcgis.com/tiles/jQV6VMr2Loovu7GU/arcgis/rest/services/Bedrock_Geology_1M_Map_600_No_Labels_NEW/MapServer/tile/{z}/{y}/{x}", + "layers": null, + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 12, + "empty_tile": "transparent", + "licence": "Open Government Licence - Alberta (https://open.alberta.ca/licence: 'licence to use the Information, including for commercial purposes'): service copyrightText 'Acknowledgement of the Alberta Energy Regulator/Alberta Geological Survey as the originator/source of this information is required as described in the Open Government License – Alberta'; AGS copyright statement https://ags.aer.ca/node/19655", + "attribution": "Contains information licensed under the Open Government Licence – Alberta. Source: Alberta Energy Regulator / Alberta Geological Survey", + "status": "verified", + "notes": "Cached ArcGIS Online tile service (Web Mercator, levels 0-12) of AGS Map 600, without labels. 0.4-0.6 s per tile; transparent PNG outside Alberta. Published in the AGS ArcGIS organisation but owned by a staff account and named _NEW: the URL may change. The detailed AGS polygons exist only as a FeatureServer." + }, + { + "id": "geology_gsnl_nf_detailed", + "name": "GSNL Newfoundland detailed bedrock geology", + "provider": "Geological Survey of Newfoundland and Labrador", + "area": [ + -59.42, + 46.61, + -52.61, + 52.02 + ], + "level": "N3", + "source_scale": 50000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "export", + "url": "https://dnrmaps.gov.nl.ca/arcgis/rest/services/GeoAtlas/Bedrock_Geology_All/MapServer/export?bbox={bbox}&bboxSR=3857&imageSR=3857&size=256,256&format=png32&transparent=true&f=image&layers=show:19", + "layers": "show:19", + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 16, + "empty_tile": "transparent", + "licence": "Not stated for the GeoAtlas services; the GSNL disclaimer (https://www.gov.nl.ca/em/mines/geoscience/reports-maps/disclaimer/) says 'The purchaser agrees not to provide a digital reproduction or copy of this product to a third party'", + "attribution": "© Government of Newfoundland and Labrador, Geological Survey", + "status": "to_check", + "notes": "TO_CHECK: no licence named, and the GSNL disclaimer forbids giving digital copies to third parties. Ask GeoscienceOnline@gov.nl.ca. Technically fine: layer 19 'Newfoundland Detailed Bedrock Geology' (island only, scale assumed ~1:50k), 0.6-0.8 s per tile." + }, + { + "id": "geology_gsnl_selab", + "name": "GSNL SE Labrador bedrock geology", + "provider": "Geological Survey of Newfoundland and Labrador", + "area": [ + -60.5, + 51.4, + -55.54, + 55.22 + ], + "level": "N2", + "source_scale": 100000, + "min_scale": 0, + "max_scale": 200000, + "protocol": "export", + "url": "https://dnrmaps.gov.nl.ca/arcgis/rest/services/GeoAtlas/Bedrock_Geology_All/MapServer/export?bbox={bbox}&bboxSR=3857&imageSR=3857&size=256,256&format=png32&transparent=true&f=image&layers=show:16", + "layers": "show:16", + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 15, + "empty_tile": "transparent", + "licence": "Not stated for the GeoAtlas services; the GSNL disclaimer (https://www.gov.nl.ca/em/mines/geoscience/reports-maps/disclaimer/) says 'The purchaser agrees not to provide a digital reproduction or copy of this product to a third party'", + "attribution": "© Government of Newfoundland and Labrador, Geological Survey", + "status": "to_check", + "notes": "TO_CHECK: same licence gap as geology_gsnl_nf_detailed. Layer 16, SE Labrador only, scale assumed." + }, + { + "id": "geology_gsnl_1m", + "name": "GSNL Bedrock Geology 1:1 000 000", + "provider": "Geological Survey of Newfoundland and Labrador", + "area": [ + -67.81, + 46.61, + -52.61, + 60.38 + ], + "level": "N1", + "source_scale": 1000000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "export", + "url": "https://dnrmaps.gov.nl.ca/arcgis/rest/services/GeoAtlas/Bedrock_Geology_All/MapServer/export?bbox={bbox}&bboxSR=3857&imageSR=3857&size=256,256&format=png32&transparent=true&f=image&layers=show:23", + "layers": "show:23", + "styles": null, + "format": "image/png", + "supported_crs": [ + "EPSG:3857" + ], + "max_zoom": 12, + "empty_tile": "transparent", + "licence": "Not stated for the GeoAtlas services; the GSNL disclaimer (https://www.gov.nl.ca/em/mines/geoscience/reports-maps/disclaimer/) says 'The purchaser agrees not to provide a digital reproduction or copy of this product to a third party'", + "attribution": "© Government of Newfoundland and Labrador, Geological Survey", + "status": "to_check", + "notes": "TO_CHECK: same licence gap. Layer 23, all of Newfoundland and Labrador, 0.6-1.8 s per tile." + }, { "id": "geology_gsc_canada_5m", "name": "Geological map of Canada (1860A)", @@ -2332,6 +2448,65 @@ "status": "to_check", "notes": "Licence contradicts commercial use. SGC general terms grant a non-exclusive, non-transferable use licence for a specific purpose. They also say the licensee shall not commercialize or exchange the data without written authorization from SGC (read in web search summary; PDF not fetched directly). Technically OK: ArcGIS WMS 1.3.0, WMS layer '3' = 'Unidades Cronoestratigráficas', 1:500k, GetMap 1-2 s. EPSG:3857 works but is not advertised. Test site Bogotá (lon -74.07, lat 4.6), good tile z9/150/249." }, + { + "id": "geology_ntgs_250k", + "name": "NTGS Geology 1:250 000 mosaic", + "provider": "Northern Territory Geological Survey", + "area": [ + 129.0, + -26.0, + 138.0, + -10.833333 + ], + "level": "N2", + "source_scale": 250000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://geoscience.nt.gov.au/erdas-iws/ogc/wms/GIWS_NT", + "layers": "NT_NT_Geology_250K_Mosaics.ecw", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:4326" + ], + "max_zoom": 13, + "empty_tile": "transparent", + "licence": "CC BY 4.0: GIWS_NT WMS GetCapabilities abstract 'all material in this publication is provided under a Creative Commons Attribution 4.0 International licence. You are free to re-use the work under the licence, on the condition that you attribute the Northern Territory of Australia (Northern Territory Geological Survey)'", + "attribution": "© Northern Territory of Australia (Northern Territory Geological Survey), CC BY 4.0", + "status": "verified", + "notes": "ERDAS APOLLO WMS 1.3.0 (Geophysical Image Web Server): raster mosaic of the scanned 1:250 000 geology sheets, the whole NT, printed map with labels and symbols. EPSG:4326 only. 1.1-2.6 s per tile, 40-200 KB tiles. About 20 m per pixel: max_zoom 13." + }, + { + "id": "geology_ntgs_2500k", + "name": "NTGS Geology 1:2 500 000", + "provider": "Northern Territory Geological Survey", + "area": [ + 129.0, + -26.0, + 138.0, + -10.833333 + ], + "level": "N1", + "source_scale": 2500000, + "min_scale": 0, + "max_scale": 100000000, + "protocol": "wms", + "url": "https://strike.nt.gov.au/wms", + "layers": "Geology%202.5M", + "styles": "", + "format": "image/png", + "supported_crs": [ + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 12, + "empty_tile": "transparent", + "licence": "CC BY 4.0: NTLIS metadata 2DBCB771210C06B6E040CD9B0F274EFE 'Northern Territory Geological Map (Interp) 2500K' ('all material in this publication is provided under a Creative Commons Attribution 4.0 International licence'); data.nt.gov.au licence cc-by", + "attribution": "© Northern Territory of Australia (Northern Territory Geological Survey), CC BY 4.0", + "status": "verified", + "notes": "STRIKE ArcGIS WMS 1.3.0, layer 'Geology 2.5M' (the space is URL-encoded in layers). Interpreted (solid) geology of the whole NT, no Web Mercator. About 1.5 s per tile. A 1:2.5M map: max_zoom 12." + }, { "id": "geology_gsnsw_seamless", "name": "NSW Seamless Geology", diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index 80f23e0e..a432a6c1 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -420,6 +420,9 @@ def test_layers_without_scale_windows_keep_one_source_per_mosaic( "geology_segemar_250k": (10, 315, 608), "geology_segemar_2500k": (6, 19, 38), "geology_inegi_rocas": (8, 55, 111), + "geology_ntgs_250k": (11, 1785, 1162), + "geology_ntgs_2500k": (9, 446, 290), + "geology_ags_1m": (9, 91, 170), "geology_gsnsw_seamless": (10, 936, 612), "geology_gsq_detailed_100k": (10, 928, 570), } From d84b4cdcf4414e52e4f769fba22b7cff12b3676e Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 26 Nov 2026 14:41:20 +0100 Subject: [PATCH 19/24] feat(basemap): luxembourg geology Luxembourg INSPIRE surface geology 1:350 000 (CC BY 4.0). The detailed harmonised map of Luxembourg, the TNO map of the Netherlands and the Lithuanian 1:200 000 maps are listed to check: their dataset licences are open but other terms or the service contradict them. Co-Authored-By: Claude Opus 5.5 --- .../basemap/geology_sources.json | 152 ++++++++++++++++++ tests/test_basemap_geology.py | 1 + 2 files changed, 153 insertions(+) diff --git a/src/opengeodeweb_back/basemap/geology_sources.json b/src/opengeodeweb_back/basemap/geology_sources.json index 728b01e5..155c823c 100644 --- a/src/opengeodeweb_back/basemap/geology_sources.json +++ b/src/opengeodeweb_back/basemap/geology_sources.json @@ -197,6 +197,127 @@ "layers": null, "styles": null }, + { + "id": "geology_sgl_luxembourg_harmonised", + "name": "Luxembourg harmonised geological map (detailed)", + "provider": "Service géologique de l'État (Administration des ponts et chaussées) via geoportail.lu", + "area": [ + 5.6, + 49.38, + 6.73, + 50.29 + ], + "level": "N3", + "source_scale": 25000, + "min_scale": 0, + "max_scale": 80000, + "protocol": "wms", + "url": "https://wms.geoportail.lu/public_map_layers/service", + "layers": "2167", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "EPSG:4326" + ], + "max_zoom": 17, + "empty_tile": "transparent", + "licence": "CC0 per data.public.lu dataset 'Harmonised geological vector map (Carte géologique harmonisée vectorielle)' published by Administration des Ponts et Chaussées (licence cc-zero); geocatalogue.geoportail.lu record 542a0caa-4b33-4019-8ce7-b8541b436106 states only accessConstraints=copyright, no licence text", + "attribution": "Administration des ponts et chaussées, Service géologique de l'État du Luxembourg", + "status": "to_check", + "notes": "TO_CHECK: data.public.lu says CC0 (2018 automatic INSPIRE as-is page) but the geoportail metadata 542a0caa-4b33-4019-8ce7-b8541b436106 gives only accessConstraints 'copyright'. Layer 2167 'Carte géologique harmonisée' of the geoportail.lu public_map_layers WMS: seamless assembly of the detailed 1:25 000 maps, whole country, faults drawn in red. 0.1-2.4 s per tile." + }, + { + "id": "geology_tno_netherlands_600k", + "name": "TNO geological map of the Netherlands 1:600 000", + "provider": "TNO Geological Survey of the Netherlands (GDN)", + "area": [ + 2.27, + 50.72, + 7.35, + 55.78 + ], + "level": "N2", + "source_scale": 600000, + "min_scale": 0, + "max_scale": 1000000, + "protocol": "wms", + "url": "https://www.gdngeoservices.nl/inspire/geoserver/geomap_as_is/ows", + "layers": "GKNederlandGeolVlak", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 16, + "empty_tile": "transparent", + "licence": "CC0 1.0: Nationaal Georegister record bf639059-05de-4ee1-b838-40e9556c25ff ('Geen beperkingen. Er zijn geen condities voor toegang en gebruik', anchor creativecommons.org/publicdomain/zero/1.0), WMS GetCapabilities AccessConstraints http://creativecommons.org/publicdomain/zero/1.0/deed, data.overheid.nl dataset 74999 licence CC0", + "attribution": "© TNO Geological Survey of the Netherlands (GDN)", + "status": "to_check", + "notes": "TO_CHECK: the dataset is CC0 everywhere (Nationaal Georegister bf639059-05de-4ee1-b838-40e9556c25ff, WMS AccessConstraints, data.overheid.nl 74999), but the dinoloket.nl / geologischedienst.nl disclaimer forbids copying 'information on this website' except for personal, non-commercial use. Ask TNO to confirm the CC0 covers the WMS. Layer GKNederlandGeolVlak of the 'Oppervlaktegeologie, Geologische kaart as-is' GeoServer WMS (formations and profile types at or near the surface, top ~5 m; 2021 map, mapping scale 1:600 000). Covers the land and the Dutch continental shelf. 0.5-2.4 s per tile. Fault and ice-margin lines are in the separate layer GKNederlandGeolLijn." + }, + { + "id": "geology_lgt_lithuania_quaternary_200k", + "name": "Lithuanian Quaternary geological map 1:200 000", + "provider": "Lithuanian Geological Survey (LGT) via geoportal.lt", + "area": [ + 20.86, + 53.86, + 26.92, + 56.46 + ], + "level": "N2", + "source_scale": 200000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "wms_version": "1.1.1", + "url": "https://www.geoportal.lt/mapproxy/lgt_kvartero_geologinis/GetMap.ashx", + "layers": "Kvartero_geologinis", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:4326" + ], + "max_zoom": 16, + "empty_tile": "transparent", + "licence": "CC BY 4.0: data.gov.lt dataset 2642 published by Lietuvos geologijos tarnyba (Licencija: Creative Commons Attribution 4.0); WMS GetCapabilities says Fees '$10', AccessConstraints 'none'", + "attribution": "Lietuvos geologijos tarnyba (Lithuanian Geological Survey), CC BY 4.0", + "status": "to_check", + "notes": "TO_CHECK: licence CC BY 4.0 on data.gov.lt (dataset 2642, LGT), but the WMS GetCapabilities says Fees '$10' and the geoportal.lt service records name no licence; technically every tile carries a 'MapXtreme 2008 SDK Developer License' watermark (so no tile is ever empty) and the first request after idle takes 10-15 s. Every tile carries a 'MapXtreme 2008 © SDK Developer License' watermark. First request after idle takes 10-15 s (cold start), then 0.2-0.8 s. WMS 1.1.1, EPSG:4326 only." + }, + { + "id": "geology_lgt_lithuania_prequaternary_200k", + "name": "Lithuanian pre-Quaternary geological map 1:200 000", + "provider": "Lithuanian Geological Survey (LGT) via geoportal.lt", + "area": [ + 20.86, + 53.86, + 26.92, + 56.46 + ], + "level": "N2", + "source_scale": 200000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "wms_version": "1.1.1", + "url": "https://www.geoportal.lt/mapproxy/lgt_prekvartero_geologinis/GetMap.ashx", + "layers": "pQ", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:4326" + ], + "max_zoom": 16, + "empty_tile": "transparent", + "licence": "CC BY 4.0: data.gov.lt dataset 2643", + "attribution": "Lietuvos geologijos tarnyba (Lithuanian Geological Survey), CC BY 4.0", + "status": "to_check", + "notes": "TO_CHECK: same licence question and watermark as geology_lgt_lithuania_quaternary_200k (data.gov.lt dataset 2643). x" + }, { "id": "geology_bgs_625k", "name": "BGS 1/625 000", @@ -1369,6 +1490,37 @@ "attribution": "Contains Irish Public Sector Data (Geological Survey Ireland) licensed under a Creative Commons Attribution 4.0 International (CC BY 4.0) licence", "status": "verified" }, + { + "id": "geology_sgl_luxembourg_350k", + "name": "Luxembourg surface geology 1:350 000 (INSPIRE)", + "provider": "Service géologique de l'État (Administration des ponts et chaussées) via geoportail.lu", + "area": [ + 5.71, + 49.44, + 6.56, + 50.2 + ], + "level": "N2", + "source_scale": 350000, + "min_scale": 0, + "max_scale": 400000, + "protocol": "wms", + "url": "https://wms.inspire.geoportail.lu/geoserver/ge/wms", + "layers": "GE.surfaceGeology", + "styles": "", + "format": "image/png", + "supported_crs": [ + "EPSG:3857", + "CRS:84", + "EPSG:4326" + ], + "max_zoom": 16, + "empty_tile": "transparent", + "licence": "CC BY 4.0: INSPIRE metadata a1b2ebe7-0ad1-42b8-b209-919a472f2dc6 (catalog.inspire.geoportail.lu) 'Creative Commons Attribution 4.0 International (CC BY 4.0)'; data.public.lu dataset 5d00d7c40f7fb07999ed1c4d licence cc-by; WMS AccessConstraints 'No restrictions apply', Fees 'No fees apply.'", + "attribution": "Service géologique de l'État du Luxembourg, CC BY 4.0", + "status": "verified", + "notes": "INSPIRE GeologicUnit surfaceGeology layer (default style = INSPIRE lithology colours), whole country. 0.1-0.2 s per tile." + }, { "id": "geology_spw_wallonie_25k", "name": "Geological map of Wallonia 1:25 000 (lithostratigraphic units)", diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index a432a6c1..43c1ce7f 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -408,6 +408,7 @@ def test_layers_without_scale_windows_keep_one_source_per_mosaic( "geology_natt_iceland_100k_west": (12, 1809, 1072), "geology_natt_iceland_100k_east": (13, 3772, 2131), "geology_gsi_100k": (12, 1943, 1333), + "geology_sgl_luxembourg_350k": (12, 2117, 1396), "geology_spw_wallonie_25k": (13, 4206, 2761), "geology_spw_wallonie_n2": (11, 1051, 690), "geology_geosphere_geofast_50k": (13, 4355, 2872), From 2d24d3e8426331ee8d531ee18ddb872180f43489 Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:22:51 +0000 Subject: [PATCH 20/24] Apply prepare changes --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index aefa233f..597e5178 100644 --- a/requirements.txt +++ b/requirements.txt @@ -84,4 +84,3 @@ werkzeug==3.1.8 # flask # flask-cors -opengeodeweb-microservice==1.*,>=1.5.0rc1 From c54235e4da73ae7ee07727a48077270391faf4cb Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 26 Nov 2026 15:50:20 +0100 Subject: [PATCH 21/24] refactor(basemap): layers declare their tile by tile fill - Layer(sources, tile_by_tile) replaces the tuples of MAPS: the geology map declares its fill instead of it being guessed from finite scale windows. MAPS is defined once. - Source.wms_crs becomes bbox_crs (map server exports use it too), and its fields are documented for every source. - WEB_MERCATOR lives next to WGS84 in crs_functions, imported by the basemap modules. Co-Authored-By: Claude Opus 5.5 --- src/opengeodeweb_back/basemap/basemap_mesh.py | 8 +-- .../basemap/basemap_providers.py | 52 ++++++++-------- .../basemap/basemap_tiles.py | 34 ++++------- .../basemap/geology_registry.py | 13 +--- src/opengeodeweb_back/crs/crs_functions.py | 3 + .../routes/basemap/blueprint_basemap.py | 2 +- tests/test_basemap.py | 11 +++- tests/test_basemap_geology.py | 59 +++++++++++-------- 8 files changed, 93 insertions(+), 89 deletions(-) diff --git a/src/opengeodeweb_back/basemap/basemap_mesh.py b/src/opengeodeweb_back/basemap/basemap_mesh.py index 0c8860d2..24cc0072 100644 --- a/src/opengeodeweb_back/basemap/basemap_mesh.py +++ b/src/opengeodeweb_back/basemap/basemap_mesh.py @@ -6,24 +6,22 @@ # Third party imports import opengeode as og -import opengeode_geosciences as og_geosciences # Local application imports from opengeodeweb_back.basemap.basemap_tiles import HALF_WORLD -from opengeodeweb_back.crs.crs_functions import convert_xy_corners +from opengeodeweb_back.crs.crs_functions import WEB_MERCATOR, convert_xy_corners from opengeodeweb_back.geode_objects.geode_triangulated_surface3d import ( GeodeTriangulatedSurface3D, ) if TYPE_CHECKING: + import opengeode_geosciences as og_geosciences + from opengeodeweb_back.basemap.basemap_tiles import TileRange GRID_SIZE = 32 MESH_NAME = "basemap" UV_ATTRIBUTE = "basemap_uv" -WEB_MERCATOR = og_geosciences.GeographicCoordinateSystemInfo( - "EPSG", "3857", "WGS 84 / Pseudo-Mercator" -) OUTSIDE_MESSAGE = "Area outside the map projection limits" diff --git a/src/opengeodeweb_back/basemap/basemap_providers.py b/src/opengeodeweb_back/basemap/basemap_providers.py index e6f2e77f..692ee857 100644 --- a/src/opengeodeweb_back/basemap/basemap_providers.py +++ b/src/opengeodeweb_back/basemap/basemap_providers.py @@ -19,17 +19,27 @@ class Source: url_template: str max_zoom: int attribution: str - # Scale window where the source is used, in scale denominators: geology sources only + # A tile-by-tile layer asks a source only for the tiles of its scale window (in scale + # denominators) and of its Web Mercator area (None for the whole world) min_scale: float = 0.0 max_scale: float = math.inf - # Scale of the data, geology sources only: the most detailed source is tried first - source_scale: float | None = None - # Web Mercator extent the source covers, None for the whole world area_3857: tuple[float, float, float, float] | None = None + # Scale of the data, None when unknown + source_scale: float | None = None # How the server says it has no data: a 404, a transparent tile or a plain colour tile empty_tile: str = "404" - # WMS only: the CRS of the GetMap bounding box - wms_crs: str | None = None + # Sources asked by bounding box (WMS, map server export): the CRS of their {bbox} + bbox_crs: str | None = None + + +@dataclass(frozen=True) +class Layer: + """The sources of one layer of a map, the preferred first.""" + + sources: tuple[str, ...] + # False: the first source serving any tile draws the whole layer, one style per mosaic. + # True: each tile takes the first source whose scale window and area hold it and that serves it + tile_by_tile: bool = False _GEOPLATEFORME = ( @@ -67,16 +77,6 @@ class Source: ), } -# The layers of each map, from the bottom up. A layer draws the first of its sources serving a -# tile: the next one is only fetched when it serves none -MAPS: dict[str, tuple[tuple[str, ...], ...]] = { - # The IGN covers the world imagery or map where it has tiles (France) - "satellite": (("eox_s2cloudless_2016",), ("ign_orthophotos",)), - "plan": (("osm",), ("ign_plan",)), - # Transparent: both sources would draw the same roads twice, EOX outside France - "routes": (("ign_roads", "eox_overlay"),), -} - def _geology_sources() -> dict[str, Source]: # Imported here: the registry builds Source objects of this module @@ -87,14 +87,18 @@ def _geology_sources() -> dict[str, Source]: _GEOLOGY = _geology_sources() SOURCES.update(_GEOLOGY) -# The fallback order of the geology map, the most detailed first +# The geology sources, the most detailed first GEOLOGY_SOURCES: tuple[str, ...] = tuple(_GEOLOGY) -# Under the roads: they stay readable over the geology. One layer filled tile by tile -MAPS = { - "satellite": MAPS["satellite"], - "plan": MAPS["plan"], - "geology": (GEOLOGY_SOURCES,), - "routes": MAPS["routes"], + +# The layers of each map, from the bottom up +MAPS: dict[str, tuple[Layer, ...]] = { + # The IGN covers the world imagery or map where it has tiles (France) + "satellite": (Layer(("eox_s2cloudless_2016",)), Layer(("ign_orthophotos",))), + "plan": (Layer(("osm",)), Layer(("ign_plan",))), + # Under the roads, which stay readable over it. Each survey fills the tiles it serves + "geology": (Layer(GEOLOGY_SOURCES, tile_by_tile=True),), + # Transparent: both sources would draw the same roads twice, EOX outside France + "routes": (Layer(("ign_roads", "eox_overlay")),), } @@ -117,7 +121,7 @@ def sorted_maps(maps: Iterable[str]) -> list[str]: def map_layers(maps: list[str], served: Container[str]) -> dict[str, list[str]]: """The served sources of each sorted map, from the bottom up: maps without any are left out.""" layers = { - name: [source for layer in MAPS[name] for source in layer if source in served] + name: [source for layer in MAPS[name] for source in layer.sources if source in served] for name in maps } return {name: sources for name, sources in layers.items() if sources} diff --git a/src/opengeodeweb_back/basemap/basemap_tiles.py b/src/opengeodeweb_back/basemap/basemap_tiles.py index 7d6be563..e55e6b97 100644 --- a/src/opengeodeweb_back/basemap/basemap_tiles.py +++ b/src/opengeodeweb_back/basemap/basemap_tiles.py @@ -23,7 +23,6 @@ # Third party imports import certifi -import opengeode_geosciences as og_geosciences from PIL import Image, ImageChops # Local application imports @@ -34,11 +33,13 @@ USER_AGENT, url_template, ) -from opengeodeweb_back.crs.crs_functions import convert_xy_corners +from opengeodeweb_back.crs.crs_functions import WEB_MERCATOR, WGS84, convert_xy_corners if TYPE_CHECKING: from collections.abc import Iterator + from opengeodeweb_back.basemap.basemap_providers import Layer + logger = logging.getLogger(__name__) # Folder of a basemap data holding its tiles: only basemaps have one @@ -162,16 +163,10 @@ def tile_range( return best -WGS84 = og_geosciences.GeographicCoordinateSystemInfo("EPSG", "4326", "WGS 84") -WEB_MERCATOR = og_geosciences.GeographicCoordinateSystemInfo( - "EPSG", "3857", "WGS 84 / Pseudo-Mercator" -) - - def tile_bbox(source: str, z: int, x: int, y: int) -> str: - """BBOX of a GetMap covering tile z/x/y, in the CRS of the source WMS.""" + """Bounding box of tile z/x/y in the {bbox} CRS of the source.""" bounds = TileRange(z, x, x, y, y).bounds_3857() - crs = SOURCES[source].wms_crs + crs = SOURCES[source].bbox_crs if crs is None or crs == "EPSG:3857": return ",".join(str(value) for value in bounds) # The CRS API converts the corners: no projection written here @@ -387,9 +382,9 @@ def fetch_tiles(source: str, tiles: TileRange) -> dict[tuple[int, int], bytes | def _first_served( - layer: tuple[str, ...], tiles: TileRange, downloads: ThreadPoolExecutor, deadline: float + layer: Layer, tiles: TileRange, downloads: ThreadPoolExecutor, deadline: float ) -> tuple[str, dict[tuple[int, int], bytes | None]] | None: - for source in layer: + for source in layer.sources: images = _source_tiles(source, tiles, downloads, deadline) if any(images.values()): return source, images @@ -397,12 +392,12 @@ def _first_served( def _each_tile_served( - layer: tuple[str, ...], tiles: TileRange, downloads: ThreadPoolExecutor, deadline: float + layer: Layer, tiles: TileRange, downloads: ThreadPoolExecutor, deadline: float ) -> dict[str, dict[tuple[int, int], bytes | None]]: """Each tile from the first source serving it, the sources in the layer order.""" missing = set(tiles.tiles()) served: dict[str, dict[tuple[int, int], bytes | None]] = {} - for source in layer: + for source in layer.sources: wanted = sorted(tile for tile in missing if eligible(source, tiles.z, tile)) if not wanted: continue @@ -418,13 +413,8 @@ def _each_tile_served( return served -def _filled_tile_by_tile(layer: tuple[str, ...]) -> bool: - # Geology sources have a scale window: each tile takes its own source - return any(math.isfinite(SOURCES[source].max_scale) for source in layer) - - def fetch_layers( - layers: list[tuple[str, ...]], tiles: TileRange + layers: list[Layer], tiles: TileRange ) -> dict[str, dict[tuple[int, int], bytes | None]]: """The tiles of each layer by source: the first source serving any, or tile by tile. @@ -436,8 +426,8 @@ def fetch_layers( ThreadPoolExecutor(max(1, len(layers))) as executor, ): - def fetch(layer: tuple[str, ...]) -> dict[str, dict[tuple[int, int], bytes | None]]: - if _filled_tile_by_tile(layer): + def fetch(layer: Layer) -> dict[str, dict[tuple[int, int], bytes | None]]: + if layer.tile_by_tile: return _each_tile_served(layer, tiles, downloads, deadline) first = _first_served(layer, tiles, downloads, deadline) return {} if first is None else dict([first]) diff --git a/src/opengeodeweb_back/basemap/geology_registry.py b/src/opengeodeweb_back/basemap/geology_registry.py index 15216b67..deb4a574 100644 --- a/src/opengeodeweb_back/basemap/geology_registry.py +++ b/src/opengeodeweb_back/basemap/geology_registry.py @@ -6,12 +6,9 @@ from pathlib import Path from typing import Any -# Third party imports -import opengeode_geosciences as og_geosciences - # Local application imports from opengeodeweb_back.basemap.basemap_providers import Source -from opengeodeweb_back.crs.crs_functions import convert_xy_corners +from opengeodeweb_back.crs.crs_functions import WEB_MERCATOR, WGS84, convert_xy_corners REGISTRY_PATH = Path(__file__).parent / "geology_sources.json" ID_PREFIX = "geology_" @@ -37,10 +34,6 @@ "max_scale", "source_scale", ) -WGS84 = og_geosciences.GeographicCoordinateSystemInfo("EPSG", "4326", "WGS 84") -WEB_MERCATOR = og_geosciences.GeographicCoordinateSystemInfo( - "EPSG", "3857", "WGS 84 / Pseudo-Mercator" -) class RegistryError(ValueError): @@ -134,7 +127,7 @@ def _url(entry: dict[str, Any]) -> tuple[str, str | None]: def _source(entry: dict[str, Any]) -> Source: - url_template, wms_crs = _url(entry) + url_template, bbox_crs = _url(entry) bbox_protocol = entry["protocol"] in ("wms", "export") return Source( url_template=url_template, @@ -145,7 +138,7 @@ def _source(entry: dict[str, Any]) -> Source: source_scale=entry["source_scale"], area_3857=_area_3857(entry.get("area")), empty_tile=entry.get("empty_tile", "404"), - wms_crs=wms_crs, + bbox_crs=bbox_crs, ) diff --git a/src/opengeodeweb_back/crs/crs_functions.py b/src/opengeodeweb_back/crs/crs_functions.py index 07b30c10..bc39a9d3 100644 --- a/src/opengeodeweb_back/crs/crs_functions.py +++ b/src/opengeodeweb_back/crs/crs_functions.py @@ -42,6 +42,9 @@ class CrsError(Exception): ORIGINAL_CRS = "points" # OpenGeode orders EPSG:4326 coordinates as (longitude, latitude), the usual GIS order WGS84 = og_geosciences.GeographicCoordinateSystemInfo("EPSG", "4326", "WGS 84") +WEB_MERCATOR = og_geosciences.GeographicCoordinateSystemInfo( + "EPSG", "3857", "WGS 84 / Pseudo-Mercator" +) MAX_LATITUDE = 90.0 MAX_LONGITUDE = 180.0 diff --git a/src/opengeodeweb_back/routes/basemap/blueprint_basemap.py b/src/opengeodeweb_back/routes/basemap/blueprint_basemap.py index 73d01a5d..5c4dd54a 100644 --- a/src/opengeodeweb_back/routes/basemap/blueprint_basemap.py +++ b/src/opengeodeweb_back/routes/basemap/blueprint_basemap.py @@ -103,7 +103,7 @@ def build(params: schemas.Build) -> schemas.BuildResponse: maps = basemap_providers.sorted_maps(map_.value for map_ in params.maps) fetched = [layer for name in maps for layer in basemap_providers.MAPS[name]] try: - tiles = _tile_range(params, crs, [source for layer in fetched for source in layer]) + tiles = _tile_range(params, crs, [source for layer in fetched for source in layer.sources]) images = basemap_tiles.fetch_layers(fetched, tiles) # Outside France the IGN sources have no tile: the others still make the map layers = basemap_providers.map_layers(maps, images) diff --git a/tests/test_basemap.py b/tests/test_basemap.py index 3cc89dd6..9e8f9771 100644 --- a/tests/test_basemap.py +++ b/tests/test_basemap.py @@ -97,11 +97,16 @@ def test_fetch_and_save_tiles(tmp_path: Path) -> None: def test_fetch_layers_downloads_every_layer(local_tiles: Path) -> None: - images = basemap_tiles.fetch_layers([("ign_orthophotos",), ("ign_roads",)], WHOLE_WORLD) + images = basemap_tiles.fetch_layers( + [basemap_providers.Layer(("ign_orthophotos",)), basemap_providers.Layer(("ign_roads",))], + WHOLE_WORLD, + ) assert list(images) == ["ign_orthophotos", "ign_roads"] assert all(all(source.values()) for source in images.values()) # The next source of a layer is not fetched while the first one serves tiles - assert list(basemap_tiles.fetch_layers([("osm", "eox_overlay")], WHOLE_WORLD)) == ["osm"] + assert list( + basemap_tiles.fetch_layers([basemap_providers.Layer(("osm", "eox_overlay"))], WHOLE_WORLD) + ) == ["osm"] assert not (local_tiles / "eox_overlay").exists() @@ -513,7 +518,7 @@ def slow(request: urllib.request.Request, timeout: float, context: object) -> No monkeypatch.setattr(urllib.request, "urlopen", slow) _serve(monkeypatch, Path("/nonexistent"), "https://tiles.example/{z}/{x}/{y}.png") sources = ["ign_orthophotos", "ign_roads", "osm"] - layers = [(source,) for source in sources] + layers = [basemap_providers.Layer((source,)) for source in sources] basemap_tiles.fetch_layers(layers, basemap_tiles.TileRange(4, 0, 3, 0, 3)) assert peak["tiles.example"] == basemap_tiles.MAX_REQUESTS_PER_HOST diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index 43c1ce7f..ea3ef0bf 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -111,7 +111,7 @@ def test_shipped_registry_feeds_the_source_table() -> None: def test_wms_source_asks_web_mercator_when_served(tmp_path: Path) -> None: wms = geology_registry.load(_registry(tmp_path, WMS_ENTRY))["geology_wms"] - assert wms.wms_crs == "EPSG:3857" + assert wms.bbox_crs == "EPSG:3857" assert wms.url_template.startswith("https://wms.test/geology?SERVICE=WMS&VERSION=1.3.0") assert "REQUEST=GetMap&LAYERS=GEOLOGY&STYLES=&CRS=EPSG:3857&BBOX={bbox}" in wms.url_template assert "WIDTH=256&HEIGHT=256&FORMAT=image/png&TRANSPARENT=TRUE" in wms.url_template @@ -119,7 +119,7 @@ def test_wms_source_asks_web_mercator_when_served(tmp_path: Path) -> None: def test_wms_source_without_web_mercator_asks_crs84(tmp_path: Path) -> None: entry = {**WMS_ENTRY, "supported_crs": ["EPSG:4326", "CRS:84"]} - assert geology_registry.load(_registry(tmp_path, entry))["geology_wms"].wms_crs == "CRS:84" + assert geology_registry.load(_registry(tmp_path, entry))["geology_wms"].bbox_crs == "CRS:84" entry = {**WMS_ENTRY, "supported_crs": ["EPSG:2154"]} with pytest.raises(geology_registry.RegistryError, match="geology_wms"): geology_registry.load(_registry(tmp_path, entry)) @@ -131,21 +131,21 @@ def test_wms_1_1_1_source_asks_srs(tmp_path: Path) -> None: assert "VERSION=1.1.1&REQUEST=GetMap" in wms.url_template assert "&SRS=EPSG:900913&BBOX={bbox}" in wms.url_template # The old name of Web Mercator: same bounding box - assert wms.wms_crs == "EPSG:3857" + assert wms.bbox_crs == "EPSG:3857" entry = {**entry, "supported_crs": ["EPSG:4326"]} wms = geology_registry.load(_registry(tmp_path, entry))["geology_wms"] assert "&SRS=EPSG:4326&BBOX={bbox}" in wms.url_template # WMS 1.1.1 reads EPSG:4326 longitude first, like CRS:84 - assert wms.wms_crs == "CRS:84" + assert wms.bbox_crs == "CRS:84" with pytest.raises(geology_registry.RegistryError, match="geology_wms"): geology_registry.load(_registry(tmp_path, {**entry, "wms_version": "1.0.0"})) -def test_tile_bbox_in_the_wms_crs(monkeypatch: pytest.MonkeyPatch) -> None: +def test_tile_bbox_in_the_bbox_crs(monkeypatch: pytest.MonkeyPatch) -> None: half = basemap_tiles.HALF_WORLD - mercator = basemap_providers.Source("u", 15, "a", wms_crs="EPSG:3857") - degrees = basemap_providers.Source("u", 15, "a", wms_crs="CRS:84") - latitude_first = basemap_providers.Source("u", 15, "a", wms_crs="EPSG:4326") + mercator = basemap_providers.Source("u", 15, "a", bbox_crs="EPSG:3857") + degrees = basemap_providers.Source("u", 15, "a", bbox_crs="CRS:84") + latitude_first = basemap_providers.Source("u", 15, "a", bbox_crs="EPSG:4326") monkeypatch.setitem(basemap_providers.SOURCES, "geology_m", mercator) monkeypatch.setitem(basemap_providers.SOURCES, "geology_d", degrees) monkeypatch.setitem(basemap_providers.SOURCES, "geology_l", latitude_first) @@ -167,7 +167,7 @@ def test_export_source_keeps_its_template(tmp_path: Path) -> None: template = "https://maps.test/server/rest/services/Geology/MapServer/export?bbox={bbox}&bboxSR=3857&size=256,256&f=image" entry = {**ENTRY, "id": "geology_export", "protocol": "export", "url": template} source = geology_registry.load(_registry(tmp_path, entry))["geology_export"] - assert (source.url_template, source.wms_crs) == (template, "EPSG:3857") + assert (source.url_template, source.bbox_crs) == (template, "EPSG:3857") without_bbox = {**entry, "url": "https://maps.test/MapServer/export?f=image"} with pytest.raises(geology_registry.RegistryError, match="geology_export"): geology_registry.load(_registry(tmp_path, without_bbox)) @@ -283,6 +283,11 @@ def test_tile_scale_follows_zoom_and_latitude() -> None: assert basemap_tiles.tile_scale(9, 148) == pytest.approx(1_091_958 / 2, rel=0.02) +GEOLOGY_LAYER = basemap_providers.Layer( + ("geology_national", "geology_continental"), tile_by_tile=True +) + + def _two_sources(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: monkeypatch.setenv("BASEMAP_CACHE_FOLDER", str(tmp_path)) monkeypatch.delenv("BASEMAP_TILE_URL", raising=False) @@ -316,7 +321,7 @@ def test_each_tile_takes_the_first_source_serving_it( monkeypatch: pytest.MonkeyPatch, tmp_path: Path ) -> None: _two_sources(monkeypatch, tmp_path) - images = basemap_tiles.fetch_layers([("geology_national", "geology_continental")], WHOLE_WORLD) + images = basemap_tiles.fetch_layers([GEOLOGY_LAYER], WHOLE_WORLD) # The west column from the national source, the east one from the continental source assert sorted(images["geology_national"]) == [(0, 0), (0, 1)] assert sorted(images["geology_continental"]) == [(1, 0), (1, 1)] @@ -334,7 +339,7 @@ def national_down(request: urllib.request.Request, **_kwargs: object) -> _Answer return _Answer(tile) monkeypatch.setattr(urllib.request, "urlopen", national_down) - images = basemap_tiles.fetch_layers([("geology_national", "geology_continental")], WHOLE_WORLD) + images = basemap_tiles.fetch_layers([GEOLOGY_LAYER], WHOLE_WORLD) assert list(images) == ["geology_continental"] assert len(images["geology_continental"]) == 4 @@ -348,32 +353,38 @@ def test_out_of_scale_source_is_not_asked(monkeypatch: pytest.MonkeyPatch, tmp_p dataclasses.replace(detailed, max_scale=80_000), ) # A whole world view is far coarser than 1/80 000: the continental source alone fills it - images = basemap_tiles.fetch_layers([("geology_national", "geology_continental")], WHOLE_WORLD) + images = basemap_tiles.fetch_layers([GEOLOGY_LAYER], WHOLE_WORLD) assert list(images) == ["geology_continental"] def test_tiles_without_a_source_stay_empty(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: _two_sources(monkeypatch, tmp_path) # No world fallback: the east column is left out, and the Viewer shows it transparent - images = basemap_tiles.fetch_layers([("geology_national",)], WHOLE_WORLD) + images = basemap_tiles.fetch_layers( + [basemap_providers.Layer(("geology_national",), tile_by_tile=True)], WHOLE_WORLD + ) assert sorted(images["geology_national"]) == [(0, 0), (0, 1)] -def test_layers_without_scale_windows_keep_one_source_per_mosaic( +def test_a_layer_not_tile_by_tile_keeps_one_source_per_mosaic( monkeypatch: pytest.MonkeyPatch, tmp_path: Path ) -> None: _two_sources(monkeypatch, tmp_path) - monkeypatch.setitem( - basemap_providers.SOURCES, - "first", - basemap_providers.Source("https://a.test/{z}/{x}/{y}.png", 15, "a"), - ) - monkeypatch.setitem( - basemap_providers.SOURCES, - "second", - basemap_providers.Source("https://b.test/{z}/{x}/{y}.png", 15, "b"), + # The same sources, but the layer does not declare a tile by tile fill + layer = dataclasses.replace(GEOLOGY_LAYER, tile_by_tile=False) + images = basemap_tiles.fetch_layers([layer], WHOLE_WORLD) + assert list(images) == ["geology_national"] + + +def test_only_the_geology_map_is_filled_tile_by_tile() -> None: + (geology,) = basemap_providers.MAPS["geology"] + assert geology == basemap_providers.Layer(basemap_providers.GEOLOGY_SOURCES, tile_by_tile=True) + assert not any( + layer.tile_by_tile + for name, layers in basemap_providers.MAPS.items() + if name != "geology" + for layer in layers ) - assert list(basemap_tiles.fetch_layers([("first", "second")], WHOLE_WORLD)) == ["first"] # A tile with data of every shipped geology source, z/x/y in Web Mercator From f84243a00620cb42ab39a420ee17ca69788c25ab Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 26 Nov 2026 16:00:07 +0100 Subject: [PATCH 22/24] feat(basemap): circuit breaker and parallel geology sources, nightly source check - A source failing 3 times in a row (timeout, HTTP error, non-image answer such as a maintenance page) is paused 120 s; it still serves its cached tiles, and one more failure after the pause pauses it again. A 404 or an empty tile is not a failure. - A tile-by-tile layer asks its sources two at a time: the wait is the slowest of the pair, not the sum, and the earlier source still wins every tile it serves. - Geology sources workflow: each night one real tile per shipped source, Slack notified on failure. Actions pinned by commit, read-only token. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/geology_sources.yml | 41 ++++ .../basemap/basemap_tiles.py | 224 +++++++++++++----- tests/conftest.py | 7 + tests/test_basemap_geology.py | 151 +++++++++++- 4 files changed, 359 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/geology_sources.yml diff --git a/.github/workflows/geology_sources.yml b/.github/workflows/geology_sources.yml new file mode 100644 index 00000000..fcfd203e --- /dev/null +++ b/.github/workflows/geology_sources.yml @@ -0,0 +1,41 @@ +name: Geology sources + +# The geology map relies on dozens of survey servers: each night one real tile per shipped +# source is fetched, so a server that moved or died is known before a user meets it +on: + workflow_dispatch: + schedule: + - cron: 0 4 * * * + +permissions: + contents: read + +jobs: + network: + runs-on: ubuntu-24.04 + timeout-minutes: 30 + steps: + # Actions pinned by commit: a moved tag cannot change what runs here + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 + with: + python-version: "3.14" + - name: Install + run: | + pip install -r requirements.txt + pip install . pytest + - name: One tile per shipped geology source + run: pytest -m network tests/test_basemap_geology.py -rf + - name: Notify Slack + if: failure() + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + [ -n "$SLACK_WEBHOOK_URL" ] || exit 0 + jq -n --arg url "$RUN_URL" \ + '{text: ("Geology basemap: a survey server no longer serves its tiles. " + $url)}' \ + | curl --fail --silent --show-error -X POST -H "Content-Type: application/json" \ + --data @- "$SLACK_WEBHOOK_URL" diff --git a/src/opengeodeweb_back/basemap/basemap_tiles.py b/src/opengeodeweb_back/basemap/basemap_tiles.py index e55e6b97..9e8a6eae 100644 --- a/src/opengeodeweb_back/basemap/basemap_tiles.py +++ b/src/opengeodeweb_back/basemap/basemap_tiles.py @@ -36,7 +36,8 @@ from opengeodeweb_back.crs.crs_functions import WEB_MERCATOR, WGS84, convert_xy_corners if TYPE_CHECKING: - from collections.abc import Iterator + from collections.abc import Callable, Iterator + from concurrent.futures import Future from opengeodeweb_back.basemap.basemap_providers import Layer @@ -58,6 +59,13 @@ MAX_RETRY_WAIT_SECONDS = 5.0 # One warning per source and per minute: a broken server must not flood the log WARNING_INTERVAL_SECONDS = 60.0 +# A source failing this many times in a row is not asked for a while: a server down or under +# maintenance would otherwise hold every build until the fetch deadline +BREAKER_FAILURES = 3 +BREAKER_PAUSE_SECONDS = 120.0 +# Sources of a tile-by-tile layer asked at once: a source without data at a tile does not delay +# the next one, at the cost of a few tiles also fetched from the next source +PARALLEL_SOURCES = 2 # Cached in place of a tile the server does not have, so it is not asked again MISSING_TILE = b"missing" FETCH_WORKERS = 8 @@ -73,7 +81,58 @@ _HOST_LIMITS: dict[str, threading.Semaphore] = {} _HOST_LIMITS_LOCK = threading.Lock() -_LAST_WARNINGS: dict[str, float] = {} + + +class CircuitBreaker: + """Failures of each source in a row: past BREAKER_FAILURES the source is paused.""" + + def __init__(self, clock: Callable[[], float] = time.monotonic) -> None: + self._clock = clock + self._lock = threading.Lock() + self._failures: dict[str, int] = {} + self._paused_until: dict[str, float] = {} + self._last_warnings: dict[str, float] = {} + + def paused(self, source: str) -> bool: + with self._lock: + return self._clock() < self._paused_until.get(source, -math.inf) + + def succeeded(self, source: str) -> None: + with self._lock: + self._failures.pop(source, None) + + def failed(self, source: str, reason: str) -> None: + now = self._clock() + with self._lock: + failures = self._failures.get(source, 0) + 1 + paused = failures >= BREAKER_FAILURES + if paused: + self._paused_until[source] = now + BREAKER_PAUSE_SECONDS + # Once the pause is over, a single failure pauses the source again + failures = BREAKER_FAILURES - 1 + self._failures[source] = failures + warn = paused or ( + now - self._last_warnings.get(source, -math.inf) + >= WARNING_INTERVAL_SECONDS + ) + if warn: + self._last_warnings[source] = now + if paused: + logger.warning( + "Basemap source %s paused for %d s after %d failures (%s)", + source, + BREAKER_PAUSE_SECONDS, + BREAKER_FAILURES, + reason, + ) + elif warn: + logger.warning( + "Basemap source %s failed (%s): the next source is used", source, reason + ) + + +# Shared by the builds of the process: a source down for one is down for all +BREAKER = CircuitBreaker() def _host_limit(url: str) -> threading.Semaphore: @@ -127,9 +186,16 @@ def eligible(source: str, z: int, tile: tuple[int, int]) -> bool: return False if settings.area_3857 is None: return True - x_min, y_min, x_max, y_max = TileRange(z, tile[0], tile[0], tile[1], tile[1]).bounds_3857() + x_min, y_min, x_max, y_max = TileRange( + z, tile[0], tile[0], tile[1], tile[1] + ).bounds_3857() area_x_min, area_y_min, area_x_max, area_y_max = settings.area_3857 - return x_min < area_x_max and area_x_min < x_max and y_min < area_y_max and area_y_min < y_max + return ( + x_min < area_x_max + and area_x_min < x_max + and y_min < area_y_max + and area_y_min < y_max + ) def _range_at(bounds_3857: tuple[float, float, float, float], z: int) -> TileRange: @@ -203,7 +269,9 @@ def _write_cache(cached: Path, content: bytes) -> None: # Best effort: a tile that cannot be cached is still used try: cached.parent.mkdir(parents=True, exist_ok=True) - descriptor, temporary = tempfile.mkstemp(dir=cached.parent, prefix=f".{cached.name}.") + descriptor, temporary = tempfile.mkstemp( + dir=cached.parent, prefix=f".{cached.name}." + ) except OSError: return try: @@ -235,15 +303,6 @@ def is_empty(content: bytes, empty_tile: str) -> bool: return beyond.getbbox() is None -def _warn_failure(source: str, reason: str) -> None: - now = time.monotonic() - with _HOST_LIMITS_LOCK: - if now - _LAST_WARNINGS.get(source, -math.inf) < WARNING_INTERVAL_SECONDS: - return - _LAST_WARNINGS[source] = now - logger.warning("Basemap source %s failed (%s): the next source is used", source, reason) - - def _retry_wait(error: urllib.error.HTTPError) -> float: try: wait_seconds = float(error.headers.get("Retry-After", "1")) @@ -267,37 +326,52 @@ def _download(url: str) -> bytes: return content -def _fetch_tile(source: str, z: int, x: int, y: int, bbox: str) -> bytes | None: - # The template hash keeps tiles of an overridden URL apart - template = url_template(source) - template_hash = hashlib.sha256(template.encode()).hexdigest()[:12] - cached = _cache_folder() / source / template_hash / str(z) / str(x) / str(y) - cached_content = _read_cache(cached) - if cached_content is not None: - return None if cached_content == MISSING_TILE else cached_content - url = template.format(z=z, x=x, y=y, bbox=bbox) - content = b"" +def _download_tile(source: str, url: str, cached: Path) -> bytes | None: + """The server answer, None when it has no tile or failed: 429 retried, failures counted.""" for attempt in range(TOO_MANY_REQUESTS_RETRIES + 1): try: - content = _download(url) - break + return _download(url) except urllib.error.HTTPError as error: error.close() - if error.code == HTTPStatus.TOO_MANY_REQUESTS and attempt < TOO_MANY_REQUESTS_RETRIES: + if ( + error.code == HTTPStatus.TOO_MANY_REQUESTS + and attempt < TOO_MANY_REQUESTS_RETRIES + ): time.sleep(_retry_wait(error)) continue # Outside its area (the IGN outside France) a server answers 404: unlike a timeout or a # network error, asking again would give the same answer if error.code == HTTPStatus.NOT_FOUND: + BREAKER.succeeded(source) _write_cache(cached, MISSING_TILE) else: - _warn_failure(source, f"HTTP {error.code}") + BREAKER.failed(source, f"HTTP {error.code}") return None except DOWNLOAD_ERRORS as error: - _warn_failure(source, type(error).__name__) + BREAKER.failed(source, type(error).__name__) return None + return None + + +def _fetch_tile(source: str, z: int, x: int, y: int, bbox: str) -> bytes | None: + # The template hash keeps tiles of an overridden URL apart + template = url_template(source) + template_hash = hashlib.sha256(template.encode()).hexdigest()[:12] + cached = _cache_folder() / source / template_hash / str(z) / str(x) / str(y) + cached_content = _read_cache(cached) + if cached_content is not None: + return None if cached_content == MISSING_TILE else cached_content + # A paused source still serves its cached tiles + if BREAKER.paused(source): + return None + content = _download_tile(source, template.format(z=z, x=x, y=y, bbox=bbox), cached) + if content is None: + return None + # A maintenance or error page served as HTTP 200 if not _is_image(content): + BREAKER.failed(source, "not an image") return None + BREAKER.succeeded(source) # Where a server has no data it may send a plain tile instead of a 404: missing as well if is_empty(content, SOURCES[source].empty_tile): _write_cache(cached, MISSING_TILE) @@ -317,7 +391,9 @@ def _overzoomed( try: # Decoded once for all its children with Image.open(io.BytesIO(parent)) as opened: - transparent = opened.mode in ("RGBA", "LA", "PA") or "transparency" in opened.info + transparent = ( + opened.mode in ("RGBA", "LA", "PA") or "transparency" in opened.info + ) # Palette and bilevel modes ignore BILINEAR: they become true colour first image = opened.convert("RGBA" if transparent else "RGB") # Opaque tiles stay JPEG: smaller and faster to encode than PNG, which ignores the quality @@ -346,13 +422,22 @@ def _downloads(workers: int) -> Iterator[ThreadPoolExecutor]: executor.shutdown(wait=False, cancel_futures=True) -def _source_tiles( +@dataclass(frozen=True) +class _SourceRequest: + """The downloads of one source, started: the tiles of each parent and its future.""" + + source: str + depth: int + children: dict[tuple[int, int], list[tuple[int, int]]] + futures: dict[tuple[int, int], Future[bytes | None]] + + +def _submit( source: str, tiles: TileRange, downloads: ThreadPoolExecutor, - deadline: float, wanted: list[tuple[int, int]] | None = None, -) -> dict[tuple[int, int], bytes | None]: +) -> _SourceRequest: # Past its max zoom a source has no tile: its parent tiles are enlarged instead depth = max(0, tiles.z - SOURCES[source].max_zoom) z = tiles.z - depth @@ -361,24 +446,42 @@ def _source_tiles( children.setdefault((x >> depth, y >> depth), []).append((x, y)) # PROJ runs through OpenGeode: the bounding boxes are converted here, not in the downloads futures = { - parent: downloads.submit(_fetch_tile, source, z, *parent, tile_bbox(source, z, *parent)) + parent: downloads.submit( + _fetch_tile, source, z, *parent, tile_bbox(source, z, *parent) + ) for parent in children } - done, _ = wait(futures.values(), timeout=max(0.0, deadline - time.monotonic())) + return _SourceRequest(source, depth, children, futures) + + +def _collect( + request: _SourceRequest, deadline: float +) -> dict[tuple[int, int], bytes | None]: + done, _ = wait( + request.futures.values(), timeout=max(0.0, deadline - time.monotonic()) + ) images: dict[tuple[int, int], bytes | None] = {} - for parent, future in futures.items(): + for parent, future in request.futures.items(): # An unfinished tile counts as missing content = future.result() if future in done else None - if depth == 0: + if request.depth == 0: images[parent] = content else: - images |= _overzoomed(content, depth, children[parent]) + images |= _overzoomed(content, request.depth, request.children[parent]) return images +def _source_tiles( + source: str, tiles: TileRange, downloads: ThreadPoolExecutor, deadline: float +) -> dict[tuple[int, int], bytes | None]: + return _collect(_submit(source, tiles, downloads), deadline) + + def fetch_tiles(source: str, tiles: TileRange) -> dict[tuple[int, int], bytes | None]: with _downloads(FETCH_WORKERS) as downloads: - return _source_tiles(source, tiles, downloads, time.monotonic() + FETCH_DEADLINE_SECONDS) + return _source_tiles( + source, tiles, downloads, time.monotonic() + FETCH_DEADLINE_SECONDS + ) def _first_served( @@ -394,22 +497,31 @@ def _first_served( def _each_tile_served( layer: Layer, tiles: TileRange, downloads: ThreadPoolExecutor, deadline: float ) -> dict[str, dict[tuple[int, int], bytes | None]]: - """Each tile from the first source serving it, the sources in the layer order.""" + """Each tile from the first source serving it, the sources in the layer order. + + The sources are asked PARALLEL_SOURCES at a time: the wait is the slowest of a wave, not the + sum of its sources. Within a wave the earlier source still wins every tile it serves. + """ missing = set(tiles.tiles()) served: dict[str, dict[tuple[int, int], bytes | None]] = {} - for source in layer.sources: - wanted = sorted(tile for tile in missing if eligible(source, tiles.z, tile)) - if not wanted: - continue - images = _source_tiles(source, tiles, downloads, deadline, wanted) - found: dict[tuple[int, int], bytes | None] = { - tile: content for tile, content in images.items() if content is not None - } - if found: - served[source] = found - missing -= found.keys() - if not missing: - break + pending = list(layer.sources) + while missing and pending: + wave: list[_SourceRequest] = [] + while pending and len(wave) < PARALLEL_SOURCES: + source = pending.pop(0) + wanted = sorted(tile for tile in missing if eligible(source, tiles.z, tile)) + if wanted: + wave.append(_submit(source, tiles, downloads, wanted)) + for request in wave: + images = _collect(request, deadline) + found: dict[tuple[int, int], bytes | None] = { + tile: content + for tile, content in images.items() + if content is not None and tile in missing + } + if found: + served[request.source] = found + missing -= found.keys() return served @@ -422,7 +534,7 @@ def fetch_layers( """ deadline = time.monotonic() + FETCH_DEADLINE_SECONDS with ( - _downloads(FETCH_WORKERS * max(1, len(layers))) as downloads, + _downloads(FETCH_WORKERS * PARALLEL_SOURCES * max(1, len(layers))) as downloads, ThreadPoolExecutor(max(1, len(layers))) as executor, ): @@ -444,7 +556,9 @@ def _extension(content: bytes) -> str: return "png" if content.startswith(PNG_SIGNATURE) else "jpg" -def save_tiles(tiles: TileRange, images: dict[tuple[int, int], bytes | None], folder: Path) -> None: +def save_tiles( + tiles: TileRange, images: dict[tuple[int, int], bytes | None], folder: Path +) -> None: """Writes each tile as _., counted from the north-west corner.""" folder.mkdir(parents=True, exist_ok=True) for (x, y), content in images.items(): diff --git a/tests/conftest.py b/tests/conftest.py index 292a66ae..e2a0e6ec 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -15,6 +15,7 @@ # Local application imports from opengeodeweb_back.app import create_app, register_ogw_back_blueprints +from opengeodeweb_back.basemap import basemap_tiles if TYPE_CHECKING: from collections.abc import Callable, Generator @@ -83,3 +84,9 @@ def closed_database() -> Generator[Callable[[], None]]: @pytest.fixture def test_id() -> str: return TEST_ID + + +@pytest.fixture(autouse=True) +def fresh_circuit_breaker(monkeypatch: pytest.MonkeyPatch) -> None: + # A source paused by one test must not leave the next one without tiles + monkeypatch.setattr(basemap_tiles, "BREAKER", basemap_tiles.CircuitBreaker()) diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index ea3ef0bf..d42db852 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -5,7 +5,10 @@ import io import json import math +import threading +import time import urllib.error +import urllib.parse import urllib.request from email.message import Message from typing import TYPE_CHECKING, Self @@ -75,7 +78,9 @@ def test_registry_loads_verified_sources_most_detailed_first(tmp_path: Path) -> {"source_scale": None}, ], ) -def test_invalid_registry_entry_names_the_entry(tmp_path: Path, change: dict[str, object]) -> None: +def test_invalid_registry_entry_names_the_entry( + tmp_path: Path, change: dict[str, object] +) -> None: with pytest.raises(geology_registry.RegistryError, match=r"geology_test|brgm"): geology_registry.load(_registry(tmp_path, {**ENTRY, **change})) @@ -112,14 +117,22 @@ def test_shipped_registry_feeds_the_source_table() -> None: def test_wms_source_asks_web_mercator_when_served(tmp_path: Path) -> None: wms = geology_registry.load(_registry(tmp_path, WMS_ENTRY))["geology_wms"] assert wms.bbox_crs == "EPSG:3857" - assert wms.url_template.startswith("https://wms.test/geology?SERVICE=WMS&VERSION=1.3.0") - assert "REQUEST=GetMap&LAYERS=GEOLOGY&STYLES=&CRS=EPSG:3857&BBOX={bbox}" in wms.url_template + assert wms.url_template.startswith( + "https://wms.test/geology?SERVICE=WMS&VERSION=1.3.0" + ) + assert ( + "REQUEST=GetMap&LAYERS=GEOLOGY&STYLES=&CRS=EPSG:3857&BBOX={bbox}" + in wms.url_template + ) assert "WIDTH=256&HEIGHT=256&FORMAT=image/png&TRANSPARENT=TRUE" in wms.url_template def test_wms_source_without_web_mercator_asks_crs84(tmp_path: Path) -> None: entry = {**WMS_ENTRY, "supported_crs": ["EPSG:4326", "CRS:84"]} - assert geology_registry.load(_registry(tmp_path, entry))["geology_wms"].bbox_crs == "CRS:84" + assert ( + geology_registry.load(_registry(tmp_path, entry))["geology_wms"].bbox_crs + == "CRS:84" + ) entry = {**WMS_ENTRY, "supported_crs": ["EPSG:2154"]} with pytest.raises(geology_registry.RegistryError, match="geology_wms"): geology_registry.load(_registry(tmp_path, entry)) @@ -212,7 +225,9 @@ def read(self) -> bytes: def _source(monkeypatch: pytest.MonkeyPatch, tmp_path: Path, **fields: object) -> None: monkeypatch.setenv("BASEMAP_CACHE_FOLDER", str(tmp_path)) monkeypatch.delenv("BASEMAP_TILE_URL", raising=False) - source = basemap_providers.Source("https://tiles.test/{z}/{x}/{y}.png", 15, "a", **fields) + source = basemap_providers.Source( + "https://tiles.test/{z}/{x}/{y}.png", 15, "a", **fields + ) monkeypatch.setitem(basemap_providers.SOURCES, "geology_t", source) @@ -271,6 +286,89 @@ def always_refused(request: urllib.request.Request, **_kwargs: object) -> _Answe assert "geology_t" in caplog.text +def _one_tile(x: int) -> dict[tuple[int, int], bytes | None]: + return basemap_tiles.fetch_tiles( + "geology_t", basemap_tiles.TileRange(5, x, x, 0, 0) + ) + + +def _paused_clock(monkeypatch: pytest.MonkeyPatch) -> list[float]: + now = [0.0] + monkeypatch.setattr( + basemap_tiles, "BREAKER", basemap_tiles.CircuitBreaker(lambda: now[0]) + ) + return now + + +def test_a_failing_source_is_paused_then_tried_again( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path, caplog: pytest.LogCaptureFixture +) -> None: + _source(monkeypatch, tmp_path) + now = _paused_clock(monkeypatch) + tile = _image("RGB", (200, 120, 40), "PNG") + calls: list[str] = [] + + def down_after_one(request: urllib.request.Request, **_kwargs: object) -> _Answer: + calls.append(request.full_url) + if len(calls) > 1: + raise TimeoutError + return _Answer(tile) + + monkeypatch.setattr(urllib.request, "urlopen", down_after_one) + assert _one_tile(0)[(0, 0)] == tile + for x in range(1, basemap_tiles.BREAKER_FAILURES + 3): + assert _one_tile(x) == {(x, 0): None} + # Paused after BREAKER_FAILURES failures in a row: the next tiles are not asked + assert len(calls) == 1 + basemap_tiles.BREAKER_FAILURES + assert "paused" in caplog.text + # A paused source still serves its cached tiles + assert _one_tile(0)[(0, 0)] == tile + now[0] += basemap_tiles.BREAKER_PAUSE_SECONDS + _one_tile(20) + _one_tile(21) + # Once the pause is over the source is asked again, and one failure pauses it again + assert len(calls) == 2 + basemap_tiles.BREAKER_FAILURES + + +def test_a_maintenance_page_counts_as_a_failure( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + _source(monkeypatch, tmp_path) + _paused_clock(monkeypatch) + calls: list[str] = [] + + def maintenance(request: urllib.request.Request, **_kwargs: object) -> _Answer: + calls.append(request.full_url) + return _Answer(b"Maintenance") + + monkeypatch.setattr(urllib.request, "urlopen", maintenance) + for x in range(basemap_tiles.BREAKER_FAILURES + 2): + _one_tile(x) + assert len(calls) == basemap_tiles.BREAKER_FAILURES + + +def test_a_tile_not_found_is_not_a_failure( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + _source(monkeypatch, tmp_path) + _paused_clock(monkeypatch) + calls: list[str] = [] + + def flaky(request: urllib.request.Request, **_kwargs: object) -> _Answer: + calls.append(request.full_url) + # Every third request is a 404: the server is up, the failures are never in a row + if len(calls) % basemap_tiles.BREAKER_FAILURES == 0: + raise urllib.error.HTTPError( + request.full_url, 404, "Not Found", Message(), None + ) + raise TimeoutError + + monkeypatch.setattr(urllib.request, "urlopen", flaky) + for x in range(3 * basemap_tiles.BREAKER_FAILURES): + _one_tile(x) + assert len(calls) == 3 * basemap_tiles.BREAKER_FAILURES + + HALF = basemap_tiles.HALF_WORLD @@ -327,6 +425,33 @@ def test_each_tile_takes_the_first_source_serving_it( assert sorted(images["geology_continental"]) == [(1, 0), (1, 1)] +def test_the_next_source_is_asked_at_the_same_time( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: + _two_sources(monkeypatch, tmp_path) + tile = _image("RGB", (200, 120, 40), "PNG") + lock = threading.Lock() + running: list[str] = [] + together: set[frozenset[str]] = set() + + def slow(request: urllib.request.Request, **_kwargs: object) -> _Answer: + host = urllib.parse.urlparse(request.full_url).netloc + with lock: + running.append(host) + together.add(frozenset(running)) + time.sleep(0.05) + with lock: + running.remove(host) + return _Answer(tile) + + monkeypatch.setattr(urllib.request, "urlopen", slow) + images = basemap_tiles.fetch_layers([GEOLOGY_LAYER], WHOLE_WORLD) + # Both sources were downloading at once, and the national one still wins its tiles + assert frozenset({"national.test", "continental.test"}) in together + assert sorted(images["geology_national"]) == [(0, 0), (0, 1)] + assert sorted(images["geology_continental"]) == [(1, 0), (1, 1)] + + def test_a_failing_source_leaves_its_tiles_to_the_next( monkeypatch: pytest.MonkeyPatch, tmp_path: Path ) -> None: @@ -344,7 +469,9 @@ def national_down(request: urllib.request.Request, **_kwargs: object) -> _Answer assert len(images["geology_continental"]) == 4 -def test_out_of_scale_source_is_not_asked(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: +def test_out_of_scale_source_is_not_asked( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: _two_sources(monkeypatch, tmp_path) detailed = basemap_providers.SOURCES["geology_national"] monkeypatch.setitem( @@ -357,7 +484,9 @@ def test_out_of_scale_source_is_not_asked(monkeypatch: pytest.MonkeyPatch, tmp_p assert list(images) == ["geology_continental"] -def test_tiles_without_a_source_stay_empty(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: +def test_tiles_without_a_source_stay_empty( + monkeypatch: pytest.MonkeyPatch, tmp_path: Path +) -> None: _two_sources(monkeypatch, tmp_path) # No world fallback: the east column is left out, and the Viewer shows it transparent images = basemap_tiles.fetch_layers( @@ -378,7 +507,9 @@ def test_a_layer_not_tile_by_tile_keeps_one_source_per_mosaic( def test_only_the_geology_map_is_filled_tile_by_tile() -> None: (geology,) = basemap_providers.MAPS["geology"] - assert geology == basemap_providers.Layer(basemap_providers.GEOLOGY_SOURCES, tile_by_tile=True) + assert geology == basemap_providers.Layer( + basemap_providers.GEOLOGY_SOURCES, tile_by_tile=True + ) assert not any( layer.tile_by_tile for name, layers in basemap_providers.MAPS.items() @@ -448,6 +579,8 @@ def test_shipped_source_serves_a_tile( monkeypatch.setenv("BASEMAP_CACHE_FOLDER", str(tmp_path)) monkeypatch.delenv("BASEMAP_TILE_URL", raising=False) z, x, y = KNOWN_TILES[source] - content = basemap_tiles.fetch_tiles(source, basemap_tiles.TileRange(z, x, x, y, y))[(x, y)] + content = basemap_tiles.fetch_tiles(source, basemap_tiles.TileRange(z, x, x, y, y))[ + (x, y) + ] assert content is not None assert not basemap_tiles.is_empty(content, "transparent") From 6f6ece78989f0417daa26d09d64362e8e26142e8 Mon Sep 17 00:00:00 2001 From: MaxNumerique <144453705+MaxNumerique@users.noreply.github.com> Date: Thu, 26 Nov 2026 15:00:45 +0000 Subject: [PATCH 23/24] Apply prepare changes --- .../basemap/basemap_tiles.py | 51 +++++------------- tests/test_basemap_geology.py | 54 +++++-------------- 2 files changed, 25 insertions(+), 80 deletions(-) diff --git a/src/opengeodeweb_back/basemap/basemap_tiles.py b/src/opengeodeweb_back/basemap/basemap_tiles.py index 9e8a6eae..221bf3ab 100644 --- a/src/opengeodeweb_back/basemap/basemap_tiles.py +++ b/src/opengeodeweb_back/basemap/basemap_tiles.py @@ -112,8 +112,7 @@ def failed(self, source: str, reason: str) -> None: failures = BREAKER_FAILURES - 1 self._failures[source] = failures warn = paused or ( - now - self._last_warnings.get(source, -math.inf) - >= WARNING_INTERVAL_SECONDS + now - self._last_warnings.get(source, -math.inf) >= WARNING_INTERVAL_SECONDS ) if warn: self._last_warnings[source] = now @@ -126,9 +125,7 @@ def failed(self, source: str, reason: str) -> None: reason, ) elif warn: - logger.warning( - "Basemap source %s failed (%s): the next source is used", source, reason - ) + logger.warning("Basemap source %s failed (%s): the next source is used", source, reason) # Shared by the builds of the process: a source down for one is down for all @@ -186,16 +183,9 @@ def eligible(source: str, z: int, tile: tuple[int, int]) -> bool: return False if settings.area_3857 is None: return True - x_min, y_min, x_max, y_max = TileRange( - z, tile[0], tile[0], tile[1], tile[1] - ).bounds_3857() + x_min, y_min, x_max, y_max = TileRange(z, tile[0], tile[0], tile[1], tile[1]).bounds_3857() area_x_min, area_y_min, area_x_max, area_y_max = settings.area_3857 - return ( - x_min < area_x_max - and area_x_min < x_max - and y_min < area_y_max - and area_y_min < y_max - ) + return x_min < area_x_max and area_x_min < x_max and y_min < area_y_max and area_y_min < y_max def _range_at(bounds_3857: tuple[float, float, float, float], z: int) -> TileRange: @@ -269,9 +259,7 @@ def _write_cache(cached: Path, content: bytes) -> None: # Best effort: a tile that cannot be cached is still used try: cached.parent.mkdir(parents=True, exist_ok=True) - descriptor, temporary = tempfile.mkstemp( - dir=cached.parent, prefix=f".{cached.name}." - ) + descriptor, temporary = tempfile.mkstemp(dir=cached.parent, prefix=f".{cached.name}.") except OSError: return try: @@ -333,10 +321,7 @@ def _download_tile(source: str, url: str, cached: Path) -> bytes | None: return _download(url) except urllib.error.HTTPError as error: error.close() - if ( - error.code == HTTPStatus.TOO_MANY_REQUESTS - and attempt < TOO_MANY_REQUESTS_RETRIES - ): + if error.code == HTTPStatus.TOO_MANY_REQUESTS and attempt < TOO_MANY_REQUESTS_RETRIES: time.sleep(_retry_wait(error)) continue # Outside its area (the IGN outside France) a server answers 404: unlike a timeout or a @@ -391,9 +376,7 @@ def _overzoomed( try: # Decoded once for all its children with Image.open(io.BytesIO(parent)) as opened: - transparent = ( - opened.mode in ("RGBA", "LA", "PA") or "transparency" in opened.info - ) + transparent = opened.mode in ("RGBA", "LA", "PA") or "transparency" in opened.info # Palette and bilevel modes ignore BILINEAR: they become true colour first image = opened.convert("RGBA" if transparent else "RGB") # Opaque tiles stay JPEG: smaller and faster to encode than PNG, which ignores the quality @@ -446,20 +429,14 @@ def _submit( children.setdefault((x >> depth, y >> depth), []).append((x, y)) # PROJ runs through OpenGeode: the bounding boxes are converted here, not in the downloads futures = { - parent: downloads.submit( - _fetch_tile, source, z, *parent, tile_bbox(source, z, *parent) - ) + parent: downloads.submit(_fetch_tile, source, z, *parent, tile_bbox(source, z, *parent)) for parent in children } return _SourceRequest(source, depth, children, futures) -def _collect( - request: _SourceRequest, deadline: float -) -> dict[tuple[int, int], bytes | None]: - done, _ = wait( - request.futures.values(), timeout=max(0.0, deadline - time.monotonic()) - ) +def _collect(request: _SourceRequest, deadline: float) -> dict[tuple[int, int], bytes | None]: + done, _ = wait(request.futures.values(), timeout=max(0.0, deadline - time.monotonic())) images: dict[tuple[int, int], bytes | None] = {} for parent, future in request.futures.items(): # An unfinished tile counts as missing @@ -479,9 +456,7 @@ def _source_tiles( def fetch_tiles(source: str, tiles: TileRange) -> dict[tuple[int, int], bytes | None]: with _downloads(FETCH_WORKERS) as downloads: - return _source_tiles( - source, tiles, downloads, time.monotonic() + FETCH_DEADLINE_SECONDS - ) + return _source_tiles(source, tiles, downloads, time.monotonic() + FETCH_DEADLINE_SECONDS) def _first_served( @@ -556,9 +531,7 @@ def _extension(content: bytes) -> str: return "png" if content.startswith(PNG_SIGNATURE) else "jpg" -def save_tiles( - tiles: TileRange, images: dict[tuple[int, int], bytes | None], folder: Path -) -> None: +def save_tiles(tiles: TileRange, images: dict[tuple[int, int], bytes | None], folder: Path) -> None: """Writes each tile as _., counted from the north-west corner.""" folder.mkdir(parents=True, exist_ok=True) for (x, y), content in images.items(): diff --git a/tests/test_basemap_geology.py b/tests/test_basemap_geology.py index d42db852..c9534ce0 100644 --- a/tests/test_basemap_geology.py +++ b/tests/test_basemap_geology.py @@ -78,9 +78,7 @@ def test_registry_loads_verified_sources_most_detailed_first(tmp_path: Path) -> {"source_scale": None}, ], ) -def test_invalid_registry_entry_names_the_entry( - tmp_path: Path, change: dict[str, object] -) -> None: +def test_invalid_registry_entry_names_the_entry(tmp_path: Path, change: dict[str, object]) -> None: with pytest.raises(geology_registry.RegistryError, match=r"geology_test|brgm"): geology_registry.load(_registry(tmp_path, {**ENTRY, **change})) @@ -117,22 +115,14 @@ def test_shipped_registry_feeds_the_source_table() -> None: def test_wms_source_asks_web_mercator_when_served(tmp_path: Path) -> None: wms = geology_registry.load(_registry(tmp_path, WMS_ENTRY))["geology_wms"] assert wms.bbox_crs == "EPSG:3857" - assert wms.url_template.startswith( - "https://wms.test/geology?SERVICE=WMS&VERSION=1.3.0" - ) - assert ( - "REQUEST=GetMap&LAYERS=GEOLOGY&STYLES=&CRS=EPSG:3857&BBOX={bbox}" - in wms.url_template - ) + assert wms.url_template.startswith("https://wms.test/geology?SERVICE=WMS&VERSION=1.3.0") + assert "REQUEST=GetMap&LAYERS=GEOLOGY&STYLES=&CRS=EPSG:3857&BBOX={bbox}" in wms.url_template assert "WIDTH=256&HEIGHT=256&FORMAT=image/png&TRANSPARENT=TRUE" in wms.url_template def test_wms_source_without_web_mercator_asks_crs84(tmp_path: Path) -> None: entry = {**WMS_ENTRY, "supported_crs": ["EPSG:4326", "CRS:84"]} - assert ( - geology_registry.load(_registry(tmp_path, entry))["geology_wms"].bbox_crs - == "CRS:84" - ) + assert geology_registry.load(_registry(tmp_path, entry))["geology_wms"].bbox_crs == "CRS:84" entry = {**WMS_ENTRY, "supported_crs": ["EPSG:2154"]} with pytest.raises(geology_registry.RegistryError, match="geology_wms"): geology_registry.load(_registry(tmp_path, entry)) @@ -225,9 +215,7 @@ def read(self) -> bytes: def _source(monkeypatch: pytest.MonkeyPatch, tmp_path: Path, **fields: object) -> None: monkeypatch.setenv("BASEMAP_CACHE_FOLDER", str(tmp_path)) monkeypatch.delenv("BASEMAP_TILE_URL", raising=False) - source = basemap_providers.Source( - "https://tiles.test/{z}/{x}/{y}.png", 15, "a", **fields - ) + source = basemap_providers.Source("https://tiles.test/{z}/{x}/{y}.png", 15, "a", **fields) monkeypatch.setitem(basemap_providers.SOURCES, "geology_t", source) @@ -287,16 +275,12 @@ def always_refused(request: urllib.request.Request, **_kwargs: object) -> _Answe def _one_tile(x: int) -> dict[tuple[int, int], bytes | None]: - return basemap_tiles.fetch_tiles( - "geology_t", basemap_tiles.TileRange(5, x, x, 0, 0) - ) + return basemap_tiles.fetch_tiles("geology_t", basemap_tiles.TileRange(5, x, x, 0, 0)) def _paused_clock(monkeypatch: pytest.MonkeyPatch) -> list[float]: now = [0.0] - monkeypatch.setattr( - basemap_tiles, "BREAKER", basemap_tiles.CircuitBreaker(lambda: now[0]) - ) + monkeypatch.setattr(basemap_tiles, "BREAKER", basemap_tiles.CircuitBreaker(lambda: now[0])) return now @@ -347,9 +331,7 @@ def maintenance(request: urllib.request.Request, **_kwargs: object) -> _Answer: assert len(calls) == basemap_tiles.BREAKER_FAILURES -def test_a_tile_not_found_is_not_a_failure( - monkeypatch: pytest.MonkeyPatch, tmp_path: Path -) -> None: +def test_a_tile_not_found_is_not_a_failure(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: _source(monkeypatch, tmp_path) _paused_clock(monkeypatch) calls: list[str] = [] @@ -358,9 +340,7 @@ def flaky(request: urllib.request.Request, **_kwargs: object) -> _Answer: calls.append(request.full_url) # Every third request is a 404: the server is up, the failures are never in a row if len(calls) % basemap_tiles.BREAKER_FAILURES == 0: - raise urllib.error.HTTPError( - request.full_url, 404, "Not Found", Message(), None - ) + raise urllib.error.HTTPError(request.full_url, 404, "Not Found", Message(), None) raise TimeoutError monkeypatch.setattr(urllib.request, "urlopen", flaky) @@ -469,9 +449,7 @@ def national_down(request: urllib.request.Request, **_kwargs: object) -> _Answer assert len(images["geology_continental"]) == 4 -def test_out_of_scale_source_is_not_asked( - monkeypatch: pytest.MonkeyPatch, tmp_path: Path -) -> None: +def test_out_of_scale_source_is_not_asked(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: _two_sources(monkeypatch, tmp_path) detailed = basemap_providers.SOURCES["geology_national"] monkeypatch.setitem( @@ -484,9 +462,7 @@ def test_out_of_scale_source_is_not_asked( assert list(images) == ["geology_continental"] -def test_tiles_without_a_source_stay_empty( - monkeypatch: pytest.MonkeyPatch, tmp_path: Path -) -> None: +def test_tiles_without_a_source_stay_empty(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None: _two_sources(monkeypatch, tmp_path) # No world fallback: the east column is left out, and the Viewer shows it transparent images = basemap_tiles.fetch_layers( @@ -507,9 +483,7 @@ def test_a_layer_not_tile_by_tile_keeps_one_source_per_mosaic( def test_only_the_geology_map_is_filled_tile_by_tile() -> None: (geology,) = basemap_providers.MAPS["geology"] - assert geology == basemap_providers.Layer( - basemap_providers.GEOLOGY_SOURCES, tile_by_tile=True - ) + assert geology == basemap_providers.Layer(basemap_providers.GEOLOGY_SOURCES, tile_by_tile=True) assert not any( layer.tile_by_tile for name, layers in basemap_providers.MAPS.items() @@ -579,8 +553,6 @@ def test_shipped_source_serves_a_tile( monkeypatch.setenv("BASEMAP_CACHE_FOLDER", str(tmp_path)) monkeypatch.delenv("BASEMAP_TILE_URL", raising=False) z, x, y = KNOWN_TILES[source] - content = basemap_tiles.fetch_tiles(source, basemap_tiles.TileRange(z, x, x, y, y))[ - (x, y) - ] + content = basemap_tiles.fetch_tiles(source, basemap_tiles.TileRange(z, x, x, y, y))[(x, y)] assert content is not None assert not basemap_tiles.is_empty(content, "transparent") From bdbf2805c2bf8dbd30e4a9410b3a307324637e51 Mon Sep 17 00:00:00 2001 From: MaxNumerique Date: Thu, 26 Nov 2026 16:13:14 +0100 Subject: [PATCH 24/24] ci: drop the nightly geology sources workflow Co-Authored-By: Claude Opus 5.5 --- .github/workflows/geology_sources.yml | 41 --------------------------- 1 file changed, 41 deletions(-) delete mode 100644 .github/workflows/geology_sources.yml diff --git a/.github/workflows/geology_sources.yml b/.github/workflows/geology_sources.yml deleted file mode 100644 index fcfd203e..00000000 --- a/.github/workflows/geology_sources.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Geology sources - -# The geology map relies on dozens of survey servers: each night one real tile per shipped -# source is fetched, so a server that moved or died is known before a user meets it -on: - workflow_dispatch: - schedule: - - cron: 0 4 * * * - -permissions: - contents: read - -jobs: - network: - runs-on: ubuntu-24.04 - timeout-minutes: 30 - steps: - # Actions pinned by commit: a moved tag cannot change what runs here - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0 - with: - python-version: "3.14" - - name: Install - run: | - pip install -r requirements.txt - pip install . pytest - - name: One tile per shipped geology source - run: pytest -m network tests/test_basemap_geology.py -rf - - name: Notify Slack - if: failure() - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - run: | - [ -n "$SLACK_WEBHOOK_URL" ] || exit 0 - jq -n --arg url "$RUN_URL" \ - '{text: ("Geology basemap: a survey server no longer serves its tiles. " + $url)}' \ - | curl --fail --silent --show-error -X POST -H "Content-Type: application/json" \ - --data @- "$SLACK_WEBHOOK_URL"