[geos-commits] r2620 - in trunk/source: headers/geos/linearref linearref

svn_geos at osgeo.org svn_geos at osgeo.org
Sat Aug 15 09:26:17 EDT 2009


Author: strk
Date: 2009-08-15 09:26:16 -0400 (Sat, 15 Aug 2009)
New Revision: 2620

Modified:
   trunk/source/headers/geos/linearref/ExtractLineByLocation.h
   trunk/source/headers/geos/linearref/LengthIndexOfPoint.h
   trunk/source/headers/geos/linearref/LengthIndexedLine.h
   trunk/source/headers/geos/linearref/LengthLocationMap.h
   trunk/source/headers/geos/linearref/LinearIterator.h
   trunk/source/headers/geos/linearref/LinearLocation.h
   trunk/source/headers/geos/linearref/LocationIndexOfLine.h
   trunk/source/headers/geos/linearref/LocationIndexOfPoint.h
   trunk/source/linearref/ExtractLineByLocation.cpp
   trunk/source/linearref/LengthIndexOfPoint.cpp
   trunk/source/linearref/LengthIndexedLine.cpp
   trunk/source/linearref/LengthLocationMap.cpp
   trunk/source/linearref/LinearIterator.cpp
   trunk/source/linearref/LinearLocation.cpp
   trunk/source/linearref/LocationIndexOfLine.cpp
   trunk/source/linearref/LocationIndexOfPoint.cpp
Log:
Const correctness of LenghtIndexedLine port, by novalis (issue #284)


Modified: trunk/source/headers/geos/linearref/ExtractLineByLocation.h
===================================================================
--- trunk/source/headers/geos/linearref/ExtractLineByLocation.h	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/headers/geos/linearref/ExtractLineByLocation.h	2009-08-15 13:26:16 UTC (rev 2620)
@@ -38,8 +38,8 @@
 {
 
 private:
-	geom::Geometry *line;
-	geom::Geometry *reverse(geom::Geometry *linear);
+	const geom::Geometry *line;
+	geom::Geometry *reverse(const geom::Geometry *linear);
 
 	/**
 	 * Assumes input is valid (e.g. start <= end)
@@ -71,9 +71,9 @@
 	 * @param end the end location
 	 * @return the extracted subline
 	 */
-	static geom::Geometry *extract(geom::Geometry *line, const LinearLocation& start, const LinearLocation& end);
+	static geom::Geometry *extract(const geom::Geometry *line, const LinearLocation& start, const LinearLocation& end);
 
-	ExtractLineByLocation(geom::Geometry *line);
+	ExtractLineByLocation(const geom::Geometry *line);
 
 	/**
 	 * Extracts a subline of the input.

Modified: trunk/source/headers/geos/linearref/LengthIndexOfPoint.h
===================================================================
--- trunk/source/headers/geos/linearref/LengthIndexOfPoint.h	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/headers/geos/linearref/LengthIndexOfPoint.h	2009-08-15 13:26:16 UTC (rev 2620)
@@ -38,18 +38,19 @@
 {
 
 private:
-	geom::Geometry *linearGeom;
+	const geom::Geometry *linearGeom;
 
-	double indexOfFromStart(geom::Coordinate& inputPt, double minIndex);
+	double indexOfFromStart(const geom::Coordinate& inputPt, const double minIndex) const;
 
-	double segmentNearestMeasure(geom::LineSegment *seg, geom::Coordinate& inputPt,
-				     double segmentStartMeasure);
+	double segmentNearestMeasure(const geom::LineSegment *seg, 
+                               const geom::Coordinate& inputPt,
+                               double segmentStartMeasure) const;
 public:
-	static double indexOf(geom::Geometry *linearGeom, geom::Coordinate& inputPt);
+	static double indexOf(const geom::Geometry *linearGeom, const geom::Coordinate& inputPt);
 
-	static double indexOfAfter(geom::Geometry *linearGeom, geom::Coordinate& inputPt, double minIndex);
+	static double indexOfAfter(const geom::Geometry *linearGeom, const geom::Coordinate& inputPt, double minIndex);
 
-	LengthIndexOfPoint(geom::Geometry *linearGeom);
+	LengthIndexOfPoint(const geom::Geometry *linearGeom);
 
 	/**
 	 * Find the nearest location along a linear {@link Geometry} to a given point.
@@ -57,7 +58,7 @@
 	 * @param inputPt the coordinate to locate
 	 * @return the location of the nearest point
 	 */
-	double indexOf(geom::Coordinate& inputPt);
+	double indexOf(const geom::Coordinate& inputPt) const;
 
 	/**
 	 * Finds the nearest index along the linear {@link Geometry}
@@ -74,7 +75,7 @@
 	 * @param minLocation the minimum location for the point location
 	 * @return the location of the nearest point
 	 */
-	double indexOfAfter(geom::Coordinate& inputPt, double minIndex);
+	double indexOfAfter(const geom::Coordinate& inputPt, double minIndex) const;
 
 };
 }

