Skip to content

Improve LFRCNP handling for cross-provider OpenLR decoding - #19

Merged
bnaul merged 4 commits into
mainfrom
relax_slip_roads
Jan 30, 2026
Merged

Improve LFRCNP handling for cross-provider OpenLR decoding#19
bnaul merged 4 commits into
mainfrom
relax_slip_roads

Conversation

@bnaul

@bnaul bnaul commented Jan 29, 2026

Copy link
Copy Markdown
Contributor

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 +1 FRC 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:

  1. Strict LFRCNP - single edge (both LRPs on same road segment)
  2. Strict LFRCNP - multi-edge path (A* search)
  3. Relaxed LFRCNP (+1) - single edge
  4. Relaxed LFRCNP (+1) - multi-edge path

This prevents mixing valid FRC edges with invalid ones while still allowing consistent cross-provider FRC shifts when necessary.

Additional changes

  • SlipRoad exception: Link roads (motorway_link, etc.) always allowed regardless of FRC since they bridge road classes
  • Length tolerance: More generous upper bound for short segments to handle cross-provider geometry differences

Test results

Code Before After
Primary road test 380m through residential 349m through primary only ✓
Divided highway Failed 39.9m on motorway ✓

🤖 Generated with Claude Code

bnaul and others added 4 commits January 29, 2026 12:02
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 bnaul changed the title Allow slip roads in LFRCNP filtering regardless of FRC Improve LFRCNP handling for cross-provider OpenLR decoding Jan 30, 2026
@bnaul
bnaul merged commit eab1e04 into main Jan 30, 2026
2 checks passed
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