Skip to content

Commit

Permalink
fix N+1 problem for Scale Tool
Browse files Browse the repository at this point in the history
  • Loading branch information
MorriganR authored and nyalldawson committed May 6, 2021
1 parent bb5871c commit 84232a2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/app/qgsmaptoolscalefeature.cpp
Expand Up @@ -364,12 +364,20 @@ void QgsMapToolScaleFeature::applyScaling( double scale )
t.scale( mScaling, mScaling );
t.translate( -layerCoords.x(), -layerCoords.y() );

for ( QgsFeatureId id : std::as_const( mScaledFeatures ) )
QgsFeatureRequest request;
request.setFilterFids( mScaledFeatures ).setNoAttributes();
QgsFeatureIterator fi = vlayer->getFeatures( request );
QgsFeature feat;
while ( fi.nextFeature( feat ) )
{
QgsFeature feat;
vlayer->getFeatures( QgsFeatureRequest().setFilterFid( id ) ).nextFeature( feat );
if ( !feat.hasGeometry() )
continue;

QgsGeometry geom = feat.geometry();
geom.transform( t );
if ( !( geom.transform( t ) == QgsGeometry::Success ) )
continue;

QgsFeatureId id = feat.id();
vlayer->changeGeometry( id, geom );
}

Expand Down

0 comments on commit 84232a2

Please sign in to comment.