[geos-commits] r3198 - in trunk: include/geos/geom src/geom
svn_geos at osgeo.org
svn_geos at osgeo.org
Thu Feb 10 16:05:16 EST 2011
Author: strk
Date: 2011-02-10 13:05:16 -0800 (Thu, 10 Feb 2011)
New Revision: 3198
Modified:
trunk/include/geos/geom/Geometry.h
trunk/src/geom/Geometry.cpp
Log:
Expose unary union trought Geometry.Union()
Modified: trunk/include/geos/geom/Geometry.h
===================================================================
--- trunk/include/geos/geom/Geometry.h 2011-02-10 21:05:06 UTC (rev 3197)
+++ trunk/include/geos/geom/Geometry.h 2011-02-10 21:05:16 UTC (rev 3198)
@@ -4,7 +4,7 @@
* GEOS - Geometry Engine Open Source
* http://geos.refractions.net
*
- * Copyright (C) 2009 Sandro Santilli <strk at keybit.net>
+ * Copyright (C) 2009 2011 Sandro Santilli <strk at keybit.net>
* Copyright (C) 2005 2006 Refractions Research Inc.
* Copyright (C) 2001-2002 Vivid Solutions Inc.
*
@@ -597,9 +597,29 @@
* non-empty GeometryCollection
*
*/
- virtual Geometry* Union(const Geometry *other) const;
+ Geometry* Union(const Geometry *other) const;
// throw(IllegalArgumentException *, TopologyException *);
+ /**
+ * Computes the union of all the elements of this geometry. Heterogeneous
+ * {@link GeometryCollection}s are fully supported.
+ *
+ * The result obeys the following contract:
+ *
+ * - Unioning a set of {@link LineString}s has the effect of fully noding
+ * and dissolving the linework.
+ * - Unioning a set of {@link Polygon}s will always
+ * return a {@link Polygonal} geometry (unlike {link #union(Geometry)},
+ * which may return geometrys of lower dimension if a topology collapse
+ * occurred.
+ *
+ * @return the union geometry
+ *
+ * @see UnaryUnionOp
+ */
+ AutoPtr Union() const;
+ // throw(IllegalArgumentException *, TopologyException *);
+
/**
* \brief
* Returns a Geometry representing the points making up this
Modified: trunk/src/geom/Geometry.cpp
===================================================================
--- trunk/src/geom/Geometry.cpp 2011-02-10 21:05:06 UTC (rev 3197)
+++ trunk/src/geom/Geometry.cpp 2011-02-10 21:05:16 UTC (rev 3198)
@@ -4,7 +4,7 @@
* GEOS - Geometry Engine Open Source
* http://geos.refractions.net
*
- * Copyright (C) 2009 Sandro Santilli <strk at keybit.net>
+ * Copyright (C) 2009 2011 Sandro Santilli <strk at keybit.net>
* Copyright (C) 2005-2006 Refractions Research Inc.
* Copyright (C) 2001-2002 Vivid Solutions Inc.
*
@@ -46,6 +46,7 @@
#include <geos/operation/relate/RelateOp.h>
#include <geos/operation/valid/IsValidOp.h>
#include <geos/operation/overlay/OverlayOp.h>
+#include <geos/operation/union/UnaryUnionOp.h>
#include <geos/operation/overlay/snap/SnapIfNeededOverlayOp.h>
#include <geos/operation/buffer/BufferOp.h>
#include <geos/operation/distance/DistanceOp.h>
@@ -587,6 +588,14 @@
return SnapIfNeededOverlayOp::overlayOp(*this, *other, OverlayOp::opUNION).release();
}
+/* public */
+Geometry::AutoPtr
+Geometry::Union() const
+{
+ using geos::operation::geounion::UnaryUnionOp;
+ return UnaryUnionOp::Union(*this);
+}
+
Geometry*
Geometry::difference(const Geometry *other) const
//throw(IllegalArgumentException *)
@@ -643,7 +652,7 @@
//throw(IllegalArgumentException *)
{
if ((typeid(*g)==typeid(GeometryCollection))) {
- throw util::IllegalArgumentException("This method does not support GeometryCollection arguments\n");
+ throw geos::util::IllegalArgumentException("This method does not support GeometryCollection arguments\n");
}
}
More information about the geos-commits
mailing list