File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -180,7 +180,10 @@ int QgsContrastEnhancement::enhanceContrast( double theValue )
180
180
181
181
if ( mLookupTable && NoEnhancement != mContrastEnhancementAlgorithm )
182
182
{
183
- return mLookupTable [static_cast <int >( theValue + mLookupTableOffset )];
183
+ double shiftedValue = theValue + mLookupTableOffset ;
184
+ if ( shiftedValue >= 0 && shiftedValue < mRasterDataTypeRange + 1 )
185
+ return mLookupTable [static_cast <int >( shiftedValue )];
186
+ return 0 ;
184
187
}
185
188
else
186
189
{
Original file line number Diff line number Diff line change @@ -49,12 +49,8 @@ int QgsContrastEnhancementFunction::enhance( double theValue )
49
49
bool QgsContrastEnhancementFunction::isValueInDisplayableRange ( double theValue )
50
50
{
51
51
// A default check is to see if the provided value is with the range for the data type
52
- if ( theValue < QgsContrastEnhancement::minimumValuePossible ( mQgsRasterDataType ) || theValue > QgsContrastEnhancement::maximumValuePossible ( mQgsRasterDataType ) )
53
- {
54
- return false ;
55
- }
56
-
57
- return true ;
52
+ // Write the test as ( v >= min && v <= max ) so that v = NaN returns false
53
+ return theValue >= QgsContrastEnhancement::minimumValuePossible ( mQgsRasterDataType ) && theValue <= QgsContrastEnhancement::maximumValuePossible ( mQgsRasterDataType );
58
54
}
59
55
60
56
void QgsContrastEnhancementFunction::setMaximumValue ( double theValue )
You can’t perform that action at this time.
0 commit comments