[geos-commits] r3021 - trunk/capi

svn_geos at osgeo.org svn_geos at osgeo.org
Sat Jun 19 08:42:44 EDT 2010


Author: strk
Date: 2010-06-19 12:42:43 +0000 (Sat, 19 Jun 2010)
New Revision: 3021

Modified:
   trunk/capi/geos_ts_c.cpp
Log:
Handle exceptions in GEOSInterpolate

Modified: trunk/capi/geos_ts_c.cpp
===================================================================
--- trunk/capi/geos_ts_c.cpp	2010-06-19 12:30:29 UTC (rev 3020)
+++ trunk/capi/geos_ts_c.cpp	2010-06-19 12:42:43 UTC (rev 3021)
@@ -5111,11 +5111,7 @@
               const Geometry *g,
               const Geometry *p)
 {
-    if ( 0 == extHandle )
-    {
-        return -1.0;
-    }
-
+    if ( 0 == extHandle ) return -1.0;
     GEOSContextHandleInternal_t *handle = 
         reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
     if ( handle->initialized == 0 ) return -1.0;
@@ -5143,12 +5139,24 @@
 Geometry*
 GEOSInterpolate_r(GEOSContextHandle_t extHandle, const Geometry *g, double d)
 {
-    geos::linearref::LengthIndexedLine lil(g);
-    geos::geom::Coordinate coord = lil.extractPoint(d);
-    GEOSContextHandleInternal_t *handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
-    const GeometryFactory *gf = handle->geomFactory;
-    Geometry* point = gf->createPoint(coord);
-    return point;
+    if ( 0 == extHandle ) return 0;
+    GEOSContextHandleInternal_t *handle = 
+        reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+    if ( handle->initialized == 0 ) return 0;
+
+    try {
+    	geos::linearref::LengthIndexedLine lil(g);
+    	geos::geom::Coordinate coord = lil.extractPoint(d);
+    	const GeometryFactory *gf = handle->geomFactory;
+    	Geometry* point = gf->createPoint(coord);
+    	return point;
+    } catch (const std::exception &e) {
+        handle->ERROR_MESSAGE("%s", e.what());
+        return 0;
+    } catch (...) {
+        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return 0;
+    }
 }
 
 



More information about the geos-commits mailing list