ST_IsPolygonCW

更新时间:
复制 MD 格式

Returns true if all exterior rings of a polygon are wound clockwise and all interior rings are wound anticlockwise.

Syntax

boolean ST_IsPolygonCW(geometry geom);

Parameters

ParameterDescription
geomThe geometry object to check.

Function properties

  • Supports 3D geometries and preserves Z coordinates.

  • Supports M coordinates.

Usage notes

No polygon component

If the input geometry contains no polygon component, the function returns true. A closed LineString is not treated as a polygon.

Same-direction rings

If one or more interior rings are wound in the same direction as an exterior ring, both ST_IsPolygonCW and ST_IsPolygonCCW return false.

Examples

Example 1: Clockwise exterior ring, anticlockwise interior ring (returns true)

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)

What's next

  • ST_IsPolygonCCW — Check whether exterior rings are anticlockwise and interior rings are clockwise.