ST_DumpRings — 返回多边形外环和内环的一组geometry_dump行。
geometry_dump[] ST_DumpRings(geometry a_polygon);
提取多边形环的集合返回函数 (SRF)。它返回一组geometry_dump 行,每行包含一个几何图形(geom字段)和一个整数数组(path 字段)。
geom 字段将每个环包含为 POLYGON。path字段是一个长度为 1 的整数数组,包含多边形环索引。外环(壳)的索引为 0。内环(孔)的索引为 1 及更高。
|
|
|
This only works for POLYGON geometries, not MULTIPOLYGONs. Use ST_Dump to extract polygon elements from polygonal geometries: |
可用性:需要 PostGIS 1.1.3 PostgreSQL 7.3 或更高版本。
该函数支持 3d 并且不会丢失 z-index。
Extracting all rings as polygons.
SELECT polyTable.field1, polyTable.field1,
(ST_DumpRings(polyTable.geom)).geom As geom
FROM polyTable
Extracting shell and holes from a polygon.
SELECT path, ST_AsText(geom) As geom
FROM ST_DumpRings(
'POLYGON ((1 9, 9 9, 9 1, 1 1, 1 9), (2 2, 2 3, 3 3, 3 2, 2 2), (4 2, 4 4, 6 4, 6 2, 4 2))');
path | geom
------+--------------------------------
{0} | POLYGON((1 9,9 9,9 1,1 1,1 9))
{1} | POLYGON((2 2,2 3,3 3,3 2,2 2))
{2} | POLYGON((4 2,4 4,6 4,6 2,4 2))