Skip to content
Permalink
Browse files
Fix off-by-one calculation of element sum (raster stats).
git-svn-id: http://svn.osgeo.org/qgis/trunk@14069 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mmassing committed Aug 12, 2010
1 parent 5dfa6e6 commit 2843a939e2e2f58e4f16f21fccaf023f54cb4a8b
Showing with 2 additions and 4 deletions.
  1. +2 −4 src/core/raster/qgsrasterlayer.cpp
@@ -824,14 +824,15 @@ const QgsRasterBandStats QgsRasterLayer::bandStatistics( int theBandNo )
continue; // NULL
}

myRasterBandStats.sum += myValue;
++myRasterBandStats.elementCount;
//only use this element if we have a non null element
if ( myFirstIterationFlag )
{
//this is the first iteration so initialise vars
myFirstIterationFlag = false;
myRasterBandStats.minimumValue = myValue;
myRasterBandStats.maximumValue = myValue;
++myRasterBandStats.elementCount;
} //end of true part for first iteration check
else
{
@@ -844,9 +845,6 @@ const QgsRasterBandStats QgsRasterLayer::bandStatistics( int theBandNo )
{
myRasterBandStats.maximumValue = myValue;
}

myRasterBandStats.sum += myValue;
++myRasterBandStats.elementCount;
} //end of false part for first iteration check
}
}

0 comments on commit 2843a93

Please sign in to comment.