GEOS  3.9.1dev
GeometryGraph.h
Go to the documentation of this file.
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 <unordered_map>
28 #include <vector>
29 #include <memory>
30 
31 #include <geos/geom/Coordinate.h>
32 #include <geos/geom/CoordinateSequence.h> // for unique_ptr<CoordinateSequence>
35 #include <geos/geom/LineString.h> // for LineStringLT
36 
37 #include <geos/inline.h>
38 
39 #ifdef _MSC_VER
40 #pragma warning(push)
41 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
42 #endif
43 
44 // Forward declarations
45 namespace geos {
46 namespace geom {
47 class LineString;
48 class LinearRing;
49 class Polygon;
50 class Geometry;
51 class GeometryCollection;
52 class Point;
53 class Envelope;
54 }
55 namespace algorithm {
56 class LineIntersector;
57 class BoundaryNodeRule;
58 }
59 namespace geomgraph {
60 class Edge;
61 class Node;
62 namespace index {
63 class EdgeSetIntersector;
64 }
65 }
66 }
67 
68 namespace geos {
69 namespace geomgraph { // geos.geomgraph
70 
75  using PlanarGraph::add;
76  using PlanarGraph::findEdge;
77 
78 private:
79 
81 
90  std::unordered_map<const geom::LineString*, Edge*> lineEdgeMap;
91 
97 
99 
104  int argIndex;
105 
107  std::unique_ptr< geom::CoordinateSequence > boundaryPoints;
108 
109  std::unique_ptr< std::vector<Node*> > boundaryNodes;
110 
112 
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) const;
191 
192  void computeSplitEdges(std::vector<Edge*>* edgelist);
193 
194  void addEdge(Edge* e);
195 
196  void addPoint(geom::Coordinate& pt);
197 
212  std::unique_ptr<index::SegmentIntersector>
215  bool computeRingSelfNodes,
216  const geom::Envelope* env = nullptr)
217  {
218  return computeSelfNodes(*li, computeRingSelfNodes, env);
219  }
220 
221  std::unique_ptr<index::SegmentIntersector>
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  std::unique_ptr<index::SegmentIntersector> computeSelfNodes(
235  bool computeRingSelfNodes, const geom::Envelope* env = nullptr);
236 
237  std::unique_ptr<index::SegmentIntersector> computeSelfNodes(
239  bool computeRingSelfNodes, bool isDoneIfProperInt, const geom::Envelope* env = nullptr);
240 
241  std::unique_ptr<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 
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
std::unique_ptr< geom::CoordinateSequence > boundaryPoints
Cache for fast responses to getBoundaryPoints.
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:58
#define GEOS_DLL
Definition: export.h:28
const geom::Geometry * parentGeom
Definition: GeometryGraph.h:80
const algorithm::BoundaryNodeRule & getBoundaryNodeRule() const
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Represents a directed graph which is embeddable in a planar surface.
A GeometryGraph is a graph that models a given Geometry.
Definition: GeometryGraph.h:74
std::unique_ptr< std::vector< Node * > > boundaryNodes
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:188
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Represents a linear polygon, which may include holes.
Definition: Polygon.h:64
const algorithm::BoundaryNodeRule & boundaryNodeRule
Definition: GeometryGraph.h:98
An EdgeSetIntersector computes all the intersections between the edges in the set.
An interface for rules which determine whether node points which are in boundaries of lineal geometry...
Location
Constants representing the location of a point relative to a geometry.
Definition: Location.h:34
Represents a collection of heterogeneous Geometry objects.
Basic namespace for all GEOS functionalities.
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple...
Definition: LinearRing.h:54
std::unique_ptr< index::SegmentIntersector > computeSelfNodes(algorithm::LineIntersector *li, bool computeRingSelfNodes, bool isDoneIfProperInt, const geom::Envelope *env=nullptr)
The internal representation of a list of coordinates inside a Geometry.
std::unordered_map< const geom::LineString *, Edge * > lineEdgeMap
Definition: GeometryGraph.h:90
std::unique_ptr< 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...