ST_IsRing

Definition

ST_IsRing takes an ST_LineString and returns 1 (Oracle and SQLite) or t (PostgreSQL) if it is a ring (for example, the ST_LineString is closed and simple); otherwise, it returns 0 (Oracle and SQLite) or f (PostgreSQL).

Syntax

Oracle and PostgreSQL

sde.st_isring (line1 sde.st_geometry)

SQLite

st_isring (line1 geometryblob)

Return type

Boolean

Example

The ring_linestring table is created with a single ST_LineString column, ln1.

The INSERT statements insert three linestrings into the ln1 column. The first row contains a linestring that's not closed and isn't a ring. The second row contains a closed and simple linestring that is a ring. The third row contains a linestring that is closed but not simple because it intersects its own interior. It is also not a ring.

The SELECT query returns the results of the ST_IsRing function. The first row returns 0 or f because the linestrings aren't rings, while the second and third rows return 1 or t because they are rings.

Oracle

CREATE TABLE ring_linestring (ln1 sde.st_geometry);
INSERT INTO RING_LINESTRING VALUES (
 sde.st_linefromtext ('linestring (10.02 20.01, 10.32 23.98, 11.92 25.64)', 4326)
);

INSERT INTO RING_LINESTRING VALUES (
 sde.st_linefromtext ('linestring (10.02 20.01, 11.92 35.64, 25.02 34.15, 19.15 33.94, 10.02 20.01)', 4326)
);

INSERT INTO ring_linestring (ln1) VALUES (
 sde.st_linestring ('linestring (11 31, 11.25 31.12, 21.83 44.13, 16.45 44.24, 11 31)', 4326)
);
SELECT sde.st_isring (ln1) Is_it_a_ring
 FROM RING_LINESTRING;

Is_it_a_ring

0
1
1

PostgreSQL

CREATE TABLE ring_linestring (ln1 sde.st_geometry);
INSERT INTO ring_linestring VALUES (
 sde.st_linestring ('linestring (10.02 20.01, 10.32 23.98, 11.92 25.64)', 4326)
);

INSERT INTO ring_linestring VALUES (
 sde.st_linestring ('linestring (10.02 20.01, 11.92 35.64, 25.02 34.15, 19.15 33.94, 10.02 20.01)', 4326)
);

INSERT INTO ring_linestring (ln1) VALUES (
 sde.st_linestring ('linestring (11 31, 11.25 31.12, 21.83 44.13, 16.45 44.24, 11 31)', 4326)
);
SELECT sde.st_isring (ln1) 
 AS Is_it_a_ring
 FROM ring_linestring;

Is_it_a_ring

f
t
t

SQLite

CREATE TABLE ring_linestring (id integer primary key autoincrement not null);

SELECT AddGeometryColumn (
 NULL,
 'ring_linestring',
 'ln1',
 4326,
 'linestring',
 'xy',
 'null'
);
INSERT INTO ring_linestring (ln1) VALUES (
 st_linestring ('linestring (10.02 20.01, 10.32 23.98, 11.92 25.64)', 4326)
);

INSERT INTO ring_linestring (ln1) VALUES (
 st_linestring ('linestring (10.02 20.01, 11.92 35.64, 25.02 34.15, 19.15 33.94, 10.02 20.01)', 4326)
);

INSERT INTO ring_linestring (ln1) VALUES (
 st_linestring ('linestring (11 31, 11.25 31.12, 21.83 44.13, 16.45 44.24, 11 31)', 4326)
);
SELECT st_isring (ln1)
 AS "Is it a ring?"
 FROM ring_linestring;

Is it a ring?

0
1
1

Related Topics

6/19/2015