spatial-monorepo / core/src / insetPolygon
Function: insetPolygon()
insetPolygon(
polygon,distance):MultiPolygon|null
Defined in: packages/core/src/layers/wall-bands.ts:332
Computes polygon inset inward by distance (i.e. polygon − band, the complement of computeUnitWallBand's per-polygon step), cleaned through polygon-clipping to resolve any self-intersection the naive vertex offset introduced on concave shapes. Falls back to a negative @turf/buffer erosion when the primary path throws, degenerates to nothing, or — the naive per-vertex offset can overshoot past the shape's own centre on shapes smaller than ~2×distance — comes back the same size as (or larger than) the original, which the subsequent intersect-with-original step doesn't by itself catch (intersecting an oversized offset with the original just returns the original, unchanged, not an error).
Returns null when the polygon can't be inset at all (e.g. a room smaller than 2×thickness fully erodes) — callers should treat the whole original polygon as wall in that case.
Parameters
polygon
Polygon | MultiPolygon
distance
number
Returns
MultiPolygon | null
