Skip to content

routing: snap CH ends onto roads, keep a parked car's heading - #40

Merged
Monstrofil merged 1 commit into
mainfrom
nav-snap-heading
Oct 27, 2026
Merged

Monstrofil merged 1 commit into
mainfrom
nav-snap-heading

Conversation

@Monstrofil

Copy link
Copy Markdown
Contributor

Root cause of the CH vs HH/A* disagreement on the Khreshchatyk pair: the point lies between the two one-way carriageways; CH snapped to the 4 nearest nodes (a split junction is several nodes at one spot) and could start the wrong way round (9.1 km vs A* 4.7 km).

  • CH start/end projected onto nearest road segments via the core's findRouteSegment, followed in travel direction to the first sidecar junction; all such junctions seed the single search (snap distance + driving time + reverse-heading penalty). Approach/exit stretches are part of the route; same-road start/end uses the road directly. Node snap remains the fallback.
  • Heading kept while the car stands where it stopped, also across restarts (/datastore/navicore-backend/parked.txt, saved once per stop at a new spot; also the map's first position).

Bench on M9304002366, 18 pairs vs plain A* (2 disputed, 8 on-road, 8 jittered 15-40 m): worst CH/A* time x2.13 → x1.29, median x0.996 → x0.980; disputed pair 9.1 km → 1.5 km; CH median 458 → 606 ms. Remaining worst (on-road pair, x1.29) is the CH cost model, not snapping.

Tests: make test 34/34 (new parked-heading and nodes_at tests), make (QNX).

🤖 Generated with Claude Code

A point between the two carriageways of a dual carriageway (Khreshchatyk,
the default origin without a fix) started on whichever side had a CH
junction nearby, and a route could begin the wrong way round: 9.1 km
where A* found 4.7 km.

- CH: start and end are projected onto the nearest road segments, as the
  core's routers do (findRouteSegment), then followed in the road's
  travel direction to the first sidecar junction; every such junction
  seeds the one search with the snap distance and the driving time to
  it (plus the reverse-heading penalty). The approach and exit stretches
  are part of the route; start and end on one road use the road itself.
  The nearest-junction snap stays as the fallback.
- A junction splits into one node per arriving and leaving edge, all at
  its coordinates, so the old "4 nearest nodes" were often one junction.
- The heading a route starts with is kept while the car stands where it
  stopped, also across a restart: a parked record (heading and position,
  /datastore/navicore-backend/parked.txt) is saved once per stop at a new
  spot and restored at start-up, also as the map's first position.

Bench, 18 pairs against plain A* (2 disputed, 8 on roads, 8 jittered
15-40 m): worst CH/A* time x2.13 -> x1.29, median x0.996 -> x0.980;
the disputed pair 9.1 km -> 1.5 km. CH route time median 458 -> 606 ms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Monstrofil
Monstrofil merged commit 42199ff into main Oct 27, 2026
1 check passed
@Monstrofil
Monstrofil deleted the nav-snap-heading branch October 27, 2026 14:14
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