GEOS  3.6.1
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  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 {
75 using PlanarGraph::add;
77 
78 private:
79 
80  const geom::Geometry* parentGeom;
81 
90 //std::map<const geom::LineString*,Edge*,geom::LineStringLT> lineEdgeMap;
91  std::map<const geom::LineString*, Edge*> lineEdgeMap;
92 
97  bool useBoundaryDeterminationRule;
98 
99  const algorithm::BoundaryNodeRule& boundaryNodeRule;
100 
105  int argIndex;
106 
108  std::auto_ptr< geom::CoordinateSequence > boundaryPoints;
109 
110  std::auto_ptr< std::vector<Node*> > boundaryNodes;
111 
112  bool hasTooFewPointsVar;
113 
114  geom::Coordinate invalidPoint;
115 
117  index::EdgeSetIntersector* createEdgeSetIntersector();
118 
119  void add(const geom::Geometry *g);
120  // throw(UnsupportedOperationException);
121 
122  void addCollection(const geom::GeometryCollection *gc);
123 
124  void addPoint(const geom::Point *p);
125 
126  void addPolygonRing(const geom::LinearRing *lr,
127  int cwLeft, int cwRight);
128 
129  void addPolygon(const geom::Polygon *p);
130 
131  void addLineString(const geom::LineString *line);
132 
133  void insertPoint(int argIndex, const geom::Coordinate& coord,
134  int onLocation);
135 
143  void insertBoundaryPoint(int argIndex, const geom::Coordinate& coord);
144 
145  void addSelfIntersectionNodes(int argIndex);
146 
154  void addSelfIntersectionNode(int argIndex,
155  const geom::Coordinate& coord, int loc);
156 
157  // Declare type as noncopyable
158  GeometryGraph(const GeometryGraph& other);
159  GeometryGraph& operator=(const GeometryGraph& rhs);
160 
161 public:
162 
163  static bool isInBoundary(int boundaryCount);
164 
165  static int determineBoundary(int boundaryCount);
166 
167  static int determineBoundary(
168  const algorithm::BoundaryNodeRule& boundaryNodeRule,
169  int boundaryCount);
170 
171  GeometryGraph();
172 
173  GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom);
174 
175  GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom,
176  const algorithm::BoundaryNodeRule& boundaryNodeRule);
177 
178  virtual ~GeometryGraph();
179 
180 
181  const geom::Geometry* getGeometry();
182 
184  std::vector<Node*>* getBoundaryNodes();
185 
186  void getBoundaryNodes(std::vector<Node*>&bdyNodes);
187 
189  geom::CoordinateSequence* getBoundaryPoints();
190 
191  Edge* findEdge(const geom::LineString *line);
192 
193  void computeSplitEdges(std::vector<Edge*> *edgelist);
194 
195  void addEdge(Edge *e);
196 
197  void addPoint(geom::Coordinate& pt);
198 
214  index::SegmentIntersector* computeSelfNodes(
216  bool computeRingSelfNodes,
217  const geom::Envelope *env=0)
218  {
219  return computeSelfNodes(*li, computeRingSelfNodes, env);
220  }
221 
222  index::SegmentIntersector* computeSelfNodes(
224  bool computeRingSelfNodes,
225  bool isDoneIfProperInt,
226  const geom::Envelope *env=0)
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=0);
236 
237  index::SegmentIntersector* computeSelfNodes(
239  bool computeRingSelfNodes, bool isDoneIfProperInt, const geom::Envelope *env=0);
240 
241  index::SegmentIntersector* computeEdgeIntersections(GeometryGraph *g,
242  algorithm::LineIntersector *li, bool includeProper,
243  const geom::Envelope *env=0);
244 
245  std::vector<Edge*> *getEdges();
246 
247  bool hasTooFewPoints();
248 
249  const geom::Coordinate& getInvalidPoint();
250 
251  const algorithm::BoundaryNodeRule& getBoundaryNodeRule() const
252  { return boundaryNodeRule; }
253 
254 };
255 
256 
257 } // namespace geos.geomgraph
258 } // namespace geos
259 
260 #ifdef _MSC_VER
261 #pragma warning(pop)
262 #endif
263 
264 #ifdef GEOS_INLINE
265 # include "geos/geomgraph/GeometryGraph.inl"
266 #endif
267 
268 #endif // ifndef GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition: Envelope.h:53
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
index::SegmentIntersector * computeSelfNodes(algorithm::LineIntersector *li, bool computeRingSelfNodes, const geom::Envelope *env=0)
Compute self-nodes, taking advantage of the Geometry type to minimize the number of intersection test...
Definition: GeometryGraph.h:214
Definition: GeometryGraph.h:73
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
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.
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