GEOS  3.8.0dev
GeometryGraph.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2011 Sandro Santilli <strk@kbt.io>
7  * Copyright (C) 2005-2006 Refractions Research Inc.
8  * Copyright (C) 2001-2002 Vivid Solutions Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************
16  *
17  * Last port: geomgraph/GeometryGraph.java r428 (JTS-1.12+)
18  *
19  **********************************************************************/
20 
21 
22 #ifndef GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
23 #define GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
24 
25 #include <geos/export.h>
26 #include <map>
27 #include <vector>
28 #include <memory>
29 
30 #include <geos/geom/Coordinate.h>
31 #include <geos/geom/CoordinateSequence.h> // for unique_ptr<CoordinateSequence>
32 #include <geos/geomgraph/PlanarGraph.h>
33 #include <geos/geom/LineString.h> // for LineStringLT
34 
35 #include <geos/inline.h>
36 
37 #ifdef _MSC_VER
38 #pragma warning(push)
39 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
40 #endif
41 
42 // Forward declarations
43 namespace geos {
44 namespace geom {
45 class LineString;
46 class LinearRing;
47 class Polygon;
48 class Geometry;
49 class GeometryCollection;
50 class Point;
51 class Envelope;
52 }
53 namespace algorithm {
54 class LineIntersector;
55 class BoundaryNodeRule;
56 }
57 namespace geomgraph {
58 class Edge;
59 class Node;
60 namespace index {
61 class SegmentIntersector;
62 class EdgeSetIntersector;
63 }
64 }
65 }
66 
67 namespace geos {
68 namespace geomgraph { // geos.geomgraph
69 
73 class GEOS_DLL GeometryGraph: public PlanarGraph {
74  using PlanarGraph::add;
76 
77 private:
78 
79  const geom::Geometry* parentGeom;
80 
89 //std::map<const geom::LineString*,Edge*,geom::LineStringLT> lineEdgeMap;
90  std::map<const geom::LineString*, Edge*> lineEdgeMap;
91 
96  bool useBoundaryDeterminationRule;
97 
98  const algorithm::BoundaryNodeRule& boundaryNodeRule;
99 
104  int argIndex;
105 
107  std::unique_ptr< geom::CoordinateSequence > boundaryPoints;
108 
109  std::unique_ptr< std::vector<Node*> > boundaryNodes;
110 
111  bool hasTooFewPointsVar;
112 
113  geom::Coordinate invalidPoint;
114 
116  index::EdgeSetIntersector* createEdgeSetIntersector();
117 
118  void add(const geom::Geometry* g);
119  // throw(UnsupportedOperationException);
120 
121  void addCollection(const geom::GeometryCollection* gc);
122 
123  void addPoint(const geom::Point* p);
124 
125  void addPolygonRing(const geom::LinearRing* lr,
126  geom::Location cwLeft, geom::Location cwRight);
127 
128  void addPolygon(const geom::Polygon* p);
129 
130  void addLineString(const geom::LineString* line);
131 
132  void insertPoint(int argIndex, const geom::Coordinate& coord,
133  geom::Location onLocation);
134 
142  void insertBoundaryPoint(int argIndex, const geom::Coordinate& coord);
143 
144  void addSelfIntersectionNodes(int argIndex);
145 
153  void addSelfIntersectionNode(int argIndex,
154  const geom::Coordinate& coord, geom::Location loc);
155 
156  // Declare type as noncopyable
157  GeometryGraph(const GeometryGraph& other) = delete;
158  GeometryGraph& operator=(const GeometryGraph& rhs) = delete;
159 
160 public:
161 
162  static bool isInBoundary(int boundaryCount);
163 
164  static geom::Location determineBoundary(int boundaryCount);
165 
166  static geom::Location determineBoundary(
167  const algorithm::BoundaryNodeRule& boundaryNodeRule,
168  int boundaryCount);
169 
170  GeometryGraph();
171 
172  GeometryGraph(int newArgIndex, const geom::Geometry* newParentGeom);
173 
174  GeometryGraph(int newArgIndex, const geom::Geometry* newParentGeom,
175  const algorithm::BoundaryNodeRule& boundaryNodeRule);
176 
177  ~GeometryGraph() override;
178 
179 
180  const geom::Geometry* getGeometry();
181 
183  std::vector<Node*>* getBoundaryNodes();
184 
185  void getBoundaryNodes(std::vector<Node*>& bdyNodes);
186 
188  geom::CoordinateSequence* getBoundaryPoints();
189 
190  Edge* findEdge(const geom::LineString* line);
191 
192  void computeSplitEdges(std::vector<Edge*>* edgelist);
193 
194  void addEdge(Edge* e);
195 
196  void addPoint(geom::Coordinate& pt);
197 
212  index::SegmentIntersector*
215  bool computeRingSelfNodes,
216  const geom::Envelope* env = nullptr)
217  {
218  return computeSelfNodes(*li, computeRingSelfNodes, env);
219  }
220 
221  index::SegmentIntersector*
222  computeSelfNodes(
224  bool computeRingSelfNodes,
225  bool isDoneIfProperInt,
226  const geom::Envelope* env = nullptr)
227  {
228  return computeSelfNodes(*li, computeRingSelfNodes, isDoneIfProperInt, env);
229  }
230 
231  // Quick inline calling the function above, the above should probably
232  // be deprecated.
233  index::SegmentIntersector* computeSelfNodes(
235  bool computeRingSelfNodes, const geom::Envelope* env = nullptr);
236 
237  index::SegmentIntersector* computeSelfNodes(
239  bool computeRingSelfNodes, bool isDoneIfProperInt, const geom::Envelope* env = nullptr);
240 
241  index::SegmentIntersector* computeEdgeIntersections(GeometryGraph* g,
242  algorithm::LineIntersector* li, bool includeProper,
243  const geom::Envelope* env = nullptr);
244 
245  std::vector<Edge*>* getEdges();
246 
247  bool hasTooFewPoints();
248 
249  const geom::Coordinate& getInvalidPoint();
250 
252  getBoundaryNodeRule() const
253  {
254  return boundaryNodeRule;
255  }
256 
257 };
258 
259 
260 } // namespace geos.geomgraph
261 } // namespace geos
262 
263 #ifdef _MSC_VER
264 #pragma warning(pop)
265 #endif
266 
267 #ifdef GEOS_INLINE
268 # include "geos/geomgraph/GeometryGraph.inl"
269 #endif
270 
271 #endif // ifndef GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
index::SegmentIntersector * computeSelfNodes(algorithm::LineIntersector *li, bool computeRingSelfNodes, const geom::Envelope *env=nullptr)
Compute self-nodes, taking advantage of the Geometry type to minimize the number of intersection test...
Definition: GeometryGraph.h:213
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Represents a directed graph which is embeddable in a planar surface.
Definition: geomgraph/PlanarGraph.h:75
A GeometryGraph is a graph that models a given Geometry.
Definition: GeometryGraph.h:73
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
Definition: LineString.h:68
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition: LineIntersector.h:49
Represents a linear polygon, which may include holes.
Definition: Polygon.h:64
An interface for rules which determine whether node points which are in boundaries of lineal geometry...
Definition: BoundaryNodeRule.h:51
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:33
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:55
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
virtual Edge * findEdge(const geom::Coordinate &p0, const geom::Coordinate &p1)
Returns the edge whose first two coordinates are p0 and p1.
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple...
Definition: LinearRing.h:54
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Definition: Point.h:65
Definition: geomgraph/Edge.h:66