GEOS: CascadedPolygonUnion.h Source File

GEOS 3.5.0

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

- File List

CascadedPolygonUnion.h
1 /**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
7 * Copyright (C) 2006 Refractions Research Inc.
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: operation/union/CascadedPolygonUnion.java r487 (JTS-1.12+)
17 *
18 **********************************************************************/
19
20 #ifndef GEOS_OP_UNION_CASCADEDPOLYGONUNION_H
21 #define GEOS_OP_UNION_CASCADEDPOLYGONUNION_H
22
23 #include <geos/export.h>
24
25 #include <vector>
26 #include <algorithm>
27 #include <memory>
28
29 #include "GeometryListHolder.h"
30
31 // Forward declarations
32 namespace geos {
33 namespace geom {
34 class GeometryFactory;
35 class Geometry;
36 class Polygon;
37 class MultiPolygon;
38 class Envelope;
39 }
40 namespace index {
41 namespace strtree {
42 class ItemsList;
43 }
44 }
45 }
46
47 namespace geos {
48 namespace operation { // geos::operation
49 namespace geounion { // geos::operation::geounion
50
70 class GEOS_DLL CascadedPolygonUnion
71 {
72 private:
73 std::vector<geom::Polygon*>* inputPolys;
74 geom::GeometryFactory const* geomFactory;
75
83 static int const STRTREE_NODE_CAPACITY = 4;
84
99 static std::auto_ptr<geom::Geometry> restrictToPolygons(std::auto_ptr<geom::Geometry> g);
100
101 public:
102 CascadedPolygonUnion();
103
111 static geom::Geometry* Union(std::vector<geom::Polygon*>* polys);
112
120 template <class T>
121 static geom::Geometry* Union(T start, T end)
122 {
123 std::vector<geom::Polygon*> polys;
124 for (T i=start; i!=end; ++i) {
125 const geom::Polygon* p = dynamic_cast<const geom::Polygon*>(*i);
126 polys.push_back(const_cast<geom::Polygon*>(p));
127 }
128 return Union(&polys);
129 }
130
138 static geom::Geometry* Union(const geom::MultiPolygon* polys);
139
147 CascadedPolygonUnion(std::vector<geom::Polygon*>* polys)
148 : inputPolys(polys),
149 geomFactory(NULL)
150 {}
151
158 geom::Geometry* Union();
159
160 private:
161 geom::Geometry* unionTree(index::strtree::ItemsList* geomTree);
162
168 geom::Geometry* binaryUnion(GeometryListHolder* geoms);
169
179 geom::Geometry* binaryUnion(GeometryListHolder* geoms, std::size_t start,
180 std::size_t end);
181
189 GeometryListHolder* reduceToGeometries(index::strtree::ItemsList* geomTree);
190
200 geom::Geometry* unionSafe(geom::Geometry* g0, geom::Geometry* g1);
201
202 geom::Geometry* unionOptimized(geom::Geometry* g0, geom::Geometry* g1);
203
223 geom::Geometry* unionUsingEnvelopeIntersection(geom::Geometry* g0,
224 geom::Geometry* g1, geom::Envelope const& common);
225
226 geom::Geometry* extractByEnvelope(geom::Envelope const& env,
227 geom::Geometry* geom, std::vector<geom::Geometry*>& disjointGeoms);
228
236 static geom::Geometry* unionActual(geom::Geometry* g0, geom::Geometry* g1);
237 };
238
239 } // namespace geos::operation::union
240 } // namespace geos::operation
241 } // namespace geos
242
243 #endif
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:53
geos::operation::geounion::CascadedPolygonUnion::CascadedPolygonUnion
CascadedPolygonUnion(std::vector< geom::Polygon * > *polys)
Definition: CascadedPolygonUnion.h:147
geos::geom::MultiPolygon
Models a collection of Polygons.
Definition: MultiPolygon.h:60
geos::geom::Geometry
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
geos::geom::Polygon
Represents a linear polygon, which may include holes.
Definition: Polygon.h:66
geos::geom::GeometryFactory
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
geos
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
geos::operation::geounion::CascadedPolygonUnion::Union
static geom::Geometry * Union(T start, T end)
Definition: CascadedPolygonUnion.h:121
geos::operation::geounion::CascadedPolygonUnion
Provides an efficient method of unioning a collection of Polygonal geometries. This algorithm is fast...
Definition: CascadedPolygonUnion.h:70
geos::operation::geounion::GeometryListHolder
Helper class holding Geometries, part of which are held by reference others are held exclusively...
Definition: GeometryListHolder.h:34