19 #include <QDomDocument> 56 #if QT_VERSION < 0x050000 57 #include <qtextdocument.h> 104 #define TVL_True QVariant(1) 105 #define TVL_False QVariant(0) 106 #define TVL_Unknown QVariant() 113 if ( v.
type() == QVariant::Int )
return true;
114 if ( v.
type() == QVariant::UInt )
return true;
115 if ( v.
type() == QVariant::LongLong )
return true;
116 if ( v.
type() == QVariant::ULongLong )
return true;
117 if ( v.
type() == QVariant::Double )
return false;
118 if ( v.
type() == QVariant::String ) {
bool ok; v.
toString().
toInt( &ok );
return ok; }
123 if ( v.
type() == QVariant::Double )
return true;
124 if ( v.
type() == QVariant::Int )
return true;
125 if ( v.
type() == QVariant::UInt )
return true;
126 if ( v.
type() == QVariant::LongLong )
return true;
127 if ( v.
type() == QVariant::ULongLong )
return true;
128 if ( v.
type() == QVariant::String )
132 ok = ok && qIsFinite( val ) && !qIsNaN( val );
140 return v.
type() == QVariant::DateTime || v.
type() == QVariant::Date ||
141 v.
type() == QVariant::Time;
151 if ( v.
type() == QVariant::String )
163 #define ENSURE_NO_EVAL_ERROR { if (parent->hasEvalError()) return QVariant(); } 164 #define SET_EVAL_ERROR(x) { parent->setEvalErrorString(x); return QVariant(); } 173 "=",
"<>",
"<=",
">=",
"<",
">",
"~",
"LIKE",
"NOT LIKE",
"ILIKE",
"NOT ILIKE",
"IS",
"IS NOT",
174 "+",
"-",
"*",
"/",
"//",
"%",
"^",
197 if ( !ok || qIsNaN( x ) || !qIsFinite( x ) )
274 if ( inter.isValid() )
303 #define FEAT_FROM_CONTEXT(c, f) if (!c || !c->hasVariable(QgsExpressionContext::EXPR_FEATURE)) return QVariant(); \ 304 QgsFeature f = qvariant_cast<QgsFeature>( c->variable( QgsExpressionContext::EXPR_FEATURE ) ); 353 if ( value.
type() == QVariant::Int )
384 return expression.evaluate( context );
402 return ( deg *
M_PI ) / 180;
407 return ( 180 * rad ) /
M_PI;
468 if ( x <= 0 || b <= 0 )
470 return QVariant( log( x ) / log( b ) );
480 double f =
static_cast< double >( qrand() ) / RAND_MAX;
481 return QVariant( min + f * ( max - min ) );
491 return QVariant( min + ( qrand() % static_cast< int >( max - min + 1 ) ) );
502 if ( domainMin >= domainMax )
509 if ( val >= domainMax )
513 else if ( val <= domainMin )
519 double m = ( rangeMax - rangeMin ) / ( domainMax - domainMin );
520 double c = rangeMin - ( domainMin * m );
535 if ( domainMin >= domainMax )
547 if ( val >= domainMax )
551 else if ( val <= domainMin )
557 return QVariant((( rangeMax - rangeMin ) / pow( domainMax - domainMin, exponent ) ) * pow( val - domainMin, exponent ) + rangeMin );
566 for (
int i = 1; i < values.length(); ++i )
569 if ( testVal > maxVal )
584 for (
int i = 1; i < values.length(); ++i )
587 if ( testVal < minVal )
613 node =
getNode( values.at( 1 ), parent );
615 value = node->
eval( parent, context );
626 node =
getNode( values.at( 2 ), parent );
632 if ( values.count() > 3 )
634 node =
getNode( values.at( 3 ), parent );
642 if ( values.count() > 4 )
644 node =
getNode( values.at( 4 ), parent );
646 value = node->
eval( parent, context );
659 result = vl->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
663 result = vl->
aggregate( aggregate, subExpression, parameters,
nullptr, &ok );
708 if ( relations.
isEmpty() || relations.
at( 0 ).referencedLayer() != vl )
715 relation = relations.
at( 0 );
722 node =
getNode( values.at( 1 ), parent );
724 value = node->
eval( parent, context );
735 node =
getNode( values.at( 2 ), parent );
741 if ( values.count() > 3 )
743 node =
getNode( values.at( 3 ), parent );
745 value = node->
eval( parent, context );
765 result = childLayer->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
806 if ( values.count() > 1 )
808 node =
getNode( values.at( 1 ), parent );
812 groupBy = node->
dump();
816 if ( values.count() > 2 )
818 node =
getNode( values.at( 2 ), parent );
849 result = vl->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
954 if ( values.count() > 3 )
973 if ( testValue <= minValue )
977 else if ( testValue >= maxValue )
1019 Q_FOREACH (
const QVariant &value, values )
1041 for (
int i = 0; i < elems.size(); i++ )
1043 if ( elems[i].size() > 1 )
1044 elems[i] = elems[i].at( 0 ).toUpper() + elems[i].
mid( 1 ).toLower();
1046 return QVariant( elems.join(
" " ) );
1091 if ( values.length() == 2 || values.length() == 3 )
1096 if ( !str.
isEmpty() && wrap != 0 )
1100 if ( values.length() == 3 ) delimiterstr =
getStringValue( values.at( 2 ), parent );
1101 if ( delimiterstr.
isEmpty() ) delimiterstr =
' ';
1102 int delimiterlength = delimiterstr.
length();
1105 int strlength, strcurrent, strhit, lasthit;
1107 for (
int i = 0; i < lines.
size(); i++ )
1109 strlength = lines[i].
length();
1114 while ( strcurrent < strlength )
1121 strhit = lines[i].
lastIndexOf( delimiterstr, strcurrent + wrap );
1122 if ( strhit == lasthit || strhit == -1 )
1125 strhit = lines[i].
indexOf( delimiterstr, strcurrent + qAbs( wrap ) );
1131 strhit = lines[i].
indexOf( delimiterstr, strcurrent + qAbs( wrap ) );
1135 newstr.
append( lines[i].midRef( strcurrent, strhit - strcurrent ) );
1137 strcurrent = strhit + delimiterlength;
1141 newstr.
append( lines[i].midRef( strcurrent ) );
1142 strcurrent = strlength;
1145 if ( i < lines.
size() - 1 ) newstr.
append(
'\n' );
1187 if ( !re.isValid() )
1201 if ( !re.isValid() )
1215 if ( !re.isValid() )
1222 ( void )re.indexIn( str );
1223 if ( re.captureCount() > 0 )
1226 return QVariant( re.capturedTexts().at( 1 ) );
1249 if ( context && context->
hasVariable(
"row_number" ) )
1250 return context->
variable(
"row_number" );
1260 if ( context && context->
hasVariable(
"map_id" ) )
1261 return context->
variable(
"map_id" );
1270 if ( context && context->
hasVariable(
"layout_numpages" ) )
1271 return context->
variable(
"layout_numpages" );
1280 if ( context && context->
hasVariable(
"layout_page" ) )
1281 return context->
variable(
"layout_page" );
1290 if ( context && context->
hasVariable(
"atlas_featurenumber" ) )
1291 return context->
variable(
"atlas_featurenumber" );
1300 if ( context && context->
hasVariable(
"atlas_featureid" ) )
1301 return context->
variable(
"atlas_featureid" );
1311 if ( context && context->
hasVariable(
"atlas_feature" ) )
1312 return context->
variable(
"atlas_feature" );
1321 if ( context && context->
hasVariable(
"atlas_geometry" ) )
1322 return context->
variable(
"atlas_geometry" );
1331 if ( context && context->
hasVariable(
"atlas_totalfeatures" ) )
1332 return context->
variable(
"atlas_totalfeatures" );
1343 return QVariant( static_cast< int >( f.id() ) );
1363 Q_FOREACH (
const QVariant &value, values )
1380 return string.right( pos );
1387 return string.left( pos );
1393 int length =
getIntValue( values.at( 1 ), parent );
1401 int length =
getIntValue( values.at( 1 ), parent );
1409 for (
int n = 1; n < values.length(); n++ )
1441 int seconds = d2.
secsTo( d1 );
1447 if ( !values.at( 0 ).canConvert<
QDate>() )
1565 #define ENSURE_GEOM_TYPE(f, g, geomtype) const QgsGeometry* g = f.constGeometry(); \ 1566 if (!g || g->type() != geomtype) return QVariant(); 1572 if ( g->isMultipart() )
1574 return g->asMultiPoint().at( 0 ).x();
1578 return g->asPoint().x();
1586 if ( g->isMultipart() )
1588 return g->asMultiPoint().at( 0 ).y();
1592 return g->asPoint().y();
1676 int idx =
getIntValue( values.at( 1 ), parent ) - 1;
1730 bool ignoreClosing =
false;
1731 if ( values.length() > 1 )
1733 ignoreClosing =
getIntValue( values.at( 1 ), parent );
1742 bool skipLast =
false;
1743 if ( ignoreClosing && ring.
count() > 2 && ring.
first() == ring.
last() )
1748 for (
int i = 0; i < ( skipLast ? ring.
count() - 1 : ring.
count() ); ++ i )
1750 mp->addGeometry( ring.
at( i ).clone() );
1771 for (
int i = 0; i < line->
numPoints() - 1; ++i )
1776 << line->
pointN( i + 1 ) );
1777 ml->addGeometry( segment );
1793 if ( !curvePolygon )
1797 int idx =
getIntValue( values.at( 1 ), parent ) - 1;
1819 int idx =
getIntValue( values.at( 1 ), parent ) - 1;
1859 if ( values.count() < 2 || values.count() > 4 )
1867 double z = values.count() >= 3 ?
getDoubleValue( values.at( 2 ), parent ) : 0.0;
1868 double m = values.count() >= 4 ?
getDoubleValue( values.at( 3 ), parent ) : 0.0;
1869 switch ( values.count() )
1891 if ( values.count() < 2 )
1897 lineString->
clear();
1899 Q_FOREACH (
const QVariant& value, values )
1920 if ( values.count() < 1 )
1933 for (
int i = 1; i < values.count(); ++i )
1953 if ( !g || g->isEmpty() )
1958 idx += g->geometry()->nCoordinates();
1960 if ( idx < 0 || idx >= g->geometry()->nCoordinates() )
1973 if ( v.
type() == QVariant::PointF )
1981 if ( v.
type() == QVariant::PointF )
2019 double area = calc->
measureArea( f.constGeometry() );
2025 return QVariant( f.constGeometry()->area() );
2052 return QVariant( f.constGeometry()->length() );
2069 return f.constGeometry()->isEmpty() ?
QVariant( 0 ) :
QVariant( f.constGeometry()->geometry()->perimeter() );
2114 for (
int i = 0; i < collection->numGeometries(); ++i )
2117 if ( !curvePolygon )
2138 bool foundPoly =
false;
2147 if ( !curvePolygon )
2221 if ( values.length() < 2 || values.length() > 3 )
2227 if ( fGeom.
isEmpty() || sGeom.isEmpty() )
2232 if ( values.length() == 2 )
2235 QString result = engine->relate( *sGeom.geometry() );
2242 bool result = engine->relatePattern( *sGeom.geometry(), pattern );
2297 if ( values.length() < 2 || values.length() > 3 )
2303 if ( values.length() == 3 )
2418 if ( values.length() < 1 || values.length() > 2 )
2423 if ( values.length() == 2 )
2431 if ( values.length() != 2 )
2450 if ( pt1->x() == pt2->
x() )
2452 if ( pt1->y() < pt2->
y() )
2454 else if ( pt1->y() > pt2->
y() )
2460 if ( pt1->y() == pt2->
y() )
2462 if ( pt1->x() < pt2->
x() )
2464 else if ( pt1->x() > pt2->
x() )
2470 if ( pt1->x() < pt2->
x() )
2472 if ( pt1->y() < pt2->
y() )
2474 return atan( fabs( pt1->x() - pt2->
x() ) / fabs( pt1->y() - pt2->
y() ) );
2478 return atan( fabs( pt1->y() - pt2->
y() ) / fabs( pt1->x() - pt2->
x() ) )
2485 if ( pt1->y() > pt2->
y() )
2487 return atan( fabs( pt1->x() - pt2->
x() ) / fabs( pt1->y() - pt2->
y() ) )
2492 return atan( fabs( pt1->y() - pt2->
y() ) / fabs( pt1->x() - pt2->
x() ) )
2519 if ( values.length() != 3 )
2534 if ( values.length() < 2 )
2540 return values.at( 0 );
2543 bool asc = values.value( 2 ).toBool();
2561 Q_ASSERT( collection );
2565 QgsExpressionSorter sorter( orderBy );
2568 for (
int i = 0; i < collection->
partCount(); ++i )
2574 sorter.sortFeatures( partFeatures, unconstedContext );
2578 Q_ASSERT( orderedGeom );
2583 Q_FOREACH (
const QgsFeature& feature, partFeatures )
2591 delete unconstedContext;
2641 int vertex =
getIntValue( values.at( 1 ), parent );
2649 int vertex =
getIntValue( values.at( 1 ), parent );
2661 return distance >= 0 ? distance :
QVariant();
2666 if ( values.length() == 2 )
2669 double scaler = pow( 10.0,
getIntValue( values.at( 1 ), parent ) );
2670 return QVariant( qRound( number * scaler ) / scaler );
2673 if ( values.length() == 1 )
2675 double number =
getIntValue( values.at( 0 ), parent );
2697 int places =
getIntValue( values.at( 1 ), parent );
2703 return QString(
"%L1" ).
arg( value, 0,
'f', places );
2716 int green =
getIntValue( values.at( 1 ), parent );
2719 if ( ! color.isValid() )
2722 color =
QColor( 0, 0, 0 );
2725 return QString(
"%1,%2,%3" ).
arg( color.red() ).arg( color.green() ).arg( color.blue() );
2736 node =
getNode( values.at( 1 ), parent );
2738 value = node->
eval( parent, context );
2743 node =
getNode( values.at( 2 ), parent );
2745 value = node->
eval( parent, context );
2754 int green =
getIntValue( values.at( 1 ), parent );
2756 int alpha =
getIntValue( values.at( 3 ), parent );
2758 if ( ! color.isValid() )
2761 color =
QColor( 0, 0, 0 );
2776 QColor color = mRamp->color( value );
2783 double hue =
getIntValue( values.at( 0 ), parent ) / 360.0;
2785 double saturation =
getIntValue( values.at( 1 ), parent ) / 100.0;
2787 double lightness =
getIntValue( values.at( 2 ), parent ) / 100.0;
2791 if ( ! color.isValid() )
2794 color =
QColor( 0, 0, 0 );
2797 return QString(
"%1,%2,%3" ).
arg( color.red() ).arg( color.green() ).arg( color.blue() );
2803 double hue =
getIntValue( values.at( 0 ), parent ) / 360.0;
2805 double saturation =
getIntValue( values.at( 1 ), parent ) / 100.0;
2807 double lightness =
getIntValue( values.at( 2 ), parent ) / 100.0;
2809 double alpha =
getIntValue( values.at( 3 ), parent ) / 255.0;
2812 if ( ! color.isValid() )
2814 parent->
setEvalErrorString(
QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
2815 color =
QColor( 0, 0, 0 );
2823 double hue =
getIntValue( values.at( 0 ), parent ) / 360.0;
2825 double saturation =
getIntValue( values.at( 1 ), parent ) / 100.0;
2827 double value =
getIntValue( values.at( 2 ), parent ) / 100.0;
2831 if ( ! color.isValid() )
2834 color =
QColor( 0, 0, 0 );
2837 return QString(
"%1,%2,%3" ).
arg( color.red() ).arg( color.green() ).arg( color.blue() );
2843 double hue =
getIntValue( values.at( 0 ), parent ) / 360.0;
2845 double saturation =
getIntValue( values.at( 1 ), parent ) / 100.0;
2847 double value =
getIntValue( values.at( 2 ), parent ) / 100.0;
2849 double alpha =
getIntValue( values.at( 3 ), parent ) / 255.0;
2852 if ( ! color.isValid() )
2854 parent->
setEvalErrorString(
QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
2855 color =
QColor( 0, 0, 0 );
2863 double cyan =
getIntValue( values.at( 0 ), parent ) / 100.0;
2865 double magenta =
getIntValue( values.at( 1 ), parent ) / 100.0;
2867 double yellow =
getIntValue( values.at( 2 ), parent ) / 100.0;
2869 double black =
getIntValue( values.at( 3 ), parent ) / 100.0;
2873 if ( ! color.isValid() )
2876 color =
QColor( 0, 0, 0 );
2879 return QString(
"%1,%2,%3" ).
arg( color.red() ).arg( color.green() ).arg( color.blue() );
2885 double cyan =
getIntValue( values.at( 0 ), parent ) / 100.0;
2887 double magenta =
getIntValue( values.at( 1 ), parent ) / 100.0;
2889 double yellow =
getIntValue( values.at( 2 ), parent ) / 100.0;
2891 double black =
getIntValue( values.at( 3 ), parent ) / 100.0;
2893 double alpha =
getIntValue( values.at( 4 ), parent ) / 255.0;
2896 if ( ! color.isValid() )
2898 parent->
setEvalErrorString(
QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
2899 color =
QColor( 0, 0, 0 );
2917 return color.
green();
2919 return color.
blue();
2921 return color.
alpha();
2927 return color.
valueF() * 100;
2935 return color.
cyanF() * 100;
2941 return color.
blackF() * 100;
2957 int value =
getIntValue( values.at( 2 ), parent );
3046 if ( ! s.isValid() )
3080 if ( attributeId == -1 )
3085 const QVariant& attVal = values.at( 2 );
3112 if ( !layersByName.
isEmpty() )
3114 layer = layersByName.
at( 0 );
3123 return layer->name();
3127 return layer->title();
3129 return layer->abstract();
3131 return layer->keywordList();
3133 return layer->dataUrl();
3135 return layer->attribution();
3137 return layer->attributionUrl();
3139 return layer->publicSource();
3141 return layer->minimumScale();
3143 return layer->maximumScale();
3145 return layer->crs().authid();
3147 return layer->crs().toProj4();
3157 switch ( layer->type() )
3193 if ( transferOwnership )
3227 <<
"abs" <<
"sqrt" <<
"cos" <<
"sin" <<
"tan" 3228 <<
"asin" <<
"acos" <<
"atan" <<
"atan2" 3229 <<
"exp" <<
"ln" <<
"log10" <<
"log" 3230 <<
"round" <<
"rand" <<
"randf" <<
"max" <<
"min" <<
"clamp" 3231 <<
"scale_linear" <<
"scale_exp" <<
"floor" <<
"ceil" <<
"$pi" 3232 <<
"toint" <<
"to_int" <<
"toreal" <<
"to_real" <<
"tostring" <<
"to_string" 3233 <<
"todatetime" <<
"to_datetime" <<
"todate" <<
"to_date" 3234 <<
"totime" <<
"to_time" <<
"tointerval" <<
"to_interval" 3235 <<
"coalesce" <<
"if" <<
"regexp_match" <<
"age" <<
"year" 3236 <<
"month" <<
"week" <<
"day" <<
"hour" <<
"day_of_week" 3237 <<
"minute" <<
"second" <<
"lower" <<
"upper" 3238 <<
"title" <<
"length" <<
"replace" <<
"trim" <<
"wordwrap" 3239 <<
"regexp_replace" <<
"regexp_substr" 3240 <<
"substr" <<
"concat" <<
"strpos" <<
"left" 3241 <<
"right" <<
"rpad" <<
"lpad" <<
"format" 3242 <<
"format_number" <<
"format_date" 3243 <<
"color_rgb" <<
"color_rgba" <<
"ramp_color" 3244 <<
"color_hsl" <<
"color_hsla" <<
"color_hsv" <<
"color_hsva" 3245 <<
"color_cmyk" <<
"color_cmyka" <<
"color_part" <<
"set_color_part" 3246 <<
"xat" <<
"yat" <<
"$area" <<
"area" <<
"perimeter" 3247 <<
"$length" <<
"$perimeter" <<
"x" <<
"y" <<
"$x" <<
"$y" <<
"z" <<
"m" <<
"num_points" 3248 <<
"num_interior_rings" <<
"num_rings" <<
"num_geometries" 3249 <<
"geometry_n" <<
"interior_ring_n" 3250 <<
"point_n" <<
"start_point" <<
"end_point" <<
"make_point" <<
"make_point_m" 3251 <<
"nodes_to_points" <<
"segments_to_lines" 3252 <<
"make_line" <<
"make_polygon" 3253 <<
"$x_at" <<
"x_at" <<
"xat" <<
"$y_at" <<
"y_at" <<
"yat" <<
"x_min" <<
"xmin" <<
"x_max" <<
"xmax" 3254 <<
"y_min" <<
"ymin" <<
"y_max" <<
"ymax" <<
"geom_from_wkt" <<
"geomFromWKT" 3255 <<
"geom_from_gml" <<
"geomFromGML" <<
"intersects_bbox" <<
"bbox" 3256 <<
"disjoint" <<
"intersects" <<
"touches" <<
"crosses" <<
"contains" 3258 <<
"overlaps" <<
"within" <<
"buffer" <<
"centroid" <<
"bounds" <<
"reverse" <<
"exterior_ring" 3259 <<
"boundary" <<
"line_merge" 3260 <<
"bounds_width" <<
"bounds_height" <<
"is_closed" <<
"convex_hull" <<
"difference" 3261 <<
"distance" <<
"intersection" <<
"sym_difference" <<
"combine" 3262 <<
"extrude" <<
"azimuth" <<
"project" <<
"closest_point" <<
"shortest_line" 3263 <<
"line_locate_point" <<
"line_interpolate_point" 3264 <<
"line_interpolate_angle" <<
"angle_at_vertex" <<
"distance_to_vertex" 3265 <<
"union" <<
"geom_to_wkt" <<
"geomToWKT" <<
"geometry" 3266 <<
"transform" <<
"get_feature" <<
"getFeature" 3267 <<
"levenshtein" <<
"longest_common_substring" <<
"hamming_distance" 3269 <<
"aggregate" <<
"relation_aggregate" <<
"count" <<
"count_distinct" 3270 <<
"count_missing" <<
"minimum" <<
"maximum" <<
"sum" <<
"mean" 3271 <<
"median" <<
"stdev" <<
"range" <<
"minority" <<
"majority" 3272 <<
"q1" <<
"q3" <<
"iqr" <<
"min_length" <<
"max_length" <<
"concatenate" 3273 <<
"attribute" <<
"var" <<
"layer_property" 3274 <<
"$id" <<
"$scale" <<
"_specialcol_";
3288 static QMutex sFunctionsMutex( QMutex::Recursive );
3573 return isValid( text, &context, errorMessage );
3598 if ( !
d->mExp.isNull() )
3643 case QVariant::LongLong:
3644 case QVariant::Double:
3647 case QVariant::Bool:
3648 return value.
toBool() ?
"TRUE" :
"FALSE";
3651 case QVariant::String:
3665 for (
int i = 0; i < count; i++ )
3685 :
d( new QgsExpressionPrivate )
3689 Q_ASSERT( !
d->mParserErrorString.isNull() ||
d->mRootNode );
3700 if ( !
d->ref.deref() )
3711 :
d( new QgsExpressionPrivate )
3718 if ( !
d->ref.deref() )
3724 if (
d == other.
d ||
d->mExp == other.
d->mExp )
3731 return d->mRootNode;
3740 if ( !
d->mRootNode )
3743 QStringList columns =
d->mRootNode->referencedColumns();
3746 for (
int i = 0; i < columns.
count(); i++ )
3749 for (
int j = i + 1; j < columns.
count(); j++ )
3764 if ( !
d->mRootNode )
3766 return d->mRootNode->needsGeometry();
3771 if (
d->mCalc.data() )
3776 d->mCalc->setEllipsoidalMode(
false );
3785 ( void )
d->ref.deref();
3787 d =
new QgsExpressionPrivate( *
d );
3807 if ( !
d->mRootNode )
3815 if ( !
d->mRootNode )
3817 d->mEvalErrorString = tr(
"No root node! Parsing failed?" );
3821 return d->mRootNode->prepare(
this, context );
3827 if ( !
d->mRootNode )
3829 d->mEvalErrorString = tr(
"No root node! Parsing failed?" );
3834 return d->mRootNode->eval(
this, &context );
3848 bool res =
prepare( &context );
3866 if ( !
d->mRootNode )
3868 d->mEvalErrorString = tr(
"No root node! Parsing failed?" );
3872 return d->mRootNode->eval(
this, static_cast<const QgsExpressionContext*>(
nullptr ) );
3878 if ( !
d->mRootNode )
3880 d->mEvalErrorString = tr(
"No root node! Parsing failed?" );
3884 return d->mRootNode->eval(
this, context );
3889 return !
d->mEvalErrorString.isNull();
3894 return d->mEvalErrorString;
3899 d->mEvalErrorString = str;
3904 d->mRowNumber = rowNumber;
3911 if ( !
d->mRootNode )
3914 return d->mRootNode->dump();
3919 return d->mCalc.data();
3924 return d->mDistanceUnit;
3929 d->mDistanceUnit = unit;
3934 return d->mAreaUnit;
3939 d->mAreaUnit = unit;
3945 d->mRootNode->accept( v );
3961 if ( substitutionMap )
3968 if ( !oldValue.isNull() )
3969 savedValues.
insert( sit.key(), oldValue );
3978 while ( index < action.
size() )
3982 int pos = rx.
indexIn( action, index );
3995 expr_action += action.
midRef( start, index - start );
4010 expr_action += action.
midRef( start, index - start );
4015 expr_action += action.
mid( start, pos - start ) + result.
toString();
4018 expr_action += action.
midRef( index );
4035 double convertedValue = text.
toDouble( &ok );
4038 return convertedValue;
4049 convertedValue = result.
toDouble( &ok );
4052 return fallbackValue;
4054 return convertedValue;
4064 Q_FOREACH (
Node* node, mList )
4077 Q_FOREACH (
Node* n, mList )
4079 if ( !first ) msg +=
", ";
4091 QVariant val = mOperand->eval( parent, context );
4111 Q_ASSERT( 0 &&
"unknown unary operation" );
4118 return mOperand->prepare( parent, context );
4135 QVariant vL = mOpLeft->eval( parent, context );
4137 QVariant vR = mOpRight->eval( parent, context );
4143 if ( vL.
type() == QVariant::String && vR.
type() == QVariant::String )
4168 if ( mOp ==
boMod && iR == 0 )
4171 return QVariant( computeInt( iL, iR ) );
4181 parent->
setEvalErrorString( tr(
"Can't preform /, *, or % on DateTime and Interval" ) );
4184 return QVariant( computeDateTimeFromInterval( dL, &iL ) );
4186 else if ( mOp ==
boPlus && (( vL.
type() == QVariant::Date && vR.
type() == QVariant::Time ) ||
4187 ( vR.
type() == QVariant::Date && vL.
type() == QVariant::Time ) ) )
4196 else if ( mOp ==
boMinus && vL.
type() == QVariant::Date && vR.
type() == QVariant::Date )
4202 return date1 - date2;
4204 else if ( mOp ==
boMinus && vL.
type() == QVariant::Time && vR.
type() == QVariant::Time )
4210 return time1 - time2;
4212 else if ( mOp ==
boMinus && vL.
type() == QVariant::DateTime && vR.
type() == QVariant::DateTime )
4218 return datetime1 - datetime2;
4227 if (( mOp ==
boDiv || mOp ==
boMod ) && fR == 0. )
4229 return QVariant( computeDouble( fL, fR ) );
4241 return QVariant( qFloor( fL / fR ) );
4280 ( vL.
type() != QVariant::String || vR.
type() != QVariant::String ) )
4311 ( vL.
type() != QVariant::String || vR.
type() != QVariant::String ) )
4354 esc_regexp.
replace( 0, 1,
".*" );
4358 while (( pos = rx.
indexIn( esc_regexp, pos ) ) != -1 )
4360 esc_regexp.
replace( pos + 1, 1,
".*" );
4364 esc_regexp.
replace( rx,
"%" );
4367 esc_regexp.
replace( 0, 1,
"." );
4371 while (( pos = rx.
indexIn( esc_regexp, pos ) ) != -1 )
4373 esc_regexp.
replace( pos + 1, 1,
'.' );
4377 esc_regexp.
replace( rx,
"_" );
4481 return fmod( x, y );
4490 bool resL = mOpLeft->prepare( parent, context );
4491 bool resR = mOpRight->prepare( parent, context );
4492 return resL && resR;
4537 Q_ASSERT( 0 &&
"unexpected binary operator" );
4573 Q_ASSERT( 0 &&
"unexpected binary operator" );
4583 QString rdump( mOpRight->dump() );
4592 if ( leftAssociative() )
4594 fmt += lOp && ( lOp->
precedence() < precedence() ) ?
"(%1)" :
"%1";
4596 fmt += rOp && ( rOp->
precedence() <= precedence() ) ?
"(%3)" :
"%3";
4600 fmt += lOp && ( lOp->
precedence() <= precedence() ) ?
"(%1)" :
"%1";
4602 fmt += rOp && ( rOp->
precedence() < precedence() ) ?
"(%3)" :
"%3";
4617 if ( mList->count() == 0 )
4619 QVariant v1 = mNode->eval( parent, context );
4624 bool listHasNull =
false;
4626 Q_FOREACH (
Node* n, mList->list() )
4667 bool res = mNode->prepare( parent, context );
4668 Q_FOREACH (
Node* n, mList->list() )
4670 res = res && n->
prepare( parent, context );
4677 return QString(
"%1 %2 IN (%3)" ).
arg( mNode->dump(), mNotIn ?
"NOT" :
"", mList->dump() );
4682 return new NodeInOperator( mNode->clone(), mList->clone(), mNotIn );
4693 QVariantList argValues;
4696 Q_FOREACH (
Node* n, mArgs->list() )
4706 v = n->
eval( parent, context );
4711 argValues.append( v );
4730 Q_FOREACH (
Node* n, mArgs->list() )
4732 res = res && n->
prepare( parent, context );
4755 return functionColumns;
4758 Q_FOREACH (
Node* n, mArgs->list() )
4764 return functionColumns.
toSet().toList();
4769 return new NodeFunction( mFnIndex, mArgs ? mArgs->clone() : nullptr );
4776 Q_UNUSED( context );
4784 Q_UNUSED( context );
4791 if ( mValue.isNull() )
4794 switch ( mValue.type() )
4798 case QVariant::Double:
4800 case QVariant::String:
4802 case QVariant::Bool:
4803 return mValue.toBool() ?
"TRUE" :
"FALSE";
4805 return tr(
"[unsupported type;%1; value:%2]" ).
arg( mValue.typeName(), mValue.toString() );
4839 return QVariant(
'[' + mName +
']' );
4856 parent->
d->mEvalErrorString = tr(
"Column '%1' not found" ).arg( mName );
4876 Q_FOREACH (
WhenThen* cond, mConditions )
4891 QVariant vElse = mElseExp->eval( parent, context );
4903 Q_FOREACH (
WhenThen* cond, mConditions )
4907 if ( !res )
return false;
4911 return mElseExp->prepare( parent, context );
4919 Q_FOREACH (
WhenThen* cond, mConditions )
4924 msg +=
QString(
" ELSE %1" ).
arg( mElseExp->dump() );
4932 Q_FOREACH (
WhenThen* cond, mConditions )
4938 lst += mElseExp->referencedColumns();
4945 Q_FOREACH (
WhenThen* cond, mConditions )
4952 if ( mElseExp && mElseExp->needsGeometry() )
4961 Q_FOREACH (
WhenThen* wt, mConditions )
4963 return new NodeCondition( conditions, mElseExp ? mElseExp->clone() : nullptr );
4972 return tr(
"function help for %1 missing" ).arg( name );
4977 if ( f.
mType == tr(
"group" ) )
4978 name =
group( name );
4980 #if QT_VERSION < 0x050000 4983 name = name.toHtmlEscaped();
4986 QString helpContents(
QString(
"<h3>%1</h3>\n<div class=\"description\"><p>%2</p></div>" )
4987 .arg( tr(
"%1 %2" ).arg( f.
mType, name ),
4997 if ( f.
mType != tr(
"group" ) && f.
mType != tr(
"expression" ) )
4998 helpContents +=
QString(
"<h4>%1</h4>\n<div class=\"syntax\">\n" ).
arg( tr(
"Syntax" ) );
5000 if ( f.
mType == tr(
"operator" ) )
5004 helpContents +=
QString(
"<code><span class=\"functionname\">%1</span> <span class=\"argument\">%2</span></code>" )
5009 helpContents +=
QString(
"<code><span class=\"argument\">%1</span> <span class=\"functionname\">%2</span> <span class=\"argument\">%3</span></code>" )
5013 else if ( f.
mType != tr(
"group" ) && f.
mType != tr(
"expression" ) )
5015 helpContents +=
QString(
"<code><span class=\"functionname\">%1</span>" ).
arg( name );
5019 helpContents +=
'(';
5024 helpContents += delim;
5028 helpContents +=
QString(
"<span class=\"argument %1\">%2%3</span>" ).
arg( a.
mOptional ?
"optional" :
"", a.
mArg,
5035 helpContents +=
"...";
5038 helpContents +=
')';
5041 helpContents +=
"</code>";
5046 helpContents +=
QString(
"<h4>%1</h4>\n<div class=\"arguments\">\n<table>" ).
arg( tr(
"Arguments" ) );
5056 helpContents +=
"</table>\n</div>\n";
5061 helpContents +=
QString(
"<h4>%1</h4>\n<div class=\"examples\">\n<ul>\n" ).
arg( tr(
"Examples" ) );
5065 helpContents +=
"<li><code>" + e.
mExpression +
"</code> → <code>" + e.
mReturns +
"</code>";
5070 helpContents +=
"</li>\n";
5073 helpContents +=
"</ul>\n</div>\n";
5078 helpContents +=
QString(
"<h4>%1</h4>\n<div class=\"notes\"><p>%2</p></div>\n" ).
arg( tr(
"Notes" ), v.
mNotes );
5082 return helpContents;
5185 gGroups.
insert(
"Fields and Values", tr(
"Fields and Values" ) );
5211 return tr(
"<i><empty geometry></i>" );
5217 return tr(
"<i>NULL</i>" );
5223 return tr(
"<i><feature: %1></i>" ).arg( feat.
id() );
5229 return tr(
"<i><interval: %1 days></i>" ).arg( interval.
days() );
5231 else if ( value.
type() == QVariant::Date )
5234 return tr(
"<i><date: %1></i>" ).arg( dt.
toString(
"yyyy-MM-dd" ) );
5236 else if ( value.
type() == QVariant::Time )
5239 return tr(
"<i><time: %1></i>" ).arg( tm.
toString(
"hh:mm:ss" ) );
5241 else if ( value.
type() == QVariant::DateTime )
5244 return tr(
"<i><datetime: %1></i>" ).arg( dt.
toString(
"yyyy-MM-dd hh:mm:ss" ) );
5246 else if ( value.
type() == QVariant::String )
5249 if ( previewString.
length() > 63 )
5251 return QString( tr(
"'%1...'" ) ).
arg( previewString.
left( 60 ) );
5268 return func( values, &c, parent );
5279 return func( values, &f, parent );
5287 return eval( parent, &c );
5298 return eval( parent, &f );
5323 return mFnc ? mFnc( values, f, parent ) :
QVariant();
5341 return d->mRootNode;
void setAreaUnits(QgsUnitTypes::AreaUnit unit)
Sets the desired areal units for calculations involving geomCalculator(), eg "$area".
static bool isFunctionName(const QString &name)
tells whether the identifier is a name of existing function
static QVariant fcnDisjoint(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnConvexHull(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QString longestCommonSubstring(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the longest common substring between two strings.
bool isValid() const
Returns the validity of this feature.
bool canConvert(Type t) const
Class for parsing and evaluation of expressions (formerly called "search strings").
qlonglong toLongLong(bool *ok) const
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
virtual QStringList referencedColumns() const =0
Abstract virtual method which returns a list of columns required to evaluate this node...
static QVariant fcnNodesToPoints(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnGeomNumInteriorRings(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QVariant cachedValue(const QString &key) const
Returns the matching cached value, if set.
Wrapper for iterator of features from vector data provider or vector layer.
static QVariant fcnAggregateMax(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
Third quartile (numeric fields only)
QString toString(Qt::DateFormat format) const
static QVariant fcnGeomLength(const QVariantList &, const QgsExpressionContext *context, QgsExpression *parent)
bool isValid() const
Returns the validity of this relation.
QColor fromCmykF(qreal c, qreal m, qreal y, qreal k, qreal a)
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
static QVariant fcnSin(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnClosestPoint(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
const QgsCurveV2 * exteriorRing() const
virtual Q_DECL_DEPRECATED QVariant eval(QgsExpression *parent, const QgsFeature *f)
Abstract virtual eval method Errors are reported to the parent.
Base class for all map layer types.
static QVariant fcnBoundsWidth(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnY(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
Inter quartile range (IQR) (numeric fields only)
void setCachedValue(const QString &key, const QVariant &value) const
Sets a value to cache within the expression context.
QString cap(int nth) const
static QVariant fcnGeomPerimeter(const QVariantList &, const QgsExpressionContext *context, QgsExpression *parent)
double convertLengthMeasurement(double length, QGis::UnitType toUnits) const
Takes a length measurement calculated by this QgsDistanceArea object and converts it to a different d...
int numGeometries() const
Returns the number of geometries within the collection.
bool isEmpty() const
Returns true if the geometry is empty.
QString & append(QChar ch)
virtual Node * clone() const =0
Generate a clone of this node.
iterator insert(const Key &key, const T &value)
static QVariant fcnAtlasCurrentGeometry(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
virtual QString dump() const override
Abstract virtual dump method.
static QVariant fcnGeomFromWKT(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QColor darker(int factor) const
virtual bool prepare(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
virtual Q_DECL_DEPRECATED QVariant func(const QVariantList &values, const QgsFeature *f, QgsExpression *parent) override
static QVariant fcnFormatDate(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsCoordinateReferenceSystem crsByOgcWmsCrs(const QString &ogcCrs) const
Returns the CRS from a given OGC WMS-format Coordinate Reference System string.
iterator erase(iterator pos)
QgsPoint asPoint() const
Return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
const QgsCurveV2 * interiorRing(int i) const
static QVariant fncLighter(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
Median of values (numeric fields only)
static QVariant fcnFormatString(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
void acceptVisitor(Visitor &v) const
Entry function for the visitor pattern.
bool intersects(const QgsRectangle &r) const
Test for intersection with a rectangle (uses GEOS)
QgsGeometry * symDifference(const QgsGeometry *geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
bool contains(const Key &key) const
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
Q_DECL_DEPRECATED QVariant evaluate(const QgsFeature *f)
Evaluate the feature and return the result.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
static QVariant fcnBuffer(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool isValid() const
Returns true if the interval is valid.
virtual QgsCoordinateSequenceV2 coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
static QVariant fcnGeomNumRings(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnShortestLine(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual bool prepare(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
static QVariant fcnClamp(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnGetGeometry(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
double distance(const QgsGeometry &geom) const
Returns the minimum distance between this geometry and another geometry, using GEOS.
double months() const
Returns the interval duration in months (based on a 30 day month).
QString toString(Qt::DateFormat format) const
static QVariant fcnMakeLine(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QString toString(Qt::DateFormat format) const
static QVariant fcnStrpos(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static void initVariableHelp()
bool hasFunction(const QString &name) const
Checks whether a specified function is contained in the context.
static QVariant fcnXat(const QVariantList &values, const QgsExpressionContext *f, QgsExpression *parent)
void setExpression(const QString &expression)
Set the expression string, will reset the whole internal structure.
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
QDateTime computeDateTimeFromInterval(const QDateTime &d, QgsInterval *i)
Computes the result date time calculation from a start datetime and an interval.
static QString group(const QString &group)
Returns the translated name for a function group.
void initGeomCalculator()
static QVariant fcnWordwrap(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnAggregateSum(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
QgsVectorLayer * getVectorLayer(const QVariant &value, QgsExpression *)
bool compare(double diff)
A abstract base class for defining QgsExpression functions.
bool touches(const QgsGeometry *geometry) const
Test for if geometry touch another (uses GEOS)
double angleAtVertex(int vertex) const
Returns the bisector angle for this geometry at the specified vertex.
Q_DECL_DEPRECATED bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes.
static QVariant fcnCentroid(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool operator==(const QgsExpression &other) const
Compares two expressions.
static QVariant fcnAggregateRelation(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
double computeDouble(double x, double y)
static QVariant fcnProject(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnIf(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
First quartile (numeric fields only)
QgsMapLayer * mapLayer(const QString &theLayerId) const
Retrieve a pointer to a registered layer by layer ID.
Number of missing (null) values.
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
static QString encodeColor(const QColor &color)
QDateTime toDateTime() const
static QgsExpressionContext createFeatureBasedContext(const QgsFeature &feature, const QgsFields &fields)
Helper function for creating an expression context which contains just a feature and fields collectio...
QStringList referencedColumns() const
Get list of columns referenced by the expression.
QString & prepend(QChar ch)
virtual QString dump() const =0
Abstract virtual dump method.
static QVariant fcnPi(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QDate getDateValue(const QVariant &value, QgsExpression *parent)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())
Query the provider for features specified in request.
virtual Node * clone() const override
Generate a clone of this node.
QString dump() const
Return an expression string, constructed from the internal abstract syntax tree.
static QVariant pointAt(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
bool hasCachedValue(const QString &key) const
Returns true if the expression context contains a cached value with a matching key.
QString escape(const QString &str)
static QVariant fcnAtan2(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QString helptext(QString name)
Returns the help text for a specified function.
#define FEAT_FROM_CONTEXT(c, f)
static QVariant fcnMapId(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
const_iterator constBegin() const
static QVariant fcnRegexpMatch(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
const T & at(int i) const
static QVariant fcnFloor(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QVariant evaluate()
Evaluate the feature and return the result.
static QVariant fncColorCmyka(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnAcos(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnAbs(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnDistanceToVertex(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnAggregateRange(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
#define Q_NOWARN_DEPRECATED_PUSH
QgsExpression()
Create an empty expression.
double seconds() const
Returns the interval duration in seconds.
static QVariant fcnAggregateMaxLength(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
virtual QVariant eval(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
QString evalErrorString() const
Returns evaluation error.
Abstract base class for all geometries.
static QVariant fncColorHsva(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
Container of fields for a vector layer.
static QgsInterval fromString(const QString &string)
Converts a string to an interval.
static QVariant fcnAge(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnToTime(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool hasVariable(const QString &name) const
Check whether a variable is specified by any scope within the context.
virtual Q_DECL_DEPRECATED bool prepare(QgsExpression *parent, const QgsFields &fields)
Abstract virtual preparation method Errors are reported to the parent.
A geometry is the spatial representation of a feature.
static const char * vectorGeometryType(GeometryType type)
description strings for geometry types
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
const_iterator constFind(const Key &key) const
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
QgsExpression::Node * parseExpression(const QString &str, QString &parserErrorMsg)
static QVariant fcnTouches(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QTime getTimeValue(const QVariant &value, QgsExpression *parent)
bool isDoubleSafe(const QVariant &v)
static QVariant fcnWithin(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnExpScale(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnAggregateCountDistinct(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
Multi point geometry collection.
c++ helper class for defining QgsExpression functions.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
double distanceToVertex(int vertex) const
Returns the distance along this geometry from its first vertex to the specified vertex.
static QString formatPreviewString(const QVariant &value)
Formats an expression result for friendly display to the user.
bool contains(const QgsPoint *p) const
Test for containment of a point (uses GEOS)
static QVariant fcnMax(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QList< HelpVariant > mVariants
double convertAreaMeasurement(double area, QgsUnitTypes::AreaUnit toUnits) const
Takes an area measurement calculated by this QgsDistanceArea object and converts it to a different ar...
QgsRelationManager * relationManager() const
double z() const
Returns the point's z-coordinate.
static QVariant fcnLCS(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
double y() const
Returns the point's y-coordinate.
virtual QgsCurveV2 * clone() const override=0
Clones the geometry by performing a deep copy.
static QVariant fcnXMin(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static TVL getTVLValue(const QVariant &value, QgsExpression *parent)
static QVariant fcnFormatNumber(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnLineMerge(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
Q_DECL_DEPRECATED int currentRowNumber()
Return the number used for $rownum special column.
double toDouble(bool *ok) const
QgsGeometry nearestPoint(const QgsGeometry &other) const
Returns the nearest point on this geometry to another geometry.
static QVariant fcnToDateTime(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fncColorHsla(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
int weekNumber(int *yearNumber) const
QString parserErrorString() const
Returns parser error.
Multi line string geometry collection.
QString tr(const char *sourceText, const char *disambiguation, int n)
static QVariant fncColorPart(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnAzimuth(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QString delimiter
Delimiter to use for joining values with the StringConcatenate aggregate.
static QString soundex(const QString &string)
Returns the Soundex representation of a string.
bool lazyEval() const
True if this function should use lazy evaluation.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
QVariant variable(const QString &name) const
Fetches a matching variable from the context.
static QVariant fcnComposerPage(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
int computeInt(int x, int y)
virtual Node * clone() const override
Generate a clone of this node.
static QVariant fncDarker(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual QString dump() const override
Abstract virtual dump method.
static QVariant fcnGeomArea(const QVariantList &, const QgsExpressionContext *context, QgsExpression *parent)
static QVariant fcnLevenshtein(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
double y() const
Get the y value of the point.
void setEvalErrorString(const QString &str)
Set evaluation error (used internally by evaluation functions)
QgsGeometry * centroid() const
Returns the center of mass of a geometry.
static QgsGeometry getGeometry(const QVariant &value, QgsExpression *parent)
#define ENSURE_NO_EVAL_ERROR
virtual bool handlesNull() const
const QgsVectorColorRampV2 * colorRampRef(const QString &name) const
return a const pointer to a symbol (doesn't create new instance)
static QVariant fcnToReal(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual QVariant eval(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
static Q_DECL_DEPRECATED void setSpecialColumn(const QString &name, const QVariant &value)
Assign a special column.
static QVariant fcnYat(const QVariantList &values, const QgsExpressionContext *f, QgsExpression *parent)
QgsFields fields() const
Returns the list of fields of this layer.
virtual QString dump() const override
Abstract virtual dump method.
QgsGeometry * difference(const QgsGeometry *geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
static QVariant fcnCos(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static const QStringList & BuiltinFunctions()
void setPattern(const QString &pattern)
const Node * rootNode() const
Returns root node of the expression. Root node is null is parsing has failed.
static QVariant fcnSymDifference(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual QStringList referencedColumns() const
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
static bool unregisterFunction(const QString &name)
Unregisters a function from the expression engine.
static const QList< Function * > & Functions()
static QVariant fcnAggregateIQR(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
long featureCount(QgsSymbolV2 *symbol)
Number of features rendered with specified symbol.
int matchedLength() const
static QVariant fcnGetLayerProperty(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnSegmentsToLines(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnColorHsl(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnExteriorRing(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
int indexIn(const QString &str, int offset, CaretMode caretMode) const
QgsGeometry mergeLines() const
Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line ...
static QVariant fcnMin(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsUnitTypes::AreaUnit areaUnits() const
Returns the desired areal units for calculations involving geomCalculator(), eg "$area".
static QVariant fcnAggregateMean(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
static QVariant fncSetColorPart(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual QVariant eval(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
static QVariant fcnAtlasFeature(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
static int functionCount()
Returns the number of functions defined in the parser.
static QVariant fcnRndF(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual bool needsGeometry() const override
Abstract virtual method which returns if the geometry is required to evaluate this expression...
static QVariant fcnMinute(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnAggregateMin(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object.
static QVariant fcnTrim(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsGeometry * convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry. ...
static QVariant fcnAggregateMinority(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
QString number(int n, int base)
int count(const T &value) const
static QVariant fcnMonth(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsDistanceArea * geomCalculator()
Return calculator used for distance and area calculations (used by $length, $area and $perimeter func...
static QVariant fcnTranslate(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnStartPoint(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
const QgsAbstractGeometryV2 * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
void append(const T &value)
static QVariant fcnLn(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnMakePoint(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
static QVariant fcnGeomY(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual void setExteriorRing(QgsCurveV2 *ring) override
Sets the exterior ring of the polygon.
virtual Node * clone() const override
Generate a clone of this node.
virtual QgsCurveV2 * reversed() const =0
Returns a reversed copy of the curve, where the direction of the curve has been flipped.
static void initFunctionHelp()
virtual QVariant eval(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
int toInt(bool *ok) const
virtual bool isClosed() const
Returns true if the curve is closed.
static QVariant fcnIntersects(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QList< Parameter > ParameterList
List of parameters, used for function definition.
static QVariant fcnColorHsv(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsGeometry * pointOnSurface() const
Returns a point within a geometry.
static QVariant fcnCoalesce(const QVariantList &values, const QgsExpressionContext *, QgsExpression *)
static int functionIndex(const QString &name)
return index of the function in Functions array
static QVariant fcnRelate(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnWeek(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QString rightJustified(int width, QChar fill, bool truncate) const
Utility class for identifying a unique vertex within a geometry.
virtual Q_DECL_DEPRECATED QVariant func(const QVariantList &, const QgsFeature *, QgsExpression *)
virtual QString dump() const override
Abstract virtual dump method.
bool isValid() const
Checks if this expression is valid.
Line string geometry type, with support for z-dimension and m-values.
static QVariant fcnScale(const QVariantList &, const QgsExpressionContext *, QgsExpression *parent)
static Aggregate stringToAggregate(const QString &string, bool *ok=nullptr)
Converts a string to a aggregate type.
static QVariant fcnRowNumber(const QVariantList &, const QgsExpressionContext *context, QgsExpression *parent)
QList< QgsRelation > relationsByName(const QString &name) const
Returns a list of relations with matching names.
static QVariant fcnConcat(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
void setPoints(const QgsPointSequenceV2 &points)
Resets the line string to match the specified list of points.
static QVariant fcnGeomNumGeometries(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
Minimum length of string (string fields only)
virtual bool prepare(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
static QVariant fcnHamming(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnOrderParts(const QVariantList &values, const QgsExpressionContext *ctx, QgsExpression *parent)
static QgsGeometry * geometryFromGML(const QString &xmlString)
Static method that creates geometry from GML.
#define SET_EVAL_ERROR(x)
static void cleanRegisteredFunctions()
Deletes all registered functions whose ownership have been transferred to the expression engine...
QgsGeometry * buffer(double distance, int segments) const
Returns a buffer region around this geometry having the given width and with a specified number of se...
double width() const
Width of the rectangle.
QgsExpression & operator=(const QgsExpression &other)
Create a copy of this expression.
Point geometry type, with support for z-dimension and m-values.
int toInt(bool *ok, int base) const
static QHash< QString, QString > gGroups
static QVariant fcnAtlasFeatureId(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static bool registerFunction(Function *function, bool transferOwnership=false)
Registers a function to the expression engine.
static QgsInterval getInterval(const QVariant &value, QgsExpression *parent, bool report_error=false)
static QgsStyleV2 * defaultStyle()
return default application-wide style
static bool hasSpecialColumn(const QString &name)
Check whether a special column exists.
static QVariant fcnIntersection(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
const_iterator constEnd() const
static QVariant fcnRadians(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsGeometry * interpolate(double distance) const
Return interpolated point on line at distance.
static QVariant fcnAggregateGeneric(QgsAggregateCalculator::Aggregate aggregate, const QVariantList &values, QgsAggregateCalculator::AggregateParameters parameters, const QgsExpressionContext *context, QgsExpression *parent)
virtual QString dump() const override
Abstract virtual dump method.
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
static QVariant fcnUpper(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnToInt(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnToDate(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual bool prepare(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
bool crosses(const QgsGeometry *geometry) const
Test for if geometry crosses another (uses GEOS)
This class wraps a request for features to a vector layer (or directly its vector data provider)...
static QVariant fcnGeomX(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual Node * clone() const override
Generate a clone of this node.
virtual QVariant eval(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
void addInteriorRing(QgsCurveV2 *ring) override
Adds an interior ring to the geometry (takes ownership)
Represents a single parameter passed to a function.
virtual QVariant eval(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
static const QString AllAttributes
A special attribute that if set matches all attributes.
QString name() const
The name of the function.
double x() const
Returns the point's x-coordinate.
static QVariant fcnExp(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnPointOnSurface(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual Node * clone() const override
Generate a clone of this node.
static QHash< QString, QString > gVariableHelpTexts
static QVariant fcnContains(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnToInterval(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QString exportToWkt(int precision=17) const
Exports the geometry to WKT.
virtual int partCount() const override
Returns count of parts contained in the geometry.
virtual int partCount() const =0
Returns count of parts contained in the geometry.
QgsFeatureRequest & setFlags(const QgsFeatureRequest::Flags &flags)
Set flags that affect how features will be fetched.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
static QVariant fcnLog10(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnBoundsHeight(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnRight(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QList< HelpArg > mArguments
static QList< Function * > gmFunctions
static QVariant fcnDifference(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnCrosses(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool within(const QgsGeometry *geometry) const
Test for if geometry is within another (uses GEOS)
static const QString EXPR_FIELDS
Inbuilt variable name for fields storage.
static QVariant fcnChar(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
Q_DECL_DEPRECATED void setCurrentRowNumber(int rowNumber)
Set the number for $rownum special column.
static QVariant tvl2variant(TVL v)
static QVariant fcnLineInterpolatePoint(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
#define ENSURE_GEOM_TYPE(f, g, geomtype)
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
static int levenshteinDistance(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the Levenshtein edit distance between two strings.
static QVariant fcnAsin(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnYMax(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnGetFeature(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QList< HelpExample > mExamples
static QVariant fcnToString(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool isIntervalSafe(const QVariant &v)
static QString createFieldEqualityExpression(const QString &fieldName, const QVariant &value)
Create an expression allowing to evaluate if a field is equal to a value.
A class to represent a point.
static QVariant fcnNow(const QVariantList &, const QgsExpressionContext *, QgsExpression *)
static QVariant fcnFeatureId(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
static QVariant fcnEval(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
Majority of values (numeric fields only)
static QVariant fcnIsClosed(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnDistance(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static int getIntValue(const QVariant &value, QgsExpression *parent)
static QVariant fcnAggregate(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
int translate(double dx, double dy)
Translate this geometry by dx, dy.
QgsGeometry * combine(const QgsGeometry *geometry) const
Returns a geometry representing all the points in this geometry and other (a union geometry operation...
double length() const
Returns the length of geometry using GEOS.
virtual int ringCount(int=0) const override
static QVariant fcnBbox(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnRound(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnGeomZ(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
const T value(const Key &key) const
QgsFeatureId id() const
Get the feature ID for this feature.
static QVariant fcnAggregateQ1(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
virtual bool prepare(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
QgsGeometry extrude(double x, double y)
Returns an extruded version of this geometry.
double weeks() const
Returns the interval duration in weeks.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometryV2 *geometry)
Creates and returns a new geometry engine.
static QVariant fcnGeomFromGML(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
int fieldNameIndex(const QString &fieldName) const
Look up field's index from name also looks up case-insensitive if there is no match otherwise...
bool contains(QChar ch, Qt::CaseSensitivity cs) const
static QVariant fcnAggregateMedian(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
virtual QgsAbstractGeometryV2 * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
void setHslF(qreal h, qreal s, qreal l, qreal a)
QVariant aggregate(QgsAggregateCalculator::Aggregate aggregate, const QString &fieldOrExpression, const QgsAggregateCalculator::AggregateParameters ¶meters=QgsAggregateCalculator::AggregateParameters(), QgsExpressionContext *context=nullptr, bool *ok=nullptr)
Calculates an aggregated value from the layer's features.
virtual QVariant eval(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
static QVariant fcnSeconds(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsVectorLayer * referencedLayer() const
Access the referenced (parent) layer.
static QVariant fcnMakePointM(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QString expression() const
Return the original, unmodified expression string.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
Number of distinct values.
void setHsvF(qreal h, qreal s, qreal v, qreal a)
bool leftAssociative() const
double measureArea(const QgsGeometry *geometry) const
Measures the area of a geometry.
static QVariant fcnExtrude(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnArea(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnCeil(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnHour(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnGeomNumPoints(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QColor lighter(int factor) const
QStringRef midRef(int position, int n) const
static QVariant fcnLeft(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QVariant fromValue(const T &value)
static QString getStringValue(const QVariant &value, QgsExpression *)
double interpolateAngle(double distance) const
Returns the angle parallel to the linestring or polygon boundary at the specified distance along the ...
A representation of the interval between two datetime values.
The OrderByClause class represents an order by clause for a QgsFeatureRequest.
static QVariant fcnDegrees(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
double xMaximum() const
Get the x maximum value (right side of rectangle)
static QVariant fcnSoundex(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QgsFeature getFeature(const QVariant &value, QgsExpression *parent)
static QVariant fcnRPad(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnAggregateStringConcat(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
static QVariant fcnLog(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
double days() const
Returns the interval duration in days.
static double getDoubleValue(const QVariant &value, QgsExpression *parent)
static QVariant fcnLineInterpolateAngle(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
#define Q_NOWARN_DEPRECATED_POP
General purpose distance and area calculator.
QgsExpression::Function * function(const QString &name) const
Fetches a matching function from the context.
static QVariant fcnAtlasCurrentFeature(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
double measurePerimeter(const QgsGeometry *geometry) const
Measures the perimeter of a polygon geometry.
virtual Node * clone() const override
Generate a clone of this node.
static QVariant fcnX(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
QString & replace(int position, int n, QChar after)
static QMap< QString, QString > gmSpecialColumnGroups
virtual QString dump() const override
Abstract virtual dump method.
static void registerContextFunctions()
Registers all known core functions provided by QgsExpressionContextScope objects. ...
Maximum length of string (string fields only)
void addVertex(const QgsPointV2 &pt)
Adds a new vertex to the end of the line string.
static QVariant fcnPointN(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnBounds(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsVectorLayer * referencingLayer() const
Access the referencing (child) layer This is the layer which has the field(s) which point to another ...
static QVariant fcnFeature(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
static QVariant fcnGetVariable(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
QVariant(* FcnEvalContext)(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
Function definition for evaluation against an expression context, using a list of values as parameter...
static QVariant fcnOverlaps(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QDateTime currentDateTime()
QString getRelatedFeaturesFilter(const QgsFeature &feature) const
Returns a filter expression which returns all the features on the referencing (child) layer which hav...
QString filter
Optional filter for calculating aggregate over a subset of features, or an empty string to use all fe...
bool isIntSafe(const QVariant &v)
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
static QHash< QString, Help > gFunctionHelpTexts
QString mid(int position, int n) const
double years() const
Returns the interval duration in years (based on an average year length)
virtual QString dump() const
bool isDateTimeSafe(const QVariant &v)
static const char * UnaryOperatorText[]
static QVariant fcnDay(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
Mean of values (numeric fields only)
static QVariant fcnGeometryN(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static const QString EXPR_FEATURE
Inbuilt variable name for feature storage.
static QVariant fcnTransformGeometry(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QList< QgsLineStringV2 * > extractLineStrings(const QgsAbstractGeometryV2 *geom)
Returns list of linestrings extracted from the passed geometry.
static QVariant fcnComposerNumPages(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
int secsTo(const QDateTime &other) const
static QVariant fcnLPad(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QgsExpression::Node * getNode(const QVariant &value, QgsExpression *parent)
QString escape(const QString &plain)
static QVariant fcnReplace(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
qreal hsvSaturationF() const
double minutes() const
Returns the interval duration in minutes.
static QList< Function * > specialColumns()
Returns a list of special Column definitions.
bool vertexIdFromVertexNr(int nr, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
QVariant value() const
The value of the literal.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
static QVariant fcnAtan(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsGeometry shortestLine(const QgsGeometry &other) const
Returns the shortest line joining this geometry to another geometry.
Class for storing a coordinate reference system (CRS)
static QVariant fcnLineLocatePoint(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual bool addGeometry(QgsAbstractGeometryV2 *g)
Adds a geometry and takes ownership.
double hours() const
Returns the interval duration in hours.
QString translate(const char *context, const char *sourceText, const char *disambiguation, Encoding encoding)
static QVariant fcnAggregateCount(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
static QVariant fcnAttribute(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual QStringList referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node...
void setDistanceUnits(QGis::UnitType unit)
Sets the desired distance units for calculations involving geomCalculator(), eg "$length" and "$perim...
static QVariant fcnAngleAtVertex(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnMakePolygon(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnAtlasNumFeatures(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
QList< T > mid(int pos, int length) const
QgsFeatureRequest & setLimit(long limit)
Set the maximum number of features to request.
QgsGeometry * intersection(const QgsGeometry *geometry) const
Returns a geometry representing the points shared by this geometry and other.
static QVariant fcnXMax(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
Support for visitor pattern - algorithms dealing with the expressions may be implemented without modi...
static QString quotedString(QString text)
Returns a quoted version of a string (in single quotes)
static QgsGeometry * fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
virtual bool prepare(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
static QVariant fcnAggregateStdev(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
QString leftJustified(int width, QChar fill, bool truncate) const
int lastIndexOf(const QRegExp &rx, int from) const
UnitType
Map units that qgis supports.
double xMinimum() const
Get the x minimum value (left side of rectangle)
int transform(const QgsCoordinateTransform &ct)
Transform this geometry as described by CoordinateTransform ct.
static QVariant fcnInteriorRingN(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual bool removeGeometry(int nr)
Removes a geometry from the collection.
qreal hslSaturationF() const
void setHsl(int h, int s, int l, int a)
virtual bool needsGeometry() const =0
Abstract virtual method which returns if the geometry is required to evaluate this expression...
void setHsv(int h, int s, int v, int a)
QString left(int n) const
static QVariant fcnGeomToWKT(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
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 i...
double measureLength(const QgsGeometry *geometry) const
Measures the length of a geometry.
QgsFeature feature() const
Convenience function for retrieving the feature for the context, if set.
void setGeomCalculator(const QgsDistanceArea &calc)
Sets the geometry calculator used for distance and area calculations in expressions.
static QVariant fcnColorCmyk(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnAggregateMinLength(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
static QVariant fcnSqrt(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnTitle(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QStringList gmBuiltinFunctions
double yMaximum() const
Get the y maximum value (top side of rectangle)
int indexOf(const QRegExp &rx, int from) const
static QVariant fcnRnd(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
double toDouble(bool *ok) const
static QColor decodeColor(const QString &str)
bool disjoint(const QgsGeometry *geometry) const
Test for if geometry is disjoint of another (uses GEOS)
static QString variableHelpText(const QString &variableName, bool showValue=true, const QVariant &value=QVariant())
Returns the help text for a specified variable.
iterator insert(const Key &key, const T &value)
bool contains(const Key &key) const
static QVariant fcnYMin(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnGeometry(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
static QVariant fcnUuid(const QVariantList &, const QgsExpressionContext *, QgsExpression *)
int params() const
The number of parameters this function takes.
static Q_DECL_DEPRECATED QVariant specialColumn(const QString &name)
Return the value of the given special column or a null QVariant if undefined.
Custom exception class for Coordinate Reference System related exceptions.
Curve polygon geometry type.
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
static QVariant fcnBoundary(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QgsGeometry * fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
static QVariant fcnReverse(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnEndPoint(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
double area() const
Returns the area of the geometry using GEOS.
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
bool nextFeature(QgsFeature &f)
static QList< Function * > gmOwnedFunctions
List of functions owned by the expression engine.
static QVariant fcnTan(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required...
Minority of values (numeric fields only)
QDateTime addSecs(int s) const
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy.
static QString displayString(Type type)
Returns a display string type for a WKB type, eg the geometry name used in WKT geometry representatio...
Abstract base class for curved geometry type.
static QVariant fcnPerimeter(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsPoint project(double distance, double bearing) const
Returns a new point which correponds to this point projected by a specified distance in a specified b...
Geometry is not required. It may still be returned if e.g. required for a filter condition.
void setScale(double scale)
QgsRelation relation(const QString &id) const
Get access to a relation by its id.
static QVariant fcnRegexpReplace(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
Represents a vector layer which manages a vector based data sets.
int hslSaturation() const
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
int compare(const QString &other) const
Abstract base class for color ramps.
void setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a)
Range of values (max - min) (numeric and datetime fields only)
static QVariant fcnAggregateQ3(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
static QVariant fcnLinearScale(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool exactMatch(const QString &str) const
static double evaluateToDouble(const QString &text, const double fallbackValue)
Attempts to evaluate a text string as an expression to a resultant double value.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
virtual QStringList referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node...
static QgsCRSCache * instance()
Returns a pointer to the QgsCRSCache singleton.
static QVariant fcnAggregateCountMissing(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
void detach()
Helper for implicit sharing.
iterator find(const Key &key)
static QVariant fcnGeomM(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool isNull(const QVariant &v)
double lineLocatePoint(const QgsGeometry &point) const
Returns a distance representing the location along this linestring of the closest point on this lines...
double m() const
Returns the point's m value.
static QVariant fcnDayOfWeek(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual QString dump() const override
Abstract virtual dump method.
virtual void clear() override
Clears the geometry, ie reset it to a null geometry.
QGis::UnitType distanceUnits() const
Returns the desired distance units for calculations involving geomCalculator(), eg "$length" and "$pe...
virtual bool prepare(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
bool overlaps(const QgsGeometry *geometry) const
Test for if geometry overlaps another (uses GEOS)
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
static QVariant fcnSubstr(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
double x() const
Get the x value of the point.
virtual QgsPointV2 vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
QColor fromHsvF(qreal h, qreal s, qreal v, qreal a)
Sample standard deviation of values (numeric fields only)
Aggregate
Available aggregates to calculate.
static QVariant fcnYear(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static int hammingDistance(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the Hamming distance between two strings.
int hsvSaturation() const
Represents a list of OrderByClauses, with the most important first and the least important last...
static QVariant fcnRegexpSubstr(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
virtual Node * clone() const override
Generate a clone of this node.
int numPoints() const override
Returns the number of points in the curve.
double height() const
Height of the rectangle.
QList< QgsPointV2 > QgsPointSequenceV2
QColor fromHslF(qreal h, qreal s, qreal l, qreal a)
NodeList * clone() const
Creates a deep copy of this list.
static QVariant fcnColorRgb(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fncColorRgba(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
const T value(const Key &key) const
A bundle of parameters controlling aggregate calculation.
static QDateTime getDateTimeValue(const QVariant &value, QgsExpression *parent)
static QVariant fcnCombine(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QVariant fcnRampColor(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnAggregateMajority(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
static Q_DECL_DEPRECATED void unsetSpecialColumn(const QString &name)
Unset a special column.
QList< QgsMapLayer * > mapLayersByName(const QString &layerName) const
Retrieve a list of matching registered layers by layer name.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
static QVariant fcnSpecialColumn(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnLength(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
int numInteriorRings() const
static QVariant fcnLower(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsPointV2 pointN(int i) const
Returns the specified point from inside the line string.
static const char * BinaryOperatorText[]
static QMap< QString, QVariant > gmSpecialColumns
bool mVariableLenArguments