spatial-monorepo / ui/src / snapToNearestNode
Function: snapToNearestNode()
snapToNearestNode(
pt,graph,activeFloorId?):string|null
Defined in: packages/ui/src/useWayfinding.ts:34
Snap pt to the nearest node in the navigation graph. Returns the node ID of the closest node by haversine distance.
Two filters are always/optionally applied (issue #460):
- Vertical-transport nodes (stairs / elevator / escalator / ramp) are always excluded — mirrors
nearestWalkableNode's semantics in@diginestai/wayfinding, since a tap/click snapping onto a stairwell or elevator shaft node is never the user's intent; those nodes exist only to carry cross-floor routing edges. - When
activeFloorIdis provided, candidates are further restricted to nodes on that floor — without this, the nearest node "as the crow flies" can belong to a different floor stacked directly above/below, silently snapping the route start/stop to the wrong level.
Parameters
pt
Position2D
graph
WayfindingGraph
activeFloorId?
string
Returns
string | null
