GEOS 3.9.1
OverlayNG.h
1/**********************************************************************
2 *
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2020 Sandro Santilli <strk@kbt.io>
7 * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
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/overlayng/OverlayNG.java 4c88fea52
17 *
18 **********************************************************************/
19
20#pragma once
21
22#include <geos/geom/Geometry.h>
23#include <geos/geom/GeometryFactory.h>
24#include <geos/operation/overlay/OverlayOp.h>
25#include <geos/operation/overlayng/OverlayGraph.h>
26#include <geos/operation/overlayng/OverlayEdgeRing.h>
27#include <geos/operation/overlayng/InputGeometry.h>
28#include <geos/export.h>
29
30// Forward declarations
31namespace geos {
32namespace geom {
33class GeometryFactory;
34class PrecisionModel;
35}
36namespace noding {
37class Noder;
38}
39namespace operation {
40namespace overlayng {
41}
42}
43}
44
45namespace geos { // geos.
46namespace operation { // geos.operation
47namespace overlayng { // geos.operation.overlayng
48
115class GEOS_DLL OverlayNG {
116
117private:
118
119 // Members
120 const geom::PrecisionModel* pm;
121 InputGeometry inputGeom;
122 const geom::GeometryFactory* geomFact;
123 int opCode;
124 noding::Noder* noder;
125 bool isStrictMode;
126 bool isOptimized;
127 bool isAreaResultOnly;
128 bool isOutputEdges;
129 bool isOutputResultEdges;
130 bool isOutputNodedEdges;
131
132 // Methods
133 std::unique_ptr<geom::Geometry> computeEdgeOverlay();
134 void labelGraph(OverlayGraph* graph);
135
150 std::unique_ptr<geom::Geometry> extractResult(int opCode, OverlayGraph* graph);
151 std::unique_ptr<geom::Geometry> createEmptyResult();
152
153
154
155public:
165 static constexpr bool STRICT_MODE_DEFAULT = false;
166
167 static constexpr int INTERSECTION = overlay::OverlayOp::opINTERSECTION;
168 static constexpr int UNION = overlay::OverlayOp::opUNION;
169 static constexpr int DIFFERENCE = overlay::OverlayOp::opDIFFERENCE;
170 static constexpr int SYMDIFFERENCE = overlay::OverlayOp::opSYMDIFFERENCE;
171
177 OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::GeometryFactory* p_geomFact, int p_opCode)
178 : pm(p_geomFact->getPrecisionModel())
179 , inputGeom(geom0, geom1)
180 , geomFact(p_geomFact)
181 , opCode(p_opCode)
182 , noder(nullptr)
183 , isStrictMode(STRICT_MODE_DEFAULT)
184 , isOptimized(true)
185 , isAreaResultOnly(false)
186 , isOutputEdges(false)
187 , isOutputResultEdges(false)
188 , isOutputNodedEdges(false)
189 {}
190
196 OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::PrecisionModel* p_pm, int p_opCode)
197 : pm(p_pm)
198 , inputGeom(geom0, geom1)
199 , geomFact(geom0->getFactory())
200 , opCode(p_opCode)
201 , noder(nullptr)
202 , isStrictMode(STRICT_MODE_DEFAULT)
203 , isOptimized(true)
204 , isAreaResultOnly(false)
205 , isOutputEdges(false)
206 , isOutputResultEdges(false)
207 , isOutputNodedEdges(false)
208 {}
209
223 OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, int p_opCode)
224 : OverlayNG(geom0, geom1, geom0->getFactory()->getPrecisionModel(), p_opCode)
225 {}
226
227 OverlayNG(const geom::Geometry* geom0, const geom::PrecisionModel* p_pm)
228 : OverlayNG(geom0, nullptr, p_pm, UNION)
229 {}
230
239 void setOptimized(bool p_isOptimized) { isOptimized = p_isOptimized; }
240 void setStrictMode(bool p_isStrictMode) { isStrictMode = p_isStrictMode; }
241 void setAreaResultOnly(bool p_areaResultOnly) { isAreaResultOnly = p_areaResultOnly; }
242 void setOutputEdges(bool p_isOutputEdges) { isOutputEdges = p_isOutputEdges; }
243 void setOutputResultEdges(bool p_isOutputResultEdges) { isOutputResultEdges = p_isOutputResultEdges; }
244 void setNoder(noding::Noder* p_noder) { noder = p_noder; }
245
246 void setOutputNodedEdges(bool p_isOutputNodedEdges)
247 {
248 isOutputEdges = true;
249 isOutputNodedEdges = p_isOutputNodedEdges;
250 }
251
260 std::unique_ptr<Geometry> getResult();
261
270 static bool isResultOfOpPoint(const OverlayLabel* label, int opCode);
271
283 static bool isResultOfOp(int overlayOpCode, Location loc0, Location loc1);
284
296 static std::unique_ptr<Geometry>
297 overlay(const Geometry* geom0, const Geometry* geom1,
298 int opCode, const PrecisionModel* pm);
299
300
312 static std::unique_ptr<Geometry>
313 overlay(const Geometry* geom0, const Geometry* geom1,
314 int opCode, const PrecisionModel* pm, noding::Noder* noder);
315
316
327 static std::unique_ptr<Geometry>
328 overlay(const Geometry* geom0, const Geometry* geom1,
329 int opCode, noding::Noder* noder);
330
351 static std::unique_ptr<Geometry>
352 overlay(const Geometry* geom0, const Geometry* geom1, int opCode);
353
354
374 static std::unique_ptr<Geometry>
375 geomunion(const Geometry* geom, const PrecisionModel* pm);
376
377
394 static std::unique_ptr<Geometry>
395 geomunion(const Geometry* geom, const PrecisionModel* pm, noding::Noder* noder);
396
397
398
399
400};
401
402
403} // namespace geos.operation.overlayng
404} // namespace geos.operation
405} // namespace geos
406
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
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
Computes all intersections between segments in a set of SegmentString.
Definition: Noder.h:49
Definition: OverlayGraph.h:54
Definition: OverlayLabel.h:90
Definition: OverlayNG.h:115
void setOptimized(bool p_isOptimized)
Definition: OverlayNG.h:239
OverlayNG(const geom::Geometry *geom0, const geom::Geometry *geom1, const geom::GeometryFactory *p_geomFact, int p_opCode)
Definition: OverlayNG.h:177
std::unique_ptr< Geometry > getResult()
static std::unique_ptr< Geometry > overlay(const Geometry *geom0, const Geometry *geom1, int opCode, const PrecisionModel *pm, noding::Noder *noder)
static std::unique_ptr< Geometry > overlay(const Geometry *geom0, const Geometry *geom1, int opCode)
static std::unique_ptr< Geometry > geomunion(const Geometry *geom, const PrecisionModel *pm, noding::Noder *noder)
OverlayNG(const geom::Geometry *geom0, const geom::Geometry *geom1, const geom::PrecisionModel *p_pm, int p_opCode)
Definition: OverlayNG.h:196
static std::unique_ptr< Geometry > overlay(const Geometry *geom0, const Geometry *geom1, int opCode, noding::Noder *noder)
static bool isResultOfOpPoint(const OverlayLabel *label, int opCode)
OverlayNG(const geom::Geometry *geom0, const geom::Geometry *geom1, int p_opCode)
Definition: OverlayNG.h:223
static std::unique_ptr< Geometry > geomunion(const Geometry *geom, const PrecisionModel *pm)
static std::unique_ptr< Geometry > overlay(const Geometry *geom0, const Geometry *geom1, int opCode, const PrecisionModel *pm)
static bool isResultOfOp(int overlayOpCode, Location loc0, Location loc1)
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:34
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:26