Skip to content

Commit

Permalink
return one entry when max==min
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Jan 21, 2021
1 parent 2b67cf5 commit 63bc752
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/core/raster/qgscolorrampshader.cpp
Expand Up @@ -186,10 +186,8 @@ void QgsColorRampShader::setSourceColorRamp( QgsColorRamp *colorramp )

void QgsColorRampShader::classifyColorRamp( const int classes, const int band, const QgsRectangle &extent, QgsRasterInterface *input )
{
if ( minimumValue() >= maximumValue() )
{
if ( minimumValue() > maximumValue() )
return;
}

bool discrete = colorRampType() == Discrete;

Expand All @@ -199,7 +197,18 @@ void QgsColorRampShader::classifyColorRamp( const int classes, const int band, c
double min = minimumValue();
double max = maximumValue();

if ( classificationMode() == Continuous )
if ( minimumValue() == maximumValue() )
{
if ( sourceColorRamp() && sourceColorRamp()->count() > 1 )
{
entryValues.push_back( min );
if ( discrete )
entryValues.push_back( std::numeric_limits<double>::infinity() );
for ( int i = 0; i < entryValues.size(); ++i )
entryColors.push_back( sourceColorRamp()->color( sourceColorRamp()->value( i ) ) );
}
}
else if ( classificationMode() == Continuous )
{
if ( sourceColorRamp() && sourceColorRamp()->count() > 1 )
{
Expand Down

0 comments on commit 63bc752

Please sign in to comment.