Skip to content

spatial-monorepo


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):

  • isFirstSegment legs keep their natural leading depart (the true start of the whole route); every other leg's leading depart is replaced with an exit-connection step (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 trailing arrive replaced with a take-connection step carrying the real destination level name and vertical category.
  • Degenerate case: a floor segment can collapse to a single walk instruction (buildWalkInstructions on 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 for exit-connection, once for take-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

IMDFArchive

walkInstructions

Instruction[]

levelId

string

isFirstSegment

boolean

incomingTransition

{ category: VerticalCategory; fromLevelId: string; } | undefined

transitionAfter

{ category: VerticalCategory; toLevelId: string; } | undefined

Returns

Instruction[]

Released under commercial licensing.