GEOS  3.13.0dev
LineBuilder.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2020 Paul Ramsey <pramsey@cleverelephant.ca>
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 #pragma once
16 
17 #include <geos/export.h>
18 
19 #include <geos/operation/overlayng/InputGeometry.h>
20 #include <geos/operation/overlayng/OverlayNG.h>
21 #include <geos/geom/Location.h>
22 #include <geos/geom/LineString.h>
23 
24 #include <vector>
25 
26 
27 // Forward declarations
28 namespace geos {
29 namespace geom {
30 class GeometryFactory;
31 class LineString;
32 }
33 namespace operation {
34 namespace overlayng {
35 class OverlayEdge;
36 class OverlayGraph;
37 class OverlayLabel;
38 class InputGeometry;
39 }
40 }
41 }
42 
43 namespace geos { // geos.
44 namespace operation { // geos.operation
45 namespace overlayng { // geos.operation.overlayng
46 
70 class GEOS_DLL LineBuilder {
71 
72 private:
73 
74  // Members
75  OverlayGraph* graph;
76  int opCode;
77  const geom::GeometryFactory* geometryFactory;
78  bool hasResultArea;
79  int8_t inputAreaIndex;
80  std::vector<std::unique_ptr<geom::LineString>> lines;
81 
88  bool isAllowMixedResult = ! OverlayNG::STRICT_MODE_DEFAULT;
89 
95  bool isAllowCollapseLines = ! OverlayNG::STRICT_MODE_DEFAULT;
96 
97  void markResultLines();
98 
107  bool isResultLine(const OverlayLabel* lbl) const;
108 
119  static geom::Location effectiveLocation(const OverlayLabel* lbl, uint8_t geomIndex);
120 
121  void addResultLines();
122  void addResultLinesMerged();
123 
124  std::unique_ptr<geom::LineString> toLine(OverlayEdge* edge) const;
125 
126  void addResultLinesForNodes();
127 
131  void addResultLinesRings();
132 
146  std::unique_ptr<geom::LineString> buildLine(OverlayEdge* node);
147 
148  /*
149  * Finds the next edge around a node which forms
150  * part of a result line.
151  */
152  static OverlayEdge* nextLineEdgeUnvisited(OverlayEdge* node) ;
153 
157  static int degreeOfLines(OverlayEdge* node) ;
158 
159 
160 
161 public:
162 
163  LineBuilder(const InputGeometry* inputGeom, OverlayGraph* p_graph, bool p_hasResultArea, int p_opCode, const geom::GeometryFactory* geomFact)
164  : graph(p_graph)
165  , opCode(p_opCode)
166  , geometryFactory(geomFact)
167  , hasResultArea(p_hasResultArea)
168  , inputAreaIndex((int8_t)inputGeom->getAreaIndex())
169  , isAllowMixedResult(! OverlayNG::STRICT_MODE_DEFAULT)
170  , isAllowCollapseLines(! OverlayNG::STRICT_MODE_DEFAULT)
171  {}
172 
173  LineBuilder(const LineBuilder&) = delete;
174  LineBuilder& operator=(const LineBuilder&) = delete;
175 
176  std::vector<std::unique_ptr<geom::LineString>> getLines();
177 
178  void setStrictMode(bool p_isStrictResultMode)
179  {
180  isAllowCollapseLines = ! p_isStrictResultMode;
181  isAllowMixedResult = ! p_isStrictResultMode;
182  }
183 
184 };
185 
186 
187 } // namespace geos.operation.overlayng
188 } // namespace geos.operation
189 } // namespace geos
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:65
Definition: LineBuilder.h:70
Definition: OverlayEdge.h:52
Definition: OverlayGraph.h:54
Definition: OverlayLabel.h:89
static constexpr bool STRICT_MODE_DEFAULT
Definition: OverlayNG.h:170
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