[geos-commits] r3221 - in trunk: capi tests/unit/capi
svn_geos at osgeo.org
svn_geos at osgeo.org
Tue Feb 15 10:24:37 EST 2011
Author: strk
Date: 2011-02-15 07:24:36 -0800 (Tue, 15 Feb 2011)
New Revision: 3221
Modified:
trunk/capi/geos_ts_c.cpp
trunk/tests/unit/capi/GEOSisValidDetailTest.cpp
Log:
Allow passing NULL for "reason" and "location" arguments of GEOSisValidDetail [RT-SIGTA]
Modified: trunk/capi/geos_ts_c.cpp
===================================================================
--- trunk/capi/geos_ts_c.cpp 2011-02-15 15:15:15 UTC (rev 3220)
+++ trunk/capi/geos_ts_c.cpp 2011-02-15 15:24:36 UTC (rev 3221)
@@ -13,7 +13,7 @@
* See the COPYING file for more information.
*
* Author: Sandro Santilli <strk at refractions.net>
- * Thread Safety modifications: Chuck Thibert <charles.thibert at ingres.com>
+ * Thread Safety modifications: Chuck Thibert <charles.thibert at ingres.com>
*
***********************************************************************/
@@ -741,14 +741,18 @@
TopologyValidationError *err = ivo.getValidationError();
if (0 != err)
{
- *location = handle->geomFactory->createPoint(err->getCoordinate());
- std::string errmsg(err->getMessage());
- *reason = gstrdup(errmsg);
- return 0;
+ if ( location ) {
+ *location = handle->geomFactory->createPoint(err->getCoordinate());
+ }
+ if ( reason ) {
+ std::string errmsg(err->getMessage());
+ *reason = gstrdup(errmsg);
+ }
+ return 0;
}
- *location = 0;
- *reason = 0;
+ if ( location ) *location = 0;
+ if ( reason ) *reason = 0;
return 1; /* valid */
}
Modified: trunk/tests/unit/capi/GEOSisValidDetailTest.cpp
===================================================================
--- trunk/tests/unit/capi/GEOSisValidDetailTest.cpp 2011-02-15 15:15:15 UTC (rev 3220)
+++ trunk/tests/unit/capi/GEOSisValidDetailTest.cpp 2011-02-15 15:24:36 UTC (rev 3221)
@@ -104,7 +104,7 @@
{
geom_ = GEOSGeomFromWKT("LINESTRING(0 0, 10 0, NaN -5)");
int r = GEOSisValidDetail(geom_, 0, &reason_, &loc_);
- ensure_equals(r, 0); // valid
+ ensure_equals(r, 0); // invalid
ensure_equals(std::string(reason_), std::string("Invalid Coordinate"));
ensure_equals(toWKT(loc_), "POINT (nan -5)");
}
@@ -116,7 +116,7 @@
{
geom_ = GEOSGeomFromWKT("POLYGON((0 1, -10 10, 10 10, 0 1, 4 6, -4 6, 0 1))");
int r = GEOSisValidDetail(geom_, 0, &reason_, &loc_);
- ensure_equals(r, 0); // valid
+ ensure_equals(r, 0); // invalid
ensure_equals(std::string(reason_), std::string("Ring Self-intersection"));
ensure_equals(toWKT(loc_), "POINT (0 1)");
}
@@ -135,5 +135,15 @@
ensure_equals(loc_, (void*)0);
}
+ // Check it is possible to not request details
+ template<>
+ template<>
+ void object::test<6>()
+ {
+ geom_ = GEOSGeomFromWKT("POLYGON((0 1, -10 10, 10 10, 0 1, 4 6, -4 6, 0 1))");
+ int r = GEOSisValidDetail(geom_, 0, 0, 0);
+ ensure_equals(r, 0); // invalid
+ }
+
} // namespace tut
More information about the geos-commits
mailing list