8 changes: 3 additions & 5 deletions src/providers/gdal/qgsgdalprovider.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,10 @@ class QgsGdalProvider : public QgsRasterDataProvider
QStringList subLayers() const;
static QStringList subLayers( GDALDatasetH dataset );

/** \brief If the provider supports it, return band stats for the
given band.
@note added in QGIS 1.7
@note overloads virtual method from QgsRasterProvider::bandStatistics
bool hasStatistics( int theBandNo,
const QgsRectangle & theExtent = QgsRectangle(),
int theSampleSize = 0 );

*/
QgsRasterBandStats bandStatistics( int theBandNo,
const QgsRectangle & theExtent = QgsRectangle(),
int theSampleSize = 0 );
Expand Down
13 changes: 7 additions & 6 deletions tests/src/core/testqgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,20 @@ void TestQgsRasterLayer::checkDimensions()
QVERIFY( mpRasterLayer->height() == 10 );
// regression check for ticket #832
// note bandStatistics call is base 1
QVERIFY( mpRasterLayer->bandStatistics( 1 ).elementCount == 100 );
QVERIFY( mpRasterLayer->dataProvider()->bandStatistics( 1 ).elementCount == 100 );
mReport += "<h2>Check Dimensions</h2>\n";
mReport += "<p>Passed</p>";
}
void TestQgsRasterLayer::checkStats()
{
QgsRasterBandStats myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1 );
QVERIFY( mpRasterLayer->width() == 10 );
QVERIFY( mpRasterLayer->height() == 10 );
QVERIFY( mpRasterLayer->bandStatistics( 1 ).elementCount == 100 );
QVERIFY( mpRasterLayer->bandStatistics( 1 ).minimumValue == 0 );
QVERIFY( mpRasterLayer->bandStatistics( 1 ).maximumValue == 9 );
QVERIFY( mpRasterLayer->bandStatistics( 1 ).mean == 4.5 );
QVERIFY( fabs( mpRasterLayer->bandStatistics( 1 ).stdDev - 2.87228132326901431 )
QVERIFY( myStatistics.elementCount == 100 );
QVERIFY( myStatistics.minimumValue == 0 );
QVERIFY( myStatistics.maximumValue == 9 );
QVERIFY( myStatistics.mean == 4.5 );
QVERIFY( fabs( myStatistics.stdDev - 2.87228132326901431 )
< 0.0000000000000001 );
mReport += "<h2>Check Stats</h2>\n";
mReport += "<p>Passed</p>";
Expand Down