Skip to content

Commit 7df062b

Browse files
committedMay 10, 2018
Updates from Nyall's review
1 parent aa2b1e9 commit 7df062b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed
 

‎src/analysis/processing/qgsoverlayutils.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ void QgsOverlayUtils::resolveOverlaps( const QgsFeatureSource &source, QgsFeatur
270270
requestOnlyIds.setFlags( QgsFeatureRequest::NoGeometry );
271271
requestOnlyIds.setSubsetOfAttributes( QgsAttributeList() );
272272

273-
// make a set of used feature IDs so they we do not try to reuse them for newly added features
273+
// make a set of used feature IDs so that we do not try to reuse them for newly added features
274274
QgsFeature f;
275275
QSet<QgsFeatureId> fids;
276276
QgsFeatureIterator it = source.getFeatures( requestOnlyIds );
@@ -296,6 +296,7 @@ void QgsOverlayUtils::resolveOverlaps( const QgsFeatureSource &source, QgsFeatur
296296

297297
QgsFeatureId fid1 = f.id();
298298
QgsGeometry g1 = f.geometry();
299+
std::unique_ptr< QgsGeometryEngine > g1engine;
299300

300301
geometries.insert( fid1, g1 );
301302
index.insertFeature( f );
@@ -307,8 +308,15 @@ void QgsOverlayUtils::resolveOverlaps( const QgsFeatureSource &source, QgsFeatur
307308
if ( fid1 == fid2 )
308309
continue;
309310

311+
if ( !g1engine )
312+
{
313+
// use prepared geometries for faster intersection tests
314+
g1engine.reset( QgsGeometry::createGeometryEngine( g1.constGet() ) );
315+
g1engine->prepareGeometry();
316+
}
317+
310318
QgsGeometry g2 = geometries.value( fid2 );
311-
if ( !g1.intersects( g2 ) )
319+
if ( !g1engine->intersects( g2.constGet() ) )
312320
continue;
313321

314322
QgsGeometry geomIntersection = g1.intersection( g2 );
@@ -384,6 +392,7 @@ void QgsOverlayUtils::resolveOverlaps( const QgsFeatureSource &source, QgsFeatur
384392

385393
// update our temporary copy of the geometry to what is left from it
386394
g1 = g12;
395+
g1engine.reset();
387396
}
388397

389398
++count;

‎src/analysis/processing/qgsoverlayutils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace QgsOverlayUtils
5050
* 2. a feature with geometry B - A with B's attributes
5151
* 3. two features with geometry intersection(A, B) - one with A's attributes, one with B's attributes.
5252
*
53-
* As a result, for all pairs of features in the output, a pair either havs no common interior or their interior is the same.
53+
* As a result, for all pairs of features in the output, a pair either has no common interior or their interior is the same.
5454
*/
5555
void resolveOverlaps( const QgsFeatureSource &source, QgsFeatureSink &sink, QgsProcessingFeedback *feedback );
5656
}

0 commit comments

Comments
 (0)
Please sign in to comment.