mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
parent
8a5924d0f1
commit
a2ba566e2b
@ -87,7 +87,7 @@ QString QgsMapSettingsUtils::worldFileContent( const QgsMapSettings &mapSettings
|
|||||||
s[1] = 0;
|
s[1] = 0;
|
||||||
s[2] = xOrigin;
|
s[2] = xOrigin;
|
||||||
s[3] = 0;
|
s[3] = 0;
|
||||||
s[4] = ms.mapUnitsPerPixel();
|
s[4] = -ms.mapUnitsPerPixel();
|
||||||
s[5] = yOrigin;
|
s[5] = yOrigin;
|
||||||
|
|
||||||
// rotation matrix
|
// rotation matrix
|
||||||
@ -104,7 +104,9 @@ QString QgsMapSettingsUtils::worldFileContent( const QgsMapSettings &mapSettings
|
|||||||
double b = r[0] * s[1] + r[1] * s[4];
|
double b = r[0] * s[1] + r[1] * s[4];
|
||||||
double c = r[0] * s[2] + r[1] * s[5] + r[2];
|
double c = r[0] * s[2] + r[1] * s[5] + r[2];
|
||||||
double d = r[3] * s[0] + r[4] * s[3];
|
double d = r[3] * s[0] + r[4] * s[3];
|
||||||
double e = r[3] * s[1] + r[4] * s[4];
|
// Pixel YDim - almost always negative
|
||||||
|
// See https://en.wikipedia.org/wiki/World_file#cite_ref-3, https://issues.qgis.org/issues/18491
|
||||||
|
double e = r[3] * s[1] + r[4] * s[4];
|
||||||
double f = r[3] * s[2] + r[4] * s[5] + r[5];
|
double f = r[3] * s[2] + r[4] * s[5] + r[5];
|
||||||
|
|
||||||
QString content;
|
QString content;
|
||||||
@ -113,10 +115,9 @@ QString QgsMapSettingsUtils::worldFileContent( const QgsMapSettings &mapSettings
|
|||||||
// Rotation on y axis
|
// Rotation on y axis
|
||||||
content += qgsDoubleToString( d ) + "\r\n";
|
content += qgsDoubleToString( d ) + "\r\n";
|
||||||
// Rotation on x axis
|
// Rotation on x axis
|
||||||
content += qgsDoubleToString( -b ) + "\r\n";
|
content += qgsDoubleToString( b ) + "\r\n";
|
||||||
// Pixel YDim - almost always negative
|
// Pixel YDim
|
||||||
// See https://en.wikipedia.org/wiki/World_file#cite_ref-3
|
content += qgsDoubleToString( e ) + "\r\n";
|
||||||
content += "-" + qgsDoubleToString( e ) + "\r\n";
|
|
||||||
// Origin X (center of top left cell)
|
// Origin X (center of top left cell)
|
||||||
content += qgsDoubleToString( c ) + "\r\n";
|
content += qgsDoubleToString( c ) + "\r\n";
|
||||||
// Origin Y (center of top left cell)
|
// Origin Y (center of top left cell)
|
||||||
|
@ -52,6 +52,9 @@ void TestQgsMapSettingsUtils::createWorldFileContent()
|
|||||||
|
|
||||||
mMapSettings.setRotation( 45 );
|
mMapSettings.setRotation( 45 );
|
||||||
QCOMPARE( QgsMapSettingsUtils::worldFileContent( mMapSettings ), QString( "0.70710678118654757\r\n0.70710678118654746\r\n0.70710678118654746\r\n-0.70710678118654757\r\n0.5\r\n0.49999999999999994\r\n" ) );
|
QCOMPARE( QgsMapSettingsUtils::worldFileContent( mMapSettings ), QString( "0.70710678118654757\r\n0.70710678118654746\r\n0.70710678118654746\r\n-0.70710678118654757\r\n0.5\r\n0.49999999999999994\r\n" ) );
|
||||||
|
|
||||||
|
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" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QGSTEST_MAIN( TestQgsMapSettingsUtils )
|
QGSTEST_MAIN( TestQgsMapSettingsUtils )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user