Repository navigation
Water: the reduced terrain keeps the shore - #164
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Delatintakes an optionallevel. 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. NewHasWrongSideandRunToLevel();Run(maxError)also clears the wrong-side points when a level is set.MeshService.TriangulateHeightMapReduced(heightMap, reduceFactor, level)passes it through, andSharpGltfService.AddTerrainMeshgives itwater.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.Measurements (GEBCO_2026, same triangle count)
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 thelevelparameter). 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: throughMeshServiceand the glTF water option.ImageryTests.ImageryProviderTestfailures need the ThunderForest API key (also on master). WebAPIModelPipelineTests: 16 passed against this branch.🤖 Generated with Claude Code