제목

ST_ForcePolygonCW — Orients all exterior rings clockwise and all interior rings counter-clockwise.

요약

geometry ST_ForcePolygonCW(geometry geom);

설명

Forces (Multi)Polygons to use a clockwise orientation for their exterior ring, and a counter-clockwise orientation for their interior rings. Non-polygonal geometries are returned unchanged.

2.2.0 버전부터 사용할 수 있습니다.

This function supports 3d and will not drop the z-index.

This function supports M coordinates.

예시

Force a polygon and its hole to use clockwise exterior rings and counter-clockwise interior rings.

Code
WITH data AS (
  SELECT 'POLYGON((0 0,4 0,4 4,0 4,0 0),
                  (1 1,1 3,3 3,3 1,1 1))'::geometry AS geom
)
SELECT geom AS input_polygon,
       ST_ForcePolygonCW(geom) AS cw_polygon
FROM data;
래스터 출력
POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1,1 3,3 3,3 1,1 1)) | POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,3 1,3 3,1 3,1 1))
Figure
Geometry figure for visual-st-forcepolygoncw-01