Skip to content
Permalink
Browse files

[Raster] Do not crash when displaying a raster with complex datatype (f…

…ixes #16405)

That said, complex datatypes are not handled, so QGIS cannot do anything useful
with such datasets.
  • Loading branch information
rouault committed Nov 14, 2017
1 parent 86247cf commit ff683a6e14edf1b1501c721890379908a3ef1d9e
@@ -180,7 +180,10 @@ int QgsContrastEnhancement::enhanceContrast( double theValue )

if ( mLookupTable && NoEnhancement != mContrastEnhancementAlgorithm )
{
return mLookupTable[static_cast <int>( theValue + mLookupTableOffset )];
double shiftedValue = theValue + mLookupTableOffset;
if ( shiftedValue >= 0 && shiftedValue < mRasterDataTypeRange + 1 )
return mLookupTable[static_cast <int>( shiftedValue )];
return 0;
}
else
{
@@ -49,12 +49,8 @@ int QgsContrastEnhancementFunction::enhance( double theValue )
bool QgsContrastEnhancementFunction::isValueInDisplayableRange( double theValue )
{
//A default check is to see if the provided value is with the range for the data type
if ( theValue < QgsContrastEnhancement::minimumValuePossible( mQgsRasterDataType ) || theValue > QgsContrastEnhancement::maximumValuePossible( mQgsRasterDataType ) )
{
return false;
}

return true;
// Write the test as ( v >= min && v <= max ) so that v = NaN returns false
return theValue >= QgsContrastEnhancement::minimumValuePossible( mQgsRasterDataType ) && theValue <= QgsContrastEnhancement::maximumValuePossible( mQgsRasterDataType );
}

void QgsContrastEnhancementFunction::setMaximumValue( double theValue )

0 comments on commit ff683a6

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