Skip to content

feat(basemap): geology map from the national geological surveys - #304

Merged
BenPinet merged 27 commits into
nextfrom
feat/geology
Dec 2, 2026
Merged

BenPinet merged 27 commits into
nextfrom
feat/geology

Conversation

@MaxNumerique

@MaxNumerique MaxNumerique commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a Geology map to the basemap, built from the national (and state/provincial) geological surveys' own map services.

  • Source registry (basemap/geology_sources.json): one entry per survey layer (area, scale, protocol, licence, attribution). Adding a country is a new entry, no code. Only verified entries are loaded; to_check entries document what was left out and why (notes).
  • Tile by tile: the geology layer takes, for each tile, the most detailed source whose scale window and area hold it and that actually serves it. A view across a border shows each country with its own survey. Every source has min_scale: 0, so a coarser map fills finer zooms where nothing more detailed serves. A tile no source serves stays empty: no world fallback.
  • Protocols: WMTS/XYZ tiles; WMS 1.3.0 and WMS 1.1.1 (wms_version, SRS, EPSG:900913, longitude-first EPSG:4326) served as tiles, one GetMap per Web Mercator tile; ArcGIS export. Bboxes are converted with convert_xy_corners when the WMS has no Web Mercator.
  • Empty tiles: a plain white or fully transparent tile counts as missing, like a 404, and passes to the next source. A 429 is retried (at most twice, capped Retry-After); a failing source logs one warning per minute. A non-image answer (e.g. a maintenance page) is not cached, so the source comes back by itself.
  • Zoom cap: past its max_zoom a source is not asked; its parent tile is enlarged. Coarse WMS sources are capped where the server draws no more detail (EGDI 1:1M: zoom 13).
  • build accepts maps: ["geology"], stacked between plan and routes.

Licence rule

A source is shipped only if its licence clearly allows commercial use and caching. Any contradiction or unclear clause keeps it to_check, whatever its technical state. Incomplete coverage of a country is accepted.

Sources shipped (47)

Area Sources Licence
France BRGM BD Charm-50 harmonised 1:50k (WMS, tried first), 1:50k scanned sheets, 1:250k, 1:1M (Géoplateforme WMTS) BRGM open data / Etalab 2.0
Europe (fallback) EGDI 1:1M (EuroGeoSurveys) CC BY 4.0
Switzerland swisstopo Geological Atlas 1:25k, GeoCover 1:25k, 1:500k swisstopo OGD
Norway NGU 1:50k, 1:250k, 1:1.35M NLOD
Sweden SGU 1:50k–1:250k, 1:1M CC0
Finland GTK 1:200k, 1:1M CC BY 4.0
Estonia Geological base map 1:50k, 1:400k Land Board open data licence (commercial use allowed)
Ireland GSI 1:100k CC BY 4.0
Northern Ireland GSNI 1:10k, 1:250k OGL
Iceland Natural Science Institute 1:600k bedrock, two 1:100k sheets CC BY 4.0
Wallonia SPW 1:25k CC BY 4.0
Luxembourg INSPIRE surface geology 1:350k CC BY 4.0
Austria GeoSphere GEOFAST 1:50k CC BY 4.0
USA USGS SGMC, Alaska, Hawaii, Puerto Rico Public domain
Canada GSC 1:5M, British Columbia 1:50k, Québec regional (WMS 1.1.1), Yukon bedrock compilation, Saskatchewan 1:250k and 1:1M, Alberta AGS Map 600 1:1M OGL Canada / BC / Québec / Yukon / Alberta, Saskatchewan Unrestricted Use Data Licence
Mexico INEGI rock map (about 1:250k) INEGI free use terms (commercial use allowed)
Argentina SEGEMAR 1:250k sheets, 1:2.5M national map CC BY 4.0
Australia Geoscience Australia 1:1M–1:2.5M, NSW seamless, Queensland 1:100k, Northern Territory NTGS 1:250k mosaic and 1:2.5M CC BY
Japan GSJ Seamless V2 1:200k Japanese Government Standard Terms of Use 2.0

