Skip to content
Permalink
Browse files

Fix build on Travis

(cherry-picked from 9259d60)
  • Loading branch information
nyalldawson committed Jul 20, 2018
1 parent 237af60 commit 39f23eb884631710369008ee05bd7394d021854e
Showing with 12 additions and 12 deletions.
  1. +12 −12 tests/src/core/testqgsrasterlayer.cpp
@@ -388,8 +388,8 @@ void TestQgsRasterLayer::checkStats()
QCOMPARE( mpRasterLayer->width(), 10 );
QCOMPARE( mpRasterLayer->height(), 10 );
//QCOMPARE( myStatistics.elementCount, 100 );
QCOMPARE( myStatistics.minimumValue, 0 );
QCOMPARE( myStatistics.maximumValue, 9 );
QCOMPARE( myStatistics.minimumValue, 0.0 );
QCOMPARE( myStatistics.maximumValue, 9.0 );
QGSCOMPARENEAR( myStatistics.mean, 4.5, 4 * std::numeric_limits<double>::epsilon() );
double stdDev = 2.87228132326901431;
// TODO: verify why GDAL stdDev is so different from generic (2.88675)
@@ -402,37 +402,37 @@ void TestQgsRasterLayer::checkStats()
QgsRasterBandStats::Min | QgsRasterBandStats::Max |
QgsRasterBandStats::Mean | QgsRasterBandStats::StdDev, QgsRectangle( 1535400, 5083280, 1535450, 5083320 ) );

QCOMPARE( myStatistics.minimumValue, 2 );
QCOMPARE( myStatistics.maximumValue, 7 );
QCOMPARE( myStatistics.minimumValue, 2.0 );
QCOMPARE( myStatistics.maximumValue, 7.0 );
QGSCOMPARENEAR( myStatistics.mean, 4.5, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( myStatistics.stdDev, 1.507557, 0.00001 );

// with sample size
myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1,
QgsRasterBandStats::Min | QgsRasterBandStats::Max |
QgsRasterBandStats::Mean | QgsRasterBandStats::StdDev, QgsRectangle( 1535400, 5083280, 1535450, 5083320 ), 10 );
QCOMPARE( myStatistics.minimumValue, 2 );
QCOMPARE( myStatistics.maximumValue, 7 );
QCOMPARE( myStatistics.elementCount, 12 );
QCOMPARE( myStatistics.minimumValue, 2.0 );
QCOMPARE( myStatistics.maximumValue, 7.0 );
QCOMPARE( myStatistics.elementCount, 12ULL );
QGSCOMPARENEAR( myStatistics.mean, 4.5, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( myStatistics.stdDev, 2.153222, 0.00001 );

// extremely limited extent - ~1 px size
myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1,
QgsRasterBandStats::Min | QgsRasterBandStats::Max |
QgsRasterBandStats::Mean | QgsRasterBandStats::StdDev, QgsRectangle( 1535400, 5083280, 1535412, 5083288 ) );
QCOMPARE( myStatistics.minimumValue, 2 );
QCOMPARE( myStatistics.maximumValue, 3 );
QCOMPARE( myStatistics.minimumValue, 2.0 );
QCOMPARE( myStatistics.maximumValue, 3.0 );
QGSCOMPARENEAR( myStatistics.mean, 2.600000, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( myStatistics.stdDev, 0.492366, 0.00001 );

// extremely limited extent - ~1 px size - with sample size
myStatistics = mpRasterLayer->dataProvider()->bandStatistics( 1,
QgsRasterBandStats::Min | QgsRasterBandStats::Max |
QgsRasterBandStats::Mean | QgsRasterBandStats::StdDev, QgsRectangle( 1535400, 5083280, 1535412, 5083288 ), 6 );
QCOMPARE( myStatistics.minimumValue, 2 );
QCOMPARE( myStatistics.maximumValue, 3 );
QCOMPARE( myStatistics.elementCount, 2 );
QCOMPARE( myStatistics.minimumValue, 2.0 );
QCOMPARE( myStatistics.maximumValue, 3.0 );
QCOMPARE( myStatistics.elementCount, 2ULL );
QGSCOMPARENEAR( myStatistics.mean, 2.500000, 4 * std::numeric_limits<double>::epsilon() );
QGSCOMPARENEAR( myStatistics.stdDev, 0.707107, 0.00001 );
}

0 comments on commit 39f23eb

Please sign in to comment.
You can’t perform that action at this time.