定义
ST_IsClosed 以 ST_LineString 或 ST_MultiLineString 作为输入参数,如果为闭合,则返回 1(Oracle 和 SQLite)或 t (PostgreSQL);否则返回 0(Oracle 和 SQLite)或 f (PostgreSQL)。
语法
Oracle 和 PostgreSQL
sde.st_isclosed (line1 sde.st_geometry) sde.st_isclosed (multiline1 sde.st_geometry)
SQLite
st_isclosed (geometry1 geometryblob)
返回类型
布尔型
示例
测试线串
创建一个包含单一 linestring 列的 closed_linestring 表。
INSERT 语句将两条记录插入 closed_linestring 表中。第一条记录不是闭合线串,而第二条记录是闭合线串。
查询将返回 ST_IsClosed 函数的结果。因为第一行的线串不闭合,所以返回 0 或 f;而第二行的线串是闭合的,所以返回 1 或 t。
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
测试多线串
创建一个包含单一 ST_MultiLineString 列的 closed_mlinestring 表。
INSERT 语句将分别插入一条闭合的和一条不闭合的 ST_MultiLineString 记录。
查询将列出 ST_IsClosed 函数的结果。因为第一行的多线串不闭合,所以返回 0 或 f。而第二行 ln1 列中存储的多线串是闭合的,所以返回 1 或 t。如果多线串的所有线串元素都闭合,则多线串是闭合的。
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