Skip to content

Commit

Permalink
Updates from Nyall's review
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed May 10, 2018
1 parent aa2b1e9 commit 7df062b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/analysis/processing/qgsoverlayutils.cpp
Expand Up @@ -270,7 +270,7 @@ void QgsOverlayUtils::resolveOverlaps( const QgsFeatureSource &source, QgsFeatur
requestOnlyIds.setFlags( QgsFeatureRequest::NoGeometry );
requestOnlyIds.setSubsetOfAttributes( QgsAttributeList() );

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

QgsFeatureId fid1 = f.id();
QgsGeometry g1 = f.geometry();
std::unique_ptr< QgsGeometryEngine > g1engine;

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

if ( !g1engine )
{
// use prepared geometries for faster intersection tests
g1engine.reset( QgsGeometry::createGeometryEngine( g1.constGet() ) );
g1engine->prepareGeometry();
}

QgsGeometry g2 = geometries.value( fid2 );
if ( !g1.intersects( g2 ) )
if ( !g1engine->intersects( g2.constGet() ) )
continue;

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

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

++count;
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/processing/qgsoverlayutils.h
Expand Up @@ -50,7 +50,7 @@ namespace QgsOverlayUtils
* 2. a feature with geometry B - A with B's attributes
* 3. two features with geometry intersection(A, B) - one with A's attributes, one with B's attributes.
*
* As a result, for all pairs of features in the output, a pair either havs no common interior or their interior is the same.
* As a result, for all pairs of features in the output, a pair either has no common interior or their interior is the same.
*/
void resolveOverlaps( const QgsFeatureSource &source, QgsFeatureSink &sink, QgsProcessingFeedback *feedback );
}
Expand Down

0 comments on commit 7df062b

Please sign in to comment.