Skip to content

Commit aa6d8c5

Browse files
committed
fix(navigation): project route flow with exact spherical matching
Flow samples were matched to the route through a longitude/latitude grid of padded edge boxes, which claimed that any snap closer than the corridor would be found. That is not true on a sphere: a great-circle edge bows away from the box its endpoints describe. A route from [-1,80] to [1,80] rises about 165 m poleward of latitude 80, so samples sitting essentially on the line — deviations of a few nanometres — fell outside every candidate cell and the route reported no flow at all. Widening the padding cannot fix this in general, because there is no bound in degree space that holds near the poles, across the antimeridian and for long edges at once. Every sample now goes through the prepared spherical matcher, which prunes with conservative great-circle bounds and evaluates survivors exactly, so the grid and its run-local translation are gone entirely. Contiguous-run formation, direction filtering, the backward-jump guard and pass selection are unchanged; they simply sit on exact candidates now. Overlap resolution was quadratic: it cut the route at every span boundary and then scanned every span for every interval, about 50 million checks for five thousand spans. It is now a boundary sweep with a max-heap ordered by severity and then submission index, which is the rule the old scan expressed by taking the first maximum it met. The ordering is explicit rather than inherited from sort stability, so the tie behaviour is pinned rather than incidental. One numeric consequence worth recording: along-route distance for a flow span used to add a prefix computed with a 6371000 m earth radius to an offset computed with Turf's 6371008.8 m, mixing two radii inside one value and leaving flow distances on a different scale from navigation progress. It is now Turf throughout, a shift of about 1.4 parts per million, and the two agree. Span shape, ordering, direction, colours, thresholds, minimum span and merge gap are unchanged. A seeded differential holds the new resolver against the old one across 1440 span arrangements, and doubling five thousand spans to ten thousand now roughly doubles the comparisons instead of quadrupling them.
1 parent 3433127 commit aa6d8c5

3 files changed

Lines changed: 801 additions & 246 deletions

File tree

0 commit comments

Comments
 (0)