Skip to content

Commit 84232a2

Browse files
MorriganRnyalldawson
authored andcommittedMay 6, 2021
fix N+1 problem for Scale Tool
1 parent bb5871c commit 84232a2

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed
 

‎src/app/qgsmaptoolscalefeature.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,20 @@ void QgsMapToolScaleFeature::applyScaling( double scale )
364364
t.scale( mScaling, mScaling );
365365
t.translate( -layerCoords.x(), -layerCoords.y() );
366366

367-
for ( QgsFeatureId id : std::as_const( mScaledFeatures ) )
367+
QgsFeatureRequest request;
368+
request.setFilterFids( mScaledFeatures ).setNoAttributes();
369+
QgsFeatureIterator fi = vlayer->getFeatures( request );
370+
QgsFeature feat;
371+
while ( fi.nextFeature( feat ) )
368372
{
369-
QgsFeature feat;
370-
vlayer->getFeatures( QgsFeatureRequest().setFilterFid( id ) ).nextFeature( feat );
373+
if ( !feat.hasGeometry() )
374+
continue;
375+
371376
QgsGeometry geom = feat.geometry();
372-
geom.transform( t );
377+
if ( !( geom.transform( t ) == QgsGeometry::Success ) )
378+
continue;
379+
380+
QgsFeatureId id = feat.id();
373381
vlayer->changeGeometry( id, geom );
374382
}
375383

0 commit comments

Comments
 (0)
Please sign in to comment.