Skip to content

Commit

Permalink
Merge pull request #40604 from elpaso/bugfix-gh40587-raster-singleban…
Browse files Browse the repository at this point in the history
…d-integer-label-3_16

[backport] Fix raster integer pseudocolor labels
  • Loading branch information
elpaso committed Dec 15, 2020
2 parents 90c0faf + 7d86f80 commit e280cbd
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 e280cbd

Please sign in to comment.