• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

CascadedPolygonUnion.h

00001 /**********************************************************************
00002  * $Id: CascadedPolygonUnion.h 3532 2011-12-09 08:46:21Z strk $
00003  *
00004  * GEOS - Geometry Engine Open Source
00005  * http://geos.refractions.net
00006  *
00007  * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
00008  * Copyright (C) 2006 Refractions Research Inc.
00009  *
00010  * This is free software; you can redistribute and/or modify it under
00011  * the terms of the GNU Lesser General Public Licence as published
00012  * by the Free Software Foundation. 
00013  * See the COPYING file for more information.
00014  *
00015  **********************************************************************
00016  *
00017  * Last port: operation/union/CascadedPolygonUnion.java r487 (JTS-1.12+)
00018  *
00019  **********************************************************************/
00020 
00021 #ifndef GEOS_OP_UNION_CASCADEDPOLYGONUNION_H
00022 #define GEOS_OP_UNION_CASCADEDPOLYGONUNION_H
00023 
00024 #include <geos/export.h>
00025 
00026 #include <vector>
00027 #include <algorithm>
00028 #include <memory>
00029 
00030 #include "GeometryListHolder.h"
00031 
00032 // Forward declarations
00033 namespace geos {
00034     namespace geom {
00035         class GeometryFactory;
00036         class Geometry;
00037         class Polygon;
00038         class MultiPolygon;
00039         class Envelope;
00040     }
00041     namespace index {
00042         namespace strtree {
00043             class ItemsList;
00044         }
00045     }
00046 }
00047 
00048 namespace geos {
00049 namespace operation { // geos::operation
00050 namespace geounion {  // geos::operation::geounion
00051 
00071 class GEOS_DLL CascadedPolygonUnion 
00072 {
00073 private:
00074     std::vector<geom::Polygon*>* inputPolys;
00075     geom::GeometryFactory const* geomFactory;
00076 
00084     static int const STRTREE_NODE_CAPACITY = 4;
00085 
00100     static std::auto_ptr<geom::Geometry> restrictToPolygons(std::auto_ptr<geom::Geometry> g);
00101 
00102 public:
00103     CascadedPolygonUnion();
00104 
00112     static geom::Geometry* Union(std::vector<geom::Polygon*>* polys);
00113 
00121     template <class T>
00122     static geom::Geometry* Union(T start, T end)
00123     {
00124       std::vector<geom::Polygon*> polys;
00125       for (T i=start; i!=end; ++i) {
00126         const geom::Polygon* p = dynamic_cast<const geom::Polygon*>(*i);
00127         polys.push_back(const_cast<geom::Polygon*>(p));
00128       }
00129       return Union(&polys);
00130     }
00131 
00139     static geom::Geometry* Union(const geom::MultiPolygon* polys);
00140 
00148     CascadedPolygonUnion(std::vector<geom::Polygon*>* polys)
00149       : inputPolys(polys),
00150         geomFactory(NULL)
00151     {}
00152 
00159     geom::Geometry* Union();
00160 
00161 private:
00162     geom::Geometry* unionTree(index::strtree::ItemsList* geomTree);
00163 
00169     geom::Geometry* binaryUnion(GeometryListHolder* geoms);
00170 
00180     geom::Geometry* binaryUnion(GeometryListHolder* geoms, std::size_t start, 
00181         std::size_t end);
00182 
00190     GeometryListHolder* reduceToGeometries(index::strtree::ItemsList* geomTree);
00191 
00201     geom::Geometry* unionSafe(geom::Geometry* g0, geom::Geometry* g1);
00202 
00203     geom::Geometry* unionOptimized(geom::Geometry* g0, geom::Geometry* g1);
00204 
00224     geom::Geometry* unionUsingEnvelopeIntersection(geom::Geometry* g0, 
00225         geom::Geometry* g1, geom::Envelope const& common);
00226 
00227     geom::Geometry* extractByEnvelope(geom::Envelope const& env, 
00228         geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms);
00229 
00237     static geom::Geometry* unionActual(geom::Geometry* g0, geom::Geometry* g1);
00238 };
00239 
00240 } // namespace geos::operation::union
00241 } // namespace geos::operation
00242 } // namespace geos
00243 
00244 #endif
00245 
00246 /**********************************************************************
00247  * $Log$
00248  *
00249  **********************************************************************/
00250 

Generated on Fri Aug 3 2012 11:53:23 for GEOS by  doxygen 1.7.2