Snapping

"/home/yossef/notes/git/projects/maplibra/modules/Snapping.md"

path: maplibra/modules/Snapping.md

- **fileName**: Snapping
- **Created on**: 2026-06-16 00:48:42

Snapping

Purpose: How user-selected coordinates attach to graph nodes before routing.

Related: ../Home.md, ./Pathfinding.md, ../flows/Route Computation.md, ./Doors and Rooms.md, ../decisions/Large Room Strict Exit Heuristic.md

What It Does

src/pathfinding/snapping.js ranks nearby graph nodes for a user-selected start or target point.

Snapping considers distance, source penalties, room/door relationships, and clearance. It can return multiple candidates so route computation can choose the best connected route instead of relying on one nearest node.

Room Exit Behavior

Dropped indoor start points can request strictRoomExit, which normally means a containing room should snap through a room door before route computation tries generic walkable nodes.

src/pathfinding/snapping.js now disables strict room exit for very large containing room polygons. The default cutoff is 300m², configurable via maxStrictRoomArea. This prevents open public areas such as concourses or main loops from being treated like small enclosed rooms that require a door exit.

For small enclosed room polygons, strict room exit remains active and getDoorSnapCandidates() receives allowTrim: true.

Why It Matters

Bad snapping can create strange route starts or force paths through the wrong room/door. Multi-candidate snapping reduces this risk by letting A* evaluate several possible anchors.

Known Tradeoff

Area is only a heuristic. Large enclosed venues over the cutoff can be treated like public open areas unless future metadata distinguishes public concourses from large private rooms. A more precise future fix would use room metadata or walkable-area context to distinguish public concourses from large enclosed destinations.

continue:[[]]
before:[[]]