ST_IsPolygonCW

更新时间:
复制 MD 格式

Tests whether the exterior rings of a polygon are orientated clockwise and the interior rings are orientated anticlockwise.

Syntax

boolean ST_IsPolygonCW(geometry geom);

Parameters

ParameterDescription
geomThe geometry object to test.

Description

ST_IsPolygonCW returns true if all exterior rings of the input polygon are orientated clockwise and all interior rings are orientated anticlockwise.

The function also supports 3D objects (Z coordinates are preserved) and M coordinates.

If the input contains no polygon components (for example, a Point or a LineString), the function returns true. A closed LineString is not treated as a polygon component.
If one or more interior rings are orientated in the same direction as an exterior ring, both ST_IsPolygonCW and ST_IsPolygonCCW return false.

Examples

Check whether a polygon's rings are in clockwise orientation:

SELECT ST_IsPolygonCW('POLYGON((1 0,0 3,3 0,1 0),(1 0,2 0,0 2,1 0))'::geometry);
 st_ispolygoncw
----------------
 t
(1 row)

Related functions

FunctionDescription
ST_IsPolygonCCWTests if exterior rings are orientated anticlockwise and interior rings are orientated clockwise.