00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #ifndef GEOS_OPRELATE_H
00047 #define GEOS_OPRELATE_H
00048
00049 #include <memory>
00050 #include <string>
00051 #include <vector>
00052 #include <geos/platform.h>
00053 #include <geos/operation.h>
00054 #include <geos/geomgraph.h>
00055 #include <geos/geosAlgorithm.h>
00056
00057 namespace geos {
00058
00059
00060
00061
00062
00063 class RelateNode: public Node {
00064 public:
00065 RelateNode(Coordinate& coord,EdgeEndStar *edges);
00066 virtual ~RelateNode();
00067 void updateIMFromEdges(IntersectionMatrix *im);
00068 protected:
00069 void computeIM(IntersectionMatrix *im);
00070 };
00071
00072
00073
00074
00075 class EdgeEndBuilder {
00076 public:
00077 EdgeEndBuilder();
00078 vector<EdgeEnd*> *computeEdgeEnds(vector<Edge*> *edges);
00079 void computeEdgeEnds(Edge *edge,vector<EdgeEnd*> *l);
00080 protected:
00081 void createEdgeEndForPrev(Edge *edge,vector<EdgeEnd*> *l,EdgeIntersection *eiCurr,EdgeIntersection *eiPrev);
00082 void createEdgeEndForNext(Edge *edge,vector<EdgeEnd*> *l,EdgeIntersection *eiCurr,EdgeIntersection *eiNext);
00083 };
00084
00085
00086
00087
00088
00089 class EdgeEndBundle: public EdgeEnd {
00090 public:
00091 EdgeEndBundle(EdgeEnd *e);
00092 virtual ~EdgeEndBundle();
00093 Label *getLabel();
00094
00095 vector<EdgeEnd*>* getEdgeEnds();
00096 void insert(EdgeEnd *e);
00097 void computeLabel() ;
00098 void updateIM(IntersectionMatrix *im);
00099 string print();
00100 protected:
00101 vector<EdgeEnd*> *edgeEnds;
00102 void computeLabelOn(int geomIndex);
00103 void computeLabelSides(int geomIndex);
00104 void computeLabelSide(int geomIndex,int side);
00105 };
00106
00107
00108
00109
00110
00111
00112
00113 class EdgeEndBundleStar: public EdgeEndStar {
00114 public:
00115 EdgeEndBundleStar();
00116 virtual ~EdgeEndBundleStar();
00117 void insert(EdgeEnd *e);
00118 void updateIM(IntersectionMatrix *im);
00119 };
00120
00121
00122
00123
00124 class RelateNodeFactory: public NodeFactory {
00125 public:
00126 Node* createNode(Coordinate coord);
00127 };
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149 class RelateNodeGraph {
00150 public:
00151 RelateNodeGraph();
00152 virtual ~RelateNodeGraph();
00153
00154 map<Coordinate,Node*,CoordLT>* getNodeMap();
00155 void build(GeometryGraph *geomGraph);
00156 void computeIntersectionNodes(GeometryGraph *geomGraph,int argIndex);
00157 void copyNodesAndLabels(GeometryGraph *geomGraph,int argIndex);
00158 void insertEdgeEnds(vector<EdgeEnd*> *ee);
00159 private:
00160 NodeMap *nodes;
00161 };
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 class RelateComputer {
00178 friend class Unload;
00179 public:
00180 RelateComputer();
00181 virtual ~RelateComputer();
00182 RelateComputer(vector<GeometryGraph*> *newArg);
00183 IntersectionMatrix* computeIM();
00184 private:
00185 static const LineIntersector* li;
00186 static const PointLocator* ptLocator;
00187 vector<GeometryGraph*> *arg;
00188 NodeMap *nodes;
00189
00190 IntersectionMatrix *im;
00191 vector<Edge*> *isolatedEdges;
00192
00193 Coordinate invalidPoint;
00194 void insertEdgeEnds(vector<EdgeEnd*> *ee);
00195 void computeProperIntersectionIM(SegmentIntersector *intersector,IntersectionMatrix *imX);
00196 void copyNodesAndLabels(int argIndex);
00197 void computeIntersectionNodes(int argIndex);
00198 void labelIntersectionNodes(int argIndex);
00199 void computeDisjointIM(IntersectionMatrix *imX);
00200 void labelNodeEdges();
00201 void updateIM(IntersectionMatrix *imX);
00202 void labelIsolatedEdges(int thisIndex,int targetIndex);
00203 void labelIsolatedEdge(Edge *e,int targetIndex, const Geometry *target);
00204 void labelIsolatedNodes();
00205 void labelIsolatedNode(Node *n,int targetIndex);
00206 };
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 class RelateOp: public GeometryGraphOperation {
00217 public:
00218 static IntersectionMatrix* relate(const Geometry *a,const Geometry *b);
00219 RelateOp(const Geometry *g0, const Geometry *g1);
00220 virtual ~RelateOp();
00221 IntersectionMatrix* getIntersectionMatrix();
00222 private:
00223 RelateComputer relateComp;
00224 };
00225 }
00226
00227 #endif
00228