Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 8c16e63
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/core/raster/qgsrasterlayer.cpp
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 );

Expand Down

0 comments on commit 8c16e63

Please sign in to comment.