[geos-commits] r3614 - in trunk: src/geomgraph tests/unit/capi

svn_geos at osgeo.org svn_geos at osgeo.org
Thu Apr 12 05:07:02 EDT 2012


Author: strk
Date: 2012-04-12 02:07:02 -0700 (Thu, 12 Apr 2012)
New Revision: 3614

Modified:
   trunk/src/geomgraph/Node.cpp
   trunk/tests/unit/capi/GEOSUnaryUnionTest.cpp
Log:
Throw an exception rather than aborting on NaN overlay input (#530)

Modified: trunk/src/geomgraph/Node.cpp
===================================================================
--- trunk/src/geomgraph/Node.cpp	2012-04-12 09:05:59 UTC (rev 3613)
+++ trunk/src/geomgraph/Node.cpp	2012-04-12 09:07:02 UTC (rev 3614)
@@ -26,6 +26,7 @@
 #include <geos/geomgraph/Label.h>
 #include <geos/geomgraph/DirectedEdge.h>
 #include <geos/geom/Location.h>
+#include <geos/util/IllegalArgumentException.h>
 
 #include <cmath>
 #include <string>
@@ -139,7 +140,12 @@
 	cerr<<"["<<this<<"] Node::add("<<e->print()<<")"<<endl;
 #endif
 	// Assert: start pt of e is equal to node point
-	assert(e->getCoordinate().equals2D(coord));
+	if ( ! e->getCoordinate().equals2D(coord) ) {
+		std::stringstream ss;
+		ss << "EdgeEnd with coordinate " << e->getCoordinate()
+		   << " invalid for node " << coord;
+		throw util::IllegalArgumentException(ss.str());
+  }
 
 	// It seems it's legal for edges to be NULL
 	// we'd not be honouring the promise of adding

Modified: trunk/tests/unit/capi/GEOSUnaryUnionTest.cpp
===================================================================
--- trunk/tests/unit/capi/GEOSUnaryUnionTest.cpp	2012-04-12 09:05:59 UTC (rev 3613)
+++ trunk/tests/unit/capi/GEOSUnaryUnionTest.cpp	2012-04-12 09:07:02 UTC (rev 3614)
@@ -192,5 +192,20 @@
 ));
     }
 
+    // Self-union a geometry with NaN coordinates
+    // See http://trac.osgeo.org/geos/ticket/530
+    template<>
+    template<>
+    void object::test<9>()
+    {
+	const char* hexwkb = "010200000002000000000000000000F8FF000000000000F8FF0000000000000000000000000000F03F";
+        geom1_ = GEOSGeomFromHEX_buf((const unsigned char*)hexwkb, std::strlen(hexwkb));
+        ensure( 0 != geom1_ );
+
+        geom2_ = GEOSUnaryUnion(geom1_);
+	ensure( 0 == geom2_ );
+
+    }
+
 } // namespace tut
 



More information about the geos-commits mailing list