@openhps/geospatial
    Preparing search index...

    Function snapToSpace

    • Snaps an absolute position to the nearest symbolic space.

      Point-in-polygon is tried first (using [[SymbolicSpace.isInside]], with the local metric polygon as a fallback). A position inside a space keeps its coordinates; a position just outside is projected onto the nearest boundary. When the nearest boundary is farther than maxDistanceMeters, the result is null, so a caller does not pretend a fix 50 m outside the building is on a corridor.

      const snapped = snapToSpace(new Absolute2DPosition(5, -1), floor.spaces);
      if (snapped) {
      console.log(snapped.space.displayName, snapped.distance);
      }

      Parameters

      • position: AbsolutePosition

        The position to snap

      • spaces: Iterable<SymbolicSpace<any>>

        The candidate spaces

      • Optionaloptions: SnapToSpaceOptions = {}

        Distance threshold and filter

      Returns SnappedSpace

      The snapped space, or null when no space is close enough