GEOS  3.4.2
GeometryGraph.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
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 auto_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  }
52  namespace algorithm {
53  class LineIntersector;
54  class BoundaryNodeRule;
55  }
56  namespace geomgraph {
57  class Edge;
58  class Node;
59  namespace index {
60  class SegmentIntersector;
61  class EdgeSetIntersector;
62  }
63  }
64 }
65 
66 namespace geos {
67 namespace geomgraph { // geos.geomgraph
68 
72 class GEOS_DLL GeometryGraph: public PlanarGraph
73 {
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::auto_ptr< geom::CoordinateSequence > boundaryPoints;
108 
109  std::auto_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  int cwLeft, int 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  int 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, int loc);
155 
156  // Declare type as noncopyable
157  GeometryGraph(const GeometryGraph& other);
158  GeometryGraph& operator=(const GeometryGraph& rhs);
159 
160 public:
161 
162  static bool isInBoundary(int boundaryCount);
163 
164  static int determineBoundary(int boundaryCount);
165 
166  static int 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  virtual ~GeometryGraph();
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 
213  index::SegmentIntersector* computeSelfNodes(
215  bool computeRingSelfNodes);
216 
217  // Quick inline calling the function above, the above should probably
218  // be deprecated.
219  index::SegmentIntersector* computeSelfNodes(
221  bool computeRingSelfNodes);
222 
223  index::SegmentIntersector* computeEdgeIntersections(GeometryGraph *g,
224  algorithm::LineIntersector *li, bool includeProper);
225 
226  std::vector<Edge*> *getEdges();
227 
228  bool hasTooFewPoints();
229 
230  const geom::Coordinate& getInvalidPoint();
231 
232  const algorithm::BoundaryNodeRule& getBoundaryNodeRule() const
233  { return boundaryNodeRule; }
234 
235 };
236 
237 
238 } // namespace geos.geomgraph
239 } // namespace geos
240 
241 #ifdef _MSC_VER
242 #pragma warning(pop)
243 #endif
244 
245 #ifdef GEOS_INLINE
246 # include "geos/geomgraph/GeometryGraph.inl"
247 #endif
248 
249 #endif // ifndef GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
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
Definition: GeometryGraph.h:72
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:167
Definition: LineString.h:70
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:66
Definition: BoundaryNodeRule.h:50
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:56
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.
Definition: LinearRing.h:57
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:59
Definition: Point.h:67
Definition: geomgraph/Edge.h:66