spatial-monorepo / wayfinding/src / routeNearestNeighborChain
Function: routeNearestNeighborChain()
routeNearestNeighborChain(
graph,origin,destinations,opts,routeLeg):DirectionsResult
Defined in: packages/wayfinding/src/directions.ts:373
Nearest-neighbour multi-destination walk, engine-agnostic (issue #483): factored out of getDirectionsMultiDestination so the grid-engine wrapper (directions-grid.ts's getDirectionsMultiDestinationGridEngine) can reuse the exact same origin-resolution + nearest-neighbour-ordering logic against a caller-supplied per-leg router instead of duplicating it. routeLeg is called once per resolved leg with the two concrete node ids; its result is returned as-is (short-circuiting the walk) on the first failure.
origin accepts the same single/array/null current-location resolution as getDirections (issue #470) — an array is resolved once, up front, to whichever candidate is haversine-closest to the destination list, then used as the concrete starting node for the nearest-neighbour walk.
Parameters
graph
origin
string | string[] | null
destinations
string[]
opts
routeLeg
(originId, destinationId, opts) => DirectionsResult
