Skip to content
Permalink
Browse files
use double instead of float for min/max values, fixes #4315
  • Loading branch information
blazek authored and alexbruy committed Dec 19, 2011
1 parent 4abade3 commit 8c16e63171a3ea10bf002095a68867a35f0f661f
Showing with 10 additions and 7 deletions.
  1. +10 −7 src/core/raster/qgsrasterlayer.cpp
@@ -484,9 +484,12 @@ void QgsRasterLayer::computeMinimumMaximumFromLastExtent( int theBand, double* t

if ( 0 < theBand && theBand <= ( int ) bandCount() )
{
float myMin = std::numeric_limits<float>::max();
float myMax = -1 * std::numeric_limits<float>::max();
float myValue = 0.0;
// Was there any reason to use float for myMin, myMax, myValue?
// It was breaking Float64 data obviously, especially if an extreme value
// was used for NoDataValue.
double myMin = std::numeric_limits<double>::max();
double myMax = -1 * std::numeric_limits<double>::max();
double myValue = 0.0;
for ( int myRow = 0; myRow < mLastViewPort.drawableAreaYDim; ++myRow )
{
for ( int myColumn = 0; myColumn < mLastViewPort.drawableAreaXDim; ++myColumn )
@@ -2634,17 +2637,17 @@ void QgsRasterLayer::setMinimumMaximumUsingDataset()
if ( rasterType() == QgsRasterLayer::GrayOrUndefined || drawingStyle() == QgsRasterLayer::SingleBandGray || drawingStyle() == QgsRasterLayer::MultiBandSingleBandGray )
{
QgsRasterBandStats myRasterBandStats = bandStatistics( bandNumber( mGrayBandName ) );
float myMin = myRasterBandStats.minimumValue;
float myMax = myRasterBandStats.maximumValue;
double myMin = myRasterBandStats.minimumValue;
double myMax = myRasterBandStats.maximumValue;
setMinimumValue( grayBandName(), myMin );
setMaximumValue( grayBandName(), myMax );
setUserDefinedGrayMinimumMaximum( false );
}
else if ( rasterType() == QgsRasterLayer::Multiband )
{
QgsRasterBandStats myRasterBandStats = bandStatistics( bandNumber( mRedBandName ) );
float myMin = myRasterBandStats.minimumValue;
float myMax = myRasterBandStats.maximumValue;
double myMin = myRasterBandStats.minimumValue;
double myMax = myRasterBandStats.maximumValue;
setMinimumValue( redBandName(), myMin );
setMaximumValue( redBandName(), myMax );

0 comments on commit 8c16e63

Please sign in to comment.