ST_IsPolygonCCW

更新时间:
复制 MD 格式

Returns true if the exterior rings of the input polygon are oriented counterclockwise and the interior rings are oriented clockwise.

Syntax

boolean ST_IsPolygonCCW(geometry geom);

Parameters

ParameterDescription
geomThe geometry object to check.

Usage notes

  • If the input contains no polygon component, the function returns true. A closed linestring is not considered a polygon component.

  • If one or more interior rings and the exterior rings are oriented in the same direction, both ST_IsPolygonCCW and ST_IsPolygonCW return false.

  • Supports 3D geometries and preserves Z coordinates.

  • Supports M coordinates.

Examples

Check whether a polygon's exterior ring is oriented counterclockwise and its interior ring is oriented clockwise:

SELECT ST_IsPolygonCCW('POLYGON((1 0,3 0,0 3,1 0),(1 0,0 2,2 0,1 0))'::geometry);

Output:

 st_ispolygonccw
-----------------
 t
(1 row)

The result t (true) indicates that the exterior ring is counterclockwise and the interior ring is clockwise.