Skip to content

Commit

Permalink
Added unit test for raster external overlay building
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@8974 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Aug 2, 2008
1 parent 1a21e18 commit 342b4ce
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/src/core/testqgsrasterlayer.cpp
Expand Up @@ -29,6 +29,7 @@

//qgis includes...
#include <qgsrasterlayer.h>
#include <qgsrasterpyramid.h>
#include <qgsrasterbandstats.h>
#include <qgsmaplayerregistry.h>
#include <qgsapplication.h>
Expand All @@ -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);
Expand Down Expand Up @@ -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";
Expand Down

0 comments on commit 342b4ce

Please sign in to comment.