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

svn_geos at osgeo.org svn_geos at osgeo.org
Sun Jun 20 17:10:10 EDT 2010


Author: strk
Date: 2010-06-20 21:10:10 +0000 (Sun, 20 Jun 2010)
New Revision: 3038

Modified:
   trunk/php/TODO
   trunk/php/geos.c
   trunk/php/test/test.php
Log:
isEmpty

Modified: trunk/php/TODO
===================================================================
--- trunk/php/TODO	2010-06-20 21:00:29 UTC (rev 3037)
+++ trunk/php/TODO	2010-06-20 21:10:10 UTC (rev 3038)
@@ -3,5 +3,7 @@
 - Complete interfaces of Geometry
 - Find a way to have GEOSGeometry contents shown on var_dump
 - Implement serialization/deserialization for Geometry
+- Documentation !! (doxygen-based?)
 - Add interfaces for WKBReader/WKBWriter ?
-- Doxygen based documentation ?
+- Add interfaces for prepared geometries ?
+- Add interfaces for STRTree ?

Modified: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c	2010-06-20 21:00:29 UTC (rev 3037)
+++ trunk/php/geos.c	2010-06-20 21:10:10 UTC (rev 3038)
@@ -194,6 +194,7 @@
 PHP_METHOD(Geometry, overlaps);
 PHP_METHOD(Geometry, equals);
 PHP_METHOD(Geometry, equalsExact);
+PHP_METHOD(Geometry, isEmpty);
 
 PHP_METHOD(Geometry, numGeometries);
 
@@ -224,6 +225,7 @@
     PHP_ME(Geometry, overlaps, NULL, 0)
     PHP_ME(Geometry, equals, NULL, 0)
     PHP_ME(Geometry, equalsExact, NULL, 0)
+    PHP_ME(Geometry, isEmpty, NULL, 0)
 
     PHP_ME(Geometry, numGeometries, NULL, 0)
     {NULL, NULL, NULL}
@@ -1331,7 +1333,26 @@
     RETURN_BOOL(retBool);
 }
 
+/**
+ * bool GEOSGeometry::isEmpty()
+ */
+PHP_METHOD(Geometry, isEmpty)
+{
+    GEOSGeometry *this;
+    int ret;
+    zend_bool retBool;
 
+    this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
+
+    ret = GEOSisEmpty(this);
+    if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
+
+    /* return_value is a zval */
+    retBool = ret;
+    RETURN_BOOL(retBool);
+}
+
+
 /* ------ Initialization / Deinitialization / Meta ------------------ */
 
 /* per-module initialization */

Modified: trunk/php/test/test.php
===================================================================
--- trunk/php/test/test.php	2010-06-20 21:00:29 UTC (rev 3037)
+++ trunk/php/test/test.php	2010-06-20 21:10:10 UTC (rev 3038)
@@ -1136,4 +1136,35 @@
         $this->assertFalse( $g1->equalsExact($g2, 1) );
 
     }
+
+    public function testGeometry_isEmpty()
+    {
+        $reader = new GEOSWKTReader();
+        $writer = new GEOSWKTWriter();
+        $writer->setRoundingPrecision(0);
+
+        $g1 = $reader->read('POINT(0 0)');
+        $this->assertFalse( $g1->isEmpty() );
+
+        $g1 = $reader->read('POINT EMPTY');
+        $this->assertTrue( $g1->isEmpty() );
+
+        $g1 = $reader->read('LINESTRING(0 0, 10 0)');
+        $this->assertFalse( $g1->isEmpty() );
+
+        $g1 = $reader->read('LINESTRING EMPTY');
+        $this->assertTrue( $g1->isEmpty() );
+
+        $g1 = $reader->read('POLYGON((0 0, 10 0, 10 10, 0 0))');
+        $this->assertFalse( $g1->isEmpty() );
+
+        $g1 = $reader->read('POLYGON EMPTY');
+        $this->assertTrue( $g1->isEmpty() );
+
+        $g1 = $reader->read('GEOMETRYCOLLECTION(POINT(0 0))');
+        $this->assertFalse( $g1->isEmpty() );
+
+        $g1 = $reader->read('GEOMETRYCOLLECTION EMPTY');
+        $this->assertTrue( $g1->isEmpty() );
+    }
 }



More information about the geos-commits mailing list