spatial-monorepo / wayfinding/src / finalizeSegmentInstructions
Function: finalizeSegmentInstructions()
finalizeSegmentInstructions(
archive,walkInstructions,levelId,isFirstSegment,incomingTransition,transitionAfter):Instruction[]
Defined in: packages/wayfinding/src/grid-multifloor.ts:362
Turns one floor segment's raw walk instructions into the final instruction list for its Leg, layering take-connection/exit-connection steps around floor transitions (issue #484):
isFirstSegmentlegs keep their natural leadingdepart(the true start of the whole route); every other leg's leadingdepartis replaced with anexit-connectionstep (you've just left the elevator/stairs/etc. that got you onto this floor).- A leg with
transitionAfter(i.e. not the final leg) has its trailingarrivereplaced with atake-connectionstep carrying the real destination level name and vertical category. - Degenerate case: a floor segment can collapse to a single walk instruction (
buildWalkInstructionson a 0/1-point path — the entry and exit portals coincide, e.g. a pass-through floor with no walking at all) while both an incoming and an outgoing transition apply. Naively replacing that lone instruction twice — once forexit-connection, once fortake-connection— would silently discard the exit step, since the second replacement overwrites the first. Emit both connection steps back to back instead of collapsing them into one.
Parameters
archive
walkInstructions
levelId
string
isFirstSegment
boolean
incomingTransition
{ category: VerticalCategory; fromLevelId: string; } | undefined
transitionAfter
{ category: VerticalCategory; toLevelId: string; } | undefined
