[geos-commits] r3334 - in trunk: include/geos/algorithm include/geos/geomgraph src/algorithm src/geomgraph

svn_geos at osgeo.org svn_geos at osgeo.org
Mon May 9 07:57:20 EDT 2011


Author: strk
Date: 2011-05-09 04:57:20 -0700 (Mon, 09 May 2011)
New Revision: 3334

Modified:
   trunk/include/geos/algorithm/LineIntersector.h
   trunk/include/geos/geomgraph/EdgeIntersection.h
   trunk/include/geos/geomgraph/EdgeIntersectionList.h
   trunk/src/algorithm/LineIntersector.cpp
   trunk/src/geomgraph/Edge.cpp
   trunk/src/geomgraph/EdgeIntersectionList.cpp
Log:
Use long double to compute edge distance. Makes noding more robust, fixes bug #350.

Modified: trunk/include/geos/algorithm/LineIntersector.h
===================================================================
--- trunk/include/geos/algorithm/LineIntersector.h	2011-05-06 18:51:56 UTC (rev 3333)
+++ trunk/include/geos/algorithm/LineIntersector.h	2011-05-09 11:57:20 UTC (rev 3334)
@@ -74,7 +74,7 @@
 	/// result of <b>rounding</b> points which lie on the line,
 	/// but not safe to use for <b>truncated</b> points.
 	///
-	static double computeEdgeDistance(const geom::Coordinate& p, const geom::Coordinate& p0, const geom::Coordinate& p1);
+	static long double computeEdgeDistance(const geom::Coordinate& p, const geom::Coordinate& p0, const geom::Coordinate& p1);
 
 	static double nonRobustComputeEdgeDistance(const geom::Coordinate& p,const geom::Coordinate& p1,const geom::Coordinate& p2);
 
@@ -241,7 +241,7 @@
 	 *
 	 * @return the edge distance of the intersection point
 	 */
-	double getEdgeDistance(int geomIndex,int intIndex) const;
+	long double getEdgeDistance(int geomIndex,int intIndex) const;
 
 private:
 

Modified: trunk/include/geos/geomgraph/EdgeIntersection.h
===================================================================
--- trunk/include/geos/geomgraph/EdgeIntersection.h	2011-05-06 18:51:56 UTC (rev 3333)
+++ trunk/include/geos/geomgraph/EdgeIntersection.h	2011-05-09 11:57:20 UTC (rev 3334)
@@ -49,13 +49,13 @@
 	geom::Coordinate coord;
 
 	// the edge distance of this point along the containing line segment
-	double dist;
+	long double dist;
 
 	// the index of the containing line segment in the parent edge
 	int segmentIndex;
 
 	EdgeIntersection(const geom::Coordinate& newCoord,
-	                 int newSegmentIndex, double newDist)
+	                 int newSegmentIndex, long double newDist)
 	  :
 	  coord(newCoord),
 	  dist(newDist),
@@ -74,7 +74,7 @@
 
 	int getSegmentIndex() const { return segmentIndex; }
 
-	double getDistance() const { return dist; }
+	long double getDistance() const { return dist; }
 
 };
 

Modified: trunk/include/geos/geomgraph/EdgeIntersectionList.h
===================================================================
--- trunk/include/geos/geomgraph/EdgeIntersectionList.h	2011-05-06 18:51:56 UTC (rev 3333)
+++ trunk/include/geos/geomgraph/EdgeIntersectionList.h	2011-05-09 11:57:20 UTC (rev 3334)
@@ -77,7 +77,7 @@
 	 * @return the EdgeIntersection found or added
 	 */
 	EdgeIntersection* add(const geom::Coordinate& coord,
-		int segmentIndex, double dist);
+		int segmentIndex, long double dist);
 
 	iterator begin() { return nodeMap.begin(); }
 	iterator end() { return nodeMap.end(); }

Modified: trunk/src/algorithm/LineIntersector.cpp
===================================================================
--- trunk/src/algorithm/LineIntersector.cpp	2011-05-06 18:51:56 UTC (rev 3333)
+++ trunk/src/algorithm/LineIntersector.cpp	2011-05-09 11:57:20 UTC (rev 3334)
@@ -55,12 +55,12 @@
 namespace algorithm { // geos.algorithm
 
 /*public static*/
-double
+long double
 LineIntersector::computeEdgeDistance(const Coordinate& p,const Coordinate& p0,const Coordinate& p1)
 {
 	double dx=fabs(p1.x-p0.x);
 	double dy=fabs(p1.y-p0.y);
-	double dist=-1.0;	// sentinel value
+	long double dist=-1.0;	// sentinel value
 	if (p==p0) {
 		dist=0.0;
 	} else if (p==p1) {
@@ -69,8 +69,8 @@
 		else
 			dist=dy;
 	} else {
-		double pdx=fabs(p.x - p0.x);
-		double pdy=fabs(p.y - p0.y);
+		long double pdx=fabsl((long double)p.x - p0.x);
+		long double pdy=fabsl((long double)p.y - p0.y);
 		if (dx > dy)
 			dist = pdx;
 		else
@@ -179,10 +179,10 @@
 }
 
 /*public*/
-double
+long double
 LineIntersector::getEdgeDistance(int segmentIndex,int intIndex) const
 {
-	double dist=computeEdgeDistance(intPt[intIndex],
+	long double dist=computeEdgeDistance(intPt[intIndex],
 		*inputLines[segmentIndex][0],
 		*inputLines[segmentIndex][1]);
 	return dist;

Modified: trunk/src/geomgraph/Edge.cpp
===================================================================
--- trunk/src/geomgraph/Edge.cpp	2011-05-06 18:51:56 UTC (rev 3333)
+++ trunk/src/geomgraph/Edge.cpp	2011-05-09 11:57:20 UTC (rev 3334)
@@ -162,7 +162,7 @@
 #endif
 	const Coordinate& intPt=li->getIntersection(intIndex);
 	unsigned int normalizedSegmentIndex=segmentIndex;
-	double dist=li->getEdgeDistance(geomIndex,intIndex);
+	long double dist = li->getEdgeDistance(geomIndex, intIndex);
 
 	// normalize the intersection point location
 	unsigned int nextSegIndex=normalizedSegmentIndex+1;

Modified: trunk/src/geomgraph/EdgeIntersectionList.cpp
===================================================================
--- trunk/src/geomgraph/EdgeIntersectionList.cpp	2011-05-06 18:51:56 UTC (rev 3333)
+++ trunk/src/geomgraph/EdgeIntersectionList.cpp	2011-05-09 11:57:20 UTC (rev 3334)
@@ -63,7 +63,7 @@
 
 EdgeIntersection*
 EdgeIntersectionList::add(const Coordinate& coord,
-	int segmentIndex, double dist)
+	int segmentIndex, long double dist)
 {
 	EdgeIntersection *eiNew=new EdgeIntersection(coord, segmentIndex, dist);
 



More information about the geos-commits mailing list