GEOS: CascadedUnion.h Source File

GEOS 3.5.0

- 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
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:53
geos::operation::geounion::CascadedUnion::Union
static geom::Geometry * Union(T start, T end)
Definition: CascadedUnion.h:89
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
geos::geom::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
geos::operation::geounion::CascadedUnion::CascadedUnion
CascadedUnion(const std::vector< geom::Geometry * > *geoms)
Definition: CascadedUnion.h:106
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::operation::geounion::CascadedUnion
Provides an efficient method of unioning a collection of Geometries.
Definition: CascadedUnion.h:55
geos::operation::geounion::GeometryListHolder
Helper class holding Geometries, part of which are held by reference others are held exclusively...
Definition: GeometryListHolder.h:34