QGIS API Documentation  2.18.3-Las Palmas (77b8c3d)
Public Types | Public Member Functions | List of all members
QgsScaleExpression Class Reference

Class storing parameters of a scale expression, which is a subclass of QgsExpression for expressions which return a size or width. More...

#include <qgsscaleexpression.h>

Inheritance diagram for QgsScaleExpression:
Inheritance graph
[legend]

Public Types

enum  Type {
  Linear, Area, Flannery, Exponential,
  Unknown
}
 
- Public Types inherited from QgsExpression
enum  BinaryOperator {
  boOr, boAnd, boEQ, boNE,
  boLE, boGE, boLT, boGT,
  boRegexp, boLike, boNotLike, boILike,
  boNotILike, boIs, boIsNot, boPlus,
  boMinus, boMul, boDiv, boIntDiv,
  boMod, boPow, boConcat
}
 list of binary operators More...
 
typedef QVariant(* FcnEval) (const QVariantList &values, const QgsFeature *f, QgsExpression *parent)
 
typedef QVariant(* FcnEvalContext) (const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
 Function definition for evaluation against an expression context, using a list of values as parameters to the function. More...
 
typedef QgsInterval Interval
 
enum  NodeType {
  ntUnaryOperator, ntBinaryOperator, ntInOperator, ntFunction,
  ntLiteral, ntColumnRef, ntCondition
}
 
typedef QList< ParameterParameterList
 List of parameters, used for function definition. More...
 
enum  SpatialOperator {
  soBbox, soIntersects, soContains, soCrosses,
  soEquals, soDisjoint, soOverlaps, soTouches,
  soWithin
}
 
enum  UnaryOperator { uoNot, uoMinus }
 list of unary operators More...
 
typedef QList< WhenThen * > WhenThenList
 

Public Member Functions

 QgsScaleExpression (const QString &expression)
 Constructor for QgsScaleExpression which parses an expression string to determine whether it's a scale expression. More...
 
 QgsScaleExpression (Type type, const QString &baseExpression, double minValue, double maxValue, double minSize, double maxSize, double nullSize=0, double exponent=1)
 Constructor for QgsScaleExpression which creates an expression from specified parameters. More...
 
QString baseExpression () const
 Returns the base expression string (or field reference) used for calculating the values to be mapped to a size. More...
 
double exponent () const
 Returns the exponent of the exponential expression. More...
 
double maxSize () const
 Returns the maximum size calculated by the expression. More...
 
double maxValue () const
 Returns the maximum value expected by the expression. More...
 
double minSize () const
 Returns the minimum size calculated by the expression. More...
 
double minValue () const
 Returns the minimum value expected by the expression. More...
 
double nullSize () const
 Returns the size value when expression evaluates to NULL. More...
 
 operator bool () const
 
double size (double value) const
 Calculates the size corresponding to a specific value. More...
 
Type type () const
 Returns the scale expression's type (method used to calculate the size from a value). More...
 
- Public Member Functions inherited from QgsExpression
 QgsExpression (const QString &expr)
 Creates a new expression based on the provided string. More...
 
 QgsExpression (const QgsExpression &other)
 Create a copy of this expression. More...
 
 QgsExpression ()
 Create an empty expression. More...
 
 ~QgsExpression ()
 
void acceptVisitor (Visitor &v) const
 Entry function for the visitor pattern. More...
 
QgsUnitTypes::AreaUnit areaUnits () const
 Returns the desired areal units for calculations involving geomCalculator(), eg "$area". More...
 
Q_DECL_DEPRECATED int currentRowNumber ()
 Return the number used for $rownum special column. More...
 
QGis::UnitType distanceUnits () const
 Returns the desired distance units for calculations involving geomCalculator(), eg "$length" and "$perimeter". More...
 
QString dump () const
 Return an expression string, constructed from the internal abstract syntax tree. More...
 
QString evalErrorString () const
 Returns evaluation error. More...
 
Q_DECL_DEPRECATED QVariant evaluate (const QgsFeature *f)
 Evaluate the feature and return the result. More...
 
Q_DECL_DEPRECATED QVariant evaluate (const QgsFeature &f)
 Evaluate the feature and return the result. More...
 
Q_DECL_DEPRECATED QVariant evaluate (const QgsFeature *f, const QgsFields &fields)
 Evaluate the feature and return the result. More...
 
Q_DECL_DEPRECATED QVariant evaluate (const QgsFeature &f, const QgsFields &fields)
 Evaluate the feature and return the result. More...
 
QVariant evaluate ()
 Evaluate the feature and return the result. More...
 
QVariant evaluate (const QgsExpressionContext *context)
 Evaluate the expression against the specified context and return the result. More...
 
QString expression () const
 Return the original, unmodified expression string. More...
 
QgsDistanceAreageomCalculator ()
 Return calculator used for distance and area calculations (used by $length, $area and $perimeter functions only) More...
 
bool hasEvalError () const
 Returns true if an error occurred when evaluating last input. More...
 
bool hasParserError () const
 Returns true if an error occurred when parsing the input expression. More...
 
bool isField () const
 Checks whether an expression consists only of a single field reference. More...
 
bool isValid () const
 Checks if this expression is valid. More...
 
bool needsGeometry () const
 Returns true if the expression uses feature geometry for some computation. More...
 
QgsExpressionoperator= (const QgsExpression &other)
 Create a copy of this expression. More...
 
bool operator== (const QgsExpression &other) const
 Compares two expressions. More...
 
QString parserErrorString () const
 Returns parser error. More...
 
Q_DECL_DEPRECATED bool prepare (const QgsFields &fields)
 Get the expression ready for evaluation - find out column indexes. More...
 
bool prepare (const QgsExpressionContext *context)
 Get the expression ready for evaluation - find out column indexes. More...
 
QStringList referencedColumns () const
 Get list of columns referenced by the expression. More...
 
const NoderootNode () const
 Returns root node of the expression. Root node is null is parsing has failed. More...
 
double scale ()
 
void setAreaUnits (QgsUnitTypes::AreaUnit unit)
 Sets the desired areal units for calculations involving geomCalculator(), eg "$area". More...
 
Q_DECL_DEPRECATED void setCurrentRowNumber (int rowNumber)
 Set the number for $rownum special column. More...
 
void setDistanceUnits (QGis::UnitType unit)
 Sets the desired distance units for calculations involving geomCalculator(), eg "$length" and "$perimeter". More...
 
void setEvalErrorString (const QString &str)
 Set evaluation error (used internally by evaluation functions) More...
 
void setExpression (const QString &expression)
 Set the expression string, will reset the whole internal structure. More...
 
void setGeomCalculator (const QgsDistanceArea &calc)
 Sets the geometry calculator used for distance and area calculations in expressions. More...
 
void setScale (double scale)
 

Additional Inherited Members

- Static Public Member Functions inherited from QgsExpression
static const QStringListBuiltinFunctions ()
 
static void cleanRegisteredFunctions ()
 Deletes all registered functions whose ownership have been transferred to the expression engine. More...
 
static double evaluateToDouble (const QString &text, const double fallbackValue)
 Attempts to evaluate a text string as an expression to a resultant double value. More...
 
static QString formatPreviewString (const QVariant &value)
 Formats an expression result for friendly display to the user. More...
 
static int functionCount ()
 Returns the number of functions defined in the parser. More...
 
static int functionIndex (const QString &name)
 return index of the function in Functions array More...
 
static const QList< Function * > & Functions ()
 
static QString group (const QString &group)
 Returns the translated name for a function group. More...
 
static bool hasSpecialColumn (const QString &name)
 Check whether a special column exists. More...
 
static QString helptext (QString name)
 Returns the help text for a specified function. More...
 
static bool isFunctionName (const QString &name)
 tells whether the identifier is a name of existing function More...
 
static Q_DECL_DEPRECATED bool isValid (const QString &text, const QgsFields &fields, QString &errorMessage)
 
static bool isValid (const QString &text, const QgsExpressionContext *context, QString &errorMessage)
 Tests whether a string is a valid expression. More...
 
static QString quotedColumnRef (QString name)
 Returns a quoted column reference (in double quotes) More...
 
static QString quotedString (QString text)
 Returns a quoted version of a string (in single quotes) More...
 
static QString quotedValue (const QVariant &value)
 Returns a string representation of a literal value, including appropriate quotations where required. More...
 
static QString quotedValue (const QVariant &value, QVariant::Type type)
 Returns a string representation of a literal value, including appropriate quotations where required. More...
 
static bool registerFunction (Function *function, bool transferOwnership=false)
 Registers a function to the expression engine. More...
 
static Q_DECL_DEPRECATED QString replaceExpressionText (const QString &action, const QgsFeature *feat, QgsVectorLayer *layer, const QMap< QString, QVariant > *substitutionMap=nullptr, const QgsDistanceArea *distanceArea=nullptr)
 This function currently replaces each expression between [% and %] in the string with the result of its evaluation on the feature passed as argument. More...
 
static QString replaceExpressionText (const QString &action, const QgsExpressionContext *context, const QMap< QString, QVariant > *substitutionMap=nullptr, const QgsDistanceArea *distanceArea=nullptr)
 This function replaces each expression between [% and %] in the string with the result of its evaluation with the specified context. More...
 
static Q_DECL_DEPRECATED void setSpecialColumn (const QString &name, const QVariant &value)
 Assign a special column. More...
 
static Q_DECL_DEPRECATED QVariant specialColumn (const QString &name)
 Return the value of the given special column or a null QVariant if undefined. More...
 
static QList< Function * > specialColumns ()
 Returns a list of special Column definitions. More...
 
static bool unregisterFunction (const QString &name)
 Unregisters a function from the expression engine. More...
 
static Q_DECL_DEPRECATED void unsetSpecialColumn (const QString &name)
 Unset a special column. More...
 
static QString variableHelpText (const QString &variableName, bool showValue=true, const QVariant &value=QVariant())
 Returns the help text for a specified variable. More...
 
- Static Public Attributes inherited from QgsExpression
static const char * BinaryOperatorText []
 
static QStringList gmBuiltinFunctions
 
static QList< Function * > gmFunctions
 
static QList< Function * > gmOwnedFunctions
 List of functions owned by the expression engine. More...
 
static const char * UnaryOperatorText []
 
- Protected Member Functions inherited from QgsExpression
void detach ()
 Helper for implicit sharing. More...
 
void initGeomCalculator ()
 
- Static Protected Member Functions inherited from QgsExpression
static void initFunctionHelp ()
 
static void initVariableHelp ()
 
- Protected Attributes inherited from QgsExpression
QgsExpressionPrivate * d
 
- Static Protected Attributes inherited from QgsExpression
static QHash< QString, HelpgFunctionHelpTexts
 
static QHash< QString, QStringgGroups
 
static QMap< QString, QStringgmSpecialColumnGroups
 
static QMap< QString, QVariantgmSpecialColumns
 
static QHash< QString, QStringgVariableHelpTexts
 

Detailed Description

Class storing parameters of a scale expression, which is a subclass of QgsExpression for expressions which return a size or width.

Note
Added in version 2.9

Definition at line 28 of file qgsscaleexpression.h.

Member Enumeration Documentation

Enumerator
Linear 
Area 
Flannery 
Exponential 
Unknown 

Definition at line 32 of file qgsscaleexpression.h.

Constructor & Destructor Documentation

QgsScaleExpression::QgsScaleExpression ( const QString expression)

Constructor for QgsScaleExpression which parses an expression string to determine whether it's a scale expression.

Parameters
expressionexpression string

Definition at line 21 of file qgsscaleexpression.cpp.

QgsScaleExpression::QgsScaleExpression ( Type  type,
const QString baseExpression,
double  minValue,
double  maxValue,
double  minSize,
double  maxSize,
double  nullSize = 0,
double  exponent = 1 
)

Constructor for QgsScaleExpression which creates an expression from specified parameters.

Parameters
typescale method
baseExpressionexpression (or field) used for value
minValueminimum value, corresponds to specified minimum size
maxValuemaximum value, corresponds to specified maximum size
minSizeminimum size
maxSizemaximum size
nullSizesize in case expression evaluates to NULL
exponentto use in case of Exponential type

Definition at line 34 of file qgsscaleexpression.cpp.

Member Function Documentation

QString QgsScaleExpression::baseExpression ( ) const
inline

Returns the base expression string (or field reference) used for calculating the values to be mapped to a size.

Definition at line 103 of file qgsscaleexpression.h.

double QgsScaleExpression::exponent ( ) const
inline

Returns the exponent of the exponential expression.

See also
exponent

Definition at line 98 of file qgsscaleexpression.h.

double QgsScaleExpression::maxSize ( ) const
inline

Returns the maximum size calculated by the expression.

See also
minSize

Definition at line 76 of file qgsscaleexpression.h.

double QgsScaleExpression::maxValue ( ) const
inline

Returns the maximum value expected by the expression.

The maximum value corresponds to the expression's maximum size.

See also
minValue

Definition at line 88 of file qgsscaleexpression.h.

double QgsScaleExpression::minSize ( ) const
inline

Returns the minimum size calculated by the expression.

See also
maxSize

Definition at line 71 of file qgsscaleexpression.h.

double QgsScaleExpression::minValue ( ) const
inline

Returns the minimum value expected by the expression.

The minimum value corresponds to the expression's minimum size.

See also
maxValue

Definition at line 82 of file qgsscaleexpression.h.

double QgsScaleExpression::nullSize ( ) const
inline

Returns the size value when expression evaluates to NULL.

See also
nullSize

Definition at line 93 of file qgsscaleexpression.h.

QgsScaleExpression::operator bool ( ) const
inline

Definition at line 60 of file qgsscaleexpression.h.

double QgsScaleExpression::size ( double  value) const

Calculates the size corresponding to a specific value.

Parameters
value
Returns
calculated size using expression's parameters and type

Definition at line 155 of file qgsscaleexpression.cpp.

Type QgsScaleExpression::type ( ) const
inline

Returns the scale expression's type (method used to calculate the size from a value).

Definition at line 108 of file qgsscaleexpression.h.


The documentation for this class was generated from the following files: