Name

ST_ForceRHR — Forces the orientation of the vertices in a polygon to follow the Right-Hand-Rule.

Synopsis

boolean ST_ForceRHR(geometry g);

Description

Forces the orientation of the vertices in a polygon to follow the Right-Hand-Rule. In GIS terminology, this means that the area that is bounded by the polygon is to the right of the boundary. In particular, the exterior ring is orientated in a clockwise direction and the interior rings in a counter-clockwise direction.

This function supports 3d and will not drop the z-index.

Examples

SELECT ST_AsEWKT(
  ST_ForceRHR(
	'POLYGON((0 0 2, 5 0 2, 0 5 2, 0 0 2),(1 1 2, 1 3 2, 3 1 2, 1 1 2))'
  )
);
						  st_asewkt
--------------------------------------------------------------
 POLYGON((0 0 2,0 5 2,5 0 2,0 0 2),(1 1 2,3 1 2,1 3 2,1 1 2))
(1 row)

See Also

ST_BuildArea, ST_Polygonize, ST_Reverse