[geos-commits] r2247 - in trunk/source: headers/geos/operation/union operation/union

svn_geos at osgeo.org svn_geos at osgeo.org
Mon Jan 19 11:44:50 EST 2009


Author: pramsey
Date: 2009-01-19 11:44:50 -0500 (Mon, 19 Jan 2009)
New Revision: 2247

Modified:
   trunk/source/headers/geos/operation/union/CascadedPolygonUnion.h
   trunk/source/operation/union/CascadedPolygonUnion.cpp
Log:
Added patch from hkaiser to allow cascadedunion to be run directly on a multipolygon.


Modified: trunk/source/headers/geos/operation/union/CascadedPolygonUnion.h
===================================================================
--- trunk/source/headers/geos/operation/union/CascadedPolygonUnion.h	2009-01-19 00:12:34 UTC (rev 2246)
+++ trunk/source/headers/geos/operation/union/CascadedPolygonUnion.h	2009-01-19 16:44:50 UTC (rev 2247)
@@ -24,6 +24,7 @@
         class GeometryFactory;
         class Geometry;
         class Polygon;
+        class MultiPolygon;
         class Envelope;
     }
     namespace index {
@@ -121,6 +122,14 @@
     static geom::Geometry* Union(std::vector<geom::Polygon*>* polys);
 
     /**
+     * Computes the union of
+     * a collection of {@link Polygonal} {@link Geometry}s.
+     * 
+     * @param polys a collection of {@link Polygonal} {@link Geometry}s
+     */
+    static geom::Geometry* Union(geom::MultiPolygon* polys);
+
+    /**
      * Creates a new instance to union
      * the given collection of {@link Geometry}s.
      * 

Modified: trunk/source/operation/union/CascadedPolygonUnion.cpp
===================================================================
--- trunk/source/operation/union/CascadedPolygonUnion.cpp	2009-01-19 00:12:34 UTC (rev 2246)
+++ trunk/source/operation/union/CascadedPolygonUnion.cpp	2009-01-19 16:44:50 UTC (rev 2247)
@@ -17,6 +17,7 @@
 #include <geos/geom/Geometry.h>
 #include <geos/geom/GeometryFactory.h>
 #include <geos/geom/Polygon.h>
+#include <geos/geom/MultiPolygon.h>
 #include <geos/geom/util/GeometryCombiner.h>
 #include <geos/index/strtree/STRtree.h>
 
@@ -37,6 +38,19 @@
     return op.Union();
 }
 
+geom::Geometry* CascadedPolygonUnion::Union(geom::MultiPolygon* multipoly)
+{
+    std::vector<geom::Polygon*> polys;
+    
+    typedef geom::MultiPolygon::const_iterator iterator;
+    iterator end = multipoly->end();
+    for (iterator i = multipoly->begin(); i != end; ++i)
+        polys.push_back(static_cast<geom::Polygon*>(*i));
+
+    CascadedPolygonUnion op (&polys);
+    return op.Union();
+}
+
 geom::Geometry* CascadedPolygonUnion::Union()
 {
     if (inputPolys->empty())



More information about the geos-commits mailing list