Modified: trunk/source/headers/geos/linearref/LengthIndexedLine.h
===================================================================
--- trunk/source/headers/geos/linearref/LengthIndexedLine.h	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/headers/geos/linearref/LengthIndexedLine.h	2009-08-15 13:26:16 UTC (rev 2620)
@@ -44,8 +44,8 @@
 class LengthIndexedLine
 {
 private:
-	geom::Geometry *linearGeom;
-	LinearLocation locationOf(double index);
+	const geom::Geometry *linearGeom;
+	LinearLocation locationOf(double index) const;
 
 public:
 
@@ -56,7 +56,7 @@
 	 * @param linearGeom the linear geometry to reference along
 	 */
 
-	LengthIndexedLine(geom::Geometry *linearGeom);
+	LengthIndexedLine(const geom::Geometry *linearGeom);
 
 	/** \brief
 	 * Computes the {@link Coordinate} for the point
@@ -69,7 +69,7 @@
 	 * @param index the index of the desired point
 	 * @return the Coordinate at the given index
 	 */
-	geom::Coordinate extractPoint(double index);
+	geom::Coordinate extractPoint(double index) const;
 
 
 	/**
@@ -88,7 +88,7 @@
 	 *    (positive is to the left, negative is to the right)
 	 * @return the Coordinate at the given index
 	 */
-	geom::Coordinate extractPoint(double index, double offsetDistance);
+	geom::Coordinate extractPoint(double index, double offsetDistance) const;
 
 	/**
 	 * Computes the {@link LineString} for the interval
@@ -100,7 +100,7 @@
 	 * @param endIndex the index of the end of the interval
 	 * @return the linear interval between the indices
 	 */
-	geom::Geometry *extractLine(double startIndex, double endIndex);
+	geom::Geometry *extractLine(double startIndex, double endIndex) const;
 
 
 	/**
@@ -120,7 +120,7 @@
 	 *
 	 * @see project
 	 */
-	double indexOf(geom::Coordinate& pt);
+	double indexOf(const geom::Coordinate& pt) const;
 
 	/**
 	 * Finds the index for a point on the line
@@ -144,7 +144,7 @@
 	 *
 	 * @see project
 	 */
-	double indexOfAfter(geom::Coordinate& pt, double minIndex);
+	double indexOfAfter(const geom::Coordinate& pt, double minIndex) const;
 
 	/**
 	 * Computes the indices for a subline of the line.
@@ -155,7 +155,7 @@
 	 * @param subLine a subLine of the line
 	 * @return a pair of indices for the start and end of the subline.
 	 */
-	double* indicesOf(geom::Geometry *subLine);
+	double* indicesOf(const geom::Geometry *subLine) const;
 
 
 	/**
@@ -167,19 +167,19 @@
 	 * @param pt a point on the line
 	 * @return the index of the point
 	 */
-	double project(geom::Coordinate pt);
+	double project(const geom::Coordinate& pt) const;
 
 	/**
 	 * Returns the index of the start of the line
 	 * @return the start index
 	 */
-	double getStartIndex();
+	double getStartIndex() const;
 
 	/**
 	 * Returns the index of the end of the line
 	 * @return the end index
 	 */
-	double getEndIndex();
+	double getEndIndex() const;
 
 	/**
 	 * Tests whether an index is in the valid index range for the line.
@@ -187,7 +187,7 @@
 	 * @param length the index to test
 	 * @return <code>true</code> if the index is in the valid range
 	 */
-	bool isValidIndex(double index);
+	bool isValidIndex(double index) const;
 
 
 	/**
@@ -196,7 +196,7 @@
 	 *
 	 * @return a valid index value
 	 */
-	double clampIndex(double index);
+	double clampIndex(double index) const;
 };
 }
 }

