Returns true if a geometry object is both closed and simple — that is, if both ST_IsClosed and ST_IsSimple return true for the input.
Syntax
boolean ST_IsRing(geometry g);Parameters
| Parameter | Description |
|---|---|
g | The geometry object to evaluate. |
Examples
The following examples run ST_IsRing alongside ST_IsClosed and ST_IsSimple to show what each function returns for a given input.
Returns true — the input LINESTRING(0 0,0 2,2 0,0 0) is closed (start and end points match) and has no self-intersections:
SELECT ST_IsRing(geom), ST_IsClosed(geom), ST_IsSimple(geom)
FROM (SELECT 'LINESTRING(0 0,0 2,2 0,0 0)'::geometry AS geom) AS test; st_isring | st_isclosed | st_issimple
-----------+-------------+-------------
t | t | t
(1 row)Returns false — the input LINESTRING(0 0,0 2,0 0) is closed but retraces itself along the same segment, so ST_IsSimple returns false:
SELECT ST_IsRing(geom), ST_IsClosed(geom), ST_IsSimple(geom)
FROM (SELECT 'LINESTRING(0 0,0 2,0 0)'::geometry AS geom) AS test; st_isring | st_isclosed | st_issimple
-----------+-------------+-------------
f | t | f
(1 row)该文章对您有帮助吗?