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

svn_geos at osgeo.org svn_geos at osgeo.org
Fri Feb 11 04:58:36 EST 2011


Author: strk
Date: 2011-02-11 01:58:36 -0800 (Fri, 11 Feb 2011)
New Revision: 3202

Modified:
   trunk/php/geos.c
   trunk/php/test/test.php
Log:
PHP support or UnaryUnion

Modified: trunk/php/geos.c
===================================================================
--- trunk/php/geos.c	2011-02-11 09:58:29 UTC (rev 3201)
+++ trunk/php/geos.c	2011-02-11 09:58:36 UTC (rev 3202)
@@ -745,7 +745,7 @@
         other = getRelay(zobj, Geometry_ce_ptr);
         ret = GEOSUnion(this, other);
     } else {
-        ret = GEOSUnionCascaded(this);
+        ret = GEOSUnaryUnion(this);
     }
 
     if ( ! ret ) RETURN_NULL(); /* should get an exception first */

Modified: trunk/php/test/test.php
===================================================================
--- trunk/php/test/test.php	2011-02-11 09:58:29 UTC (rev 3201)
+++ trunk/php/test/test.php	2011-02-11 09:58:36 UTC (rev 3202)
@@ -844,7 +844,7 @@
             , $writer->write($gi));
     }
 
-    public function testGeometry_unionCascaded()
+    public function testGeometry_unaryunion()
     {
         $reader = new GEOSWKTReader();
         $writer = new GEOSWKTWriter();
@@ -862,6 +862,56 @@
 'POLYGON ((1 0, 0 0, 0 1, 0 11, 10 11, 10 14, 14 14, 14 10, 11 10, 11 0, 1 0), (11 11, 12 11, 12 12, 11 12, 11 11))'
             , $writer->write($gu));
 
+        $g = $reader->read('MULTILINESTRING(
+                 (0 0, 1 0, 1 1, 0 1, 0 0),
+                 (10 10, 10 14, 14 14, 14 10, 10 10),
+                  (11 11, 11 12, 12 12, 12 11, 11 11),
+                 (0 0, 11 0, 11 11, 0 11, 0 0)
+                )');
+
+        $gu = $g->union();
+        $this->assertEquals(
+'MULTILINESTRING ((0 0, 1 0), (1 0, 1 1, 0 1), (0 1, 0 0), (10 10, 10 11), (10 11, 10 14, 14 14, 14 10, 11 10), (11 10, 10 10), (11 11, 11 12, 12 12, 12 11, 11 11), (1 0, 11 0, 11 10), (11 10, 11 11), (11 11, 10 11), (10 11, 0 11, 0 1))'
+            , $writer->write($gu));
+
+        $g = $reader->read('MULTIPOINT(
+                 0 0, 1 0, 1 1, 0 1, 0 0,
+                 10 10, 10 14, 14 14, 14 10, 10 10,
+                  11 11, 11 12, 12 12, 12 11, 11 11,
+                 0 0, 11 0, 11 11, 0 11, 0 0
+                )');
+
+        $gu = $g->union();
+        $this->assertEquals(
+'MULTIPOINT (0 0, 0 1, 0 11, 1 0, 1 1, 10 10, 10 14, 11 0, 11 11, 11 12, 12 11, 12 12, 14 10, 14 14)'
+            , $writer->write($gu));
+
+        $g = $reader->read('GEOMETRYCOLLECTION(
+MULTIPOLYGON(
+                 ((0 0, 1 0, 1 1, 0 1, 0 0)),
+                 ((10 10, 10 14, 14 14, 14 10, 10 10),
+                  (11 11, 11 12, 12 12, 12 11, 11 11)),
+                 ((0 0, 11 0, 11 11, 0 11, 0 0))
+                ),
+MULTILINESTRING(
+                 (0 0, 1 0, 1 1, 0 1, 0 0),
+                 (10 10, 10 14, 14 14, 14 10, 10 10),
+                  (11 11, 11 12, 12 12, 12 11, 11 11),
+                 (0 0, 11 0, 11 11, 0 11, 0 0),(-8 8, -8 6)
+                ),
+MULTIPOINT(
+                 0 0, 1 0, 1 1, 0 1, 0 0,
+                 10 10, 10 14, 14 14, 14 10, 10 10,
+                  11 11, 11 12, 12 12, 12 11, 11 11,
+                 0 0, 11 0, 11 11, 0 11, 0 0, -10 -10
+                ))');
+
+        $gu = $g->union();
+        $this->assertEquals(
+'GEOMETRYCOLLECTION (POINT (-10 -10), LINESTRING (-8 8, -8 6), POLYGON ((1 0, 0 0, 0 1, 0 11, 10 11, 10 14, 14 14, 14 10, 11 10, 11 0, 1 0), (11 12, 11 11, 12 11, 12 12, 11 12)))'
+            , $writer->write($gu));
+
+
     }
 
     public function testGeometry_pointOnSurface()



More information about the geos-commits mailing list