[geos-commits] r2938 - in trunk: capi tests/unit/capi

svn_geos at osgeo.org svn_geos at osgeo.org
Sat Mar 13 17:07:18 EST 2010


Author: strk
Date: 2010-03-13 17:07:17 -0500 (Sat, 13 Mar 2010)
New Revision: 2938

Modified:
   trunk/capi/geos_ts_c.cpp
   trunk/tests/unit/capi/GEOSOrientationIndex.cpp
Log:
Fix GEOSOrientationIndex implementation and testcase. Closes ticket #335.


Modified: trunk/capi/geos_ts_c.cpp
===================================================================
--- trunk/capi/geos_ts_c.cpp	2010-03-12 07:54:45 UTC (rev 2937)
+++ trunk/capi/geos_ts_c.cpp	2010-03-13 22:07:17 UTC (rev 2938)
@@ -4811,9 +4811,11 @@
     }
 }
 
-int GEOSOrientationIndex_r(GEOSContextHandle_t /*handle*/,
+int GEOSOrientationIndex_r(GEOSContextHandle_t extHandle,
 	double Ax, double Ay, double Bx, double By, double Px, double Py)
 {
+    GEOSContextHandleInternal_t *handle = 0;
+
     using geos::geom::Coordinate;
     using geos::algorithm::CGAlgorithms;
 
@@ -4822,7 +4824,6 @@
         return 2;
     }
 
-    GEOSContextHandleInternal_t *handle = 0;
     handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
     if ( 0 == handle->initialized )
     {
@@ -4835,11 +4836,17 @@
         Coordinate B(Bx, By);
         Coordinate P(Px, Py);
         return CGAlgorithms::orientationIndex(A, B, P);
-    catch (...)
+    }
+    catch (const std::exception &e)
     {
         handle->ERROR_MESSAGE("%s", e.what());
         return 2;
     }
+    catch (...)
+    {
+        handle->ERROR_MESSAGE("Unknown exception thrown");
+        return 2;
+    }
 }
 
 

Modified: trunk/tests/unit/capi/GEOSOrientationIndex.cpp
===================================================================
--- trunk/tests/unit/capi/GEOSOrientationIndex.cpp	2010-03-12 07:54:45 UTC (rev 2937)
+++ trunk/tests/unit/capi/GEOSOrientationIndex.cpp	2010-03-13 22:07:17 UTC (rev 2938)
@@ -61,7 +61,7 @@
     template<>
     void object::test<1>()
     {
-	int ret = GEOSOrientationIndex(0, 0, 10, 0, 5, 0);
+	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 5, 0);
 	ensure_equals(ret, 0);
     }
 
@@ -70,7 +70,7 @@
     template<>
     void object::test<2>()
     {
-	int ret = GEOSOrientationIndex(0, 0, 10, 0, 10, 0);
+	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 10, 0);
 	ensure_equals(ret, 0);
     }
 
@@ -79,7 +79,7 @@
     template<>
     void object::test<3>()
     {
-	int ret = GEOSOrientationIndex(0, 0, 10, 0, 0, 0);
+	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 0, 0);
 	ensure_equals(ret, 0);
     }
 
@@ -88,7 +88,7 @@
     template<>
     void object::test<4>()
     {
-	int ret = GEOSOrientationIndex(0, 0, 10, 0, -5, 0);
+	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, -5, 0);
 	ensure_equals(ret, 0);
     }
 
@@ -97,7 +97,7 @@
     template<>
     void object::test<5>()
     {
-	int ret = GEOSOrientationIndex(0, 0, 10, 0, 20, 0);
+	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 0, 20, 0);
 	ensure_equals(ret, 0);
     }
 
@@ -106,7 +106,7 @@
     template<>
     void object::test<6>()
     {
-	int ret = GEOSOrientationIndex(0, 0, 10, 10, 5, 6);
+	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, 6);
 	ensure_equals(ret, 1);
     }
 
@@ -115,7 +115,7 @@
     template<>
     void object::test<7>()
     {
-	int ret = GEOSOrientationIndex(0, 0, 10, 10, 5, 20);
+	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, 20);
 	ensure_equals(ret, 1);
     }
 
@@ -124,7 +124,7 @@
     template<>
     void object::test<8>()
     {
-	int ret = GEOSOrientationIndex(0, 0, 10, 10, 5, 3);
+	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, 3);
 	ensure_equals(ret, -1);
     }
 
@@ -133,7 +133,7 @@
     template<>
     void object::test<9>()
     {
-	int ret = GEOSOrientationIndex(0, 0, 10, 10, 5, -2);
+	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 5, -2);
 	ensure_equals(ret, -1);
     }
 
@@ -142,7 +142,7 @@
     template<>
     void object::test<10>()
     {
-	int ret = GEOSOrientationIndex(0, 0, 10, 10, 1000000, 1000001);
+	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 1000000, 1000001);
 	ensure_equals(ret, 1);
     }
 
@@ -151,7 +151,7 @@
     template<>
     void object::test<11>()
     {
-	int ret = GEOSOrientationIndex(0, 0, 10, 10, 1000000,  999999);
+	int ret = GEOSOrientationIndex_r(handle_, 0, 0, 10, 10, 1000000,  999999);
 	ensure_equals(ret, -1);
     }
 



More information about the geos-commits mailing list