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

svn_geos at osgeo.org svn_geos at osgeo.org
Tue Feb 15 10:15:15 EST 2011


Author: strk
Date: 2011-02-15 07:15:15 -0800 (Tue, 15 Feb 2011)
New Revision: 3220

Modified:
   trunk/php/geos.c
   trunk/php/test/test.php
Log:
Adapt PHP binding to the new GEOSisValidDetail interface

Modified: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c	2011-02-15 15:15:09 UTC (rev 3219)
+++ trunk/php/geos.c	2011-02-15 15:15:15 UTC (rev 3220)
@@ -1157,10 +1157,16 @@
     zend_bool retBool;
     char *reasonVal = NULL;
     zval *locationVal = NULL;
+    long int flags = 0;
 
     this = (GEOSGeometry*)getRelay(getThis(), Geometry_ce_ptr);
 
-    ret = GEOSisValidDetail(this, &reason, &location);
+    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l",
+        &flags) == FAILURE) {
+        RETURN_NULL();
+    }
+
+    ret = GEOSisValidDetail(this, flags, &reason, &location);
     if ( ret == 2 ) RETURN_NULL(); /* should get an exception first */
 
     if ( reason ) {
@@ -2474,6 +2480,10 @@
     REGISTER_LONG_CONSTANT("GEOS_GEOMETRYCOLLECTION", GEOS_GEOMETRYCOLLECTION,
         CONST_CS|CONST_PERSISTENT);
 
+    REGISTER_LONG_CONSTANT("GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE",
+        GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE,
+        CONST_CS|CONST_PERSISTENT);
+
     return SUCCESS;
 }
 

Modified: trunk/php/test/test.php
===================================================================
--- trunk/php/test/test.php	2011-02-15 15:15:09 UTC (rev 3219)
+++ trunk/php/test/test.php	2011-02-15 15:15:15 UTC (rev 3220)
@@ -33,6 +33,8 @@
         $this->assertEquals(5, GEOS_MULTILINESTRING);
         $this->assertEquals(6, GEOS_MULTIPOLYGON);
         $this->assertEquals(7, GEOS_GEOMETRYCOLLECTION);
+
+        $this->assertEquals(1, GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE);
     }
 
     public function testWKTReader__construct()
@@ -1328,6 +1330,26 @@
         $this->assertEquals( 'Invalid Coordinate', $val['reason'] );
         $this->assertEquals( 'POINT (0 nan)',
             $writer->write($val['location']) );
+
+        $g = $reader->read(
+           'POLYGON((0 0, -10 10, 10 10, 0 0, 4 5, -4 5, 0 0)))'
+        );
+        $val = $g->checkValidity();
+        $this->assertType( 'array', $val );
+        $this->assertFalse( $val['valid'] );
+        $this->assertEquals( 'Ring Self-intersection', $val['reason'] );
+        $this->assertEquals( 'POINT (0 0)',
+            $writer->write($val['location']) );
+
+        $g = $reader->read(
+           'POLYGON((0 0, -10 10, 10 10, 0 0, 4 5, -4 5, 0 0)))'
+        );
+        $flags = GEOSVALID_ALLOW_SELFTOUCHING_RING_FORMING_HOLE;
+        $val = $g->checkValidity($flags);
+        $this->assertType( 'array', $val );
+        $this->assertTrue( $val['valid'] );
+        $this->assertFalse( isset($val['reason']) );
+        $this->assertFalse( isset($val['location']) );
     }
 
     public function testGeometry_isSimple()



More information about the geos-commits mailing list