[geos-commits] r2940 - trunk/capi
svn_geos at osgeo.org
svn_geos at osgeo.org
Tue Mar 16 08:32:25 EDT 2010
Author: strk
Date: 2010-03-16 08:32:24 -0400 (Tue, 16 Mar 2010)
New Revision: 2940
Modified:
trunk/capi/geos_ts_c.cpp
Log:
Now that IsValidOp doesn't cache the 'checked' status it is better to trigger a single check rather than two (also fix leaks)
Modified: trunk/capi/geos_ts_c.cpp
===================================================================
--- trunk/capi/geos_ts_c.cpp 2010-03-14 10:13:43 UTC (rev 2939)
+++ trunk/capi/geos_ts_c.cpp 2010-03-16 12:32:24 UTC (rev 2940)
@@ -589,16 +589,16 @@
using geos::operation::valid::TopologyValidationError;
IsValidOp ivo(g1);
- bool valid = ivo.isValid();
- if (!valid)
+ TopologyValidationError *err = ivo.getValidationError();
+ if ( err )
{
- TopologyValidationError *err = ivo.getValidationError();
- if ( err )
- {
- handle->NOTICE_MESSAGE("%s", err->toString().c_str());
- }
+ handle->NOTICE_MESSAGE("%s", err->toString().c_str());
+ return 0;
}
- return valid;
+ else
+ {
+ return 1;
+ }
}
catch (const std::exception &e)
{
@@ -636,17 +636,13 @@
char const* const validstr = "Valid Geometry";
IsValidOp ivo(g1);
- bool isvalid = ivo.isValid();
- if ( ! isvalid )
+ TopologyValidationError *err = ivo.getValidationError();
+ if (0 != err)
{
- TopologyValidationError *err = ivo.getValidationError();
- if (0 != err)
- {
- const std::string errloc = err->getCoordinate().toString();
- std::string errmsg(err->getMessage());
- errmsg += "[" + errloc + "]";
- result = gstrdup(errmsg);
- }
+ const std::string errloc = err->getCoordinate().toString();
+ std::string errmsg(err->getMessage());
+ errmsg += "[" + errloc + "]";
+ result = gstrdup(errmsg);
}
else
{
@@ -689,19 +685,15 @@
using geos::operation::valid::TopologyValidationError;
IsValidOp ivo(g);
- bool isvalid = ivo.isValid();
- if ( ! isvalid )
+ TopologyValidationError *err = ivo.getValidationError();
+ if (0 != err)
{
- TopologyValidationError *err = ivo.getValidationError();
- if (0 != err)
- {
- *location = handle->geomFactory->createPoint(err->getCoordinate());
- std::string errmsg(err->getMessage());
- *reason = gstrdup(errmsg);
- }
- else {
- /* is it ever possible for getValidationError to be 0 ? */
- }
+ *location = handle->geomFactory->createPoint(err->getCoordinate());
+ std::string errmsg(err->getMessage());
+ *reason = gstrdup(errmsg);
+ }
+ else
+ {
return 0; /* invalid */
}
More information about the geos-commits
mailing list