This example creates several linestrings. The last two linestrings
have the same X and Y coordinates, but one linestring contains varying
Z coordinates that cause the linestring to not be closed, and the
other linestring contains varying M coordinates (measures) that do
not affect whether the linestring is closed.
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 m(10 10 1, 20 10 2, 20 20 3,
10 10 4)' ,0))
INSERT INTO sample_lines VALUES
(5, ST_Linestring('linestring z(10 10 5, 20 10 6, 20 20 7,
10 10 8)' ,0))
SELECT id, ST_IsClosed(geometry) Is_Closed
FROM sample_lines
Results:
ID IS_CLOSED
----------- -----------
1 0
2 0
3 1
4 1
5 0
In this example, two multilinestrings are created. ST_IsClosed
is used to determine if the multilinestrings are closed. The first
one is not closed, even though all of the curves together form a complete
closed loop. This is because each curve itself is not closed.
The
second multilinestring is closed because each curve itself is closed.
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_mlines (id INTEGER, geometry ST_MultiLinestring)
INSERT INTO sample_mlines
VALUES
(6, ST_MultiLinestring('multilinestring((10 10, 20 10, 20 20),
(20 20, 30 20, 30 30),
(30 30, 10 30, 10 10))',0))
INSERT INTO sample_mlines
VALUES
(7,ST_MultiLinestring('multilinestring((10 10, 20 10, 20 20, 10 10),
(30 30, 50 30, 50 50, 30 30))',0))
SELECT id, ST_IsClosed(geometry) Is_Closed
FROM sample_mlines
Results:
ID IS_CLOSED
----------- -----------
6 0
7 1