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
00038 namespace geos {
00039 namespace geom {
00040 class LineString;
00041 class LinearRing;
00042 class Polygon;
00043 class Geometry;
00044 class GeometryCollection;
00045 class Point;
00046 }
00047 namespace algorithm {
00048 class LineIntersector;
00049 class BoundaryNodeRule;
00050 }
00051 namespace geomgraph {
00052 class Edge;
00053 class Node;
00054 namespace index {
00055 class SegmentIntersector;
00056 class EdgeSetIntersector;
00057 }
00058 }
00059 }
00060
00061 namespace geos {
00062 namespace geomgraph {
00063
00064 class GEOS_DLL GeometryGraph: public PlanarGraph
00065 {
00066 using PlanarGraph::add;
00067 using PlanarGraph::findEdge;
00068
00069 private:
00070
00071 const geom::Geometry* parentGeom;
00072
00081
00082 std::map<const geom::LineString*, Edge*> lineEdgeMap;
00083
00088 bool useBoundaryDeterminationRule;
00089
00090 const algorithm::BoundaryNodeRule& boundaryNodeRule;
00091
00096 int argIndex;
00097
00099 std::auto_ptr< geom::CoordinateSequence > boundaryPoints;
00100
00101 std::auto_ptr< std::vector<Node*> > boundaryNodes;
00102
00103 bool hasTooFewPointsVar;
00104
00105 geom::Coordinate invalidPoint;
00106
00107 std::vector<index::SegmentIntersector*> newSegmentIntersectors;
00108
00110 index::EdgeSetIntersector* createEdgeSetIntersector();
00111
00112 void add(const geom::Geometry *g);
00113
00114
00115 void addCollection(const geom::GeometryCollection *gc);
00116
00117 void addPoint(const geom::Point *p);
00118
00119 void addPolygonRing(const geom::LinearRing *lr,
00120 int cwLeft, int cwRight);
00121
00122 void addPolygon(const geom::Polygon *p);
00123
00124 void addLineString(const geom::LineString *line);
00125
00126 void insertPoint(int argIndex, const geom::Coordinate& coord,
00127 int onLocation);
00128
00136 void insertBoundaryPoint(int argIndex, const geom::Coordinate& coord);
00137
00138 void addSelfIntersectionNodes(int argIndex);
00139
00147 void addSelfIntersectionNode(int argIndex,
00148 const geom::Coordinate& coord, int loc);
00149
00150
00151 GeometryGraph(const GeometryGraph& other);
00152 GeometryGraph& operator=(const GeometryGraph& rhs);
00153
00154 public:
00155
00156 static bool isInBoundary(int boundaryCount);
00157
00158 static int determineBoundary(int boundaryCount);
00159
00160 static int determineBoundary(
00161 const algorithm::BoundaryNodeRule& boundaryNodeRule,
00162 int boundaryCount);
00163
00164 GeometryGraph();
00165
00166 GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom);
00167
00168 GeometryGraph(int newArgIndex, const geom::Geometry *newParentGeom,
00169 const algorithm::BoundaryNodeRule& boundaryNodeRule);
00170
00171 virtual ~GeometryGraph();
00172
00173
00174 const geom::Geometry* getGeometry();
00175
00177 std::vector<Node*>* getBoundaryNodes();
00178
00179 void getBoundaryNodes(std::vector<Node*>&bdyNodes);
00180
00182 geom::CoordinateSequence* getBoundaryPoints();
00183
00184 Edge* findEdge(const geom::LineString *line);
00185
00186 void computeSplitEdges(std::vector<Edge*> *edgelist);
00187
00188 void addEdge(Edge *e);
00189
00190 void addPoint(geom::Coordinate& pt);
00191
00207 index::SegmentIntersector* computeSelfNodes(
00208 algorithm::LineIntersector *li,
00209 bool computeRingSelfNodes);
00210
00211
00212
00213 index::SegmentIntersector* computeSelfNodes(
00214 algorithm::LineIntersector& li,
00215 bool computeRingSelfNodes);
00216
00217 index::SegmentIntersector* computeEdgeIntersections(GeometryGraph *g,
00218 algorithm::LineIntersector *li, bool includeProper);
00219
00220 std::vector<Edge*> *getEdges();
00221
00222 bool hasTooFewPoints();
00223
00224 const geom::Coordinate& getInvalidPoint();
00225
00226 const algorithm::BoundaryNodeRule& getBoundaryNodeRule() const
00227 { return boundaryNodeRule; }
00228
00229 };
00230
00231
00232 }
00233 }
00234
00235 #ifdef GEOS_INLINE
00236 # include "geos/geomgraph/GeometryGraph.inl"
00237 #endif
00238
00239 #endif // ifndef GEOS_GEOMGRAPH_GEOMETRYGRAPH_H
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256