Skip to content

Commit

Permalink
[core] Fix QgsMapSettingsUtils::worldFileParameters function not taki…
Browse files Browse the repository at this point in the history
…ng device pixel ratio into account
  • Loading branch information
nirvn committed Mar 11, 2024
1 parent 12bc994 commit 3925a5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/qgsmapsettingsutils.cpp
Expand Up @@ -93,11 +93,11 @@ void QgsMapSettingsUtils::worldFileParameters( const QgsMapSettings &mapSettings

// scaling matrix
double s[6];
s[0] = ms.mapUnitsPerPixel();
s[0] = ms.mapUnitsPerPixel() / ms.devicePixelRatio();
s[1] = 0;
s[2] = xOrigin;
s[3] = 0;
s[4] = -ms.mapUnitsPerPixel();
s[4] = -ms.mapUnitsPerPixel() / ms.devicePixelRatio();
s[5] = yOrigin;

// rotation matrix
Expand Down
10 changes: 10 additions & 0 deletions tests/src/core/testqgsmapsettingsutils.cpp
Expand Up @@ -66,6 +66,16 @@ void TestQgsMapSettingsUtils::createWorldFileContent()

mMapSettings.setRotation( 145 );
QCOMPARE( QgsMapSettingsUtils::worldFileContent( mMapSettings ), QString( "-0.81915204428899191\r\n0.57357643635104594\r\n0.57357643635104594\r\n0.81915204428899191\r\n0.5\r\n0.49999999999999994\r\n" ) );

mMapSettings.setRotation( 0 );
mMapSettings.setDevicePixelRatio( 2.0 );
QgsMapSettingsUtils::worldFileParameters( mMapSettings, a, b, c, d, e, f );
QCOMPARE( a, 0.5 );
QCOMPARE( b, 0.0 );
QCOMPARE( c, 0.5 );
QCOMPARE( d, 0.0 );
QCOMPARE( e, -0.5 );
QCOMPARE( f, 0.5 );
}

void TestQgsMapSettingsUtils::containsAdvancedEffects()
Expand Down

0 comments on commit 3925a5a

Please sign in to comment.