[QGIS Commit] r8974 - trunk/qgis/tests/src/core
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Aug 2 01:34:30 EDT 2008
Author: timlinux
Date: 2008-08-02 01:34:30 -0400 (Sat, 02 Aug 2008)
New Revision: 8974
Modified:
trunk/qgis/tests/src/core/testqgsrasterlayer.cpp
Log:
Added unit test for raster external overlay building
Modified: trunk/qgis/tests/src/core/testqgsrasterlayer.cpp
===================================================================
--- trunk/qgis/tests/src/core/testqgsrasterlayer.cpp 2008-08-01 22:29:05 UTC (rev 8973)
+++ trunk/qgis/tests/src/core/testqgsrasterlayer.cpp 2008-08-02 05:34:30 UTC (rev 8974)
@@ -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 @@
void landsatBasic();
void landsatBasic875Qml();
void checkDimensions();
+ void buildExternalOverviews();
private:
bool render(QString theFileName);
bool setQml (QString theType);
@@ -154,6 +156,54 @@
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";
More information about the QGIS-commit
mailing list