Precision on the test models

Same 4 km faulted BRep placed in each country with its own projected CRS (D:\data\crs_test_models), 2026-11-26:

Country (test place) Geology served Scale
France (3.0°E 45.5°N, a gap of the scanned sheets) BD Charm-50, native zoom 15 1:50 000
Sweden SGU 1:50 000
Switzerland GA25 + swissGEOCOVER (two styles side by side at a tile edge) 1:25 000
USA (Colorado) USGS SGMC 1:500 000
Japan (Tokyo) GSJ, enlarged ×2 1:200 000
Mexico INEGI rock map about 1:250 000
Germany, Slovakia, Italy, Spain EGDI (asked up to zoom 13, enlarged ×2) 1:1 000 000
Australia (Victoria) Geoscience Australia 1:1 000 000
Canada (Québec) GSC (MRNF server under maintenance) 1:5 000 000
Croatia none (EGDI has no Croatian units) —
New Zealand, India, El Salvador, Peru none —

The coarse countries are limited by licences, not by code: their detailed surveys are listed to_check below.

Performance (4 km extent, satellite + geology, 25-30 tiles at zoom 14): 1.6-2.5 s on first display (network), 0.05 s from the tile cache, 0.03 s for the mesh.

Left out (to_check)

  • Licence unclear or contradictory: BGS, IGME, BGR, ŠGÚDŠ (Slovakia), HGI (Croatia), LNEG, ISPRA, ČGS, PIG-PIB, GEUS, GSC 1:250k compilation, Ontario, Brazil, Colombia, Victoria, GNS (NZ), Western Australia, Tasmania, KIGAM, GSJ 1:1M, New Brunswick, Nova Scotia, Newfoundland and Labrador (no licence named; the GSNL disclaimer forbids digital copies to third parties), Hungary (SZTFH 1:100k: metadata "no conditions" vs portal "contact SZTFH before any use"), Israel (GSI 1:50k: no terms found), Peru (INGEMMET 1:50k: terms name no commercial use, national map CC BY-NC-ND; also an incomplete TLS chain), Netherlands (TNO 1:600k: CC0 dataset vs non-commercial website disclaimer), Luxembourg harmonised detailed map (CC0 page vs "copyright" metadata), Lithuania 1:200k (CC BY on data.gov.lt, but "$10" fees in the WMS and a MapXtreme watermark on every tile).
  • Other: Flanders (Tertiary subcrop map, not surface geology), GeoSphere 1:500k (server down), South Australia (30 s per tile), swisstopo legacy GeoCover (being withdrawn), WMS duplicates of GA and GSJ.
  • Not added, licence forbids commercial use or needs a per-user paid licence: Manitoba, Slovenia (GeoZS 1:1M), Romania (IGR), Latvia (LVĢMC, CC BY-NC), Chile (SERNAGEOMIN, personal non-commercial), South Africa 1:1M (personal non-commercial; the 1:250k/1:50k service timed out), India (GSI Bhukosh, single-user registration licence). Mexico's SGM service answers 403 to direct clients (INEGI is used instead).

Test plan

  • pytest tests/test_basemap.py tests/test_basemap_geology.py
  • pytest -m network tests/test_basemap_geology.py: one real tile per shipped source, through the Back code (deselected by default in pytest.ini, not run in CI). Québec fails while the MRNF server shows its maintenance page.
  • ruff, mypy

Related: OpenGeodeWeb-Front#609, Vease#936, Vease-Back#174 (all on feat/geology).

🤖 Generated with Claude Code

MaxNumerique and others added 25 commits November 25, 2026 14:21
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
- 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 <noreply@anthropic.com>
…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 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaxNumerique
MaxNumerique marked this pull request as ready for review November 26, 2026 15:27
@BenPinet
BenPinet merged commit 0789eb7 into next Dec 2, 2026
30 checks passed
@BenPinet
BenPinet deleted the feat/geology branch December 2, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants