Skip to content
Permalink
Browse files

avoid creating a histogram without range (fixes #11217)

  • Loading branch information
jef-n committed Oct 16, 2014
1 parent d05b039 commit 086b262e41d3969daef149c2ccd2eca2ecd9a4ab
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/core/raster/qgsrasterinterface.cpp
@@ -517,17 +517,20 @@ void QgsRasterInterface::cumulativeCut( int theBandNo,

int mySrcDataType = srcDataType( theBandNo );

// Init to NaN is better than histogram min/max to catch errors
theLowerValue = std::numeric_limits<double>::quiet_NaN();
theUpperValue = std::numeric_limits<double>::quiet_NaN();

//get band stats to specify real histogram min/max (fix #9793 Byte bands)
QgsRasterBandStats stats = bandStatistics( theBandNo, QgsRasterBandStats::Min, theExtent, theSampleSize );
if( stats.maximumValue < stats.minimumValue )
return;

// for byte bands make sure bin count == actual range
int myBinCount = ( mySrcDataType == QGis::Byte ) ? int( ceil( stats.maximumValue - stats.minimumValue + 1 ) ) : 0;
QgsRasterHistogram myHistogram = histogram( theBandNo, myBinCount, stats.minimumValue, stats.maximumValue, theExtent, theSampleSize );
//QgsRasterHistogram myHistogram = histogram( theBandNo, 0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), theExtent, theSampleSize );

// Init to NaN is better than histogram min/max to catch errors
theLowerValue = std::numeric_limits<double>::quiet_NaN();
theUpperValue = std::numeric_limits<double>::quiet_NaN();

double myBinXStep = ( myHistogram.maximum - myHistogram.minimum ) / myHistogram.binCount;
int myCount = 0;
int myMinCount = ( int ) qRound( theLowerCount * myHistogram.nonNullCount );

0 comments on commit 086b262

Please sign in to comment.
You can’t perform that action at this time.