spatial-monorepo / editor/src / buildDoorSwingPolygon
Function: buildDoorSwingPolygon()
buildDoorSwingPolygon(
pivot,wallAngleDeg,widthMeters?,segments?):Polygon
Defined in: packages/editor/src/layers/doorSwingLayer.ts:46
Build a GeoJSON Polygon representing a quarter-circle (door swing arc).
The ring layout is: [0] pivot point (hinge) [1..seg+1] arc vertices from wallAngleDeg to wallAngleDeg+90° (seg+1 points) [seg+2] closing vertex === pivot (same as [0])
Total ring length: segments + 3 (i.e. segments + 2 unique positions + 1 close)
pivot is a GeoJSON [lng, lat] position in degrees. widthMeters is a real-world metre distance, so it is converted to a degree-space radius at the pivot's latitude (rLng = widthMeters / (111320 * cos(latRad)), rLat = widthMeters / 110540) before being applied to the pivot coordinates.
Parameters
pivot
[number, number]
GeoJSON [lng, lat] position of the hinge point
wallAngleDeg
number
Angle in degrees of the wall — arc starts here
widthMeters?
number = DEFAULT_WIDTH_METERS
Door leaf width (radius of the arc, in metres) — defaults to 0.9 m
segments?
number = DEFAULT_SEGMENTS
Number of arc subdivisions — defaults to 12
Returns
Polygon
