Definition
ST_IsClosed takes an ST_LineString or ST_MultiLineString and returns 1 (Oracle and SQLite) or t (PostgreSQL) if it is closed; otherwise, it returns 0 (Oracle and SQLite) or f (PostgreSQL).
Syntax
Oracle and PostgreSQL
sde.st_isclosed (line1 sde.st_geometry) sde.st_isclosed (multiline1 sde.st_geometry)
SQLite
st_isclosed (geometry1 geometryblob)
Return type
Boolean
Examples
Testing a linestring
The closed_linestring table is created with a single linestring column.
The INSERT statements insert two records into the closed_linestring table. The first record is not a closed linestring, while the second is.
The query returns the results of the ST_IsClosed function. The first row returns a 0 or f because the linestring is not closed, while the second row returns a 1 or t because the linestring is closed.
Oracle
CREATE TABLE closed_linestring (ln1 sde.st_geometry);
INSERT INTO CLOSED_LINESTRING VALUES (
sde.st_linefromtext ('linestring (10.02 20.01, 10.32 23.98, 11.92 25.64)', 4326)
);
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)', 4326)
);
SELECT sde.st_isclosed (ln1) Is_it_closed
FROM CLOSED_LINESTRING;
Is_it_closed
0
1
PostgreSQL
CREATE TABLE closed_linestring (ln1 sde.st_geometry);
INSERT INTO closed_linestring VALUES (
sde.st_linestring ('linestring (10.02 20.01, 10.32 23.98, 11.92 25.64)', 4326)
);
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)', 4326)
);
SELECT sde.st_isclosed (ln1) AS Is_it_closed
FROM closed_linestring;
is_it_closed
f
t
SQLite
CREATE TABLE closed_linestring (id integer);
SELECT AddGeometryColumn (
NULL,
'closed_linestring',
'ln1',
4326,
'linestring',
'xy',
'null'
);
INSERT INTO closed_linestring VALUES (
1,
st_linefromtext ('linestring (10.02 20.01, 10.32 23.98, 11.92 25.64)', 4326)
);
INSERT INTO closed_linestring VALUES (
2,
st_linefromtext ('linestring (10.02 20.01, 11.92 35.64, 25.02 34.15, 19.15 33.94, 10.02 20.01)', 4326)
);
SELECT st_isclosed (ln1)
AS "Is_it_closed"
FROM closed_linestring;
Is_it_closed
0
1
Testing a multilinestring
The closed_mlinestring table is created with a single ST_MultiLineString column.
The INSERT statements insert an ST_MultiLineString record that is not closed and another that is.
The query lists the results of the ST_IsClosed function. The first row returns 0 or f because the multilinestring is not closed. The second row returns 1 or t because the multilinestring stored in the ln1 column is closed. A multilinestring is closed if all its linestring elements are closed.
Oracle
CREATE TABLE closed_mlinestring (mln1 sde.st_geometry);
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))', 4326)
);
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))', 4326)
);
SELECT sde.st_isclosed (mln1) Is_it_closed
FROM CLOSED_MLINESTRING;
Is_it_closed
0
1
PostgreSQL
CREATE TABLE closed_mlinestring (mln1 sde.st_geometry);
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))', 4326)
);
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))', 4326)
);
SELECT st_isclosed (mln1)
AS Is_it_closed
FROM closed_mlinestring;
is_it_closed
f
t
SQLite
CREATE TABLE closed_mlinestring (mln1 geometryblob);
SELECT AddGeometryColumn (
NULL,
'closed_mlinestring',
'mln1',
4326,
'multilinestring',
'xy',
'null'
);
INSERT INTO closed_mlinestring VALUES (
st_mlinefromtext ('multilinestring ((10.02 20.01, 10.32 23.98, 11.92 25.64), (9.55 23.75, 15.36 30.11))', 4326)
);
INSERT INTO closed_mlinestring VALUES (
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))', 4326)
);
SELECT sde.st_isclosed (mln1)
AS "Is_it_closed"
FROM CLOSED_MLINESTRING;
Is_it_closed
0
1