24
24
#include < QDesktopServices>
25
25
26
26
#include " cpl_conv.h"
27
+ #include " gdal.h"
27
28
28
29
// qgis includes...
29
30
#include < qgsrasterlayer.h>
@@ -512,6 +513,7 @@ void TestQgsRasterLayer::buildExternalOverviews()
512
513
QString myResult =
513
514
mypLayer->dataProvider ()->buildPyramids ( myPyramidList, " NEAREST" , myFormatFlag );
514
515
qDebug ( " %s" , myResult.toLocal8Bit ().constData () );
516
+ QVERIFY ( myResult.isEmpty () );
515
517
//
516
518
// Lets verify we have pyramids now...
517
519
//
@@ -526,8 +528,42 @@ void TestQgsRasterLayer::buildExternalOverviews()
526
528
// And that they were indeed in an external file...
527
529
//
528
530
QVERIFY ( QFile::exists ( myTempPath + " landsat.tif.ovr" ) );
531
+
532
+ // cleanup
533
+ delete mypLayer;
534
+
535
+ QFile::remove ( myTempPath + " landsat.tif.ovr" );
536
+ mypLayer = new QgsRasterLayer ( myRasterFileInfo.filePath (),
537
+ myRasterFileInfo.completeBaseName () );
538
+ myPyramidList = mypLayer->dataProvider ()->buildPyramidList ();
539
+ for ( int myCounterInt = 0 ; myCounterInt < myPyramidList.count (); myCounterInt++ )
540
+ {
541
+ // mark to be pyramided
542
+ myPyramidList[myCounterInt].build = true ;
543
+ }
544
+
545
+ // Test with options
546
+ QStringList optionList;
547
+ optionList << " COMPRESS_OVERVIEW=DEFLATE" ;
548
+ optionList << " invalid" ;
549
+
550
+ myResult =
551
+ mypLayer->dataProvider ()->buildPyramids ( myPyramidList, " NEAREST" , myFormatFlag, optionList );
552
+ qDebug ( " %s" , myResult.toLocal8Bit ().constData () );
553
+ QVERIFY ( myResult.isEmpty () );
554
+ QVERIFY ( QFile::exists ( myTempPath + " landsat.tif.ovr" ) );
555
+
529
556
// cleanup
530
557
delete mypLayer;
558
+
559
+ // Check that the overview is Deflate compressed
560
+ QString ovrFilename ( myTempPath + " landsat.tif.ovr" );
561
+ GDALDatasetH hDS = GDALOpen ( ovrFilename.toLocal8Bit ().constData (), GA_ReadOnly );
562
+ QVERIFY ( hDS );
563
+ const char * pszCompression = GDALGetMetadataItem ( hDS, " COMPRESSION" , " IMAGE_STRUCTURE" );
564
+ QVERIFY ( pszCompression && EQUAL ( pszCompression, " DEFLATE" ) );
565
+ GDALClose ( hDS );
566
+
531
567
mReport += " <h2>Check Overviews</h2>\n " ;
532
568
mReport += " <p>Passed</p>" ;
533
569
}
0 commit comments