Skip to content

Commit

Permalink
Short-circuit for empty layers
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros authored and nyalldawson committed Nov 29, 2021
1 parent de44380 commit 7b5cd9b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/analysis/processing/qgsalgorithmextractbylocation.cpp
Expand Up @@ -83,9 +83,17 @@ void QgsLocationBasedAlgorithm::process( const QgsProcessingContext &context, Qg
QgsProcessingFeedback *feedback,
const QgsFeatureIds &skipTargetFeatureIds )
{
// skip if there are no features to select from!
if ( targetSource->featureCount() == 0 )
return;

if ( targetSource->featureCount() > 0 && intersectSource->featureCount() > 0
&& targetSource->featureCount() < intersectSource->featureCount() )
// skip if intersect layer is empty, unless we are looking for disjoints
if ( intersectSource->featureCount() == 0 &&
!selectedPredicates.contains( Disjoint ) )
return;

if ( targetSource->featureCount() > 0 && intersectSource->featureCount() > 0 &&
targetSource->featureCount() < intersectSource->featureCount() )
{
// joining FEWER features to a layer with MORE features. So we iterate over the FEW features and find matches from the MANY
processByIteratingOverTargetSource( context, targetSource, intersectSource,
Expand Down

0 comments on commit 7b5cd9b

Please sign in to comment.