[geos-commits] r2694 - in trunk: source/headers/geos/linearref source/linearref tests/unit/linearref

svn_geos at osgeo.org svn_geos at osgeo.org
Fri Oct 23 05:43:52 EDT 2009


Author: strk
Date: 2009-10-23 05:43:52 -0400 (Fri, 23 Oct 2009)
New Revision: 2694

Modified:
   trunk/source/headers/geos/linearref/LocationIndexOfLine.h
   trunk/source/linearref/LengthIndexedLine.cpp
   trunk/source/linearref/LocationIndexOfLine.cpp
   trunk/tests/unit/linearref/LengthIndexedLineTest.cpp
Log:
Document ownership of return from LocationIndexOfLine::indicesOf, fix mismatch delete/delete[] in core and unit test


Modified: trunk/source/headers/geos/linearref/LocationIndexOfLine.h
===================================================================
--- trunk/source/headers/geos/linearref/LocationIndexOfLine.h	2009-10-23 09:34:24 UTC (rev 2693)
+++ trunk/source/headers/geos/linearref/LocationIndexOfLine.h	2009-10-23 09:43:52 UTC (rev 2694)
@@ -50,10 +50,25 @@
 	const geom::Geometry* linearGeom;
 
 public:
+
+	/** \brief
+	 * Determines the location of a subline along a linear {@link Geometry}.
+	 *
+	 * The location is reported as a pair of {@link LinearLocation}s.
+	 * 
+	 * <b>Note:</b> Currently this algorithm is not guaranteed to
+	 * return the correct substring in some situations where
+	 * an endpoint of the test line occurs more than once in the input line.
+	 * (However, the common case of a ring is always handled correctly).
+	 *
+	 * Caller must take of releasing with delete[]
+	 *
+	 */
 	static LinearLocation* indicesOf(const geom::Geometry* linearGeom, const geom::Geometry* subLine);
 
 	LocationIndexOfLine(const geom::Geometry* linearGeom);
 
+	/// Caller must take of releasing with delete[]
 	LinearLocation* indicesOf(const geom::Geometry* subLine) const;
 };
 }

Modified: trunk/source/linearref/LengthIndexedLine.cpp
===================================================================
--- trunk/source/linearref/LengthIndexedLine.cpp	2009-10-23 09:34:24 UTC (rev 2693)
+++ trunk/source/linearref/LengthIndexedLine.cpp	2009-10-23 09:43:52 UTC (rev 2694)
@@ -86,7 +86,7 @@
 	double* index = new double[2];
 	index[0] = LengthLocationMap::getLength(linearGeom, locIndex[0]);
 	index[1] = LengthLocationMap::getLength(linearGeom, locIndex[1]);
-	delete locIndex;
+	delete [] locIndex;
 	return index;
 }
 

Modified: trunk/source/linearref/LocationIndexOfLine.cpp
===================================================================
--- trunk/source/linearref/LocationIndexOfLine.cpp	2009-10-23 09:34:24 UTC (rev 2693)
+++ trunk/source/linearref/LocationIndexOfLine.cpp	2009-10-23 09:43:52 UTC (rev 2694)
@@ -33,17 +33,10 @@
 namespace linearref   // geos.linearref
 {
 
-/**
- * Determines the location of a subline along a linear {@link Geometry}.
- * The location is reported as a pair of {@link LinearLocation}s.
- * <p>
- * <b>Note:</b> Currently this algorithm is not guaranteed to
- * return the correct substring in some situations where
- * an endpoint of the test line occurs more than once in the input line.
- * (However, the common case of a ring is always handled correctly).
- */
-
-LinearLocation* LocationIndexOfLine::indicesOf(const Geometry* linearGeom, const Geometry* subLine)
+/* public static */
+LinearLocation*
+LocationIndexOfLine::indicesOf(const Geometry* linearGeom,
+		const Geometry* subLine)
 {
 	LocationIndexOfLine locater(linearGeom);
 	return locater.indicesOf(subLine);
@@ -52,7 +45,9 @@
 LocationIndexOfLine::LocationIndexOfLine(const Geometry* linearGeom) :
 		linearGeom(linearGeom) {}
 
-LinearLocation* LocationIndexOfLine::indicesOf(const Geometry* subLine) const
+/* public */
+LinearLocation*
+LocationIndexOfLine::indicesOf(const Geometry* subLine) const
 {
 	Coordinate startPt = dynamic_cast<const LineString*> (subLine->getGeometryN(0))->getCoordinateN(0);
 	const LineString* lastLine = dynamic_cast<const LineString*> (subLine->getGeometryN(subLine->getNumGeometries() - 1));

Modified: trunk/tests/unit/linearref/LengthIndexedLineTest.cpp
===================================================================
--- trunk/tests/unit/linearref/LengthIndexedLineTest.cpp	2009-10-23 09:34:24 UTC (rev 2693)
+++ trunk/tests/unit/linearref/LengthIndexedLineTest.cpp	2009-10-23 09:43:52 UTC (rev 2694)
@@ -148,7 +148,7 @@
     LengthIndexedLine indexedLine(linearGeom);
     double* loc = indexedLine.indicesOf(subLine);
     Geometry* result = indexedLine.extractLine(loc[0], loc[1]);
-    delete loc;
+    delete [] loc;
     return result;
   }
 



More information about the geos-commits mailing list