ST_NumInteriorRings — 返回多边形的内部环(孔)数。
integer ST_NumInteriorRings(
geometry a_polygon)
;
返回多边形几何的内部环数。如果几何不是多边形,则返回 NULL。
此方法实现 SQL/MM 规范。
SQL-MM 3: 8.2.5
更改:2.0.0 - 在之前的版本中,它允许传递多边形,返回第一个多边形的内部环数。
--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;