Skip to content
Permalink
Browse files
Added unit test for raster external overlay building
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8974 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Aug 2, 2008
1 parent 030f920 commit 998b61599be3c71edb81d4c70c4b06e1607dd75a
Showing with 50 additions and 0 deletions.
  1. +50 −0 tests/src/core/testqgsrasterlayer.cpp
@@ -29,6 +29,7 @@

//qgis includes...
#include <qgsrasterlayer.h>
#include <qgsrasterpyramid.h>
#include <qgsrasterbandstats.h>
#include <qgsmaplayerregistry.h>
#include <qgsapplication.h>
@@ -55,6 +56,7 @@ class TestQgsRasterLayer: public QObject
void landsatBasic();
void landsatBasic875Qml();
void checkDimensions();
void buildExternalOverviews();
private:
bool render(QString theFileName);
bool setQml (QString theType);
@@ -154,6 +156,54 @@ void TestQgsRasterLayer::checkDimensions()
QVERIFY ( mpRasterLayer->getRasterBandStats(1).elementCount == 100 );
}

void TestQgsRasterLayer::buildExternalOverviews()
{
//before we begin delete any old ovr file (if it exists)
//and make a copy of the landsat raster into the temp dir

QString myTempPath = QDir::tempPath() + QDir::separator();
QFile::remove( myTempPath + "landsat.tif.ovr" );
QFile::copy( mTestDataDir + "landsat.tif" , myTempPath + "landsat.tif" );
QFileInfo myRasterFileInfo ( myTempPath + "landsat.tif" );
QgsRasterLayer * mypLayer = new QgsRasterLayer ( myRasterFileInfo.filePath(),
myRasterFileInfo.completeBaseName() );


//
// Ok now we can go on to test
//

bool myInternalFlag = false;
QgsRasterLayer::RasterPyramidList myPyramidList = mypLayer->buildRasterPyramidList();
for ( int myCounterInt = 0; myCounterInt < myPyramidList.count(); myCounterInt++ )
{
//mark to be pyramided
myPyramidList[myCounterInt].existsFlag=true;
}
//now actually make the pyramids
QString myResult = mypLayer->buildPyramids(
myPyramidList,
"NEAREST",
myInternalFlag
);
qDebug (myResult.toLocal8Bit());
//
// Lets verify we have pyramids now...
//
myPyramidList = mypLayer->buildRasterPyramidList();
for ( int myCounterInt = 0; myCounterInt < myPyramidList.count(); myCounterInt++ )
{
//mark to be pyramided
QVERIFY(myPyramidList.at(myCounterInt).existsFlag);
}

//
// And that they were indeed in an external file...
//
QVERIFY(QFile::exists(myTempPath + "landsat.tif.ovr"));
//cleanup
delete mypLayer;
}
bool TestQgsRasterLayer::render(QString theTestType)
{
mReport += "<h2>" + theTestType + "</h2>\n";

0 comments on commit 998b615

Please sign in to comment.