29
29
30
30
// qgis includes...
31
31
#include < qgsrasterlayer.h>
32
+ #include < qgsrasterpyramid.h>
32
33
#include < qgsrasterbandstats.h>
33
34
#include < qgsmaplayerregistry.h>
34
35
#include < qgsapplication.h>
@@ -55,6 +56,7 @@ class TestQgsRasterLayer: public QObject
55
56
void landsatBasic ();
56
57
void landsatBasic875Qml ();
57
58
void checkDimensions ();
59
+ void buildExternalOverviews ();
58
60
private:
59
61
bool render (QString theFileName);
60
62
bool setQml (QString theType);
@@ -154,6 +156,54 @@ void TestQgsRasterLayer::checkDimensions()
154
156
QVERIFY ( mpRasterLayer->getRasterBandStats (1 ).elementCount == 100 );
155
157
}
156
158
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
+ }
157
207
bool TestQgsRasterLayer::render (QString theTestType)
158
208
{
159
209
mReport += " <h2>" + theTestType + " </h2>\n " ;
0 commit comments