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_EDGEINTERSECTION_H
00023 #define GEOS_GEOMGRAPH_EDGEINTERSECTION_H
00024
00025 #include <geos/export.h>
00026
00027 #include <geos/geom/Coordinate.h>
00028
00029 #include <geos/inline.h>
00030
00031 #include <ostream>
00032
00033
00034 namespace geos {
00035 namespace geomgraph {
00036
00045 class GEOS_DLL EdgeIntersection {
00046 public:
00047
00048
00049 geom::Coordinate coord;
00050
00051
00052 double dist;
00053
00054
00055 int segmentIndex;
00056
00057 EdgeIntersection(const geom::Coordinate& newCoord,
00058 int newSegmentIndex, double newDist)
00059 :
00060 coord(newCoord),
00061 dist(newDist),
00062 segmentIndex(newSegmentIndex)
00063 {}
00064
00065 bool isEndPoint(int maxSegmentIndex) const {
00066 if (segmentIndex==0 && dist==0.0) return true;
00067 if (segmentIndex==maxSegmentIndex) return true;
00068 return false;
00069 }
00070
00071 const geom::Coordinate& getCoordinate() const {
00072 return coord;
00073 }
00074
00075 int getSegmentIndex() const { return segmentIndex; }
00076
00077 double getDistance() const { return dist; }
00078
00079 };
00080
00082
00084 inline bool operator< (const EdgeIntersection& ei1, const EdgeIntersection& ei2)
00085 {
00086 if ( ei1.segmentIndex < ei2.segmentIndex ) return true;
00087 if ( ei1.segmentIndex == ei2.segmentIndex )
00088 {
00089 if ( ei1.dist < ei2.dist ) return true;
00090
00091
00092
00093
00094 }
00095 return false;
00096 }
00097
00098
00099 struct GEOS_DLL EdgeIntersectionLessThen {
00100 bool operator()(const EdgeIntersection *ei1,
00101 const EdgeIntersection *ei2) const
00102 {
00103 return *ei1 < *ei2;
00104 }
00105 };
00106
00108 inline std::ostream& operator<< (std::ostream& os, const EdgeIntersection& e)
00109 {
00110 os << e.coord << " seg # = " << e.segmentIndex << " dist = " << e.dist;
00111 return os;
00112 }
00113
00114 }
00115 }
00116
00117 #endif // ifndef GEOS_GEOMGRAPH_EDGEINTERSECTION_H
00118
00119