[geos-commits] r3623 - trunk/src/geom
svn_geos at osgeo.org
svn_geos at osgeo.org
Tue May 8 14:41:40 EDT 2012
Author: strk
Date: 2012-05-08 11:41:40 -0700 (Tue, 08 May 2012)
New Revision: 3623
Modified:
trunk/src/geom/Geometry.cpp
Log:
Envelope-based short-circuit for Geometry->symDifference (#543)
Modified: trunk/src/geom/Geometry.cpp
===================================================================
--- trunk/src/geom/Geometry.cpp 2012-05-08 18:23:38 UTC (rev 3622)
+++ trunk/src/geom/Geometry.cpp 2012-05-08 18:41:40 UTC (rev 3623)
@@ -606,6 +606,39 @@
if ( isEmpty() ) return other->clone();
if ( other->isEmpty() ) return clone();
+ // if envelopes are disjoint return a MULTI geom or
+ // a geometrycollection
+ if ( ! getEnvelopeInternal()->intersects(other->getEnvelopeInternal()) )
+ {
+ const GeometryCollection *coll;
+
+ size_t ngeomsThis = getNumGeometries();
+ size_t ngeomsOther = other->getNumGeometries();
+
+ // Allocated for ownership transfer
+ vector<Geometry *> *v = new vector<Geometry *>();
+ v->reserve(ngeomsThis+ngeomsOther);
+
+
+ if ( NULL != (coll = dynamic_cast<const GeometryCollection *>(this)) )
+ {
+ for (size_t i=0; i<ngeomsThis; ++i)
+ v->push_back(coll->getGeometryN(i)->clone());
+ } else {
+ v->push_back(this->clone());
+ }
+
+ if ( NULL != (coll = dynamic_cast<const GeometryCollection *>(other)) )
+ {
+ for (size_t i=0; i<ngeomsOther; ++i)
+ v->push_back(coll->getGeometryN(i)->clone());
+ } else {
+ v->push_back(other->clone());
+ }
+
+ return factory->buildGeometry(v);
+ }
+
return BinaryOp(this, other, overlayOp(OverlayOp::opSYMDIFFERENCE)).release();
}
More information about the geos-commits
mailing list