Skip to content

routing: fix one-way and partial-edge correctness in edge-snapped routes#16

Merged
blackopsrepl merged 1 commit intomainfrom
issue/3-fix-edge-snapped-oneway-partials
Mar 21, 2026
Merged

routing: fix one-way and partial-edge correctness in edge-snapped routes#16
blackopsrepl merged 1 commit intomainfrom
issue/3-fix-edge-snapped-oneway-partials

Conversation

@blackopsrepl
Copy link
Copy Markdown
Contributor

Summary

  • make same-edge edge-snapped routing direction-aware so backward travel on a directed edge returns NoPath
  • route between snapped segments using only forward-valid exit and entry choices on directed edges
  • compute partial-edge time and distance from the actual chosen decomposition and add focused hermetic regression tests

Validation

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test edge_snapped --test integration
  • cargo test

Fixes #3

@blackopsrepl blackopsrepl merged commit d142abe into main Mar 21, 2026
3 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a5a964318a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +362 to +365
let start_exit = EdgeTraversal {
node: from.to_node,
time_s: from_edge.travel_time_s * (1.0 - from.position),
distance_m: from_edge.distance_m * (1.0 - from.position),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve zero-cost routing when a snap lands on an edge endpoint

If snap_to_edge returns position == 0.0 (or symmetrically 1.0), the traveler is already at from.from_node (to.to_node). This code still forces the search to depart via from.to_node, which can turn valid routes into NoPath or charge an entire extra edge. On the reviewed commit, a network with one-way edges 0->1 and 0->2 reproduces this: snap_to_edge(Coord::new(0.0, 0.0)) snaps to edge 0->1 at position: 0.0, and routing to a point halfway along 0->2 now fails even though the trip should just traverse half of 0->2.

Useful? React with 👍 / 👎.

Comment on lines +345 to +349
if to.position < from.position {
return Err(RoutingError::NoPath {
from: from.original,
to: to.original,
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Handle reverse travel on bidirectional roads after edge snapping

This early NoPath check breaks common two-way roads modeled as overlapping 0->1 and 1->0 edges. snap_to_edge is geometry-only, and SegmentIndex::nearest_segment keeps the first equally-close segment, so both points on that road can snap to the same 0->1 edge. A trip from 80% back to 20% along the road then fails here, even though the reverse-direction sibling edge provides a valid path; I reproduced that locally with edges (0,1) and (1,0), where both snaps landed on EdgeIdx(0) and route_edge_snapped returned NoPath.

Useful? React with 👍 / 👎.

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.

routing: fix one-way and partial-edge correctness in edge-snapped routes

1 participant