Modified: trunk/source/headers/geos/linearref/LengthLocationMap.h
===================================================================
--- trunk/source/headers/geos/linearref/LengthLocationMap.h	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/headers/geos/linearref/LengthLocationMap.h	2009-08-15 13:26:16 UTC (rev 2620)
@@ -41,7 +41,7 @@
 
 
 private:
-	geom::Geometry *linearGeom;
+	const geom::Geometry *linearGeom;
 
 	LinearLocation getLocationForward(double length) const;
 
@@ -59,7 +59,7 @@
 	 * @param length the length index of the location
 	 * @return the {@link LinearLocation} for the length
 	 */
-	static LinearLocation getLocation(geom::Geometry *linearGeom, double length);
+	static LinearLocation getLocation(const geom::Geometry *linearGeom, double length);
 
 	/**
 	 * Computes the length for a given {@link LinearLocation}
@@ -69,9 +69,9 @@
 	 * @param loc the {@link LinearLocation} index of the location
 	 * @return the length for the {@link LinearLocation}
 	 */
-	static double getLength(geom::Geometry *linearGeom, const LinearLocation& loc);
+	static double getLength(const geom::Geometry *linearGeom, const LinearLocation& loc);
 
-	LengthLocationMap(geom::Geometry *linearGeom);
+	LengthLocationMap(const geom::Geometry *linearGeom);
 
 	/**
 	 * Compute the {@link LinearLocation} corresponding to a length.

Modified: trunk/source/headers/geos/linearref/LinearIterator.h
===================================================================
--- trunk/source/headers/geos/linearref/LinearIterator.h	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/headers/geos/linearref/LinearIterator.h	2009-08-15 13:26:16 UTC (rev 2620)
@@ -58,7 +58,7 @@
 	const geom::LineString *currentLine;
 	unsigned int vertexIndex;
 	unsigned int componentIndex;
-	geom::Geometry *linear;
+	const geom::Geometry *linear;
 	const unsigned int numLines;
 
 	/**
@@ -74,7 +74,7 @@
 	 *
 	 * @param linear the linear geometry to iterate over
 	 */
-	LinearIterator(geom::Geometry *linear);
+	LinearIterator(const geom::Geometry *linear);
 
 	/**
 	 * Creates an iterator starting at
@@ -83,7 +83,7 @@
 	 * @param linear the linear geometry to iterate over
 	 * @param start the location to start at
 	 */
-	LinearIterator(geom::Geometry *linear, const LinearLocation& start);
+	LinearIterator(const geom::Geometry *linear, const LinearLocation& start);
 
 	/**
 	 * Creates an iterator starting at
@@ -93,7 +93,7 @@
 	 * @param componentIndex the component to start at
 	 * @param vertexIndex the vertex to start at
 	 */
-	LinearIterator(geom::Geometry *linear, unsigned int componentIndex, unsigned int vertexIndex);
+	LinearIterator(const geom::Geometry *linear, unsigned int componentIndex, unsigned int vertexIndex);
 
 	/**
 	 * Tests whether there are any vertices left to iterator over.

Modified: trunk/source/headers/geos/linearref/LinearLocation.h
===================================================================
--- trunk/source/headers/geos/linearref/LinearLocation.h	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/headers/geos/linearref/LinearLocation.h	2009-08-15 13:26:16 UTC (rev 2620)
@@ -62,7 +62,7 @@
 	 * @param linear the linear geometry
 	 * @return a new <tt>LinearLocation</tt>
 	 */
-	static LinearLocation getEndLocation(geom::Geometry* linear);
+	static LinearLocation getEndLocation(const geom::Geometry* linear);
 
 	/**
 	 * Computes the {@link Coordinate} of a point a given fraction
@@ -79,7 +79,7 @@
 	 * @param frac the length to the desired point
 	 * @return the <tt>Coordinate</tt> of the desired point
 	 */
-	static geom::Coordinate pointAlongSegmentByFraction(geom::Coordinate& p0, geom::Coordinate& p1, double frac);
+	static geom::Coordinate pointAlongSegmentByFraction(const geom::Coordinate& p0, const geom::Coordinate& p1, double frac);
 
 
 	/**
@@ -95,7 +95,7 @@
 	 *
 	 * @param linear a linear geometry
 	 */
