Skip to content

Commit

Permalink
[backport] Fix raster integer pseudocolor labels
Browse files Browse the repository at this point in the history
Fixes #40587

Backported from master fdb403f
  • Loading branch information
elpaso committed Dec 15, 2020
1 parent f059703 commit 7d86f80
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/gui/raster/qgscolorrampshaderwidget.cpp
Expand Up @@ -725,6 +725,7 @@ QString QgsColorRampShaderWidget::createLabel( QTreeWidgetItem *currentItem, int
{
auto applyPrecision = [ = ]( const QString & value )
{
double val { value.toDouble( ) };
Qgis::DataType dataType { mRasterDataProvider ? mRasterDataProvider->dataType( mBand ) : Qgis::DataType::Float64 };
switch ( dataType )
{
Expand All @@ -738,12 +739,11 @@ QString QgsColorRampShaderWidget::createLabel( QTreeWidgetItem *currentItem, int
case Qgis::DataType::ARGB32:
case Qgis::DataType::ARGB32_Premultiplied:
{
return QLocale().toString( QLocale().toLongLong( value ) );
return QLocale().toString( std::round( val ), 'f', 0 );
}
case Qgis::DataType::Float32:
case Qgis::DataType::CFloat32:
{
double val { value.toFloat( ) };
if ( mLabelPrecisionSpinBox->value() < 0 )
{
const double factor = std::pow( 10, - mLabelPrecisionSpinBox->value() );
Expand All @@ -756,7 +756,6 @@ QString QgsColorRampShaderWidget::createLabel( QTreeWidgetItem *currentItem, int
case Qgis::DataType::CFloat64:
case Qgis::DataType::UnknownDataType:
{
double val { value.toDouble( ) };
if ( mLabelPrecisionSpinBox->value() < 0 )
{
const double factor = std::pow( 10, - mLabelPrecisionSpinBox->value() );
Expand Down

0 comments on commit 7d86f80

Please sign in to comment.