GEOS 3.4.2

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

- File List

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