18 #include <QStringList> 35 :
QgsExpression( createExpression( type, baseExpression, minValue, maxValue, minSize, maxSize, nullSize, exponent ) )
36 , mExpression( baseExpression )
40 , mMinValue( minValue )
41 , mMaxValue( maxValue )
42 , mNullSize( nullSize )
64 void QgsScaleExpression::init()
127 mExpression = args[0]->dump();
142 return QString(
"coalesce(scale_linear(%1, %2, %3, %4, %5), %6)" ).
arg( baseExpr, minValueString, maxValueString, minSizeString, maxSizeString, nullSizeString );
147 return QString(
"coalesce(scale_exp(%1, %2, %3, %4, %5, %6), %7)" ).
arg( baseExpr, minValueString, maxValueString, minSizeString, maxSizeString, exponentString, nullSizeString );
160 return mMinSize + ( qBound( mMinValue, value, mMaxValue ) - mMinValue ) * ( mMaxSize - mMinSize ) / ( mMaxValue - mMinValue );
165 return mMinSize + qPow( qBound( mMinValue, value, mMaxValue ) - mMinValue, mExponent ) * ( mMaxSize - mMinSize ) / qPow( mMaxValue - mMinValue, mExponent );
QgsScaleExpression(const QString &expression)
Constructor for QgsScaleExpression which parses an expression string to determine whether it's a scal...
Class for parsing and evaluation of expressions (formerly called "search strings").
QString dump() const
Return an expression string, constructed from the internal abstract syntax tree.
double exponent() const
Returns the exponent of the exponential expression.
QgsExpression()
Create an empty expression.
double size(double value) const
Calculates the size corresponding to a specific value.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
QString baseExpression() const
Returns the base expression string (or field reference) used for calculating the values to be mapped ...
double maxValue() const
Returns the maximum value expected by the expression.
const Node * rootNode() const
Returns root node of the expression. Root node is null is parsing has failed.
static const QList< Function * > & Functions()
QString number(int n, int base)
double maxSize() const
Returns the maximum size calculated by the expression.
double minValue() const
Returns the minimum value expected by the expression.
Type type() const
Returns the scale expression's type (method used to calculate the size from a value).
double nullSize() const
Returns the size value when expression evaluates to NULL.
double minSize() const
Returns the minimum size calculated by the expression.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const