Skip to content
Permalink
Browse files

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 375ab0ea6d96b23dfa5b37d8321ef244de994734
Showing with 16 additions and 3 deletions.
  1. +16 −3 src/app/qgsmaptoolmovefeature.cpp
@@ -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() )
{
@@ -208,7 +221,7 @@ void QgsMapToolMoveFeature::cadCanvasReleaseEvent( QgsMapMouseEvent *e )
mSnapIndicator->setMatch( QgsPointLocator::Match() );
cadDockWidget()->clear();
break;

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

0 comments on commit 375ab0e

Please sign in to comment.