[geos-commits] r3263 - trunk/capi
svn_geos at osgeo.org
svn_geos at osgeo.org
Fri Mar 4 11:30:55 EST 2011
Author: strk
Date: 2011-03-04 08:30:55 -0800 (Fri, 04 Mar 2011)
New Revision: 3263
Modified:
trunk/capi/geos_c.cpp
trunk/capi/geos_c.h.in
trunk/capi/geos_ts_c.cpp
Log:
GEOSRelateBoundaryNodeRule, ticket #399 [RT-SIGTA]
Modified: trunk/capi/geos_c.cpp
===================================================================
--- trunk/capi/geos_c.cpp 2011-03-04 16:30:48 UTC (rev 3262)
+++ trunk/capi/geos_c.cpp 2011-03-04 16:30:55 UTC (rev 3263)
@@ -201,6 +201,11 @@
return GEOSRelate_r( handle, g1, g2 );
}
+char *
+GEOSRelateBoundaryNodeRule(const Geometry *g1, const Geometry *g2, int bnr)
+{
+ return GEOSRelateBoundaryNodeRule_r( handle, g1, g2, bnr );
+}
//-----------------------------------------------------------------
Modified: trunk/capi/geos_c.h.in
===================================================================
--- trunk/capi/geos_c.h.in 2011-03-04 16:30:48 UTC (rev 3262)
+++ trunk/capi/geos_c.h.in 2011-03-04 16:30:55 UTC (rev 3263)
@@ -497,7 +497,6 @@
extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface(const GEOSGeometry* g1);
extern GEOSGeometry GEOS_DLL *GEOSGetCentroid(const GEOSGeometry* g);
-extern char GEOS_DLL *GEOSRelate(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern GEOSGeometry GEOS_DLL *GEOSEnvelope_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1);
@@ -524,9 +523,6 @@
const GEOSGeometry* g1);
extern GEOSGeometry GEOS_DLL *GEOSGetCentroid_r(GEOSContextHandle_t handle,
const GEOSGeometry* g);
-extern char GEOS_DLL *GEOSRelate_r(GEOSContextHandle_t handle,
- const GEOSGeometry* g1,
- const GEOSGeometry* g2);
/*
* all arguments remain ownership of the caller
@@ -631,8 +627,6 @@
*
***********************************************************************/
-extern char GEOS_DLL GEOSRelatePattern(const GEOSGeometry* g1, const GEOSGeometry* g2, const char *pat);
-extern char GEOS_DLL GEOSRelatePatternMatch(const char* mat, const char *pat);
extern char GEOS_DLL GEOSDisjoint(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSTouches(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSIntersects(const GEOSGeometry* g1, const GEOSGeometry* g2);
@@ -645,13 +639,6 @@
extern char GEOS_DLL GEOSCovers(const GEOSGeometry* g1, const GEOSGeometry* g2);
extern char GEOS_DLL GEOSCoveredBy(const GEOSGeometry* g1, const GEOSGeometry* g2);
-extern char GEOS_DLL GEOSRelatePattern_r(GEOSContextHandle_t handle,
- const GEOSGeometry* g1,
- const GEOSGeometry* g2,
- const char *pat);
-extern char GEOS_DLL GEOSRelatePatternMatch_r(GEOSContextHandle_t handle,
- const char* mat,
- const char *pat);
extern char GEOS_DLL GEOSDisjoint_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
@@ -804,6 +791,52 @@
/************************************************************************
*
+ * Dimensionally Extended 9 Intersection Model related
+ *
+ ***********************************************************************/
+
+/* These are for use with GEOSRelateBoundaryNodeRule (flags param) */
+enum GEOSRelateBoundaryNodeRules {
+ /* MOD2 and OGC are the same rule, and is the default
+ * used by GEOSRelatePattern
+ */
+ GEOSRELATE_BNR_MOD2=1,
+ GEOSRELATE_BNR_OGC=1,
+ GEOSRELATE_BNR_ENDPOINT=2,
+ GEOSRELATE_BNR_MULTIVALENT_ENDPOINT=3,
+ GEOSRELATE_BNR_MONOVALENT_ENDPOINT=4
+};
+
+/* return 2 on exception, 1 on true, 0 on false */
+extern char GEOS_DLL GEOSRelatePattern(const GEOSGeometry* g1, const GEOSGeometry* g2, const char *pat);
+extern char GEOS_DLL GEOSRelatePattern_r(GEOSContextHandle_t handle,
+ const GEOSGeometry* g1,
+ const GEOSGeometry* g2,
+ const char *pat);
+
+/* return NULL on exception, a string to GEOSFree otherwise */
+extern char GEOS_DLL *GEOSRelate(const GEOSGeometry* g1, const GEOSGeometry* g2);
+extern char GEOS_DLL *GEOSRelate_r(GEOSContextHandle_t handle,
+ const GEOSGeometry* g1,
+ const GEOSGeometry* g2);
+
+/* return 2 on exception, 1 on true, 0 on false */
+extern char GEOS_DLL GEOSRelatePatternMatch(const char* mat, const char *pat);
+extern char GEOS_DLL GEOSRelatePatternMatch_r(GEOSContextHandle_t handle,
+ const char* mat,
+ const char *pat);
+
+/* return NULL on exception, a string to GEOSFree otherwise */
+extern char GEOS_DLL *GEOSRelateBoundaryNodeRule(const GEOSGeometry* g1,
+ const GEOSGeometry* g2,
+ int bnr);
+extern char GEOS_DLL *GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t handle,
+ const GEOSGeometry* g1,
+ const GEOSGeometry* g2,
+ int bnr);
+
+/************************************************************************
+ *
* Validity checking
*
***********************************************************************/
Modified: trunk/capi/geos_ts_c.cpp
===================================================================
--- trunk/capi/geos_ts_c.cpp 2011-03-04 16:30:48 UTC (rev 3262)
+++ trunk/capi/geos_ts_c.cpp 2011-03-04 16:30:55 UTC (rev 3263)
@@ -43,6 +43,7 @@
#include <geos/io/WKBWriter.h>
#include <geos/algorithm/distance/DiscreteHausdorffDistance.h>
#include <geos/algorithm/CGAlgorithms.h>
+#include <geos/algorithm/BoundaryNodeRule.h>
#include <geos/simplify/DouglasPeuckerSimplifier.h>
#include <geos/simplify/TopologyPreservingSimplifier.h>
#include <geos/operation/valid/IsValidOp.h>
@@ -53,6 +54,7 @@
#include <geos/operation/buffer/BufferOp.h>
#include <geos/operation/buffer/BufferParameters.h>
#include <geos/operation/buffer/BufferBuilder.h>
+#include <geos/operation/relate/RelateOp.h>
#include <geos/operation/sharedpaths/SharedPathsOp.h>
#include <geos/linearref/LengthIndexedLine.h>
#include <geos/geom/BinaryOp.h>
@@ -675,8 +677,74 @@
return NULL;
}
+char *
+GEOSRelateBoundaryNodeRule_r(GEOSContextHandle_t extHandle, const Geometry *g1, const Geometry *g2, int bnr)
+{
+ if ( 0 == extHandle )
+ {
+ return NULL;
+ }
+ GEOSContextHandleInternal_t *handle = 0;
+ handle = reinterpret_cast<GEOSContextHandleInternal_t*>(extHandle);
+ if ( 0 == handle->initialized )
+ {
+ return NULL;
+ }
+ try
+ {
+ using geos::operation::relate::RelateOp;
+ using geos::geom::IntersectionMatrix;
+ using geos::algorithm::BoundaryNodeRule;
+
+ IntersectionMatrix* im;
+ switch (bnr) {
+ case GEOSRELATE_BNR_MOD2: /* same as OGC */
+ im = RelateOp::relate(g1, g2,
+ BoundaryNodeRule::MOD2_BOUNDARY_RULE);
+ break;
+ case GEOSRELATE_BNR_ENDPOINT:
+ im = RelateOp::relate(g1, g2,
+ BoundaryNodeRule::ENDPOINT_BOUNDARY_RULE);
+ break;
+ case GEOSRELATE_BNR_MULTIVALENT_ENDPOINT:
+ im = RelateOp::relate(g1, g2,
+ BoundaryNodeRule::MULTIVALENT_ENDPOINT_BOUNDARY_RULE);
+ break;
+ case GEOSRELATE_BNR_MONOVALENT_ENDPOINT:
+ im = RelateOp::relate(g1, g2,
+ BoundaryNodeRule::MONOVALENT_ENDPOINT_BOUNDARY_RULE);
+ break;
+ default:
+ handle->ERROR_MESSAGE("Invalid boundary node rule %d", bnr);
+ return 0;
+ break;
+ }
+
+ if (0 == im) return 0;
+
+ char *result = gstrdup(im->toString());
+
+ delete im;
+ im = 0;
+
+ return result;
+ }
+ catch (const std::exception &e)
+ {
+ handle->ERROR_MESSAGE("%s", e.what());
+ }
+ catch (...)
+ {
+ handle->ERROR_MESSAGE("Unknown exception thrown");
+ }
+
+ return NULL;
+}
+
+
+
//-----------------------------------------------------------------
// isValid
//-----------------------------------------------------------------
More information about the geos-commits
mailing list