GEOS 3.6.2
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
30namespace 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
44namespace geos {
45namespace operation { // geos::operation
46namespace geounion { // geos::operation::geounion
47
55class GEOS_DLL CascadedUnion
56{
57private:
58 const std::vector<geom::Geometry*>* inputGeoms;
59 geom::GeometryFactory const* geomFactory;
60
68 static int const STRTREE_NODE_CAPACITY = 4;
69
70public:
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
118
119private:
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
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:53
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:67
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:167
CascadedUnion(const std::vector< geom::Geometry * > *geoms)
Definition CascadedUnion.h:106
static geom::Geometry * Union(std::vector< geom::Geometry * > *geoms)
static geom::Geometry * Union(T start, T end)
Definition CascadedUnion.h:89
Helper class holding Geometries, part of which are held by reference others are held exclusively.
Definition GeometryListHolder.h:35
Contains the Geometry interface hierarchy and supporting classes.
Definition IndexedNestedRingTester.h:26
Contains 2-D and 1-D versions of the Sort-Tile-Recursive (STR) tree, a query-only R-tree.
Definition SIRtreePointInRing.h:32
Provides classes for various kinds of spatial indexes.
Definition IndexedNestedRingTester.h:31
Provides classes for implementing operations on geometries.
Definition IndexedNestedRingTester.h:40
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:25