GEOS 3.9.1
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 <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>
33#include <geos/geomgraph/PlanarGraph.h>
34#include <geos/geomgraph/index/SegmentIntersector.h>
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
45namespace geos {
46namespace geom {
47class LineString;
48class LinearRing;
49class Polygon;
50class Geometry;
51class GeometryCollection;
52class Point;
53class Envelope;
54}
55namespace algorithm {
56class LineIntersector;
57class BoundaryNodeRule;
58}
59namespace geomgraph {
60class Edge;
61class Node;
62namespace index {
63class EdgeSetIntersector;
64}
65}
66}
67
68namespace geos {
69namespace geomgraph { // geos.geomgraph
70
74class GEOS_DLL GeometryGraph: public PlanarGraph {
75 using PlanarGraph::add;
76 using PlanarGraph::findEdge;
77
78private:
79
80 const geom::Geometry* parentGeom;
81
90 std::unordered_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
160public:
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
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
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>
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 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
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
An interface for rules which determine whether node points which are in boundaries of lineal geometry...
Definition BoundaryNodeRule.h:51
A LineIntersector is an algorithm that can both test whether two line segments intersect and compute ...
Definition LineIntersector.h:49
The internal representation of a list of coordinates inside a Geometry.
Definition CoordinateSequence.h:58
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:60
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:58
Represents a collection of heterogeneous Geometry objects.
Definition GeometryCollection.h:55
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:188
Definition LineString.h:68
Models an OGC SFS LinearRing. A LinearRing is a LineString which is both closed and simple.
Definition LinearRing.h:54
Definition Point.h:66
Represents a linear polygon, which may include holes.
Definition Polygon.h:64
Definition geomgraph/Edge.h:66
A GeometryGraph is a graph that models a given Geometry.
Definition GeometryGraph.h:74
geom::CoordinateSequence * getBoundaryPoints()
Returned object is owned by this GeometryGraph.
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...
Definition GeometryGraph.h:213
std::vector< Node * > * getBoundaryNodes()
Returned object is owned by this GeometryGraph.
Represents a directed graph which is embeddable in a planar surface.
Definition geomgraph/PlanarGraph.h:75
An EdgeSetIntersector computes all the intersections between the edges in the set.
Definition EdgeSetIntersector.h:41
Location
Constants representing the location of a point relative to a geometry.
Definition Location.h:34
Basic namespace for all GEOS functionalities.
Definition IndexedNestedRingTester.h:26