[geos-commits] r3048 - in trunk/php: . test

svn_geos at osgeo.org svn_geos at osgeo.org
Sun Jun 20 21:05:00 EDT 2010


Author: strk
Date: 2010-06-21 01:05:00 +0000 (Mon, 21 Jun 2010)
New Revision: 3048

Modified:
   trunk/php/geos.c
   trunk/php/test/test.php
Log:
numInteriorRings


Modified: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c	2010-06-21 00:56:12 UTC (rev 3047)
+++ trunk/php/geos.c	2010-06-21 01:05:00 UTC (rev 3048)
@@ -206,6 +206,7 @@
 PHP_METHOD(Geometry, setSRID);
 PHP_METHOD(Geometry, numGeometries);
 PHP_METHOD(Geometry, getGeometryN);
+PHP_METHOD(Geometry, numInteriorRings);
 
 static function_entry Geometry_methods[] = {
     PHP_ME(Geometry, __construct, NULL, 0)
@@ -246,6 +247,7 @@
     PHP_ME(Geometry, setSRID, NULL, 0)
     PHP_ME(Geometry, numGeometries, NULL, 0)
     PHP_ME(Geometry, getGeometryN, NULL, 0)
+    PHP_ME(Geometry, numInteriorRings, NULL, 0)
     {NULL, NULL, NULL}
 };
 
@@ -1585,8 +1587,24 @@
     setRelay(return_value, cc);
 }
 
+/**
+ * long GEOSGeometry::numInteriorRings()
+ */
+PHP_METHOD(Geometry, numInteriorRings)
+{
+    GEOSGeometry *geom;
+    long int ret;
 
+    geom = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
 
+    ret = GEOSGetNumInteriorRings(geom);
+    if ( ret == -1 ) RETURN_NULL(); /* should get an exception first */
+
+    RETURN_LONG(ret);
+}
+
+
+
 /* ------ Initialization / Deinitialization / Meta ------------------ */
 
 /* per-module initialization */

Modified: trunk/php/test/test.php
===================================================================
--- trunk/php/test/test.php	2010-06-21 00:56:12 UTC (rev 3047)
+++ trunk/php/test/test.php	2010-06-21 01:05:00 UTC (rev 3048)
@@ -1358,4 +1358,32 @@
 
     }
 
+    public function testGeometry_numInteriorRings()
+    {
+        $reader = new GEOSWKTReader();
+
+        $g = $reader->read('POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))');
+        $this->assertEquals(0, $g->numInteriorRings());
+
+        $g = $reader->read('POLYGON (
+            (10 10, 10 14, 14 14, 14 10, 10 10),
+                (11 11, 11 12, 12 12, 12 11, 11 11))');
+        $this->assertEquals(1, $g->numInteriorRings());
+
+        $g = $reader->read('POLYGON (
+            (10 10, 10 14, 14 14, 14 10, 10 10),
+                (11 11, 11 12, 12 12, 12 11, 11 11),
+                (13 11, 13 12, 13.5 12, 13.5 11, 13 11))');
+        $this->assertEquals(2, $g->numInteriorRings());
+
+        $g = $reader->read('POINT (0 0)');
+        try {
+            $this->assertEquals(2, $g->numInteriorRings());
+            $this->assertTrue( FALSE );
+        } catch (Exception $e) {
+            $this->assertContains( 'Polygon', $e->getMessage() );
+        }
+
+    }
+
 }



More information about the geos-commits mailing list