名称

ST_NumInteriorRings — 返回多边形的内部环(孔)的数量。

概要

integer ST_NumInteriorRings(geometry a_polygon);

描述

返回多边形几何体的内部环的数量。如果几何体不是多边形,则返回 NULL。

此方法实现了 SQL/MM 规范。SQL-MM 3: 8.2.5

更改:2.0.0 - 在之前的版本中,它允许传递 MULTIPOLYGON,返回第一个 POLYGON 的内部环的数量。

示例

--If you have a regular polygon
SELECT gid, field1, field2, ST_NumInteriorRings(geom) AS numholes
FROM sometable;

--If you have multipolygons
--And you want to know the total number of interior rings in the MULTIPOLYGON
SELECT gid, field1, field2, SUM(ST_NumInteriorRings(geom)) AS numholes
FROM (SELECT gid, field1, field2, (ST_Dump(geom)).geom As geom
	FROM sometable) As foo
GROUP BY gid, field1,field2;