Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Optimise Extract/Select by Location alg
Only create and prepare the GEOS representation for intersection
layer features when we encounter a feature in the target layer
within that feature's bounding box.
Loading branch information
Showing
1 changed file
with
9 additions
and
3 deletions .
+9
−3
src/core/processing/qgsnativealgorithms.cpp
@@ -1422,6 +1422,7 @@ void QgsLocationBasedAlgorithm::process( QgsFeatureSource *targetSource,
double step = intersectSource->featureCount () > 0 ? 100.0 / intersectSource->featureCount () : 1 ;
int current = 0 ;
QgsFeature f;
std::unique_ptr< QgsGeometryEngine > engine;
while ( fIt .nextFeature ( f ) )
{
if ( feedback->isCanceled () )
@@ -1430,10 +1431,9 @@ void QgsLocationBasedAlgorithm::process( QgsFeatureSource *targetSource,
if ( !f.hasGeometry () )
continue ;
std::unique_ptr< QgsGeometryEngine > engine ( QgsGeometry::createGeometryEngine ( f.geometry ().geometry () ) );
engine->prepareGeometry ();
QgsRectangle bbox = f.geometry ().boundingBox ();
engine.reset ();
QgsRectangle bbox = f.geometry ().boundingBox ();
request = QgsFeatureRequest ().setFilterRect ( bbox );
if ( onlyRequireTargetIds )
request.setFlags ( QgsFeatureRequest::NoGeometry ).setSubsetOfAttributes ( QgsAttributeList () );
@@ -1451,6 +1451,12 @@ void QgsLocationBasedAlgorithm::process( QgsFeatureSource *targetSource,
continue ;
}
if ( !engine )
{
engine.reset ( QgsGeometry::createGeometryEngine ( f.geometry ().geometry () ) );
engine->prepareGeometry ();
}
for ( Predicate predicate : qgsAsConst ( predicates ) )
{
bool isMatch = false ;
Toggle all file notes