Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixes ticket #832 Raster cell coount returns incorrect value
Added regression test to raster layer unit test


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7650 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Nov 23, 2007
1 parent 36f261a commit cef0582
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -2945,6 +2945,7 @@ const QgsRasterBandStats QgsRasterLayer::getRasterBandStats(int theBandNoInt)
myFirstIterationFlag = false;
myRasterBandStats.minValDouble = myDouble;
myRasterBandStats.maxValDouble = myDouble;
++myRasterBandStats.elementCountInt;
} //end of true part for first iteration check
else
{
Expand Down
11 changes: 10 additions & 1 deletion tests/src/core/testqgsrasterlayer.cpp
Expand Up @@ -24,6 +24,7 @@

//qgis includes...
#include <qgsrasterlayer.h>
#include <qgsrasterbandstats.h>
#include <qgsapplication.h>

/** \ingroup UnitTests
Expand All @@ -39,7 +40,7 @@ class TestQgsRasterLayer: public QObject
void cleanup(){};// will be called after every testfunction.

void isValid();

void checkDimensions();
private:
QgsRasterLayer * mpLayer;
};
Expand Down Expand Up @@ -71,6 +72,14 @@ void TestQgsRasterLayer::isValid()
{
QVERIFY ( mpLayer->isValid() );
}
void TestQgsRasterLayer::checkDimensions()
{
QVERIFY ( mpLayer->getRasterXDim() == 10 );
QVERIFY ( mpLayer->getRasterYDim() == 10 );
// regression check for ticket #832
// note getRasterBandStats call is base 1
QVERIFY ( mpLayer->getRasterBandStats(1).elementCountInt == 100 );
}

QTEST_MAIN(TestQgsRasterLayer)
#include "moc_testqgsrasterlayer.cxx"
Expand Down

0 comments on commit cef0582

Please sign in to comment.