ST_IsRing

ST_IsRing takes a linestring as an input parameter and returns 1 if it is a ring. Otherwise, 0 (zero) is returned. A linestring is a ring if it is simple and closed.

If the given linestring is empty, then 0 (zero) is returned. If the linestring is null, then null is returned.

Syntax

Read syntax diagramSkip visual syntax diagramdb2gse.ST_IsRing(linestring)

Parameter

linestring
A value of type ST_LineString that represents the linestring that is to be tested.

Return type

INTEGER

Examples

In this example, four linestrings are created. ST_IsRing is used to check if they are rings. The last one is not considered a ring even though it is closed, because the path crosses over itself.

SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_lines (id INTEGER, geometry ST_Linestring)

INSERT INTO sample_lines VALUES
       (1, ST_Linestring('linestring EMPTY',0))

INSERT INTO sample_lines VALUES
       (2, ST_Linestring('linestring(10 10, 20 10, 20 20)' ,0))

INSERT INTO sample_lines VALUES
       (3, ST_Linestring('linestring(10 10, 20 10, 20 20, 10 10)' ,0))

INSERT INTO sample_lines VALUES
       (4, ST_Linestring('linestring(10 10, 20 10, 10 20, 20 20, 10 10)' ,0))


SELECT id, ST_IsClosed(geometry) Is_Closed, ST_IsRing(geometry)  Is_Ring
FROM sample_lines

Results:

ID          IS_CLOSED   IS_RING
----------- ----------- -----------
          1           1           0
          2           0           0
          3           1           1
          4           1           0