mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Added unit test for raster external overlay building
git-svn-id: http://svn.osgeo.org/qgis/trunk@8974 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
1a21e1856d
commit
342b4ce7ea
@ -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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user