[geos-commits] r2251 - in trunk: capi
source/headers/geos/operation/union source/operation/union
svn_geos at osgeo.org
svn_geos at osgeo.org
Mon Jan 19 20:01:24 EST 2009
Author: pramsey
Date: 2009-01-19 20:01:24 -0500 (Mon, 19 Jan 2009)
New Revision: 2251
Modified:
trunk/capi/geos_c.cpp
trunk/capi/geos_c.h.in
trunk/capi/geos_ts_c.cpp
trunk/source/headers/geos/operation/union/CascadedPolygonUnion.h
trunk/source/operation/union/CascadedPolygonUnion.cpp
Log:
Add GEOSUnionCascaded(*GEOSGeometry) to CAPI in preparation for PostGIS hook-up.
Modified: trunk/capi/geos_c.cpp
===================================================================
--- trunk/capi/geos_c.cpp 2009-01-19 23:55:24 UTC (rev 2250)
+++ trunk/capi/geos_c.cpp 2009-01-20 01:01:24 UTC (rev 2251)
@@ -22,6 +22,7 @@
#include <geos/io/WKBWriter.h>
#include <geos/io/CLocalizer.h>
#include <geos/operation/overlay/OverlayOp.h>
+#include <geos/operation/union/CascadedPolygonUnion.h>
// Some extra magic to make type declarations in geos_c.h work - for cross-checking of types in header.
#define GEOSGeometry geos::geom::Geometry
@@ -60,7 +61,9 @@
using geos::operation::overlay::OverlayOp;
using geos::operation::overlay::overlayOp;
+using geos::operation::geounion::CascadedPolygonUnion;
+
typedef std::auto_ptr<Geometry> GeomAutoPtr;
//## GLOBALS ################################################
@@ -331,6 +334,11 @@
return GEOSUnion_r( handle, g1, g2 );
}
+Geometry *
+GEOSUnionCascaded(const Geometry *g1)
+{
+ return GEOSUnionCascaded_r( handle, g1 );
+}
Geometry *
GEOSPointOnSurface(const Geometry *g1)
Modified: trunk/capi/geos_c.h.in
===================================================================
--- trunk/capi/geos_c.h.in 2009-01-19 23:55:24 UTC (rev 2250)
+++ trunk/capi/geos_c.h.in 2009-01-20 01:01:24 UTC (rev 2251)
@@ -390,6 +390,8 @@
const GEOSGeometry* g2);
extern GEOSGeometry GEOS_DLL *GEOSBoundary(const GEOSGeometry* g1);
extern GEOSGeometry GEOS_DLL *GEOSUnion(const GEOSGeometry* g1, const GEOSGeometry* g2);
+extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded(const GEOSGeometry* g1);
+
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);
@@ -415,6 +417,7 @@
extern GEOSGeometry GEOS_DLL *GEOSUnion_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1,
const GEOSGeometry* g2);
+extern GEOSGeometry GEOS_DLL *GEOSUnionCascaded_r(GEOSContextHandle_t handle, const GEOSGeometry* g1);
extern GEOSGeometry GEOS_DLL *GEOSPointOnSurface_r(GEOSContextHandle_t handle,
const GEOSGeometry* g1);
extern GEOSGeometry GEOS_DLL *GEOSGetCentroid_r(GEOSContextHandle_t handle,
Modified: trunk/capi/geos_ts_c.cpp
===================================================================
--- trunk/capi/geos_ts_c.cpp 2009-01-19 23:55:24 UTC (rev 2250)
+++ trunk/capi/geos_ts_c.cpp 2009-01-20 01:01:24 UTC (rev 2251)
@@ -42,6 +42,7 @@
#include <geos/operation/polygonize/Polygonizer.h>
#include <geos/operation/linemerge/LineMerger.h>
#include <geos/operation/overlay/OverlayOp.h>
+#include <geos/operation/union/CascadedPolygonUnion.h>
#include <geos/geom/BinaryOp.h>
#include <geos/version.h>
@@ -94,6 +95,7 @@
using geos::operation::overlay::OverlayOp;
using geos::operation::overlay::overlayOp;
+using geos::operation::geounion::CascadedPolygonUnion;
typedef std::auto_ptr<Geometry> GeomAutoPtr;
@@ -1496,7 +1498,44 @@
}
}
+Geometry *
+GEOSUnionCascaded_r(GEOSContextHandle_t extHandle, const Geometry *g1)
+{
+ GEOSContextHandleInternal_t *handle;
+ if( extHandle == NULL )
+ {
+ return NULL;
+ }
+
+ handle = (GEOSContextHandleInternal_t*)extHandle;
+ if( handle->initialized == 0 )
+ {
+ return NULL;
+ }
+
+ try{
+ const geos::geom::MultiPolygon *p = dynamic_cast<const geos::geom::MultiPolygon *>(g1);
+ if ( ! p )
+ {
+ handle->ERROR_MESSAGE("Invalid argument (must be a MultiPolygon)");
+ return NULL;
+ }
+ using geos::operation::geounion::CascadedPolygonUnion;
+ return CascadedPolygonUnion::Union(p);
+ }
+ catch (const std::exception &e)
+ {
+ handle->ERROR_MESSAGE("%s", e.what());
+ return NULL;
+ }
+ catch (...)
+ {
+ handle->ERROR_MESSAGE("Unknown exception thrown");
+ return NULL;
+ }
+}
+
Geometry *
GEOSPointOnSurface_r(GEOSContextHandle_t extHandle, const Geometry *g1)
{
@@ -1520,7 +1559,7 @@
{
const GeometryFactory *gf;
gf=handle->geomFactory;
-
+ // return an empty collection
return gf->createGeometryCollection();
}
return ret;
Modified: trunk/source/headers/geos/operation/union/CascadedPolygonUnion.h
===================================================================
--- trunk/source/headers/geos/operation/union/CascadedPolygonUnion.h 2009-01-19 23:55:24 UTC (rev 2250)
+++ trunk/source/headers/geos/operation/union/CascadedPolygonUnion.h 2009-01-20 01:01:24 UTC (rev 2251)
@@ -127,7 +127,7 @@
*
* @param polys a collection of {@link Polygonal} {@link Geometry}s
*/
- static geom::Geometry* Union(geom::MultiPolygon* polys);
+ static geom::Geometry* Union(const geom::MultiPolygon* polys);
/**
* Creates a new instance to union
Modified: trunk/source/operation/union/CascadedPolygonUnion.cpp
===================================================================
--- trunk/source/operation/union/CascadedPolygonUnion.cpp 2009-01-19 23:55:24 UTC (rev 2250)
+++ trunk/source/operation/union/CascadedPolygonUnion.cpp 2009-01-20 01:01:24 UTC (rev 2251)
@@ -38,7 +38,7 @@
return op.Union();
}
-geom::Geometry* CascadedPolygonUnion::Union(geom::MultiPolygon* multipoly)
+geom::Geometry* CascadedPolygonUnion::Union(const geom::MultiPolygon* multipoly)
{
std::vector<geom::Polygon*> polys;
More information about the geos-commits
mailing list