Improve LFRCNP handling for cross-provider OpenLR decoding - #19
Merged
Conversation
Add exception for SlipRoad (FOW=6) edges in bounded_astar's LFRCNP filter. This handles cross-provider decoding where motorway_link, trunk_link, etc. are mapped to FRC3 in OSM but need to be traversable when connecting to/from motorways (FRC0/FRC1). The +1 FRC tolerance is retained for general cross-provider mismatches where HERE's classification doesn't align exactly with OSM highway tags. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Previously, the +1 FRC tolerance was applied uniformly, allowing residential roads (FRC4) to be used even when LFRCNP=3 indicated the path should stay on higher-class roads. This caused detours through residential areas when direct primary road paths existed. Changes: - Two-pass approach: try strict LFRCNP first, fall back to +1 only if no path found. This prevents mixing valid FRC with invalid. - Apply same LFRCNP threshold to both end candidate filtering AND middle path A* search (no separate fallback that could leak). - SlipRoads (links) still allowed regardless of FRC to bridge classes. - Length tolerance: use max() instead of min() for upper bound, giving short segments more slack for cross-provider geometry diffs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The try_same_edge_solution shortcut was bypassing LFRCNP filtering, allowing a residential edge to be chosen when LFRCNP forbade it. Changes: - Add max_frc parameter to try_same_edge_solution - Check edge FRC against LFRCNP (SlipRoads always allowed) - Defer relaxed same-edge fallback until after strict A* search fails Order of attempts: 1. Same-edge with strict LFRCNP 2. Multi-edge A* with strict LFRCNP 3. Same-edge with relaxed LFRCNP (+1) 4. Multi-edge A* with relaxed LFRCNP (+1) This ensures same-edge shortcuts cannot bypass the LFRCNP constraint, and relaxed solutions are only used when no strict path exists. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
bnaul
force-pushed
the
relax_slip_roads
branch
from
January 30, 2026 00:25
4dec442 to
6df292d
Compare
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
Fixes issues where the decoder would take detours through low-importance roads (e.g., residential) even when LFRCNP indicated the path should stay on higher-class roads.
Problem
When decoding HERE OpenLR onto OSM networks, the
+1FRC tolerance was applied uniformly, allowing residential roads (FRC4) to be used when LFRCNP=3. This caused the decoder to prefer closer but incorrect candidates, resulting in longer paths through residential areas instead of direct routes on primary roads.Solution
Two-pass LFRCNP approach: Try strict LFRCNP first, only fall back to +1 tolerance if no path exists.
Order of attempts:
This prevents mixing valid FRC edges with invalid ones while still allowing consistent cross-provider FRC shifts when necessary.
Additional changes
Test results
🤖 Generated with Claude Code