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 020972c commit b861db47f58b8488966f41232ed0d2a637d93159
@@ -175,7 +175,10 @@ int QgsContrastEnhancement::enhanceContrast( double value )

if ( mLookupTable && NoEnhancement != mContrastEnhancementAlgorithm )
{
return mLookupTable[static_cast <int>( value + mLookupTableOffset )];
double shiftedValue = value + mLookupTableOffset;
if ( shiftedValue >= 0 && shiftedValue < mRasterDataTypeRange + 1 )
return mLookupTable[static_cast <int>( shiftedValue )];
return 0;
}
else
{
@@ -50,7 +50,8 @@ int QgsContrastEnhancementFunction::enhance( double value )
bool QgsContrastEnhancementFunction::isValueInDisplayableRange( double value )
{
//A default check is to see if the provided value is with the range for the data type
return !( value < QgsContrastEnhancement::minimumValuePossible( mQgsRasterDataType ) || value > QgsContrastEnhancement::maximumValuePossible( mQgsRasterDataType ) );
// Write the test as ( v >= min && v <= max ) so that v = NaN returns false
return value >= QgsContrastEnhancement::minimumValuePossible( mQgsRasterDataType ) && value <= QgsContrastEnhancement::maximumValuePossible( mQgsRasterDataType );
}

void QgsContrastEnhancementFunction::setMaximumValue( double value )

0 comments on commit b861db4

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