ST_IsClosed

Definition

ST_IsClosed takes an ST_LineString or ST_MultiLineString and returns 1 (Oracle) or t (PostgreSQL) if it is closed; otherwise, it returns 0 (Oracle) or f (PostgreSQL).

Syntax

sde.st_isclosed (ln1 sde.st_geometry)
sde.st_isclosed (mln1 sde.st_geometry)

Return type

Boolean

Examples

Testing a linestring

The closed_linestring table is created with a single linestring column.

CREATE TABLE closed_linestring (ln1 sde.st_geometry);

The INSERT statements insert two records into the closed_linestring table. The first record is not a closed linestring, while the second is.

Oracle

INSERT INTO CLOSED_LINESTRING VALUES (
sde.st_linefromtext ('linestring (10.02 20.01, 10.32 23.98, 11.92 25.64)', 0)
);

INSERT INTO CLOSED_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)', 0)
);

PostgreSQL

INSERT INTO closed_linestring VALUES (
sde.st_linestring ('linestring (10.02 20.01, 10.32 23.98, 11.92 25.64)', 0)
);

INSERT INTO closed_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)', 0)
);

The query returns the results of the ST_IsClosed function. The first row returns a 0 because the linestring is not closed, while the second row returns a 1 because the linestring is closed.

Oracle

SELECT sde.st_isclosed (ln1) Is_it_closed
FROM CLOSED_LINESTRING;

Is_it_closed

0
1

PostgreSQL

SELECT sde.st_isclosed (ln1) AS Is_it_closed
FROM closed_linestring;

is_it_closed

f
t

Testing a multilinestring

The closed_mlinestring table is created with a single ST_MultiLineString column.

CREATE TABLE closed_mlinestring (mln1 sde.st_geometry);

The INSERT statements insert an ST_MultiLineString record that is not closed and another that is.

INSERT INTO closed_mlinestring VALUES (
sde.st_mlinefromtext ('multilinestring ((10.02 20.01, 10.32 23.98, 11.92 25.64), (9.55 23.75, 15.36 30.11))', 0)
);

INSERT INTO closed_mlinestring VALUES (
sde.st_mlinefromtext ('multilinestring ((10.02 20.01, 11.92 35.64, 25.02
34.15, 19.15 33.94, 10.02 20.01), (51.71 21.73, 73.36 27.04, 71.52 32.87, 52.43 31.90, 51.71 21.73))', 0)
);

The query lists the results of the ST_IsClosed function. The first row returns 0 because the multilinestring is not closed. The second row returns 1 because the multilinestring stored in the ln1 column is closed. A multilinestring is closed if all its linestring elements are closed.

Oracle

SELECT sde.st_isclosed (mln1) Is_it_closed
FROM CLOSED_MLINESTRING;

Is_it_closed

0
1

PostgreSQL

SELECT st_isclosed (mln1) AS Is_it_closed
FROM closed_mlinestring;

is_it_closed

f
t

2/5/2013