GEOS
3.3.5
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.refractions.net 00005 * 00006 * Copyright (C) 2009-2011 Sandro Santilli <strk@keybit.net> 00007 * Copyright (C) 2005-2006 Refractions Research Inc. 00008 * Copyright (C) 2001-2002 Vivid Solutions Inc. 00009 * 00010 * This is free software; you can redistribute and/or modify it under 00011 * the terms of the GNU Lesser General Public Licence as published 00012 * by the Free Software Foundation. 00013 * See the COPYING file for more information. 00014 * 00015 ********************************************************************** 00016 * 00017 * Last port: geomgraph/EdgeIntersection.java rev. 1.5 (JTS-1.10) 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> // for composition and inlines 00028 00029 #include <geos/inline.h> 00030 00031 #include <ostream> 00032 00033 00034 namespace geos { 00035 namespace geomgraph { // geos.geomgraph 00036 00045 class GEOS_DLL EdgeIntersection { 00046 public: 00047 00048 // the point of intersection 00049 geom::Coordinate coord; 00050 00051 // the edge distance of this point along the containing line segment 00052 double dist; 00053 00054 // the index of the containing line segment in the parent edge 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 // TODO: check if the Coordinate matches, or this will 00092 // be a robustness issue in computin distance 00093 // See http://trac.osgeo.org/geos/ticket/350 00094 } 00095 return false; 00096 } 00097 00098 // @deprecated, use strict weak ordering operator 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 } // namespace geos.geomgraph 00115 } // namespace geos 00116 00117 #endif // ifndef GEOS_GEOMGRAPH_EDGEINTERSECTION_H 00118 00119