將一個Geometry對象轉換為GeometryCollection對象。

語法

geometry  ST_ForceCollection(geometry  geomA);

參數

參數名稱 描述
geomA 目標Geometry對象。

描述

  • 該函數對于簡化WKB表示法很有用。
  • 該函數支持Circular Strings、Curves和Polyhedral surfaces對象。
  • 該函數支持3D對象,并且不會刪除Z坐標。

示例

SELECT ST_AsText(ST_ForceCollection(ST_GeomFromText('POLYGON((1 1,2 1,2 2,1 2,1 1))')));
                     st_astext
----------------------------------------------------
 GEOMETRYCOLLECTION(POLYGON((1 1,2 1,2 2,1 2,1 1)))
(1 row)