Skip to content

Commit

Permalink
Fix off-by-one calculation of element sum (raster stats).
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14069 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mmassing committed Aug 12, 2010
1 parent c9902b7 commit 1c804db
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/core/raster/qgsrasterlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
}
}
Expand Down

0 comments on commit 1c804db

Please sign in to comment.