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@14069 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mmassing committed Aug 12, 2010
1 parent 5dfa6e6 commit 2843a93
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 2843a93

Please sign in to comment.