Skip to content

Water: the reduced terrain keeps the shore - #164

Merged
xfischer merged 1 commit into
masterfrom
feat/delatin-coastline
Nov 23, 2026
Merged

xfischer merged 1 commit into
masterfrom
feat/delatin-coastline

Conversation

@xfischer

Copy link
Copy Markdown
Member

Summary

With the water option (bathymetry datasets), the shore under the translucent water surface didn't follow the data: Delatin keeps few grid points (10 % mesh detail by default), and the triangles between them crossed the water level elsewhere than the DEM. On a low coast (Landes / Bayonne, GEBCO_2026), the coastline moved by up to 3 cells (~1 km) seaward or inland.

  • Delatin takes an optional level. Grid points the mesh puts on the wrong side of it (land under the water, or sea above it) are inserted before any other; otherwise the largest error first, as before. New HasWrongSide and RunToLevel(); Run(maxError) also clears the wrong-side points when a level is set.
  • MeshService.TriangulateHeightMapReduced(heightMap, reduceFactor, level) passes it through, and SharpGltfService.AddTerrainMesh gives it water.Level (model units, the same as the height map, lift included). Every glTF model with water goes through it (bbox, OSM, GPX): no WebAPI change.
  • Without water (and in STL models), the meshes are unchanged.

Measurements (GEBCO_2026, same triangle count)

Grid, mesh detail Wrong-side cells RMS error Max error
Biscay 95×51, 10 % 94 → 0 4.3 → 4.3 m 18.5 → 15.0 m
Biscay, 25 % 18 → 0 1.4 → 1.4 m 4.2 → 4.1 m
Gibraltar 288×144, 10 % 432 → 0 10.6 → 10.8 m 30.4 → 31.8 m
Gibraltar, 25 % 182 → 0 3.9 → 4.0 m 11.5 → 33.0 m

The coast is fixed within the same budget, so it takes a few triangles from the relief: the max error elsewhere can rise (one point). From 10 % of the triangles (the Elevation API's minimum, ClampMeshReduceFactor) the RMS cost is small; with far fewer triangles a long coast takes most of them (documented on the level parameter). Adding extra triangles for the coast after a plain reduction was also tried: 5–10 % more triangles, and the max error rose as well.

Tests

  • DelatinTests: no wrong-side grid point at 10/25/50 % (checked independently of Delatin's rasterization), same triangle count, RMS within 10 %; a level outside the data gives the same mesh; Run(maxError) also clears the level.
  • TerrainWaterTests.Reduced_terrain_keeps_the_shore_under_the_water: through MeshService and the glTF water option.
  • Full suite: 282 passed; the 13 ImageryTests.ImageryProviderTest failures need the ThunderForest API key (also on master). WebAPI ModelPipelineTests: 16 passed against this branch.

🤖 Generated with Claude Code

With the water option, the coastline under the water surface moved by up to
~1 km (GEBCO_2026, 10 % mesh detail): the triangles between the kept grid
points crossed the water level elsewhere than the data.

- Delatin takes an optional level: grid points that the mesh puts on the
  wrong side of it are inserted first, within the same triangle budget
  (HasWrongSide, RunToLevel; Run(maxError) also clears them).
- MeshService.TriangulateHeightMapReduced passes it through, and
  SharpGltfService.AddTerrainMesh gives it the water level.

Biscay coast (GEBCO_2026, 95x51 grid, 10 %): 94 wrong-side cells -> 0, RMS
error unchanged (4.3 m). Without water, models are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xfischer
xfischer merged commit eef68b2 into master Nov 23, 2026
3 checks passed
@xfischer
xfischer deleted the feat/delatin-coastline branch November 23, 2026 21:18
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.

1 participant