Skip to main content

orientPolygons

Enforces a ring orientation on all polygonal elements in the input geometry. Polygon exterior ring can be oriented clockwise (CW) or counter-clockwise (CCW), interior rings (holes) are oriented in the opposite direction.

Modifies the geometry in-place. Non-polygonal geometries will not be modified.

Parameters

NameTypeDefaultDescription
exterior'cw' | 'ccw''cw'Exterior ring orientation. Interior rings are always oriented in the opposite direction.

Returns

this

The same geometry but with oriented rings, modified in-place

Examples

exterior ring CCW, holes CW (GeoJSON compliance)
polygonal = // (Multi)Polygon or GeometryCollection with some (Multi)Polygons
polygonal.orientPolygons('ccw');
exterior ring CW, holes CCW
polygonal.orientPolygons('cw');