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").
double size(double value) const
Calculates the size corresponding to a specific value.
double nullSize() const
Returns the size value when expression evaluates to NULL.
double maxValue() const
Returns the maximum value expected by the expression.
QgsExpression()
Used by QgsOgcUtils to create an empty.
QString baseExpression() const
Returns the base expression string (or field reference) used for calculating the values to be mapped ...
QString dump() const
Return an expression string, constructed from the internal abstract syntax tree.
const Node * rootNode() const
Returns root node of the expression. Root node is null is parsing has failed.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
static const QList< Function * > & Functions()
QString number(int n, int base)
Type type() const
Returns the scale expression's type (method used to calculate the size from a value).
double minSize() const
Returns the minimum size calculated by the expression.
double minValue() const
Returns the minimum value expected by the expression.
double exponent() const
Returns the exponent of the exponential expression.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
double maxSize() const
Returns the maximum size calculated by the expression.