Skip to content
Permalink
Browse files

Reduce color map display decimals to max 15

Using 16 decimals gives rounding issues, (e.g. 64.4 displayed as 64.40000000000001)
  • Loading branch information
pierstitus authored and nyalldawson committed Apr 18, 2016
1 parent 8f667bb commit 97c4bd7f074c812df498d7a80e6e7cf44339afb6
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp
@@ -513,7 +513,7 @@ void QgsSingleBandPseudoColorRendererWidget::on_mClassifyButton_clicked()

// calculate a reasonable number of decimals to display
double maxabs = log10( qMax( qAbs( max ), qAbs( min ) ) );
int nDecimals = qRound( qMax( 3.0 + maxabs - log10( max - min ), maxabs <= 16.0 ? maxabs + 0.49 : 0.0 ) );
int nDecimals = qRound( qMax( 3.0 + maxabs - log10( max - min ), maxabs <= 15.0 ? maxabs + 0.49 : 0.0 ) );

for ( ; value_it != entryValues.end(); ++value_it, ++color_it )
{
@@ -561,7 +561,7 @@ void QgsSingleBandPseudoColorRendererWidget::populateColormapTreeWidget( const Q
for ( ; it != colorRampItems.constEnd(); ++it )
{
QgsTreeWidgetItem* newItem = new QgsTreeWidgetItem( mColormapTreeWidget );
newItem->setText( ValueColumn, QString::number( it->value, 'g', 16 ) );
newItem->setText( ValueColumn, QString::number( it->value, 'g', 15 ) );
newItem->setBackground( ColorColumn, QBrush( it->color ) );
newItem->setText( LabelColumn, it->label );
newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );
@@ -830,7 +830,7 @@ void QgsSingleBandPseudoColorRendererWidget::setFromRenderer( const QgsRasterRen
for ( ; it != colorRampItemList.end(); ++it )
{
QgsTreeWidgetItem* newItem = new QgsTreeWidgetItem( mColormapTreeWidget );
newItem->setText( ValueColumn, QString::number( it->value, 'g', 16 ) );
newItem->setText( ValueColumn, QString::number( it->value, 'g', 15 ) );
newItem->setBackground( ColorColumn, QBrush( it->color ) );
newItem->setText( LabelColumn, it->label );
newItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable );

0 comments on commit 97c4bd7

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