Skip to content

Commit 342b4ce

Browse files
author
timlinux
committed
Added unit test for raster external overlay building
git-svn-id: http://svn.osgeo.org/qgis/trunk@8974 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1a21e18 commit 342b4ce

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/src/core/testqgsrasterlayer.cpp

+50
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
//qgis includes...
3131
#include <qgsrasterlayer.h>
32+
#include <qgsrasterpyramid.h>
3233
#include <qgsrasterbandstats.h>
3334
#include <qgsmaplayerregistry.h>
3435
#include <qgsapplication.h>
@@ -55,6 +56,7 @@ class TestQgsRasterLayer: public QObject
5556
void landsatBasic();
5657
void landsatBasic875Qml();
5758
void checkDimensions();
59+
void buildExternalOverviews();
5860
private:
5961
bool render(QString theFileName);
6062
bool setQml (QString theType);
@@ -154,6 +156,54 @@ void TestQgsRasterLayer::checkDimensions()
154156
QVERIFY ( mpRasterLayer->getRasterBandStats(1).elementCount == 100 );
155157
}
156158

159+
void TestQgsRasterLayer::buildExternalOverviews()
160+
{
161+
//before we begin delete any old ovr file (if it exists)
162+
//and make a copy of the landsat raster into the temp dir
163+
164+
QString myTempPath = QDir::tempPath() + QDir::separator();
165+
QFile::remove( myTempPath + "landsat.tif.ovr" );
166+
QFile::copy( mTestDataDir + "landsat.tif" , myTempPath + "landsat.tif" );
167+
QFileInfo myRasterFileInfo ( myTempPath + "landsat.tif" );
168+
QgsRasterLayer * mypLayer = new QgsRasterLayer ( myRasterFileInfo.filePath(),
169+
myRasterFileInfo.completeBaseName() );
170+
171+
172+
//
173+
// Ok now we can go on to test
174+
//
175+
176+
bool myInternalFlag = false;
177+
QgsRasterLayer::RasterPyramidList myPyramidList = mypLayer->buildRasterPyramidList();
178+
for ( int myCounterInt = 0; myCounterInt < myPyramidList.count(); myCounterInt++ )
179+
{
180+
//mark to be pyramided
181+
myPyramidList[myCounterInt].existsFlag=true;
182+
}
183+
//now actually make the pyramids
184+
QString myResult = mypLayer->buildPyramids(
185+
myPyramidList,
186+
"NEAREST",
187+
myInternalFlag
188+
);
189+
qDebug (myResult.toLocal8Bit());
190+
//
191+
// Lets verify we have pyramids now...
192+
//
193+
myPyramidList = mypLayer->buildRasterPyramidList();
194+
for ( int myCounterInt = 0; myCounterInt < myPyramidList.count(); myCounterInt++ )
195+
{
196+
//mark to be pyramided
197+
QVERIFY(myPyramidList.at(myCounterInt).existsFlag);
198+
}
199+
200+
//
201+
// And that they were indeed in an external file...
202+
//
203+
QVERIFY(QFile::exists(myTempPath + "landsat.tif.ovr"));
204+
//cleanup
205+
delete mypLayer;
206+
}
157207
bool TestQgsRasterLayer::render(QString theTestType)
158208
{
159209
mReport += "<h2>" + theTestType + "</h2>\n";

0 commit comments

Comments
 (0)