[geos-commits] r2226 - trunk/capi
svn_geos at osgeo.org
svn_geos at osgeo.org
Wed Nov 26 14:06:56 EST 2008
Author: pramsey
Date: 2008-11-26 14:06:56 -0500 (Wed, 26 Nov 2008)
New Revision: 2226
Modified:
trunk/capi/geos_c.cpp
trunk/capi/geos_c.h.in
Log:
Expose GEOSIsValidReason to CAPI
Modified: trunk/capi/geos_c.cpp
===================================================================
--- trunk/capi/geos_c.cpp 2008-11-21 00:26:46 UTC (rev 2225)
+++ trunk/capi/geos_c.cpp 2008-11-26 19:06:56 UTC (rev 2226)
@@ -372,6 +372,7 @@
}
return result;
}
+
catch (const std::exception &e)
{
@@ -387,7 +388,47 @@
}
+char *
+GEOSisValidReason(const Geometry *g1)
+{
+ using geos::operation::valid::IsValidOp;
+ using geos::operation::valid::TopologyValidationError;
+ IsValidOp ivo(g1);
+ try {
+ char *result = NULL;
+ bool isvalid = ivo.isValid();
+ if ( ! isvalid )
+ {
+ int msglen = 0;
+ int loclen = 0;
+ TopologyValidationError *err = ivo.getValidationError();
+ std::string errmsg = err->getMessage();
+ std::string errloc = err->getCoordinate().toString();
+ msglen = errmsg.length();
+ loclen = errloc.length();
+ result = (char*)std::malloc(msglen + loclen + 3);
+ sprintf(result, "%s [%s]", errmsg.c_str(), errloc.c_str());
+ }
+ else {
+ result = strdup( "Valid Geometry" );
+ }
+ return result;
+ }
+ catch (const std::exception &e)
+ {
+ ERROR_MESSAGE("%s", e.what());
+ return NULL;
+ }
+
+ catch (...)
+ {
+ ERROR_MESSAGE("Unknown exception thrown");
+ return NULL;
+ }
+
+}
+
//-----------------------------------------------------------------
// general purpose
//-----------------------------------------------------------------
Modified: trunk/capi/geos_c.h.in
===================================================================
--- trunk/capi/geos_c.h.in 2008-11-21 00:26:46 UTC (rev 2225)
+++ trunk/capi/geos_c.h.in 2008-11-26 19:06:56 UTC (rev 2226)
@@ -348,6 +348,7 @@
extern char GEOS_DLL GEOSisEmpty(const GEOSGeometry* g1);
extern char GEOS_DLL GEOSisValid(const GEOSGeometry* g1);
+extern char GEOS_DLL *GEOSisValidReason(const GEOSGeometry *g1);
extern char GEOS_DLL GEOSisSimple(const GEOSGeometry* g1);
extern char GEOS_DLL GEOSisRing(const GEOSGeometry* g1);
extern char GEOS_DLL GEOSHasZ(const GEOSGeometry* g1);
More information about the geos-commits
mailing list