GEOS 3.3.8

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

CascadedUnion.h
1 /**********************************************************************
2 * $Id$
3 *
4 * GEOS - Geometry Engine Open Source
5 * http://trac.osgeo.org/geos
6 *
7 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
8 *
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
13 *
14 **********************************************************************
15 *
16 * Last port: ORIGINAL WORK, generalization of CascadedPolygonUnion
17 *
18 **********************************************************************/
19
20 #ifndef GEOS_OP_UNION_CASCADEDUNION_H
21 #define GEOS_OP_UNION_CASCADEDUNION_H
22
23 #include <geos/export.h>
24
25 #include <vector>
26 #include <algorithm>
27
28 #include "GeometryListHolder.h"
29
30 // Forward declarations
31 namespace geos {
32 namespace geom {
33 class GeometryFactory;
34 class Geometry;
35 class Geometry;
36 class Envelope;
37 }
38 namespace index {
39 namespace strtree {
40 class ItemsList;
41 }
42 }
43 }
44
45 namespace geos {
46 namespace operation { // geos::operation
47 namespace geounion { // geos::operation::geounion
48
56 class GEOS_DLL CascadedUnion
57 {
58 private:
59 const std::vector<geom::Geometry*>* inputGeoms;
60 geom::GeometryFactory const* geomFactory;
61
69 static int const STRTREE_NODE_CAPACITY = 4;
70
71 public:
72 CascadedUnion();
73
80 static geom::Geometry* Union(std::vector<geom::Geometry*>* geoms);
81
89 template <class T>
90 static geom::Geometry* Union(T start, T end)
91 {
92 std::vector<geom::Geometry*> polys;
93 for (T i=start; i!=end; ++i) {
94 const geom::Geometry* p = dynamic_cast<const geom::Geometry*>(*i);
95 polys.push_back(const_cast<geom::Geometry*>(p));
96 }
97 return Union(&polys);
98 }
99
107 CascadedUnion(const std::vector<geom::Geometry*>* geoms)
108 : inputGeoms(geoms),
109 geomFactory(NULL)
110 {}
111
118 geom::Geometry* Union();
119
120 private:
121 geom::Geometry* unionTree(index::strtree::ItemsList* geomTree);
122
128 geom::Geometry* binaryUnion(GeometryListHolder* geoms);
129
139 geom::Geometry* binaryUnion(GeometryListHolder* geoms, std::size_t start,
140 std::size_t end);
141
149 GeometryListHolder* reduceToGeometries(index::strtree::ItemsList* geomTree);
150
160 geom::Geometry* unionSafe(geom::Geometry* g0, geom::Geometry* g1);
161
162 geom::Geometry* unionOptimized(geom::Geometry* g0, geom::Geometry* g1);
163
180 geom::Geometry* unionUsingEnvelopeIntersection(geom::Geometry* g0,
181 geom::Geometry* g1, geom::Envelope const& common);
182
183 geom::Geometry* extractByEnvelope(geom::Envelope const& env,
184 geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms);
185
193 static geom::Geometry* unionActual(geom::Geometry* g0, geom::Geometry* g1);
194 };
195
196 } // namespace geos::operation::union
197 } // namespace geos::operation
198 } // namespace geos
199
200 #endif