ST_ForcePolygonCW

更新时间:
复制 MD 格式

Forces the exterior rings of a polygon or multipolygon geometry to be oriented clockwise (CW) and the interior rings to be oriented counterclockwise (CCW).

Syntax

geometry ST_ForcePolygonCW(geometry geom);

Parameters

ParameterDescription
geomThe input geometry.

Description

  • Non-polygon geometries are returned unchanged.

  • 3D geometries are supported. Z coordinates are preserved.

  • Geometries with M coordinates are supported.

Examples

SELECT ST_AsText(ST_ForcePolygonCW(ST_GeomFromText('POLYGON((1 1,2 1,2 2,1 2,1 1))')));

Output:

           st_astext
--------------------------------
 POLYGON((1 1,1 2,2 2,2 1,1 1))
(1 row)