Skip to content

Commit 2843a93

Browse files
author
mmassing
committedAug 12, 2010
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
1 parent 5dfa6e6 commit 2843a93

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed
 

‎src/core/raster/qgsrasterlayer.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -824,14 +824,15 @@ const QgsRasterBandStats QgsRasterLayer::bandStatistics( int theBandNo )
824824
continue; // NULL
825825
}
826826

827+
myRasterBandStats.sum += myValue;
828+
++myRasterBandStats.elementCount;
827829
//only use this element if we have a non null element
828830
if ( myFirstIterationFlag )
829831
{
830832
//this is the first iteration so initialise vars
831833
myFirstIterationFlag = false;
832834
myRasterBandStats.minimumValue = myValue;
833835
myRasterBandStats.maximumValue = myValue;
834-
++myRasterBandStats.elementCount;
835836
} //end of true part for first iteration check
836837
else
837838
{
@@ -844,9 +845,6 @@ const QgsRasterBandStats QgsRasterLayer::bandStatistics( int theBandNo )
844845
{
845846
myRasterBandStats.maximumValue = myValue;
846847
}
847-
848-
myRasterBandStats.sum += myValue;
849-
++myRasterBandStats.elementCount;
850848
} //end of false part for first iteration check
851849
}
852850
}

0 commit comments

Comments
 (0)
Please sign in to comment.