GEOS 3.11.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
121class GEOS_DLL OverlayNG {
122
123private:
124
125 // Members
126 const geom::PrecisionModel* pm;
127 InputGeometry inputGeom;
128 const geom::GeometryFactory* geomFact;
129 int opCode;
130 noding::Noder* noder;
131 bool isStrictMode;
132 bool isOptimized;
133 bool isAreaResultOnly;
134 bool isOutputEdges;
135 bool isOutputResultEdges;
136 bool isOutputNodedEdges;
137
138 // Methods
139 std::unique_ptr<geom::Geometry> computeEdgeOverlay();
140 void labelGraph(OverlayGraph* graph);
141
156 std::unique_ptr<geom::Geometry> extractResult(int opCode, OverlayGraph* graph);
157 std::unique_ptr<geom::Geometry> createEmptyResult();
158
159
160
161public:
171 static constexpr bool STRICT_MODE_DEFAULT = false;
172
173 static constexpr int INTERSECTION = overlay::OverlayOp::opINTERSECTION;
174 static constexpr int UNION = overlay::OverlayOp::opUNION;
175 static constexpr int DIFFERENCE = overlay::OverlayOp::opDIFFERENCE;
176 static constexpr int SYMDIFFERENCE = overlay::OverlayOp::opSYMDIFFERENCE;
177
183 OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::GeometryFactory* p_geomFact, int p_opCode)
184 : pm(p_geomFact->getPrecisionModel())
185 , inputGeom(geom0, geom1)
186 , geomFact(p_geomFact)
187 , opCode(p_opCode)
188 , noder(nullptr)
189 , isStrictMode(STRICT_MODE_DEFAULT)
190 , isOptimized(true)
191 , isAreaResultOnly(false)
192 , isOutputEdges(false)
193 , isOutputResultEdges(false)
194 , isOutputNodedEdges(false)
195 {}
196
202 OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::PrecisionModel* p_pm, int p_opCode)
203 : pm(p_pm)
204 , inputGeom(geom0, geom1)
205 , geomFact(geom0->getFactory())
206 , opCode(p_opCode)
207 , noder(nullptr)
208 , isStrictMode(STRICT_MODE_DEFAULT)
209 , isOptimized(true)
210 , isAreaResultOnly(false)
211 , isOutputEdges(false)
212 , isOutputResultEdges(false)
213 , isOutputNodedEdges(false)
214 {}
215
229 OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, int p_opCode)
230 : OverlayNG(geom0, geom1, geom0->getFactory()->getPrecisionModel(), p_opCode)
231 {}
232
233 OverlayNG(const geom::Geometry* geom0, const geom::PrecisionModel* p_pm)
234 : OverlayNG(geom0, nullptr, p_pm, UNION)
235 {}
236
245 void setOptimized(bool p_isOptimized) { isOptimized = p_isOptimized; }
246 void setStrictMode(bool p_isStrictMode) { isStrictMode = p_isStrictMode; }
247 void setAreaResultOnly(bool p_areaResultOnly) { isAreaResultOnly = p_areaResultOnly; }
248 void setOutputEdges(bool p_isOutputEdges) { isOutputEdges = p_isOutputEdges; }
249 void setOutputResultEdges(bool p_isOutputResultEdges) { isOutputResultEdges = p_isOutputResultEdges; }
250 void setNoder(noding::Noder* p_noder) { noder = p_noder; }
251
252 void setOutputNodedEdges(bool p_isOutputNodedEdges)
253 {
254 isOutputEdges = true;
255 isOutputNodedEdges = p_isOutputNodedEdges;
256 }
257
266 std::unique_ptr<Geometry> getResult();
267
276 static bool isResultOfOpPoint(const OverlayLabel* label, int opCode);
277
289 static bool isResultOfOp(int overlayOpCode, Location loc0, Location loc1);
290
302 static std::unique_ptr<Geometry>
303 overlay(const Geometry* geom0, const Geometry* geom1,
304 int opCode, const PrecisionModel* pm);
305
306
318 static std::unique_ptr<Geometry>
319 overlay(const Geometry* geom0, const Geometry* geom1,
320 int opCode, const PrecisionModel* pm, noding::Noder* noder);
321
322
333 static std::unique_ptr<Geometry>
334 overlay(const Geometry* geom0, const Geometry* geom1,
335 int opCode, noding::Noder* noder);
336
357 static std::unique_ptr<Geometry>
358 overlay(const Geometry* geom0, const Geometry* geom1, int opCode);
359
360
380 static std::unique_ptr<Geometry>
381 geomunion(const Geometry* geom, const PrecisionModel* pm);
382
383
400 static std::unique_ptr<Geometry>
401 geomunion(const Geometry* geom, const PrecisionModel* pm, noding::Noder* noder);
402
403
404
405
406};
407
408
409} // namespace geos.operation.overlayng
410} // namespace geos.operation
411} // namespace geos
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:186
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:90
Computes all intersections between segments in a set of SegmentString.
Definition: Noder.h:46
@ opSYMDIFFERENCE
The code for the Symmetric Difference overlay operation.
Definition: OverlayOp.h:86
@ opUNION
The code for the Union overlay operation.
Definition: OverlayOp.h:82
@ opINTERSECTION
The code for the Intersection overlay operation.
Definition: OverlayOp.h:80
@ opDIFFERENCE
The code for the Difference overlay operation.
Definition: OverlayOp.h:84
Definition: OverlayGraph.h:54
Definition: OverlayLabel.h:87
Definition: OverlayNG.h:121
void setOptimized(bool p_isOptimized)
Definition: OverlayNG.h:245
OverlayNG(const geom::Geometry *geom0, const geom::Geometry *geom1, const geom::GeometryFactory *p_geomFact, int p_opCode)
Definition: OverlayNG.h:183
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:202
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:229
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:32
Basic namespace for all GEOS functionalities.
Definition: geos.h:39