]> granicus.if.org Git - postgis/commitdiff
Examples of using ST_ExteriorRing and ST_NumInteriorRings
authorRegina Obe <lr@pcorp.us>
Thu, 10 Jul 2008 13:16:20 +0000 (13:16 +0000)
committerRegina Obe <lr@pcorp.us>
Thu, 10 Jul 2008 13:16:20 +0000 (13:16 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@2837 b70326c6-7e19-0410-871a-916f4a2858ee

doc/reference.xml

index 50230b92e669be885636df5b945ed5be2a51fae6..1703058c443af5ca9bf2e6fc3f85cfe179c4ab66 100644 (file)
@@ -739,21 +739,46 @@ ST_Dimension
         </varlistentry>
 
         <varlistentry>
-          <term>ST_ExteriorRing(geometry)</term>
+          <term>ST_ExteriorRing(polygon geometry)</term>
 
           <listitem>
             <para>Return the exterior ring of the polygon geometry. Return
-            NULL if the geometry is not a polygon.</para>
+            NULL if the geometry is not a polygon.  Will not work with MULTIPOLYGON</para>
+                       <programlisting>
+--If you have a table of polygons
+SELECT gid, ST_ExteriorRing(the_geom) AS ering
+FROM sometable;
+
+--If you have a table of MULTIPOLYGONs 
+--and want to return a MULTILINESTRING composed of the exterior rings of each polygon
+SELECT gid, ST_Collect(ST_ExteriorRing(the_geom)) AS erings
+       FROM (SELECT gid, (ST_Dump(the_geom)).geom As the_geom
+                       FROM sometable) As foo
+GROUP BY gid;
+                       </programlisting>
           </listitem>
         </varlistentry>
 
         <varlistentry>
-          <term>ST_NumInteriorRings(geometry)</term>
+          <term>ST_NumInteriorRings(polygon geometry)</term>
 
           <listitem>
             <para>Return the number of interior rings of the first polygon in
-            the geometry. Return NULL if there is no polygon in the
+            the geometry. This will work with both POLYGON and MULTIPOLYGON types but only looks at the first polygon.
+                       Return NULL if there is no polygon in the
             geometry.</para>
+                       <programlisting>
+--If you have a regular polygon
+SELECT gid, field1, field2, ST_NumInteriorRings(the_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(the_geom)) AS numholes
+FROM (SELECT gid, field1, field2, (ST_Dump(the_geom)).geom As the_geom
+       FROM sometable) As foo
+GROUP BY gid, field1,field2;
+                       </programlisting>
           </listitem>
         </varlistentry>