定义
ST_IsRing 以 ST_LineString 作为输入参数,如果是环(如 ST_LineString 是闭合的简单线串),则返回 1(Oracle 和 SQLite)或 t (PostgreSQL);否则返回 0(Oracle 和 SQLite)或 f (PostgreSQL)。
语法
Oracle 和 PostgreSQL
sde.st_isring (line1 sde.st_geometry)
SQLite
st_isring (line1 geometryblob)
返回类型
布尔型
示例
创建一个包含单个 ST_LineString 列 ln1 的 ring_linestring 表。
INSERT 语句将三个线串插入 ln1 列中。第一行包含一个不闭合不是环的线串。第二行包含一个闭合的简单线串(线串是环)。第三行包含一个闭合的非简单线串,因为线串与自己的内部相交。此线串也不是环。
SELECT 查询将返回 ST_IsRing 函数的结果。因为第一行的线串不是环,所以返回 0 或 f;而第二行和第三行的线串是环,所以返回 1 或 t。
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