Skip to content

Commit

Permalink
Fix raster integer pseudocolor labels
Browse files Browse the repository at this point in the history
Fixes #40587
  • Loading branch information
elpaso committed Dec 14, 2020
1 parent efc4afc commit fdb403f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/gui/raster/qgscolorrampshaderwidget.cpp
Expand Up @@ -727,6 +727,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 @@ -740,12 +741,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 @@ -758,7 +758,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 fdb403f

Please sign in to comment.