ST_ForceRHR

更新时间:
复制 MD 格式

Forces the vertex orientation of a polygon to follow the Right-Hand Rule (RHR), so the bounded area lies to the right of the boundary.

Syntax

geometry ST_ForceRHR(geometry g);

Parameters

ParameterDescription
gThe input geometry.

Description

  • Exterior rings are oriented clockwise; interior rings are oriented anticlockwise.

  • ST_ForceRHR is a synonym for ST_ForcePolygonCW.

  • Supports polyhedral surfaces.

  • Supports 3D geometries and preserves z coordinates.

Examples

Basic example: 2D polygon

SELECT ST_AsText(ST_ForceRHR(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)