ST_IsPolygonCCW

更新时间:
复制 MD 格式

Tests whether the exterior rings of a polygon are oriented counter-clockwise and the interior rings are oriented clockwise.

Syntax

boolean ST_IsPolygonCCW(geometry geom);

Parameters

ParameterDescription
geomThe geometry object to evaluate.

Description

Returns true if all exterior rings of the input polygon are oriented counter-clockwise and all interior rings are oriented clockwise.

Returns true if the geometry has no polygonal components.

A closed LineString is not considered a polygonal component.
If one or more interior rings are oriented in the same direction as an exterior ring, both ST_IsPolygonCCW and ST_IsPolygonCW return false.

This function supports 3D geometries and preserves Z coordinates. It also supports M coordinates.

Examples

Check whether the exterior ring of a polygon with one interior ring is oriented counter-clockwise:

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

See also

  • ST_IsPolygonCW — Tests whether exterior rings are oriented clockwise and interior rings counter-clockwise.