Skip to content

Commit

Permalink
warn with 0 or negative values when using log scale in graduated rend…
Browse files Browse the repository at this point in the history
…erer (#38128)

* warn with 0 or negative values when using log scale in graduated renderer

* fix windows build
  • Loading branch information
3nids committed Aug 4, 2020
1 parent 63f939e commit 12a1a0d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/core/classification/qgsclassificationlogarithmic.cpp
Expand Up @@ -110,9 +110,20 @@ QList<double> QgsClassificationLogarithmic::calculateBreaks( double &minimum, do
QString QgsClassificationLogarithmic::valueToLabel( double value ) const
{
if ( value <= 0 )
{
return QString( QStringLiteral( "%1" ) ).arg( value );
}
else
return QString( QStringLiteral( "10^%1" ) ).arg( std::log10( value ) );
{
if ( std::isnan( value ) )
{
return QObject::tr( "invalid (0 or negative values in the data)" );
}
else
{
return QString( QStringLiteral( "10^%1" ) ).arg( std::log10( value ) );
}
}
}

QString QgsClassificationLogarithmic::labelForRange( double lowerValue, double upperValue, QgsClassificationMethod::ClassPosition position ) const
Expand Down

0 comments on commit 12a1a0d

Please sign in to comment.