名稱

ST_IsClosed — 測試 LineString 的起點和終點是否重合。對於多面體表面,測試其是否為封閉(體積)的。

概要

boolean ST_IsClosed(geometry g);

描述

如果 LINESTRING 的起點和終點重合,則返回 TRUE。對於多面體表面,報告該表面是面狀(開放)還是體積狀(封閉)。

此方法實作 OGC Simple Features Implementation Specification for SQL 1.1.

此方法實作 SQL/MM 規範。SQL-MM 3: 7.1.5, 9.3.3

[Note]

SQL-MM 定義 ST_IsClosed(NULL) 的結果為 0,而 PostGIS 返回 NULL

此函數支援 3D,且不會丟棄 Z 索引。

此方法支援圓弧字串和曲線。

增強功能:引入了 2.0.0 對多面體表面的支援。

此函數支援多面體表面。

線字串和點範例

postgis=# SELECT ST_IsClosed('LINESTRING(0 0, 1 1)'::geometry);
 st_isclosed
-------------
 f
(1 row)

postgis=# SELECT ST_IsClosed('LINESTRING(0 0, 0 1, 1 1, 0 0)'::geometry);
 st_isclosed
-------------
 t
(1 row)

postgis=# SELECT ST_IsClosed('MULTILINESTRING((0 0, 0 1, 1 1, 0 0),(0 0, 1 1))'::geometry);
 st_isclosed
-------------
 f
(1 row)

postgis=# SELECT ST_IsClosed('POINT(0 0)'::geometry);
 st_isclosed
-------------
 t
(1 row)

postgis=# SELECT ST_IsClosed('MULTIPOINT((0 0), (1 1))'::geometry);
 st_isclosed
-------------
 t
(1 row)

多面體表面範例

		-- A cube --
		SELECT ST_IsClosed(ST_GeomFromEWKT('POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),
		((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),
		((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)),
		((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)), ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) )'));

 st_isclosed
-------------
 t


 -- Same as cube but missing a side --
 SELECT ST_IsClosed(ST_GeomFromEWKT('POLYHEDRALSURFACE( ((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),
		((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)),
		((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)),
		((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)) )'));

 st_isclosed
-------------
 f

另請參閱

ST_IsRing