Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Optimise Move Features tool
Avoid multiple requests for features when moving many features at once
  • Loading branch information
MorriganR committed Mar 29, 2021
1 parent 468e134 commit 375ab0e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/app/qgsmaptoolmovefeature.cpp
Expand Up @@ -190,9 +190,22 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
switch ( mMode )
{
case Move:
for ( QgsFeatureId id : std::as_const( mMovedFeatures ) )
{
QgsFeatureRequest request;
request.setFilterFids( mMovedFeatures ).setNoAttributes();
QgsFeatureIterator fi = vlayer->getFeatures( request );
QgsFeature f;
while ( fi.nextFeature( f ) )
{
vlayer->translateFeature( id, dx, dy );
if ( !f.hasGeometry() )
continue;

QgsGeometry geom = f.geometry();
if ( !( geom.translate( dx, dy ) == QgsGeometry::Success ) )
continue;

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

if ( QgsProject::instance()->topologicalEditing() )
{
Expand All @@ -208,7 +221,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
mSnapIndicator->setMatch( QgsPointLocator::Match() );
cadDockWidget()->clear();
break;

}
case CopyMove:
QgsFeatureRequest request;
request.setFilterFids( mMovedFeatures );
Expand Down

0 comments on commit 375ab0e

Please sign in to comment.