[geos-commits] r2659 - in trunk/source: algorithm/distance headers/geos/algorithm/distance

svn_geos at osgeo.org svn_geos at osgeo.org
Mon Oct 5 17:36:18 EDT 2009


Author: strk
Date: 2009-10-05 17:36:17 -0400 (Mon, 05 Oct 2009)
New Revision: 2659

Modified:
   trunk/source/algorithm/distance/DistanceToPoint.cpp
   trunk/source/headers/geos/algorithm/distance/DistanceToPoint.h
Log:
Drop use of static data in DistanceToPoint class (for thread-safety)


Modified: trunk/source/algorithm/distance/DistanceToPoint.cpp
===================================================================
--- trunk/source/algorithm/distance/DistanceToPoint.cpp	2009-10-05 19:29:45 UTC (rev 2658)
+++ trunk/source/algorithm/distance/DistanceToPoint.cpp	2009-10-05 21:36:17 UTC (rev 2659)
@@ -35,10 +35,6 @@
 namespace algorithm { // geos.algorithm
 namespace distance { // geos.algorithm.distance
 
-/* static */
-LineSegment DistanceToPoint::tempSegment;
-
-
 /* public static */
 void
 DistanceToPoint::computeDistance(const geom::Geometry& geom,
@@ -76,12 +72,13 @@
 {
 	const CoordinateSequence* coordsRO = line.getCoordinatesRO();
 	const CoordinateSequence& coords = *coordsRO;
+
+	LineSegment tempSegment;
+	Coordinate closestPt;
 	for (size_t i=0, n=coords.size()-1; i<n; ++i)
 	{
-		// NOT THREAD SAFE
-		tempSegment.setCoordinates(coords[i], coords[i + 1]);
 		// this is somewhat inefficient - could do better
-		Coordinate closestPt;
+		tempSegment.setCoordinates(coords[i], coords[i + 1]);
 		tempSegment.closestPoint(pt, closestPt);
 		ptDist.setMinimum(closestPt, pt);
 	}

Modified: trunk/source/headers/geos/algorithm/distance/DistanceToPoint.h
===================================================================
--- trunk/source/headers/geos/algorithm/distance/DistanceToPoint.h	2009-10-05 19:29:45 UTC (rev 2658)
+++ trunk/source/headers/geos/algorithm/distance/DistanceToPoint.h	2009-10-05 21:36:17 UTC (rev 2659)
@@ -67,11 +67,6 @@
 			            const geom::Coordinate& pt,
 	                            PointPairDistance& ptDist);
 
-private:
-
-	// used for point-line distance calculation
-	// NOT THREAD SAFE !!
-	static geom::LineSegment tempSegment;
 };
 
 } // geos::algorithm::distance



More information about the geos-commits mailing list