QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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, 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)
 
enum  NodeType {
  ntUnaryOperator, ntBinaryOperator, ntInOperator, ntFunction,
  ntLiteral, ntColumnRef, ntCondition
}
 
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)
 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 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)
 
 ~QgsExpression ()
 
void acceptVisitor (Visitor &v) const
 entry function for the visitor pattern More...
 
int currentRowNumber ()
 Return the number used for $rownum special column. More...
 
QString dump () const
 Return the expression string that represents this QgsExpression. More...
 
QString evalErrorString () const
 Returns evaluation error. More...
 
QVariant evaluate (const QgsFeature *f=NULL)
 Evaluate the feature and return the result. More...
 
QVariant evaluate (const QgsFeature &f)
 Evaluate the feature and return the result. More...
 
QVariant evaluate (const QgsFeature *f, const QgsFields &fields)
 Evaluate the feature and return the result. More...
 
QVariant evaluate (const QgsFeature &f, const QgsFields &fields)
 Evaluate the feature and return the result. More...
 
const QString expression () const
 Alias for dump() More...
 
QgsDistanceAreageomCalculator ()
 Return calculator used for distance and area calculations (used by internal functions) 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 needsGeometry () const
 Returns true if the expression uses feature geometry for some computation. More...
 
QString parserErrorString () const
 Returns parser error. More...
 
bool prepare (const QgsFields &fields)
 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 setCurrentRowNumber (int rowNumber)
 Set the number for $rownum special column. More...
 
void setEvalErrorString (QString str)
 Set evaluation error (used internally by evaluation functions) More...
 
void setGeomCalculator (const QgsDistanceArea &calc)
 Sets the geometry calculator used in evaluation of expressions,. More...
 
void setScale (double scale)
 

Additional Inherited Members

- Static Public Member Functions inherited from QgsExpression
static const QStringListBuiltinFunctions ()
 
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 int functionCount ()
 Returns the number of functions defined in the parser. More...
 
static int functionIndex (const QString &name)
 
static const QList< Function * > & Functions ()
 
static QString group (QString group)
 
static bool hasSpecialColumn (const QString &name)
 Check whether a special column exists. More...
 
static QString helptext (QString name)
 
static bool isFunctionName (QString name)
 
static bool isValid (const QString &text, const QgsFields &fields, QString &errorMessage)
 
static QString quotedColumnRef (QString name)
 return quoted column reference (in double quotes) More...
 
static QString quotedString (QString text)
 return quoted string (in single quotes) More...
 
static bool registerFunction (Function *function)
 
static QString replaceExpressionText (const QString &action, const QgsFeature *feat, QgsVectorLayer *layer, const QMap< QString, QVariant > *substitutionMap=0, const QgsDistanceArea *distanceArea=0)
 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 void setSpecialColumn (const QString &name, QVariant value)
 Assign a special column. More...
 
static 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 (QString name)
 
static void unsetSpecialColumn (const QString &name)
 Unset a special column. More...
 
- Static Public Attributes inherited from QgsExpression
static const char * BinaryOperatorText []
 
static QStringList gmBuiltinFunctions
 
static QList< Function * > gmFunctions
 
static const char * UnaryOperatorText []
 
- Protected Member Functions inherited from QgsExpression
 QgsExpression ()
 Used by QgsOgcUtils to create an empty. More...
 
void initGeomCalculator ()
 
- Static Protected Member Functions inherited from QgsExpression
static void initFunctionHelp ()
 
- Protected Attributes inherited from QgsExpression
QgsDistanceAreamCalc
 
QString mEvalErrorString
 
QString mExp
 
QString mParserErrorString
 
NodemRootNode
 
int mRowNumber
 
double mScale
 
- Static Protected Attributes inherited from QgsExpression
static QHash< QString, QStringgFunctionHelpTexts
 
static QHash< QString, QStringgGroups
 
static QMap< QString, QStringgmSpecialColumnGroups
 
static QMap< QString, QVariantgmSpecialColumns
 

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 
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 
)

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

Definition at line 33 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 96 of file qgsscaleexpression.h.

double QgsScaleExpression::maxSize ( ) const
inline

Returns the maximum size calculated by the expression.

See Also
minSize

Definition at line 74 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 86 of file qgsscaleexpression.h.

double QgsScaleExpression::minSize ( ) const
inline

Returns the minimum size calculated by the expression.

See Also
maxSize

Definition at line 69 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 80 of file qgsscaleexpression.h.

double QgsScaleExpression::nullSize ( ) const
inline

Returns the size value when expression evaluates to NULL.

See Also
nullSize

Definition at line 91 of file qgsscaleexpression.h.

QgsScaleExpression::operator bool ( ) const
inline

Definition at line 58 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 139 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 101 of file qgsscaleexpression.h.


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