GEOS 3.9.1
OverlapUnion.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://trac.osgeo.org/geos
5 *
6 * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
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_OVERLAPUNION_H
20#define GEOS_OP_UNION_OVERLAPUNION_H
21
22#include <geos/export.h>
23
24#include <vector>
25#include <algorithm>
26#include <unordered_set>
27
28#include <geos/geom/Geometry.h>
29#include <geos/operation/union/UnionStrategy.h>
30#include <geos/operation/union/CascadedPolygonUnion.h>
31
32// Forward declarations
33namespace geos {
34namespace geom {
35class Envelope;
36class LineSegment;
37}
38}
39
40namespace geos {
41namespace operation { // geos::operation
42namespace geounion { // geos::operation::geounion
43
97class GEOS_DLL OverlapUnion {
98
99public:
100
101 OverlapUnion(const geom::Geometry* p_g0, const geom::Geometry* p_g1, geounion::UnionStrategy* unionFun)
102 : g0(p_g0)
103 , g1(p_g1)
104 , unionFunction(unionFun)
105 , geomFactory(p_g0->getFactory())
106 , isUnionSafe(false)
107 {};
108
109 OverlapUnion(const geom::Geometry* p_g0, const geom::Geometry* p_g1)
110 : OverlapUnion(p_g0, p_g1, &defaultUnionFunction)
111 {};
112
113
114 std::unique_ptr<geom::Geometry> doUnion();
115
116private:
117
118 const geom::Geometry* g0;
119 const geom::Geometry* g1;
120 geounion::UnionStrategy* unionFunction;
121 const geom::GeometryFactory* geomFactory;
122 bool isUnionSafe;
123
124 geounion::ClassicUnionStrategy defaultUnionFunction;
125
126 geom::Envelope overlapEnvelope(const geom::Geometry* geom0, const geom::Geometry* geom1);
127 std::unique_ptr<geom::Geometry> extractByEnvelope(const geom::Envelope& env, const geom::Geometry* geom, std::vector<std::unique_ptr<geom::Geometry>>& disjointGeoms);
128 std::unique_ptr<geom::Geometry> combine(std::unique_ptr<geom::Geometry>& unionGeom, std::vector<std::unique_ptr<geom::Geometry>>& disjointPolys);
129 std::unique_ptr<geom::Geometry> unionFull(const geom::Geometry* geom0, const geom::Geometry* geom1);
130 std::unique_ptr<geom::Geometry> unionBuffer(const geom::Geometry* geom0, const geom::Geometry* geom1);
131 bool isBorderSegmentsSame(const geom::Geometry* result, const geom::Envelope& env);
132 bool isEqual(std::vector<geom::LineSegment>& segs0, std::vector<geom::LineSegment>& segs1);
133 std::vector<geom::LineSegment> extractBorderSegments(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::Envelope& env);
134 void extractBorderSegments(const geom::Geometry* geom, const geom::Envelope& penv, std::vector<geom::LineSegment>& psegs);
135
136};
137
138} // namespace geos::operation::union
139} // namespace geos::operation
140} // namespace geos
141
142#endif
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:58
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:68
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:188
const GeometryFactory * getFactory() const
Gets the factory which contains the context in which this geometry was created.
Definition Geometry.h:218
Implementation of UnionStrategy that provides overlay using the first generation overlay routines.
Definition CascadedPolygonUnion.h:59
Unions MultiPolygons efficiently by using full topological union only for polygons which may overlap ...
Definition OverlapUnion.h:97
Definition UnionStrategy.h:40
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26