[geos-commits] r3019 - trunk/src/linearref

svn_geos at osgeo.org svn_geos at osgeo.org
Sat Jun 19 08:28:31 EDT 2010


Author: strk
Date: 2010-06-19 12:28:31 +0000 (Sat, 19 Jun 2010)
New Revision: 3019

Modified:
   trunk/src/linearref/LinearLocation.cpp
Log:
Handle illegal argument to LinearLocation::getCoordinate

Modified: trunk/src/linearref/LinearLocation.cpp
===================================================================
--- trunk/src/linearref/LinearLocation.cpp	2010-06-19 12:20:18 UTC (rev 3018)
+++ trunk/src/linearref/LinearLocation.cpp	2010-06-19 12:28:31 UTC (rev 3019)
@@ -22,6 +22,7 @@
 #include <geos/linearref/LengthIndexedLine.h>
 #include <geos/linearref/LinearLocation.h>
 #include <geos/linearref/LengthLocationMap.h>
+#include <geos/util/IllegalArgumentException.h>
 
 using namespace std;
 
@@ -201,6 +202,9 @@
 LinearLocation::getCoordinate(const Geometry* linearGeom) const
 {
 	const LineString* lineComp = dynamic_cast<const LineString *> (linearGeom->getGeometryN(componentIndex));
+	if ( ! lineComp ) {
+		throw util::IllegalArgumentException("LinearLocation::getCoordinate only works with LineString geometries");
+	}  
 	Coordinate p0 = lineComp->getCoordinateN(segmentIndex);
 	if (segmentIndex >= lineComp->getNumPoints() - 1)
 		return p0;



More information about the geos-commits mailing list