Skip to content

smoother elevation for tunnels and bridges - #3362

Merged
karussell merged 12 commits into
masterfrom
bridge_ele_improvements
Jun 9, 2026
Merged

karussell merged 12 commits into
masterfrom
bridge_ele_improvements

Conversation

@karussell

@karussell karussell commented Jun 4, 2026 •

Copy link
Copy Markdown
Member

The elevation for the "entry nodes" of a bridge (or tunnel or ferry) is often disturbed because the elevation data already starts deviating from the true road level before the OSM bridge tag begins. And so the tower node needs some lifting, including the neighboring ramp. AI helped me implementing 3 different approaches and I picked this one because of its simplicity and overall good results.

There are several examples:

  1. tunnel-bridge complex in Cotta (before/after)

  2. Bähnle-Radweg bridge (before/after):

  3. Thiergarten tunnel (before/after):

  4. Neudorf bridge (before/after):
    image image

  5. An inclined bridge in Daun also works (before/after):
    image image

  6. Tricky bridge structure for Marienbrücke and although total incline/decline stays the same you see that it got smoother:

  7. Another bridge structure with multiple parallel ways

  8. Similar improvements for motorway bridges

Unsolved challenges:

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new preprocessing step for elevation handling at bridge/tunnel/ferry endpoints (“tower” nodes) to reduce slope artifacts at structure entries/exits by correcting tower elevations from nearby ground-road samples before running the existing structure interpolation.

Changes:

  • Add BridgeTunnelTowerCorrection to adjust structure-touching tower elevations using nearby non-structure road samples and then re-interpolate adjacent ramp pillars.
  • Run the new correction step before existing bridge/tunnel/ferry interpolation in GraphHopper.interpolateBridgesTunnelsAndFerries().
  • Update/add tests and expected routing/elevation assertions to reflect the new elevation behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
core/src/main/java/com/graphhopper/reader/dem/BridgeTunnelTowerCorrection.java New elevation correction pass for structure endpoint (“tower”) nodes and adjacent ramp pillars
core/src/main/java/com/graphhopper/GraphHopper.java Integrates tower correction step into the elevation interpolation pipeline and updates timing log
core/src/main/java/com/graphhopper/reader/dem/EdgeElevationInterpolator.java Renames method to clarify it interpolates inner tower nodes
core/src/test/java/com/graphhopper/reader/dem/BridgeTunnelTowerCorrectionTest.java New unit tests for tower correction + ramp pillar re-interpolation behavior
core/src/test/java/com/graphhopper/GraphHopperTest.java Updates expected distances/point elevations/ascend-descend values impacted by new correction
core/src/test/java/com/graphhopper/routing/RoutingAlgorithmWithOSMTest.java Updates expected route distances affected by changed elevation processing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>

This comment was marked as duplicate.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Use a priority queue ordered by accumulated distance instead of a FIFO
queue so that distFromStart always holds the true shortest-path distance
to each node. This ensures:
- IDW weights are based on the nearest approach, not an arbitrary
  traversal-order distance
- The BFS_MAX_DIST_M budget cutoff correctly includes all nodes reachable
  within 50 m via any path, not just the first-discovered path

Also rename bfsCollectRoadSamples -> dijkstraCollectRoadSamples and
update comments/Javadoc throughout.
@karussell
karussell merged commit 13961fc into master Jun 9, 2026
4 checks passed
@karussell
karussell deleted the bridge_ele_improvements branch June 9, 2026 07:10

This branch was previously deployed

1 inactive deployment
benchmarks — 8e9926c6 Deployed Jun 9, 2026 by karussell via trigger_measurement #2499
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants