[geos-commits] r3622 - in branches/3.3: . src/geom
svn_geos at osgeo.org
svn_geos at osgeo.org
Tue May 8 14:23:38 EDT 2012
Author: strk
Date: 2012-05-08 11:23:38 -0700 (Tue, 08 May 2012)
New Revision: 3622
Modified:
branches/3.3/NEWS
branches/3.3/src/geom/Geometry.cpp
Log:
Envelope-based short-circuit for Geometry->symDifference (#543)
Modified: branches/3.3/NEWS
===================================================================
--- branches/3.3/NEWS 2012-05-08 17:39:21 UTC (rev 3621)
+++ branches/3.3/NEWS 2012-05-08 18:23:38 UTC (rev 3622)
@@ -6,6 +6,7 @@
- Reduce CommonBitsRemover harmful effects during overlay op (#527)
- Better cross-compiler support (#534)
- Enable overlay ops short-circuits (#542)
+ - Envelope-based short-circuit for symDifference (#543)
Changes in 3.3.3
2012-04-01
Modified: branches/3.3/src/geom/Geometry.cpp
===================================================================
--- branches/3.3/src/geom/Geometry.cpp 2012-05-08 17:39:21 UTC (rev 3621)
+++ branches/3.3/src/geom/Geometry.cpp 2012-05-08 18:23:38 UTC (rev 3622)
@@ -607,6 +607,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