Skip to content

Commit 50f86c8

Browse files
Hugo Merciermhugent
Hugo Mercier
authored andcommitted
Add unit test for world file generation
1 parent 387c88d commit 50f86c8

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

tests/src/core/testqgscomposermap.cpp

+21-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class TestQgsComposerMap: public QObject
4242
void uniqueId(); //test if map id is adapted when doing copy paste
4343
void zebraStyle(); //test zebra map border style
4444
void overviewMapCenter(); //test if centering of overview map frame works
45+
void worldFileGeneration(); // test world file generation
4546

4647
private:
4748
QgsComposition* mComposition;
@@ -84,7 +85,6 @@ void TestQgsComposerMap::cleanupTestCase()
8485

8586
void TestQgsComposerMap::init()
8687
{
87-
8888
}
8989

9090
void TestQgsComposerMap::cleanup()
@@ -235,5 +235,25 @@ void TestQgsComposerMap::overviewMapCenter()
235235
mComposition->removeComposerItem( overviewMapCenter );
236236
QVERIFY( testResult );
237237
}
238+
239+
void TestQgsComposerMap::worldFileGeneration()
240+
{
241+
mComposerMap->setNewExtent( QgsRectangle( 781662.375, 3339523.125, 793062.375, 3345223.125 ) );
242+
mComposerMap->setRotation( 30.0 );
243+
244+
mComposition->setGenerateWorldFile( true );
245+
mComposition->setWorldFileMap( mComposerMap );
246+
247+
double params[6];
248+
mComposition->computeWorldFileParameters( params );
249+
250+
QVERIFY( fabs(params[0] - 4.18048) < 0.001 );
251+
QVERIFY( fabs(params[1] - 2.41331) < 0.001 );
252+
QVERIFY( fabs(params[2] - 779444) < 1 );
253+
QVERIFY( fabs(params[3] - 2.4136) < 0.001 );
254+
QVERIFY( fabs(params[4] + 4.17997) < 0.001 );
255+
QVERIFY( fabs(params[5] - 3.34241e+06) < 1e+03 );
256+
}
257+
238258
QTEST_MAIN( TestQgsComposerMap )
239259
#include "moc_testqgscomposermap.cxx"

0 commit comments

Comments
 (0)