-	void clamp(geom::Geometry* linear);
+	void clamp(const geom::Geometry* linear);
 
 	/**
 	 * Snaps the value of this location to
@@ -105,7 +105,7 @@
 	 * @param linearGeom a linear geometry
 	 * @param minDistance the minimum allowable distance to a vertex
 	 */
-	void snapToVertex(geom::Geometry* linearGeom, double minDistance);
+	void snapToVertex(const geom::Geometry* linearGeom, double minDistance);
 
 	/**
 	 * Gets the length of the segment in the given
@@ -114,14 +114,14 @@
 	 * @param linearGeom a linear geometry
 	 * @return the length of the segment
 	 */
-	double getSegmentLength(geom::Geometry* linearGeom) const;
+	double getSegmentLength(const geom::Geometry* linearGeom) const;
 	/**
 	 * Sets the value of this location to
 	 * refer the end of a linear geometry
 	 *
 	 * @param linear the linear geometry to set
 	 */
-	void setToEnd(geom::Geometry* linear);
+	void setToEnd(const geom::Geometry* linear);
 
 	/**
 	 * Gets the component index for this location.
@@ -159,7 +159,7 @@
 	 * @param linearGeom a linear geometry
 	 * @return the <tt>Coordinate</tt> at the location
 	 */
-	geom::Coordinate getCoordinate(geom::Geometry* linearGeom) const;
+	geom::Coordinate getCoordinate(const geom::Geometry* linearGeom) const;
 
 	/**
 	 * Gets a {@link LineSegment} representing the segment of the
@@ -168,7 +168,7 @@
 	 * @param linearGeom a linear geometry
 	 * @return the <tt>LineSegment</tt> containing the location
 	 */
-	geom::LineSegment *getSegment(geom::Geometry* linearGeom) const;
+	geom::LineSegment *getSegment(const geom::Geometry* linearGeom) const;
 
 	/**
 	 * Tests whether this location refers to a valid
@@ -177,7 +177,7 @@
 	 * @param linearGeom a linear geometry
 	 * @return true if this location is valid
 	 */
-	bool isValid(geom::Geometry* linearGeom) const;
+	bool isValid(const geom::Geometry* linearGeom) const;
 
 	/**
 	 *  Compares this object with the specified object for order.

Modified: trunk/source/headers/geos/linearref/LocationIndexOfLine.h
===================================================================
--- trunk/source/headers/geos/linearref/LocationIndexOfLine.h	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/headers/geos/linearref/LocationIndexOfLine.h	2009-08-15 13:26:16 UTC (rev 2620)
@@ -47,14 +47,14 @@
 	* and also to use the internal vertex information to unambiguously locate the subline.
 	*/
 private:
-	geom::Geometry* linearGeom;
+	const geom::Geometry* linearGeom;
 
 public:
-	static LinearLocation* indicesOf(geom::Geometry* linearGeom, geom::Geometry* subLine);
+	static LinearLocation* indicesOf(const geom::Geometry* linearGeom, const geom::Geometry* subLine);
 
-	LocationIndexOfLine(geom::Geometry* linearGeom);
+	LocationIndexOfLine(const geom::Geometry* linearGeom);
 
-	LinearLocation* indicesOf(geom::Geometry* subLine) const;
+	LinearLocation* indicesOf(const geom::Geometry* subLine) const;
 };
 }
 }

