GEOS 3.13.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/overlayng/OverlayGraph.h>
25#include <geos/operation/overlayng/OverlayEdgeRing.h>
26#include <geos/operation/overlayng/InputGeometry.h>
27#include <geos/export.h>
28
29// Forward declarations
30namespace geos {
31namespace geom {
32class GeometryFactory;
33class PrecisionModel;
34}
35namespace noding {
36class Noder;
37}
38namespace operation {
39namespace overlayng {
40}
41}
42}
43
44namespace geos { // geos.
45namespace operation { // geos.operation
46namespace overlayng { // geos.operation.overlayng
47
120class GEOS_DLL OverlayNG {
121
122private:
123
124 // Members
125 const geom::PrecisionModel* pm;
126 InputGeometry inputGeom;
127 const geom::GeometryFactory* geomFact;
128 int opCode;
129 noding::Noder* noder;
130 bool isStrictMode;
131 bool isOptimized;
132 bool isAreaResultOnly;
133 bool isOutputEdges;
134 bool isOutputResultEdges;
135 bool isOutputNodedEdges;
136
137 // Methods
138 std::unique_ptr<geom::Geometry> computeEdgeOverlay();
139 void labelGraph(OverlayGraph* graph);
140
155 std::unique_ptr<geom::Geometry> extractResult(int opCode, OverlayGraph* graph);
156 std::unique_ptr<geom::Geometry> createEmptyResult();
157
158
159
160public:
170 static constexpr bool STRICT_MODE_DEFAULT = false;
171
172 static constexpr int INTERSECTION = 1;
173 static constexpr int UNION = 2;
174 static constexpr int DIFFERENCE = 3;
175 static constexpr int SYMDIFFERENCE = 4;
176
182 OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::GeometryFactory* p_geomFact, int p_opCode)
183 : pm(p_geomFact->getPrecisionModel())
184 , inputGeom(geom0, geom1)
185 , geomFact(p_geomFact)
186 , opCode(p_opCode)
187 , noder(nullptr)
188 , isStrictMode(STRICT_MODE_DEFAULT)
189 , isOptimized(true)
190 , isAreaResultOnly(false)
191 , isOutputEdges(false)
192 , isOutputResultEdges(false)
193 , isOutputNodedEdges(false)
194 {}
195
201 OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::PrecisionModel* p_pm, int p_opCode)
202 : pm(p_pm)
203 , inputGeom(geom0, geom1)
204 , geomFact(geom0->getFactory())
205 , opCode(p_opCode)
206 , noder(nullptr)
207 , isStrictMode(STRICT_MODE_DEFAULT)
208 , isOptimized(true)
209 , isAreaResultOnly(false)
210 , isOutputEdges(false)
211 , isOutputResultEdges(false)
212 , isOutputNodedEdges(false)
213 {}
214
228 OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, int p_opCode)
229 : OverlayNG(geom0, geom1, geom0->getFactory()->getPrecisionModel(), p_opCode)
230 {}
231
232 OverlayNG(const geom::Geometry* geom0, const geom::PrecisionModel* p_pm)
233 : OverlayNG(geom0, nullptr, p_pm, UNION)
234 {}
235
244 void setOptimized(bool p_isOptimized) { isOptimized = p_isOptimized; }
245 void setStrictMode(bool p_isStrictMode) { isStrictMode = p_isStrictMode; }
246 void setAreaResultOnly(bool p_areaResultOnly) { isAreaResultOnly = p_areaResultOnly; }
247 void setOutputEdges(bool p_isOutputEdges) { isOutputEdges = p_isOutputEdges; }
248 void setOutputResultEdges(bool p_isOutputResultEdges) { isOutputResultEdges = p_isOutputResultEdges; }
249 void setNoder(noding::Noder* p_noder) { noder = p_noder; }
250
251 void setOutputNodedEdges(bool p_isOutputNodedEdges)
252 {
253 isOutputEdges = true;
254 isOutputNodedEdges = p_isOutputNodedEdges;
255 }
256
265 std::unique_ptr<Geometry> getResult();
266
275 static bool isResultOfOpPoint(const OverlayLabel* label, int opCode);
276
288 static bool isResultOfOp(int overlayOpCode, Location loc0, Location loc1);
289
301 static std::unique_ptr<Geometry>
302 overlay(const Geometry* geom0, const Geometry* geom1,
303 int opCode, const PrecisionModel* pm);
304
305
317 static std::unique_ptr<Geometry>
318 overlay(const Geometry* geom0, const Geometry* geom1,
319 int opCode, const PrecisionModel* pm, noding::Noder* noder);
320
321
332 static std::unique_ptr<Geometry>
333 overlay(const Geometry* geom0, const Geometry* geom1,
334 int opCode, noding::Noder* noder);
335
356 static std::unique_ptr<Geometry>
357 overlay(const Geometry* geom0, const Geometry* geom1, int opCode);
358
359
379 static std::unique_ptr<Geometry>
380 geomunion(const Geometry* geom, const PrecisionModel* pm);
381
382
399 static std::unique_ptr<Geometry>
400 geomunion(const Geometry* geom, const PrecisionModel* pm, noding::Noder* noder);
401
402
403
404
405};
406
407
408} // namespace geos.operation.overlayng
409} // namespace geos.operation
410} // namespace geos
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:70
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:197
Specifies the precision model of the Coordinate in a Geometry.
Definition PrecisionModel.h:88
Computes all intersections between segments in a set of SegmentString.
Definition Noder.h:46
Definition OverlayGraph.h:54
Definition OverlayLabel.h:89
Definition OverlayNG.h:120
void setOptimized(bool p_isOptimized)
Definition OverlayNG.h:244
OverlayNG(const geom::Geometry *geom0, const geom::Geometry *geom1, const geom::GeometryFactory *p_geomFact, int p_opCode)
Definition OverlayNG.h:182
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:201
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:228
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