00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
00023 #define GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
00024
00025 #include <geos/export.h>
00026 #include <map>
00027 #include <vector>
00028 #include <memory>
00029
00030 #include <geos/geom/Coordinate.h>
00031 #include <geos/geom/CoordinateSequence.h>
00032 #include <geos/geomgraph/PlanarGraph.h>
00033 #include <geos/geom/LineString.h>
00034
00035 #include <geos/inline.h>
00036
00037 #ifdef _MSC_VER
00038 #pragma warning(push)
00039 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00040 #endif
00041
00042
00043 namespace geos {
00044 namespace geom {
00045 class LineString;
00046 class LinearRing;
00047 class Polygon;
00048 class Geometry;
00049 class GeometryCollection;
00050 class Point;
00051 class Envelope;
00052 }
00053 namespace algorithm {
00054 class LineIntersector;
00055 class BoundaryNodeRule;
00056 }
00057 namespace geomgraph {
00058 class Edge;
00059 class Node;
00060 namespace index {
00061 class SegmentIntersector;
00062 class EdgeSetIntersector;
00063 }
00064 }
00065 }
00066
00067 namespace geos {
00068 namespace geomgraph {
00069
00073 class GEOS_DLL GeometryGraph: public PlanarGraph
00074 {
00075 using PlanarGraph::add;
00076 using PlanarGraph::findEdge;
00077
00078 private:
00079
00080 const geom::Geometry* parentGeom;
00081
00090
00091 std::map<const geom::LineString*, Edge*> lineEdgeMap;
00092
00097 bool useBoundaryDeterminationRule;
00098
00099 const algorithm::BoundaryNodeRule& boundaryNodeRule;
00100
00105 int argIndex;
00106
00108 std::auto_ptr< geom::CoordinateSequence > boundaryPoints;
00109
00110 std::auto_ptr< std::vector<Node*> > boundaryNodes;
00111
00112 bool hasTooFewPointsVar;
00113
00114 geom::Coordinate invalidPoint;
00115
00117 index::EdgeSetIntersector* createEdgeSetIntersector();
00118
00119 void add(const geom::Geometry *g);
00120
00121
00122 void addCollection(const geom::GeometryCollection *gc);
00123
00124 void addPoint(const geom::Point *p);
00125
00126 void addPolygonRing(const geom::LinearRing *lr,
00127 int cwLeft, int cwRight);
00128
00129 void addPolygon(const geom::Polygon *p);
00130
00131 void addLineString(const geom::LineString *line);
00132
00133 void insertPoint(int argIndex, const geom::Coordinate& coord,
00134 int onLocation);
00135
00143 void insertBoundaryPoint(int argIndex, const geom::Coordinate& coord);
00144
00145 void addSelfIntersectionNodes(int argIndex);
00146
00154 void addSelfIntersectionNode(int argIndex,
00155 const geom::Coordinate& coord, int loc);
00156
00157
00158 GeometryGraph(const GeometryGraph& other);
00159 GeometryGraph& operator=(const GeometryGraph& rhs);
00160
00161 public:
00162
00163 static bool isInBoundary(int boundaryCount);
00164
00165 static int determineBoundary(int boundaryCount);
00166
00167 static int determineBoundary(
00168 const algorithm::BoundaryNodeRule& boundaryNodeRule,
00169 int boundaryCount);
00170
00171 GeometryGraph();
00172
00173 GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom);
00174
00175 GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom,
00176 const algorithm::BoundaryNodeRule& boundaryNodeRule);
00177
00178 virtual ~GeometryGraph();
00179
00180
00181 const geom::Geometry* getGeometry();
00182
00184 std::vector<Node*>* getBoundaryNodes();
00185
00186 void getBoundaryNodes(std::vector<Node*>&bdyNodes);
00187
00189 geom::CoordinateSequence* getBoundaryPoints();
00190
00191 Edge* findEdge(const geom::LineString *line);
00192
00193 void computeSplitEdges(std::vector<Edge*> *edgelist);
00194
00195 void addEdge(Edge *e);
00196
00197 void addPoint(geom::Coordinate& pt);
00198
00214 index::SegmentIntersector* computeSelfNodes(
00215 algorithm::LineIntersector *li,
00216 bool computeRingSelfNodes,
00217 const geom::Envelope *env=0)
00218 {
00219 return computeSelfNodes(*li, computeRingSelfNodes, env);
00220 }
00221
00222
00223
00224 index::SegmentIntersector* computeSelfNodes(
00225 algorithm::LineIntersector& li,
00226 bool computeRingSelfNodes, const geom::Envelope *env=0);
00227
00228 index::SegmentIntersector* computeEdgeIntersections(GeometryGraph *g,
00229 algorithm::LineIntersector *li, bool includeProper,
00230 const geom::Envelope *env=0);
00231
00232 std::vector<Edge*> *getEdges();
00233
00234 bool hasTooFewPoints();
00235
00236 const geom::Coordinate& getInvalidPoint();
00237
00238 const algorithm::BoundaryNodeRule& getBoundaryNodeRule() const
00239 { return boundaryNodeRule; }
00240
00241 };
00242
00243
00244 }
00245 }
00246
00247 #ifdef _MSC_VER
00248 #pragma warning(pop)
00249 #endif
00250
00251 #ifdef GEOS_INLINE
00252 # include "geos/geomgraph/GeometryGraph.inl"
00253 #endif
00254
00255 #endif // ifndef GEOS_GEOMGRAPH_GEOMETRYGRAPH_H