Skip to content
Permalink
Browse files

fix handling discrete colormaps in continuous mode

  • Loading branch information
pierstitus authored and nyalldawson committed Apr 13, 2016
1 parent 5893647 commit cf72b5975c03f7265ada0b9d09cc65a3cb066eaa
Showing with 16 additions and 1 deletion.
  1. +16 −1 src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp
@@ -367,7 +367,22 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked()
entryValues.reserve( numberOfEntries );
if ( discrete )
{
double intervalDiff = ( max - min ) * ( numberOfEntries - 1 ) / numberOfEntries;
double intervalDiff = max - min;

// remove last class when ColorRamp is gradient and discrete, as they are implemented with an extra stop
QgsVectorGradientColorRampV2* colorGradientRamp = dynamic_cast<QgsVectorGradientColorRampV2*>( colorRamp );
if ( colorGradientRamp != NULL && colorGradientRamp->isDiscrete() )
{
numberOfEntries--;
}
else
{
// if color ramp is continuous scale values to get equally distributed classes.
// Doesn't work perfectly when stops are non equally distributed.
intervalDiff *= ( numberOfEntries - 1 ) / numberOfEntries;
}

// skip first value (always 0.0)
for ( int i = 1; i < numberOfEntries; ++i )
{
double value = colorRamp->value( i );

0 comments on commit cf72b59

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