GEOS
3.3.1
|
00001 /********************************************************************** 00002 * $Id: CascadedPolygonUnion.h 3294 2011-04-22 18:46:37Z 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 r320 (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 00029 #include "GeometryListHolder.h" 00030 00031 // Forward declarations 00032 namespace geos { 00033 namespace geom { 00034 class GeometryFactory; 00035 class Geometry; 00036 class Polygon; 00037 class MultiPolygon; 00038 class Envelope; 00039 } 00040 namespace index { 00041 namespace strtree { 00042 class ItemsList; 00043 } 00044 } 00045 } 00046 00047 namespace geos { 00048 namespace operation { // geos::operation 00049 namespace geounion { // geos::operation::geounion 00050 00070 class GEOS_DLL CascadedPolygonUnion 00071 { 00072 private: 00073 std::vector<geom::Polygon*>* inputPolys; 00074 geom::GeometryFactory const* geomFactory; 00075 00083 static int const STRTREE_NODE_CAPACITY = 4; 00084 00085 public: 00086 CascadedPolygonUnion(); 00087 00095 static geom::Geometry* Union(std::vector<geom::Polygon*>* polys); 00096 00104 template <class T> 00105 static geom::Geometry* Union(T start, T end) 00106 { 00107 std::vector<geom::Polygon*> polys; 00108 for (T i=start; i!=end; ++i) { 00109 const geom::Polygon* p = dynamic_cast<const geom::Polygon*>(*i); 00110 polys.push_back(const_cast<geom::Polygon*>(p)); 00111 } 00112 return Union(&polys); 00113 } 00114 00122 static geom::Geometry* Union(const geom::MultiPolygon* polys); 00123 00131 CascadedPolygonUnion(std::vector<geom::Polygon*>* polys) 00132 : inputPolys(polys), 00133 geomFactory(NULL) 00134 {} 00135 00142 geom::Geometry* Union(); 00143 00144 private: 00145 geom::Geometry* unionTree(index::strtree::ItemsList* geomTree); 00146 00152 geom::Geometry* binaryUnion(GeometryListHolder* geoms); 00153 00163 geom::Geometry* binaryUnion(GeometryListHolder* geoms, std::size_t start, 00164 std::size_t end); 00165 00173 GeometryListHolder* reduceToGeometries(index::strtree::ItemsList* geomTree); 00174 00184 geom::Geometry* unionSafe(geom::Geometry* g0, geom::Geometry* g1); 00185 00186 geom::Geometry* unionOptimized(geom::Geometry* g0, geom::Geometry* g1); 00187 00204 geom::Geometry* unionUsingEnvelopeIntersection(geom::Geometry* g0, 00205 geom::Geometry* g1, geom::Envelope const& common); 00206 00207 geom::Geometry* extractByEnvelope(geom::Envelope const& env, 00208 geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms); 00209 00217 static geom::Geometry* unionActual(geom::Geometry* g0, geom::Geometry* g1); 00218 }; 00219 00220 } // namespace geos::operation::union 00221 } // namespace geos::operation 00222 } // namespace geos 00223 00224 #endif 00225 00226 /********************************************************************** 00227 * $Log$ 00228 * 00229 **********************************************************************/ 00230