navi/backend/services/navi_offroute
Matt c8e2568f64 perf(offroute): query_radius uses k-NN <-> ordering for index-supported nearest-neighbor
The old ST_DWithin(50km) scan returned ~226k candidate points near dense areas before
sorting (~3-10s/call). Replace with PostGIS k-NN ordering: ORDER BY geom::geography <->
point LIMIT k, which the existing GiST index on (geom::geography) walks nearest-first and
stops after K rows. SELECT still computes ST_Distance AS distance_m so callers see real
meters. radius_km is kept as a Python soft cap applied after fetch (drops rows beyond it),
preserving the caller expanded-radius fallback (now effectively a no-op).

2 tests: SQL contains <-> + LIMIT and no ST_DWithin; radius_km soft cap filters beyond-cap rows.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 07:28:46 +00:00
..
tests perf(offroute): query_radius uses k-NN <-> ordering for index-supported nearest-neighbor 2026-05-25 07:28:46 +00:00
__init__.py Add navi-offroute service (extraction #8 — final) (#10) 2026-05-22 23:30:43 -06:00
admin.py Add navi-offroute service (extraction #8 — final) (#10) 2026-05-22 23:30:43 -06:00
app.py Add navi-offroute service (extraction #8 — final) (#10) 2026-05-22 23:30:43 -06:00
barriers.py Add navi-offroute service (extraction #8 — final) (#10) 2026-05-22 23:30:43 -06:00
cost.py Add navi-offroute service (extraction #8 — final) (#10) 2026-05-22 23:30:43 -06:00
friction.py Add navi-offroute service (extraction #8 — final) (#10) 2026-05-22 23:30:43 -06:00
mvum.py Add navi-offroute service (extraction #8 — final) (#10) 2026-05-22 23:30:43 -06:00
offroute_route.py feat(offroute): Auto eligible-mode-set with category hints + parallel spatial fallback 2026-05-25 02:15:48 +00:00
router.py perf(offroute): query_radius uses k-NN <-> ordering for index-supported nearest-neighbor 2026-05-25 07:28:46 +00:00
trails.py Add navi-offroute service (extraction #8 — final) (#10) 2026-05-22 23:30:43 -06:00