GEOS  3.14.0dev
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
30 namespace geos {
31 namespace geom {
32 class GeometryFactory;
33 class PrecisionModel;
34 }
35 namespace noding {
36 class Noder;
37 }
38 namespace operation {
39 namespace overlayng {
40 }
41 }
42 }
43 
44 namespace geos { // geos.
45 namespace operation { // geos.operation
46 namespace overlayng { // geos.operation.overlayng
47 
120 class GEOS_DLL OverlayNG {
124 
125 private:
126 
127  // Members
128  const geom::PrecisionModel* pm;
129  InputGeometry inputGeom;
130  const geom::GeometryFactory* geomFact;
131  int opCode;
132  noding::Noder* noder;
133  bool isStrictMode;
134  bool isOptimized;
135  bool isAreaResultOnly;
136  bool isOutputEdges;
137  bool isOutputResultEdges;
138  bool isOutputNodedEdges;
139 
140  // Methods
141  std::unique_ptr<geom::Geometry> computeEdgeOverlay();
142  void labelGraph(OverlayGraph* graph);
143 
158  std::unique_ptr<geom::Geometry> extractResult(int opCode, OverlayGraph* graph);
159  std::unique_ptr<geom::Geometry> createEmptyResult();
160 
161 
162 
163 public:
173  static constexpr bool STRICT_MODE_DEFAULT = false;
174 
175  static constexpr int INTERSECTION = 1;
176  static constexpr int UNION = 2;
177  static constexpr int DIFFERENCE = 3;
178  static constexpr int SYMDIFFERENCE = 4;
179 
185  OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::GeometryFactory* p_geomFact, int p_opCode)
186  : pm(p_geomFact->getPrecisionModel())
187  , inputGeom(geom0, geom1)
188  , geomFact(p_geomFact)
189  , opCode(p_opCode)
190  , noder(nullptr)
191  , isStrictMode(STRICT_MODE_DEFAULT)
192  , isOptimized(true)
193  , isAreaResultOnly(false)
194  , isOutputEdges(false)
195  , isOutputResultEdges(false)
196  , isOutputNodedEdges(false)
197  {}
198 
204  OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, const geom::PrecisionModel* p_pm, int p_opCode)
205  : pm(p_pm)
206  , inputGeom(geom0, geom1)
207  , geomFact(geom0->getFactory())
208  , opCode(p_opCode)
209  , noder(nullptr)
210  , isStrictMode(STRICT_MODE_DEFAULT)
211  , isOptimized(true)
212  , isAreaResultOnly(false)
213  , isOutputEdges(false)
214  , isOutputResultEdges(false)
215  , isOutputNodedEdges(false)
216  {}
217 
231  OverlayNG(const geom::Geometry* geom0, const geom::Geometry* geom1, int p_opCode)
232  : OverlayNG(geom0, geom1, geom0->getFactory()->getPrecisionModel(), p_opCode)
233  {}
234 
235  OverlayNG(const geom::Geometry* geom0, const geom::PrecisionModel* p_pm)
236  : OverlayNG(geom0, nullptr, p_pm, UNION)
237  {}
238 
247  void setOptimized(bool p_isOptimized) { isOptimized = p_isOptimized; }
248  void setStrictMode(bool p_isStrictMode) { isStrictMode = p_isStrictMode; }
249  void setAreaResultOnly(bool p_areaResultOnly) { isAreaResultOnly = p_areaResultOnly; }
250  void setOutputEdges(bool p_isOutputEdges) { isOutputEdges = p_isOutputEdges; }
251  void setOutputResultEdges(bool p_isOutputResultEdges) { isOutputResultEdges = p_isOutputResultEdges; }
252  void setNoder(noding::Noder* p_noder) { noder = p_noder; }
253 
254  void setOutputNodedEdges(bool p_isOutputNodedEdges)
255  {
256  isOutputEdges = true;
257  isOutputNodedEdges = p_isOutputNodedEdges;
258  }
259 
268  std::unique_ptr<Geometry> getResult();
269 
278  static bool isResultOfOpPoint(const OverlayLabel* label, int opCode);
279 
291  static bool isResultOfOp(int overlayOpCode, Location loc0, Location loc1);
292 
304  static std::unique_ptr<Geometry>
305  overlay(const Geometry* geom0, const Geometry* geom1,
306  int opCode, const PrecisionModel* pm);
307 
308 
320  static std::unique_ptr<Geometry>
321  overlay(const Geometry* geom0, const Geometry* geom1,
322  int opCode, const PrecisionModel* pm, noding::Noder* noder);
323 
324 
335  static std::unique_ptr<Geometry>
336  overlay(const Geometry* geom0, const Geometry* geom1,
337  int opCode, noding::Noder* noder);
338 
359  static std::unique_ptr<Geometry>
360  overlay(const Geometry* geom0, const Geometry* geom1, int opCode);
361 
362 
382  static std::unique_ptr<Geometry>
383  geomunion(const Geometry* geom, const PrecisionModel* pm);
384 
385 
402  static std::unique_ptr<Geometry>
403  geomunion(const Geometry* geom, const PrecisionModel* pm, noding::Noder* noder);
404 
405 
406 
407 
408 };
409 
410 
411 } // namespace geos.operation.overlayng
412 } // namespace geos.operation
413 } // 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: InputGeometry.h:41
Definition: OverlayGraph.h:52
Definition: OverlayLabel.h:86
Definition: OverlayNG.h:120
void setOptimized(bool p_isOptimized)
Definition: OverlayNG.h:247
OverlayNG(const geom::Geometry *geom0, const geom::Geometry *geom1, const geom::GeometryFactory *p_geomFact, int p_opCode)
Definition: OverlayNG.h:185
static std::unique_ptr< Geometry > overlay(const Geometry *geom0, const Geometry *geom1, int opCode, noding::Noder *noder)
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)
std::unique_ptr< Geometry > getResult()
static std::unique_ptr< Geometry > overlay(const Geometry *geom0, const Geometry *geom1, int opCode)
OverlayNG(const geom::Geometry *geom0, const geom::Geometry *geom1, const geom::PrecisionModel *p_pm, int p_opCode)
Definition: OverlayNG.h:204
static std::unique_ptr< Geometry > overlay(const Geometry *geom0, const Geometry *geom1, int opCode, const PrecisionModel *pm, 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:231
static bool isResultOfOp(int overlayOpCode, Location loc0, Location loc1)
static std::unique_ptr< Geometry > geomunion(const Geometry *geom, const PrecisionModel *pm, noding::Noder *noder)
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:32
Basic namespace for all GEOS functionalities.
Definition: Angle.h:25