Skip to content

Commit

Permalink
Fix scale tool on different map crs
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros committed Apr 26, 2021
1 parent b6e354f commit a734477
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/app/qgsmaptoolscalefeature.cpp
Expand Up @@ -317,15 +317,16 @@ void QgsMapToolScaleFeature::updateRubberband( double scale )
{
mScaling = scale;

QTransform t;
t.translate( mFeatureCenterMapCoords.x(), mFeatureCenterMapCoords.y() );
t.scale( mScaling, mScaling );
t.translate( -mFeatureCenterMapCoords.x(), -mFeatureCenterMapCoords.y() );

QgsVectorLayer *vlayer = currentVectorLayer();
if ( !vlayer )
return;

QgsPointXY layerCoords = toLayerCoordinates( vlayer, mFeatureCenterMapCoords );
QTransform t;
t.translate( layerCoords.x(), layerCoords.y() );
t.scale( mScaling, mScaling );
t.translate( -layerCoords.x(), -layerCoords.y() );

mRubberBand->reset( vlayer->geometryType() );
for ( const QgsGeometry &originalGeometry : mOriginalGeometries )
{
Expand Down Expand Up @@ -355,10 +356,11 @@ void QgsMapToolScaleFeature::applyScaling( double scale )

vlayer->beginEditCommand( tr( "Features Scaled" ) );

QgsPointXY layerCoords = toLayerCoordinates( vlayer, mFeatureCenterMapCoords );
QTransform t;
t.translate( mFeatureCenterMapCoords.x(), mFeatureCenterMapCoords.y() );
t.translate( layerCoords.x(), layerCoords.y() );
t.scale( mScaling, mScaling );
t.translate( -mFeatureCenterMapCoords.x(), -mFeatureCenterMapCoords.y() );
t.translate( -layerCoords.x(), -layerCoords.y() );

for ( QgsFeatureId id : std::as_const( mScaledFeatures ) )
{
Expand Down

0 comments on commit a734477

Please sign in to comment.