Modified: trunk/source/headers/geos/linearref/LocationIndexOfPoint.h
===================================================================
--- trunk/source/headers/geos/linearref/LocationIndexOfPoint.h	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/headers/geos/linearref/LocationIndexOfPoint.h	2009-08-15 13:26:16 UTC (rev 2620)
@@ -41,16 +41,16 @@
 {
 
 private:
-	geom::Geometry *linearGeom;
+	const geom::Geometry *linearGeom;
 
 	LinearLocation indexOfFromStart(const geom::Coordinate& inputPt, LinearLocation* minIndex) const;
 
 public:
-	static LinearLocation indexOf(geom::Geometry *linearGeom, const geom::Coordinate& inputPt);
+	static LinearLocation indexOf(const geom::Geometry *linearGeom, const geom::Coordinate& inputPt);
 
-	static LinearLocation indexOfAfter(geom::Geometry *linearGeom, const geom::Coordinate& inputPt, LinearLocation* minIndex);
+	static LinearLocation indexOfAfter(const geom::Geometry *linearGeom, const geom::Coordinate& inputPt, LinearLocation* minIndex);
 
-	LocationIndexOfPoint(geom::Geometry *linearGeom);
+	LocationIndexOfPoint(const geom::Geometry *linearGeom);
 
 	/**
 	 * Find the nearest location along a linear {@link Geometry} to a given point.

Modified: trunk/source/linearref/ExtractLineByLocation.cpp
===================================================================
--- trunk/source/linearref/ExtractLineByLocation.cpp	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/linearref/ExtractLineByLocation.cpp	2009-08-15 13:26:16 UTC (rev 2620)
@@ -42,13 +42,13 @@
 {
 
 
-Geometry *ExtractLineByLocation::extract(Geometry *line, const LinearLocation& start, const LinearLocation& end)
+Geometry *ExtractLineByLocation::extract(const Geometry *line, const LinearLocation& start, const LinearLocation& end)
 {
 	ExtractLineByLocation ls(line);
 	return ls.extract(start, end);
 }
 
-ExtractLineByLocation::ExtractLineByLocation(Geometry *line) :
+ExtractLineByLocation::ExtractLineByLocation(const Geometry *line) :
 		line(line) {}
 
 
@@ -64,16 +64,16 @@
 	return computeLinear(start, end);
 }
 
-Geometry *ExtractLineByLocation::reverse(Geometry *linear)
+Geometry *ExtractLineByLocation::reverse(const Geometry *linear)
 {
-	LineString* ls = dynamic_cast<LineString *>(linear);
+	const LineString* ls = dynamic_cast<const LineString *>(linear);
 	if (ls)
 	{
 		return ls->reverse();
 	}
 	else
 	{
-		MultiLineString* mls = dynamic_cast<MultiLineString *>(linear);
+		const MultiLineString* mls = dynamic_cast<const MultiLineString *>(linear);
 		if (mls)
 		{
 			return mls->reverse();

Modified: trunk/source/linearref/LengthIndexOfPoint.cpp
===================================================================
--- trunk/source/linearref/LengthIndexOfPoint.cpp	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/linearref/LengthIndexOfPoint.cpp	2009-08-15 13:26:16 UTC (rev 2620)
@@ -36,28 +36,28 @@
 namespace linearref   // geos.linearref
 {
 
-double LengthIndexOfPoint::indexOf(Geometry *linearGeom, Coordinate& inputPt)
+double LengthIndexOfPoint::indexOf(const Geometry *linearGeom, const Coordinate& inputPt)
 {
 	LengthIndexOfPoint locater(linearGeom);
 	return locater.indexOf(inputPt);
 }
 
-double LengthIndexOfPoint::indexOfAfter(Geometry *linearGeom, Coordinate& inputPt, double minIndex)
+double LengthIndexOfPoint::indexOfAfter(const Geometry *linearGeom, const Coordinate& inputPt, double minIndex)
 {
 	LengthIndexOfPoint locater(linearGeom);
 	return locater.indexOfAfter(inputPt, minIndex);
 }
 
-LengthIndexOfPoint::LengthIndexOfPoint(Geometry *linearGeom):
+LengthIndexOfPoint::LengthIndexOfPoint(const Geometry *linearGeom):
 		linearGeom(linearGeom) {}
 
-double LengthIndexOfPoint::indexOf(Coordinate& inputPt)
+double LengthIndexOfPoint::indexOf(const Coordinate& inputPt) const
 {
 	return indexOfFromStart(inputPt, -1.0);
 }
 
 
-double LengthIndexOfPoint::indexOfAfter(Coordinate& inputPt, double minIndex)
+double LengthIndexOfPoint::indexOfAfter(const Coordinate& inputPt, double minIndex) const
 {
 	if (minIndex < 0.0) return indexOf(inputPt);
 
@@ -78,7 +78,7 @@
 	return closestAfter;
 }
 
-double LengthIndexOfPoint::indexOfFromStart(Coordinate& inputPt, double minIndex)
+double LengthIndexOfPoint::indexOfFromStart(const Coordinate& inputPt, double minIndex) const
 {
 	double minDistance = numeric_limits<double>::max();
 
@@ -107,8 +107,9 @@
 	return ptMeasure;
 }
 
-double LengthIndexOfPoint::segmentNearestMeasure(LineSegment* seg, Coordinate& inputPt,
-		double segmentStartMeasure)
+double LengthIndexOfPoint::segmentNearestMeasure(const LineSegment* seg, 
+                                                 const Coordinate& inputPt,
+                                                 double segmentStartMeasure) const
 {
 	// found new minimum, so compute location distance of point
 	double projFactor = seg->projectionFactor(inputPt);

Modified: trunk/source/linearref/LengthIndexedLine.cpp
===================================================================
--- trunk/source/linearref/LengthIndexedLine.cpp	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/linearref/LengthIndexedLine.cpp	2009-08-15 13:26:16 UTC (rev 2620)
@@ -34,17 +34,17 @@
 namespace linearref   // geos.linearref
 {
 
-LengthIndexedLine::LengthIndexedLine(Geometry* linearGeom) :
+LengthIndexedLine::LengthIndexedLine(const Geometry* linearGeom) :
 		linearGeom(linearGeom) {}
 
-Coordinate LengthIndexedLine::extractPoint(double index)
+Coordinate LengthIndexedLine::extractPoint(double index) const
 {
 	LinearLocation loc = LengthLocationMap::getLocation(linearGeom, index);
 	Coordinate coord = loc.getCoordinate(linearGeom);
 	return coord;
 }
 
-Coordinate LengthIndexedLine::extractPoint(double index, double offsetDistance)
+Coordinate LengthIndexedLine::extractPoint(double index, double offsetDistance) const
 {
 	LinearLocation loc = LengthLocationMap::getLocation(linearGeom, index);
 	Coordinate ret;
@@ -53,34 +53,34 @@
 }
 
 
-Geometry *LengthIndexedLine::extractLine(double startIndex, double endIndex)
+Geometry *LengthIndexedLine::extractLine(double startIndex, double endIndex) const
 {
 
-	LinearLocation startLoc = locationOf(startIndex);
-	LinearLocation endLoc = locationOf(endIndex);
+	const LinearLocation startLoc = locationOf(startIndex);
+	const LinearLocation endLoc = locationOf(endIndex);
 	Geometry* g = ExtractLineByLocation::extract(linearGeom, startLoc, endLoc);
 	return g;
 }
 
-LinearLocation LengthIndexedLine::locationOf(double index)
+LinearLocation LengthIndexedLine::locationOf(double index) const
 {
 	return LengthLocationMap::getLocation(linearGeom, index);
 }
 
 
-double LengthIndexedLine::indexOf(Coordinate& pt)
+double LengthIndexedLine::indexOf(const Coordinate& pt) const
 {
 	return LengthIndexOfPoint::indexOf(linearGeom, pt);
 }
 
 
-double LengthIndexedLine::indexOfAfter(Coordinate& pt, double minIndex)
+double LengthIndexedLine::indexOfAfter(const Coordinate& pt, double minIndex) const
 {
 	return LengthIndexOfPoint::indexOfAfter(linearGeom, pt, minIndex);
 }
 
 
-double* LengthIndexedLine::indicesOf(Geometry* subLine)
+double* LengthIndexedLine::indicesOf(const Geometry* subLine) const
 {
 	LinearLocation* locIndex = LocationIndexOfLine::indicesOf(linearGeom, subLine);
 	double* index = new double[2];
@@ -91,28 +91,28 @@
 }
 
 
-double LengthIndexedLine::project(Coordinate pt)
+double LengthIndexedLine::project(const Coordinate& pt) const
 {
 	return LengthIndexOfPoint::indexOf(linearGeom, pt);
 }
 
-double LengthIndexedLine::getStartIndex()
+double LengthIndexedLine::getStartIndex() const
 {
 	return 0.0;
 }
 
-double LengthIndexedLine::getEndIndex()
+double LengthIndexedLine::getEndIndex() const
 {
 	return linearGeom->getLength();
 }
 
-bool LengthIndexedLine::isValidIndex(double index)
+bool LengthIndexedLine::isValidIndex(double index) const
 {
 	return (index >= getStartIndex()
 		&& index <= getEndIndex());
 }
 
-double LengthIndexedLine::clampIndex(double index)
+double LengthIndexedLine::clampIndex(double index) const
 {
 	double startIndex = getStartIndex();
 	if (index < startIndex) return startIndex;

Modified: trunk/source/linearref/LengthLocationMap.cpp
===================================================================
--- trunk/source/linearref/LengthLocationMap.cpp	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/linearref/LengthLocationMap.cpp	2009-08-15 13:26:16 UTC (rev 2620)
@@ -34,20 +34,20 @@
 {
 
 
-LinearLocation LengthLocationMap::getLocation(Geometry* linearGeom, double length)
+LinearLocation LengthLocationMap::getLocation(const Geometry* linearGeom, double length)
 {
 	LengthLocationMap locater(linearGeom);
 	return locater.getLocation(length);
 }
 
-double LengthLocationMap::getLength(Geometry* linearGeom, const LinearLocation& loc)
+double LengthLocationMap::getLength(const Geometry* linearGeom, const LinearLocation& loc)
 {
 	LengthLocationMap locater(linearGeom);
 	return locater.getLength(loc);
 }
 
 
-LengthLocationMap::LengthLocationMap(Geometry* linearGeom) :
+LengthLocationMap::LengthLocationMap(const Geometry* linearGeom) :
 		linearGeom(linearGeom) {}
 
 LinearLocation LengthLocationMap::getLocation(double length) const

Modified: trunk/source/linearref/LinearIterator.cpp
===================================================================
--- trunk/source/linearref/LinearIterator.cpp	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/linearref/LinearIterator.cpp	2009-08-15 13:26:16 UTC (rev 2620)
@@ -38,7 +38,7 @@
 	return loc.getSegmentIndex();
 }
 
-LinearIterator::LinearIterator(Geometry* linear) :
+LinearIterator::LinearIterator(const Geometry* linear) :
 		vertexIndex(0),
 		componentIndex(0),
 		linear(linear),
@@ -48,7 +48,7 @@
 }
 
 
-LinearIterator::LinearIterator(Geometry* linear, const LinearLocation& start):
+LinearIterator::LinearIterator(const Geometry* linear, const LinearLocation& start):
 		vertexIndex(segmentEndVertexIndex(start)),
 		componentIndex(start.getComponentIndex()),
 		linear(linear),
@@ -57,7 +57,7 @@
 	loadCurrentLine();
 }
 
-LinearIterator::LinearIterator(Geometry* linear, unsigned int componentIndex, unsigned int vertexIndex) :
+LinearIterator::LinearIterator(const Geometry* linear, unsigned int componentIndex, unsigned int vertexIndex) :
 		vertexIndex(vertexIndex),
 		componentIndex(componentIndex),
 		linear(linear),

Modified: trunk/source/linearref/LinearLocation.cpp
===================================================================
--- trunk/source/linearref/LinearLocation.cpp	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/linearref/LinearLocation.cpp	2009-08-15 13:26:16 UTC (rev 2620)
@@ -32,7 +32,7 @@
 namespace linearref   // geos.linearref
 {
 
-LinearLocation LinearLocation::getEndLocation(Geometry* linear)
+LinearLocation LinearLocation::getEndLocation(const Geometry* linear)
 {
 	// assert: linear is LineString or MultiLineString
 	LinearLocation loc;
@@ -40,7 +40,7 @@
 	return loc;
 }
 
-Coordinate LinearLocation::pointAlongSegmentByFraction(Coordinate& p0, Coordinate& p1, double frac)
+Coordinate LinearLocation::pointAlongSegmentByFraction(const Coordinate& p0, const Coordinate& p1, double frac)
 {
 	if (frac <= 0.0) return p0;
 	if (frac >= 1.0) return p1;
@@ -93,7 +93,7 @@
 
 
 
-void LinearLocation::clamp(Geometry* linear)
+void LinearLocation::clamp(const Geometry* linear)
 {
 	if (componentIndex >= linear->getNumGeometries())
 	{
@@ -108,7 +108,7 @@
 	}
 }
 
-void LinearLocation::snapToVertex(Geometry* linearGeom, double minDistance)
+void LinearLocation::snapToVertex(const Geometry* linearGeom, double minDistance)
 {
 	if (segmentFraction <= 0.0 || segmentFraction >= 1.0)
 		return;
@@ -125,7 +125,7 @@
 	}
 }
 
-double LinearLocation::getSegmentLength(Geometry* linearGeom) const
+double LinearLocation::getSegmentLength(const Geometry* linearGeom) const
 {
 	const LineString* lineComp = dynamic_cast<const LineString*> (linearGeom->getGeometryN(componentIndex));
 
@@ -139,7 +139,7 @@
 	return p0.distance(p1);
 }
 
-void LinearLocation::setToEnd(Geometry* linear)
+void LinearLocation::setToEnd(const Geometry* linear)
 {
 	componentIndex = linear->getNumGeometries() - 1;
 	const LineString* lastLine = dynamic_cast<const LineString*>(linear->getGeometryN(componentIndex));
@@ -167,7 +167,7 @@
 	return segmentFraction <= 0.0 || segmentFraction >= 1.0;
 }
 
-Coordinate LinearLocation::getCoordinate(Geometry* linearGeom) const
+Coordinate LinearLocation::getCoordinate(const Geometry* linearGeom) const
 {
 	const LineString* lineComp = dynamic_cast<const LineString *> (linearGeom->getGeometryN(componentIndex));
 	Coordinate p0 = lineComp->getCoordinateN(segmentIndex);
@@ -177,7 +177,7 @@
 	return pointAlongSegmentByFraction(p0, p1, segmentFraction);
 }
 
-LineSegment* LinearLocation::getSegment(Geometry* linearGeom) const
+LineSegment* LinearLocation::getSegment(const Geometry* linearGeom) const
 {
 	const LineString* lineComp = dynamic_cast<const LineString *> (linearGeom->getGeometryN(componentIndex));
 	Coordinate p0 = lineComp->getCoordinateN(segmentIndex);
@@ -192,7 +192,7 @@
 }
 
 
-bool LinearLocation::isValid(Geometry* linearGeom) const
+bool LinearLocation::isValid(const Geometry* linearGeom) const
 {
 	if (componentIndex < 0 || componentIndex >= linearGeom->getNumGeometries())
 		return false;

Modified: trunk/source/linearref/LocationIndexOfLine.cpp
===================================================================
--- trunk/source/linearref/LocationIndexOfLine.cpp	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/linearref/LocationIndexOfLine.cpp	2009-08-15 13:26:16 UTC (rev 2620)
@@ -43,16 +43,16 @@
  * (However, the common case of a ring is always handled correctly).
  */
 
-LinearLocation* LocationIndexOfLine::indicesOf(Geometry* linearGeom, Geometry* subLine)
+LinearLocation* LocationIndexOfLine::indicesOf(const Geometry* linearGeom, const Geometry* subLine)
 {
 	LocationIndexOfLine locater(linearGeom);
 	return locater.indicesOf(subLine);
 }
 
-LocationIndexOfLine::LocationIndexOfLine(Geometry* linearGeom) :
+LocationIndexOfLine::LocationIndexOfLine(const Geometry* linearGeom) :
 		linearGeom(linearGeom) {}
 
-LinearLocation* LocationIndexOfLine::indicesOf(Geometry* subLine) const
+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/source/linearref/LocationIndexOfPoint.cpp
===================================================================
--- trunk/source/linearref/LocationIndexOfPoint.cpp	2009-08-12 19:01:57 UTC (rev 2619)
+++ trunk/source/linearref/LocationIndexOfPoint.cpp	2009-08-15 13:26:16 UTC (rev 2620)
@@ -77,19 +77,19 @@
 }
 
 
-LinearLocation LocationIndexOfPoint::indexOf(Geometry *linearGeom, const Coordinate& inputPt)
+LinearLocation LocationIndexOfPoint::indexOf(const Geometry *linearGeom, const Coordinate& inputPt)
 {
 	LocationIndexOfPoint locater(linearGeom);
 	return locater.indexOf(inputPt);
 }
 
-LinearLocation LocationIndexOfPoint::indexOfAfter(Geometry *linearGeom, const Coordinate& inputPt, LinearLocation* minIndex)
+LinearLocation LocationIndexOfPoint::indexOfAfter(const Geometry *linearGeom, const Coordinate& inputPt, LinearLocation* minIndex)
 {
 	LocationIndexOfPoint locater(linearGeom);
 	return locater.indexOfAfter(inputPt, minIndex);
 }
 
-LocationIndexOfPoint::LocationIndexOfPoint(Geometry *linearGeom) :
+LocationIndexOfPoint::LocationIndexOfPoint(const Geometry *linearGeom) :
 		linearGeom(linearGeom)
 {}
 



More information about the geos-commits mailing list