19 #include <QDomDocument> 52 #if QT_VERSION < 0x050000 53 #include <qtextdocument.h> 69 QRegExp rx(
"([-+]?\\d?\\.?\\d+\\s+\\S+)", Qt::CaseInsensitive );
73 while (( pos = rx.
indexIn(
string, pos ) ) != -1 )
80 map.
insert( 1,
QStringList() <<
"second" <<
"seconds" <<
tr(
"second|seconds",
"list of words separated by | which reference years" ).split(
'|' ) );
81 map.
insert( 0 + MINUTE,
QStringList() <<
"minute" <<
"minutes" <<
tr(
"minute|minutes",
"list of words separated by | which reference minutes" ).split(
'|' ) );
82 map.
insert( 0 + HOUR,
QStringList() <<
"hour" <<
"hours" <<
tr(
"hour|hours",
"list of words separated by | which reference minutes hours" ).split(
'|' ) );
83 map.
insert( 0 + DAY,
QStringList() <<
"day" <<
"days" <<
tr(
"day|days",
"list of words separated by | which reference days" ).split(
'|' ) );
84 map.
insert( 0 + WEEKS,
QStringList() <<
"week" <<
"weeks" <<
tr(
"week|weeks",
"wordlist separated by | which reference weeks" ).split(
'|' ) );
85 map.
insert( 0 + MONTHS,
QStringList() <<
"month" <<
"months" <<
tr(
"month|months",
"list of words separated by | which reference months" ).split(
'|' ) );
86 map.
insert( 0 + YEARS,
QStringList() <<
"year" <<
"years" <<
tr(
"year|years",
"list of words separated by | which reference years" ).split(
'|' ) );
88 Q_FOREACH (
const QString& match, list )
92 double value = split.
at( 0 ).toDouble( &ok );
100 for ( ; it != map.
constEnd(); ++it )
102 int duration = it.
key();
105 if ( match.
contains( name, Qt::CaseInsensitive ) )
114 seconds += value * duration;
173 #define TVL_True QVariant(1) 174 #define TVL_False QVariant(0) 175 #define TVL_Unknown QVariant() 182 if ( v.
type() == QVariant::Int )
return true;
183 if ( v.
type() == QVariant::UInt )
return true;
184 if ( v.
type() == QVariant::LongLong )
return true;
185 if ( v.
type() == QVariant::ULongLong )
return true;
186 if ( v.
type() == QVariant::Double )
return false;
187 if ( v.
type() == QVariant::String ) {
bool ok; v.
toString().
toInt( &ok );
return ok; }
192 if ( v.
type() == QVariant::Double )
return true;
193 if ( v.
type() == QVariant::Int )
return true;
194 if ( v.
type() == QVariant::UInt )
return true;
195 if ( v.
type() == QVariant::LongLong )
return true;
196 if ( v.
type() == QVariant::ULongLong )
return true;
197 if ( v.
type() == QVariant::String )
201 ok = ok && qIsFinite( val ) && !qIsNaN( val );
209 return v.
type() == QVariant::DateTime || v.
type() == QVariant::Date ||
210 v.
type() == QVariant::Time;
220 if ( v.
type() == QVariant::String )
232 #define ENSURE_NO_EVAL_ERROR { if (parent->hasEvalError()) return QVariant(); } 233 #define SET_EVAL_ERROR(x) { parent->setEvalErrorString(x); return QVariant(); } 242 "=",
"<>",
"<=",
">=",
"<",
">",
"~",
"LIKE",
"NOT LIKE",
"ILIKE",
"NOT ILIKE",
"IS",
"IS NOT",
243 "+",
"-",
"*",
"/",
"//",
"%",
"^",
266 if ( !ok || qIsNaN( x ) || !qIsFinite( x ) )
343 if ( inter.isValid() )
402 if ( value.
type() == QVariant::Int )
433 return expression.evaluate( context );
451 return ( deg *
M_PI ) / 180;
456 return ( 180 * rad ) /
M_PI;
517 if ( x <= 0 || b <= 0 )
519 return QVariant( log( x ) / log( b ) );
529 double f =
static_cast< double >( qrand() ) / RAND_MAX;
530 return QVariant( min + f * ( max - min ) );
540 return QVariant( min + ( qrand() % static_cast< int >( max - min + 1 ) ) );
551 if ( domainMin >= domainMax )
558 if ( val >= domainMax )
562 else if ( val <= domainMin )
568 double m = ( rangeMax - rangeMin ) / ( domainMax - domainMin );
569 double c = rangeMin - ( domainMin * m );
584 if ( domainMin >= domainMax )
596 if ( val >= domainMax )
600 else if ( val <= domainMin )
606 return QVariant((( rangeMax - rangeMin ) / pow( domainMax - domainMin, exponent ) ) * pow( val - domainMin, exponent ) + rangeMin );
615 for (
int i = 1; i < values.length(); ++i )
618 if ( testVal > maxVal )
633 for (
int i = 1; i < values.length(); ++i )
636 if ( testVal < minVal )
652 if ( testValue <= minValue )
656 else if ( testValue >= maxValue )
698 Q_FOREACH (
const QVariant &value, values )
720 for (
int i = 0; i < elems.size(); i++ )
722 if ( elems[i].size() > 1 )
723 elems[i] = elems[i].left( 1 ).toUpper() + elems[i].
mid( 1 ).toLower();
725 return QVariant( elems.join(
" " ) );
764 if ( values.length() == 2 || values.length() == 3 )
769 if ( !str.
isEmpty() && wrap != 0 )
773 if ( values.length() == 3 ) delimiterstr =
getStringValue( values.at( 2 ), parent );
774 if ( delimiterstr.
isEmpty() ) delimiterstr =
' ';
775 int delimiterlength = delimiterstr.
length();
778 int strlength, strcurrent, strhit, lasthit;
780 for (
int i = 0; i < lines.
size(); i++ )
782 strlength = lines[i].
length();
787 while ( strcurrent < strlength )
794 strhit = lines[i].
lastIndexOf( delimiterstr, strcurrent + wrap );
795 if ( strhit == lasthit || strhit == -1 )
798 strhit = lines[i].
indexOf( delimiterstr, strcurrent + qAbs( wrap ) );
804 strhit = lines[i].
indexOf( delimiterstr, strcurrent + qAbs( wrap ) );
808 newstr.
append( lines[i].midRef( strcurrent, strhit - strcurrent ) );
810 strcurrent = strhit + delimiterlength;
814 newstr.
append( lines[i].midRef( strcurrent ) );
815 strcurrent = strlength;
818 if ( i < lines.
size() - 1 ) newstr.
append(
'\n' );
895 ( void )re.indexIn( str );
896 if ( re.captureCount() > 0 )
899 return QVariant( re.capturedTexts().at( 1 ) );
922 if ( context && context->
hasVariable(
"row_number" ) )
923 return context->
variable(
"row_number" );
934 return context->
variable(
"map_id" );
943 if ( context && context->
hasVariable(
"layout_numpages" ) )
944 return context->
variable(
"layout_numpages" );
953 if ( context && context->
hasVariable(
"layout_page" ) )
954 return context->
variable(
"layout_page" );
963 if ( context && context->
hasVariable(
"atlas_featurenumber" ) )
964 return context->
variable(
"atlas_featurenumber" );
973 if ( context && context->
hasVariable(
"atlas_featureid" ) )
974 return context->
variable(
"atlas_featureid" );
984 if ( context && context->
hasVariable(
"atlas_feature" ) )
985 return context->
variable(
"atlas_feature" );
994 if ( context && context->
hasVariable(
"atlas_geometry" ) )
995 return context->
variable(
"atlas_geometry" );
1004 if ( context && context->
hasVariable(
"atlas_totalfeatures" ) )
1005 return context->
variable(
"atlas_totalfeatures" );
1012 #define FEAT_FROM_CONTEXT(c, f) if (!c || !c->hasVariable(QgsExpressionContext::EXPR_FEATURE)) return QVariant(); \ 1013 QgsFeature f = qvariant_cast<QgsFeature>( c->variable( QgsExpressionContext::EXPR_FEATURE ) ); 1019 return QVariant( static_cast< int >( f.id() ) );
1039 Q_FOREACH (
const QVariant &value, values )
1056 return string.right( pos );
1063 return string.left( pos );
1069 int length =
getIntValue( values.at( 1 ), parent );
1077 int length =
getIntValue( values.at( 1 ), parent );
1085 for (
int n = 1; n < values.length(); n++ )
1117 int seconds = d2.secsTo( d1 );
1123 if ( !values.at( 0 ).canConvert<
QDate>() )
1241 #define ENSURE_GEOM_TYPE(f, g, geomtype) const QgsGeometry* g = f.constGeometry(); \ 1242 if (!g || g->type() != geomtype) return QVariant(); 1248 if ( g->isMultipart() )
1250 return g->asMultiPoint().at( 0 ).x();
1254 return g->asPoint().x();
1262 if ( g->isMultipart() )
1264 return g->asMultiPoint().at( 0 ).y();
1268 return g->asPoint().y();
1352 int idx =
getIntValue( values.at( 1 ), parent ) - 1;
1406 bool ignoreClosing =
false;
1407 if ( values.length() > 1 )
1409 ignoreClosing =
getIntValue( values.at( 1 ), parent );
1418 bool skipLast =
false;
1419 if ( ignoreClosing && ring.
count() > 2 && ring.
first() == ring.
last() )
1424 for (
int i = 0; i < ( skipLast ? ring.
count() - 1 : ring.
count() ); ++ i )
1426 mp->addGeometry( ring.
at( i ).clone() );
1447 for (
int i = 0; i < line->
numPoints() - 1; ++i )
1452 << line->
pointN( i + 1 ) );
1453 ml->addGeometry( segment );
1469 if ( !curvePolygon )
1473 int idx =
getIntValue( values.at( 1 ), parent ) - 1;
1495 int idx =
getIntValue( values.at( 1 ), parent ) - 1;
1507 if ( values.count() < 2 || values.count() > 4 )
1515 double z = values.count() >= 3 ?
getDoubleValue( values.at( 2 ), parent ) : 0.0;
1516 double m = values.count() >= 4 ?
getDoubleValue( values.at( 3 ), parent ) : 0.0;
1517 switch ( values.count() )
1539 if ( values.count() < 2 )
1545 lineString->
clear();
1547 Q_FOREACH (
const QVariant& value, values )
1568 if ( values.count() < 1 )
1581 for (
int i = 1; i < values.count(); ++i )
1603 idx += polyline.
count();
1605 if ( idx < 0 || idx >= polyline.
count() )
1616 if ( v.
type() == QVariant::PointF )
1624 if ( v.
type() == QVariant::PointF )
1662 double area = calc->
measureArea( f.constGeometry() );
1668 return QVariant( f.constGeometry()->area() );
1695 return QVariant( f.constGeometry()->length() );
1712 return f.constGeometry()->isEmpty() ?
QVariant( 0 ) :
QVariant( f.constGeometry()->geometry()->perimeter() );
1757 for (
int i = 0; i < collection->numGeometries(); ++i )
1760 if ( !curvePolygon )
1781 bool foundPoly =
false;
1790 if ( !curvePolygon )
1864 if ( values.length() < 2 || values.length() > 3 )
1870 if ( fGeom.
isEmpty() || sGeom.isEmpty() )
1875 if ( values.length() == 2 )
1878 QString result = engine->relate( *sGeom.geometry() );
1885 bool result = engine->relatePattern( *sGeom.geometry(), pattern );
1940 if ( values.length() < 2 || values.length() > 3 )
1946 if ( values.length() == 3 )
2061 if ( values.length() < 1 || values.length() > 2 )
2066 if ( values.length() == 2 )
2074 if ( values.length() != 2 )
2093 if ( pt1->x() == pt2->
x() )
2095 if ( pt1->y() < pt2->
y() )
2097 else if ( pt1->y() > pt2->
y() )
2103 if ( pt1->y() == pt2->
y() )
2105 if ( pt1->x() < pt2->
x() )
2107 else if ( pt1->x() > pt2->
x() )
2113 if ( pt1->x() < pt2->
x() )
2115 if ( pt1->y() < pt2->
y() )
2117 return atan( fabs( pt1->x() - pt2->
x() ) / fabs( pt1->y() - pt2->
y() ) );
2121 return atan( fabs( pt1->y() - pt2->
y() ) / fabs( pt1->x() - pt2->
x() ) )
2128 if ( pt1->y() > pt2->
y() )
2130 return atan( fabs( pt1->x() - pt2->
x() ) / fabs( pt1->y() - pt2->
y() ) )
2135 return atan( fabs( pt1->y() - pt2->
y() ) / fabs( pt1->x() - pt2->
x() ) )
2143 if ( values.length() != 3 )
2158 if ( values.length() < 2 )
2164 return values.at( 0 );
2167 bool asc = values.value( 2 ).toBool();
2185 Q_ASSERT( collection );
2189 QgsExpressionSorter sorter( orderBy );
2192 for (
int i = 0; i < collection->
partCount(); ++i )
2198 sorter.sortFeatures( partFeatures, unconstedContext );
2202 Q_ASSERT( orderedGeom );
2207 Q_FOREACH (
const QgsFeature& feature, partFeatures )
2215 delete unconstedContext;
2244 if ( values.length() == 2 )
2247 double scaler = pow( 10.0,
getIntValue( values.at( 1 ), parent ) );
2248 return QVariant( qRound( number * scaler ) / scaler );
2251 if ( values.length() == 1 )
2253 double number =
getIntValue( values.at( 0 ), parent );
2275 int places =
getIntValue( values.at( 1 ), parent );
2281 return QString(
"%L1" ).
arg( value, 0,
'f', places );
2294 int green =
getIntValue( values.at( 1 ), parent );
2297 if ( ! color.isValid() )
2300 color =
QColor( 0, 0, 0 );
2303 return QString(
"%1,%2,%3" ).
arg( color.red() ).arg( color.green() ).arg( color.blue() );
2314 node =
getNode( values.at( 1 ), parent );
2316 value = node->
eval( parent, context );
2321 node =
getNode( values.at( 2 ), parent );
2323 value = node->
eval( parent, context );
2332 int green =
getIntValue( values.at( 1 ), parent );
2334 int alpha =
getIntValue( values.at( 3 ), parent );
2336 if ( ! color.isValid() )
2339 color =
QColor( 0, 0, 0 );
2354 QColor color = mRamp->color( value );
2361 double hue =
getIntValue( values.at( 0 ), parent ) / 360.0;
2363 double saturation =
getIntValue( values.at( 1 ), parent ) / 100.0;
2365 double lightness =
getIntValue( values.at( 2 ), parent ) / 100.0;
2369 if ( ! color.isValid() )
2372 color =
QColor( 0, 0, 0 );
2375 return QString(
"%1,%2,%3" ).
arg( color.red() ).arg( color.green() ).arg( color.blue() );
2381 double hue =
getIntValue( values.at( 0 ), parent ) / 360.0;
2383 double saturation =
getIntValue( values.at( 1 ), parent ) / 100.0;
2385 double lightness =
getIntValue( values.at( 2 ), parent ) / 100.0;
2387 double alpha =
getIntValue( values.at( 3 ), parent ) / 255.0;
2390 if ( ! color.isValid() )
2392 parent->
setEvalErrorString(
QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
2393 color =
QColor( 0, 0, 0 );
2401 double hue =
getIntValue( values.at( 0 ), parent ) / 360.0;
2403 double saturation =
getIntValue( values.at( 1 ), parent ) / 100.0;
2405 double value =
getIntValue( values.at( 2 ), parent ) / 100.0;
2409 if ( ! color.isValid() )
2412 color =
QColor( 0, 0, 0 );
2415 return QString(
"%1,%2,%3" ).
arg( color.red() ).arg( color.green() ).arg( color.blue() );
2421 double hue =
getIntValue( values.at( 0 ), parent ) / 360.0;
2423 double saturation =
getIntValue( values.at( 1 ), parent ) / 100.0;
2425 double value =
getIntValue( values.at( 2 ), parent ) / 100.0;
2427 double alpha =
getIntValue( values.at( 3 ), parent ) / 255.0;
2430 if ( ! color.isValid() )
2432 parent->
setEvalErrorString(
QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
2433 color =
QColor( 0, 0, 0 );
2441 double cyan =
getIntValue( values.at( 0 ), parent ) / 100.0;
2443 double magenta =
getIntValue( values.at( 1 ), parent ) / 100.0;
2445 double yellow =
getIntValue( values.at( 2 ), parent ) / 100.0;
2447 double black =
getIntValue( values.at( 3 ), parent ) / 100.0;
2451 if ( ! color.isValid() )
2454 color =
QColor( 0, 0, 0 );
2457 return QString(
"%1,%2,%3" ).
arg( color.red() ).arg( color.green() ).arg( color.blue() );
2463 double cyan =
getIntValue( values.at( 0 ), parent ) / 100.0;
2465 double magenta =
getIntValue( values.at( 1 ), parent ) / 100.0;
2467 double yellow =
getIntValue( values.at( 2 ), parent ) / 100.0;
2469 double black =
getIntValue( values.at( 3 ), parent ) / 100.0;
2471 double alpha =
getIntValue( values.at( 4 ), parent ) / 255.0;
2474 if ( ! color.isValid() )
2476 parent->
setEvalErrorString(
QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
2477 color =
QColor( 0, 0, 0 );
2495 return color.
green();
2497 return color.
blue();
2499 return color.
alpha();
2505 return color.
valueF() * 100;
2513 return color.
cyanF() * 100;
2519 return color.
blackF() * 100;
2535 int value =
getIntValue( values.at( 2 ), parent );
2624 if ( ! s.createFromOgcWmsCrs( sAuthId ) )
2644 if ( !layersByName.
isEmpty() )
2657 int attributeId = vl->fieldNameIndex( attribute );
2658 if ( attributeId == -1 )
2663 const QVariant& attVal = values.at( 2 );
2690 if ( !layersByName.
isEmpty() )
2692 layer = layersByName.
at( 0 );
2701 return layer->name();
2705 return layer->title();
2707 return layer->abstract();
2709 return layer->keywordList();
2711 return layer->dataUrl();
2713 return layer->attribution();
2715 return layer->attributionUrl();
2717 return layer->publicSource();
2719 return static_cast< double >( layer->minimumScale() );
2721 return static_cast< double >( layer->maximumScale() );
2723 return layer->crs().authid();
2725 return layer->crs().toProj4();
2735 switch ( layer->type() )
2771 if ( transferOwnership )
2805 <<
"abs" <<
"sqrt" <<
"cos" <<
"sin" <<
"tan" 2806 <<
"asin" <<
"acos" <<
"atan" <<
"atan2" 2807 <<
"exp" <<
"ln" <<
"log10" <<
"log" 2808 <<
"round" <<
"rand" <<
"randf" <<
"max" <<
"min" <<
"clamp" 2809 <<
"scale_linear" <<
"scale_exp" <<
"floor" <<
"ceil" <<
"$pi" 2810 <<
"toint" <<
"to_int" <<
"toreal" <<
"to_real" <<
"tostring" <<
"to_string" 2811 <<
"todatetime" <<
"to_datetime" <<
"todate" <<
"to_date" 2812 <<
"totime" <<
"to_time" <<
"tointerval" <<
"to_interval" 2813 <<
"coalesce" <<
"if" <<
"regexp_match" <<
"age" <<
"year" 2814 <<
"month" <<
"week" <<
"day" <<
"hour" <<
"day_of_week" 2815 <<
"minute" <<
"second" <<
"lower" <<
"upper" 2816 <<
"title" <<
"length" <<
"replace" <<
"trim" <<
"wordwrap" 2817 <<
"regexp_replace" <<
"regexp_substr" 2818 <<
"substr" <<
"concat" <<
"strpos" <<
"left" 2819 <<
"right" <<
"rpad" <<
"lpad" <<
"format" 2820 <<
"format_number" <<
"format_date" 2821 <<
"color_rgb" <<
"color_rgba" <<
"ramp_color" 2822 <<
"color_hsl" <<
"color_hsla" <<
"color_hsv" <<
"color_hsva" 2823 <<
"color_cmyk" <<
"color_cmyka" <<
"color_part" <<
"set_color_part" 2824 <<
"xat" <<
"yat" <<
"$area" <<
"area" <<
"perimeter" 2825 <<
"$length" <<
"$perimeter" <<
"x" <<
"y" <<
"$x" <<
"$y" <<
"z" <<
"m" <<
"num_points" 2826 <<
"num_interior_rings" <<
"num_rings" <<
"num_geometries" 2827 <<
"geometry_n" <<
"interior_ring_n" 2828 <<
"point_n" <<
"start_point" <<
"end_point" <<
"make_point" <<
"make_point_m" 2829 <<
"nodes_to_points" <<
"segments_to_lines" 2830 <<
"make_line" <<
"make_polygon" 2831 <<
"$x_at" <<
"x_at" <<
"xat" <<
"$y_at" <<
"y_at" <<
"yat" <<
"x_min" <<
"xmin" <<
"x_max" <<
"xmax" 2832 <<
"y_min" <<
"ymin" <<
"y_max" <<
"ymax" <<
"geom_from_wkt" <<
"geomFromWKT" 2833 <<
"geom_from_gml" <<
"geomFromGML" <<
"intersects_bbox" <<
"bbox" 2834 <<
"disjoint" <<
"intersects" <<
"touches" <<
"crosses" <<
"contains" 2836 <<
"overlaps" <<
"within" <<
"buffer" <<
"centroid" <<
"bounds" <<
"reverse" <<
"exterior_ring" 2837 <<
"bounds_width" <<
"bounds_height" <<
"is_closed" <<
"convex_hull" <<
"difference" 2838 <<
"distance" <<
"intersection" <<
"sym_difference" <<
"combine" 2839 <<
"extrude" <<
"azimuth" <<
"closest_point" <<
"shortest_line" 2840 <<
"union" <<
"geom_to_wkt" <<
"geomToWKT" <<
"geometry" 2841 <<
"transform" <<
"get_feature" <<
"getFeature" 2842 <<
"levenshtein" <<
"longest_common_substring" <<
"hamming_distance" 2844 <<
"attribute" <<
"var" <<
"layer_property" 2845 <<
"$id" <<
"$scale" <<
"_specialcol_";
3095 return isValid( text, &context, errorMessage );
3112 if ( !
d->mExp.isNull() )
3157 case QVariant::LongLong:
3158 case QVariant::Double:
3161 case QVariant::Bool:
3162 return value.
toBool() ?
"TRUE" :
"FALSE";
3165 case QVariant::String:
3179 for (
int i = 0; i < count; i++ )
3199 :
d( new QgsExpressionPrivate )
3203 Q_ASSERT( !
d->mParserErrorString.isNull() ||
d->mRootNode );
3220 :
d( new QgsExpressionPrivate )
3227 if ( !
d->ref.deref() )
3237 if ( !
d->mRootNode )
3240 QStringList columns =
d->mRootNode->referencedColumns();
3243 for (
int i = 0; i < columns.
count(); i++ )
3246 for (
int j = i + 1; j < columns.
count(); j++ )
3261 if ( !
d->mRootNode )
3263 return d->mRootNode->needsGeometry();
3268 if (
d->mCalc.data() )
3273 d->mCalc->setEllipsoidalMode(
false );
3282 ( void )
d->ref.deref();
3284 d =
new QgsExpressionPrivate( *
d );
3304 if ( !
d->mRootNode )
3312 if ( !
d->mRootNode )
3314 d->mEvalErrorString =
tr(
"No root node! Parsing failed?" );
3318 return d->mRootNode->prepare(
this, context );
3324 if ( !
d->mRootNode )
3326 d->mEvalErrorString =
tr(
"No root node! Parsing failed?" );
3331 return d->mRootNode->eval(
this, &context );
3345 bool res =
prepare( &context );
3363 if ( !
d->mRootNode )
3365 d->mEvalErrorString =
tr(
"No root node! Parsing failed?" );
3369 return d->mRootNode->eval(
this, static_cast<const QgsExpressionContext*>(
nullptr ) );
3375 if ( !
d->mRootNode )
3377 d->mEvalErrorString =
tr(
"No root node! Parsing failed?" );
3381 return d->mRootNode->eval(
this, context );
3386 return !
d->mEvalErrorString.isNull();
3391 return d->mEvalErrorString;
3396 d->mEvalErrorString = str;
3401 d->mRowNumber = rowNumber;
3408 if ( !
d->mRootNode )
3409 return tr(
"(no root)" );
3411 return d->mRootNode->dump();
3416 return d->mCalc.data();
3421 return d->mDistanceUnit;
3426 d->mDistanceUnit = unit;
3431 return d->mAreaUnit;
3436 d->mAreaUnit = unit;
3442 d->mRootNode->accept( v );
3458 if ( substitutionMap )
3465 if ( !oldValue.isNull() )
3466 savedValues.
insert( sit.key(), oldValue );
3475 while ( index < action.
size() )
3479 int pos = rx.
indexIn( action, index );
3492 expr_action += action.
midRef( start, index - start );
3507 expr_action += action.
midRef( start, index - start );
3512 expr_action += action.
mid( start, pos - start ) + result.
toString();
3515 expr_action += action.
midRef( index );
3532 double convertedValue = text.
toDouble( &ok );
3535 return convertedValue;
3546 convertedValue = result.
toDouble( &ok );
3549 return fallbackValue;
3551 return convertedValue;
3561 Q_FOREACH (
Node* node, mList )
3573 Q_FOREACH (
Node* n, mList )
3575 if ( !first ) msg +=
", ";
3587 QVariant val = mOperand->eval( parent, context );
3607 Q_ASSERT( 0 &&
"unknown unary operation" );
3614 return mOperand->prepare( parent, context );
3631 QVariant vL = mOpLeft->eval( parent, context );
3633 QVariant vR = mOpRight->eval( parent, context );
3639 if ( vL.
type() == QVariant::String && vR.
type() == QVariant::String )
3664 if ( mOp ==
boMod && iR == 0 )
3667 return QVariant( computeInt( iL, iR ) );
3680 return QVariant( computeDateTimeFromInterval( dL, &iL ) );
3689 if (( mOp ==
boDiv || mOp ==
boMod ) && fR == 0. )
3691 return QVariant( computeDouble( fL, fR ) );
3703 return QVariant( qFloor( fL / fR ) );
3811 esc_regexp.
replace(
'%',
".*" );
3812 esc_regexp.
replace(
'_',
'.' );
3916 return fmod( x, y );
3925 bool resL = mOpLeft->prepare( parent, context );
3926 bool resR = mOpRight->prepare( parent, context );
3927 return resL && resR;
3972 Q_ASSERT( 0 &&
"unexpected binary operator" );
4008 Q_ASSERT( 0 &&
"unexpected binary operator" );
4018 QString rdump( mOpRight->dump() );
4027 if ( leftAssociative() )
4029 fmt += lOp && ( lOp->
precedence() < precedence() ) ?
"(%1)" :
"%1";
4031 fmt += rOp && ( rOp->
precedence() <= precedence() ) ?
"(%3)" :
"%3";
4035 fmt += lOp && ( lOp->
precedence() <= precedence() ) ?
"(%1)" :
"%1";
4037 fmt += rOp && ( rOp->
precedence() < precedence() ) ?
"(%3)" :
"%3";
4052 if ( mList->count() == 0 )
4054 QVariant v1 = mNode->eval( parent, context );
4059 bool listHasNull =
false;
4061 Q_FOREACH (
Node* n, mList->list() )
4102 bool res = mNode->prepare( parent, context );
4103 Q_FOREACH (
Node* n, mList->list() )
4105 res = res && n->
prepare( parent, context );
4112 return QString(
"%1 %2 IN (%3)" ).
arg( mNode->dump(), mNotIn ?
"NOT" :
"", mList->dump() );
4117 return new NodeInOperator( mNode->clone(), mList->clone(), mNotIn );
4128 QVariantList argValues;
4131 Q_FOREACH (
Node* n, mArgs->list() )
4141 v = n->
eval( parent, context );
4146 argValues.append( v );
4163 Q_FOREACH (
Node* n, mArgs->list() )
4165 res = res && n->
prepare( parent, context );
4188 return functionColumns;
4191 Q_FOREACH (
Node* n, mArgs->list() )
4197 return functionColumns.
toSet().toList();
4202 return new NodeFunction( mFnIndex, mArgs ? mArgs->clone() : nullptr );
4209 Q_UNUSED( context );
4217 Q_UNUSED( context );
4224 if ( mValue.isNull() )
4227 switch ( mValue.type() )
4231 case QVariant::Double:
4233 case QVariant::String:
4235 case QVariant::Bool:
4236 return mValue.toBool() ?
"TRUE" :
"FALSE";
4238 return tr(
"[unsupported type;%1; value:%2]" ).arg( mValue.typeName(), mValue.toString() );
4260 return QVariant(
'[' + mName +
']' );
4277 parent->
d->mEvalErrorString =
tr(
"Column '%1' not found" ).arg( mName );
4297 Q_FOREACH (
WhenThen* cond, mConditions )
4312 QVariant vElse = mElseExp->eval( parent, context );
4324 Q_FOREACH (
WhenThen* cond, mConditions )
4328 if ( !res )
return false;
4332 return mElseExp->prepare( parent, context );
4340 Q_FOREACH (
WhenThen* cond, mConditions )
4345 msg +=
QString(
" ELSE %1" ).
arg( mElseExp->dump() );
4353 Q_FOREACH (
WhenThen* cond, mConditions )
4359 lst += mElseExp->referencedColumns();
4366 Q_FOREACH (
WhenThen* cond, mConditions )
4373 if ( mElseExp && mElseExp->needsGeometry() )
4382 Q_FOREACH (
WhenThen* wt, mConditions )
4384 return new NodeCondition( conditions, mElseExp ? mElseExp->clone() : nullptr );
4393 return tr(
"function help for %1 missing" ).arg( name );
4398 if ( f.
mType ==
tr(
"group" ) )
4399 name =
group( name );
4401 #if QT_VERSION < 0x050000 4404 name = name.toHtmlEscaped();
4407 QString helpContents(
QString(
"<h3>%1</h3>\n<div class=\"description\"><p>%2</p></div>" )
4408 .arg(
tr(
"%1 %2" ).arg( f.
mType, name ),
4419 helpContents +=
QString(
"<h4>%1</h4>\n<div class=\"syntax\">\n" ).
arg(
tr(
"Syntax" ) );
4421 if ( f.
mType ==
tr(
"operator" ) )
4425 helpContents +=
QString(
"<code><span class=\"functionname\">%1</span> <span class=\"argument\">%2</span></code>" )
4430 helpContents +=
QString(
"<code><span class=\"argument\">%1</span> <span class=\"functionname\">%2</span> <span class=\"argument\">%3</span></code>" )
4434 else if ( f.
mType !=
tr(
"group" ) && f.
mType !=
tr(
"expression" ) )
4436 helpContents +=
QString(
"<code><span class=\"functionname\">%1</span>" ).
arg( name );
4440 helpContents +=
'(';
4445 helpContents += delim;
4448 helpContents +=
QString(
"<span class=\"argument\">%1</span>" ).
arg( a.
mArg );
4453 helpContents +=
"...";
4456 helpContents +=
')';
4459 helpContents +=
"</code>";
4464 helpContents +=
QString(
"<h4>%1</h4>\n<div class=\"arguments\">\n<table>" ).
arg(
tr(
"Arguments" ) );
4474 helpContents +=
"</table>\n</div>\n";
4479 helpContents +=
QString(
"<h4>%1</h4>\n<div class=\"examples\">\n<ul>\n" ).
arg(
tr(
"Examples" ) );
4483 helpContents +=
"<li><code>" + e.
mExpression +
"</code> → <code>" + e.
mReturns +
"</code>";
4488 helpContents +=
"</li>\n";
4491 helpContents +=
"</ul>\n</div>\n";
4496 helpContents +=
QString(
"<h4>%1</h4>\n<div class=\"notes\"><p>%2</p></div>\n" ).
arg(
tr(
"Notes" ), v.
mNotes );
4500 return helpContents;
4627 return tr(
"<i><empty geometry></i>" );
4635 return tr(
"<i><feature: %1></i>" ).arg( feat.
id() );
4641 return tr(
"<i><interval: %1 days></i>" ).arg( interval.
days() );
4643 else if ( value.
type() == QVariant::Date )
4646 return tr(
"<i><date: %1></i>" ).arg( dt.
toString(
"yyyy-MM-dd" ) );
4648 else if ( value.
type() == QVariant::Time )
4651 return tr(
"<i><time: %1></i>" ).arg( tm.
toString(
"hh:mm:ss" ) );
4653 else if ( value.
type() == QVariant::DateTime )
4656 return tr(
"<i><datetime: %1></i>" ).arg( dt.
toString(
"yyyy-MM-dd hh:mm:ss" ) );
4658 else if ( value.
type() == QVariant::String )
4661 if ( previewString.
length() > 63 )
4680 return func( values, &c, parent );
4691 return func( values, &f, parent );
4699 return eval( parent, &c );
4710 return eval( parent, &f );
4735 return mFnc ? mFnc( values, f, parent ) :
QVariant();
4741 return d->mRootNode;
QgsFeatureId id() const
Get the feature ID for this feature.
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.
const QgsCurveV2 * exteriorRing() const
bool canConvert(Type t) const
Class for parsing and evaluation of expressions (formerly called "search strings").
double years()
interval length in years
qlonglong toLongLong(bool *ok) const
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)
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
static QVariant fcnGeomNumInteriorRings(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
Wrapper for iterator of features from vector data provider or vector layer.
QString toString(Qt::DateFormat format) const
const QgsVectorColorRampV2 * colorRampRef(const QString &name) const
return a const pointer to a symbol (doesn't create new instance)
static QVariant fcnGeomLength(const QVariantList &, const QgsExpressionContext *context, QgsExpression *parent)
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)
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
virtual Q_DECL_DEPRECATED QVariant eval(QgsExpression *parent, const QgsFeature *f)
Abstract virtual eval method Errors are reported to the parent.
bool hasFunction(const QString &name) const
Checks whether a specified function is contained in the context.
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 *)
QString cap(int nth) const
static QVariant fcnGeomPerimeter(const QVariantList &, const QgsExpressionContext *context, QgsExpression *parent)
QString & append(QChar ch)
virtual Node * clone() const =0
Generate a clone of this node.
iterator insert(const Key &key, const T &value)
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
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)
QgsPointV2 pointN(int i) const
Returns the specified point from inside the line string.
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)
iterator erase(iterator pos)
QStringList referencedColumns() const
Get list of columns referenced by the expression.
static QVariant fncLighter(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnFormatString(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsGeometry * convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry. ...
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.
virtual bool handlesNull() const
static QVariant fcnBuffer(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
double months()
interval length in months
virtual QgsCoordinateSequenceV2 coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
QgsGeometry * symDifference(const QgsGeometry *geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
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)
bool hasVariable(const QString &name) const
Check whether a variable is specified by any scope within the context.
static QVariant fcnGetGeometry(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool lazyEval()
True if this function should use lazy evaluation.
bool isValid() const
Returns the validity of this feature.
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)
double x() const
Returns the point's x-coordinate.
static void initVariableHelp()
static QVariant fcnXat(const QVariantList &values, const QgsExpressionContext *f, QgsExpression *parent)
QgsGeometry * difference(const QgsGeometry *geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
double distance(const QgsGeometry &geom) const
Returns the minimum distance between this geometry and another geometry, using GEOS.
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)
bool compare(double diff)
A abstract base class for defining QgsExpression functions.
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)
double yMaximum() const
Get the y maximum value (top side of rectangle)
QgsFields fields() const
Returns the list of fields of this layer.
double computeDouble(double x, double y)
static QVariant fcnIf(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
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...
int fieldNameIndex(const QString &fieldName) const
Look up field's index from name also looks up case-insensitive if there is no match otherwise...
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)
virtual Node * clone() const override
Generate a clone of this node.
static QVariant pointAt(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
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.
double weeks()
interval length in weeks
#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)
#define Q_NOWARN_DEPRECATED_PUSH
QgsExpression()
Used by QgsOgcUtils to create an empty.
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
virtual QVariant eval(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
Abstract base class for all geometries.
bool crosses(const QgsGeometry *geometry) const
Test for if geometry crosses another (uses GEOS)
static QVariant fncColorHsva(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
Container of fields for a vector layer.
static QVariant fcnAge(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnToTime(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QgsGeometry * pointOnSurface() const
Returns a point within a geometry.
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
const_iterator constFind(const Key &key) const
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)
QString dump() const
Return an expression string, constructed from the internal abstract syntax tree.
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)
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...
static QString formatPreviewString(const QVariant &value)
Formats an expression result for friendly display to the user.
static QVariant fcnMax(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QList< HelpVariant > mVariants
static QVariant fcnLCS(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
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)
Q_DECL_DEPRECATED int currentRowNumber()
Return the number used for $rownum special column.
double toDouble(bool *ok) const
static Q_DECL_DEPRECATED bool isValid(const QString &text, const QgsFields &fields, QString &errorMessage)
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
Multi line string geometry collection.
QString tr(const char *sourceText, const char *disambiguation, int n)
const Node * rootNode() const
Returns root node of the expression. Root node is null is parsing has failed.
static QVariant fncColorPart(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnAzimuth(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QString soundex(const QString &string)
Returns the Soundex representation of a string.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
QGis::UnitType distanceUnits() const
Returns the desired distance units for calculations involving geomCalculator(), eg "$length" and "$pe...
double x() const
Get the x value of the point.
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)
int nCoordinates() const
Returns the number of nodes contained in the geometry.
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)
QVariant variable(const QString &name) const
Fetches a matching variable from the context.
QgsMapLayer * mapLayer(const QString &theLayerId)
Retrieve a pointer to a loaded layer by id.
void setEvalErrorString(const QString &str)
Set evaluation error (used internally by evaluation functions)
static QgsGeometry getGeometry(const QVariant &value, QgsExpression *parent)
#define ENSURE_NO_EVAL_ERROR
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)
virtual QString dump() const override
Abstract virtual dump method.
double y() const
Returns the point's y-coordinate.
static QVariant fcnCos(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static const QStringList & BuiltinFunctions()
static QVariant fcnSymDifference(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
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()
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)
bool isValid()
getter interval validity
int indexIn(const QString &str, int offset, CaretMode caretMode) const
static QVariant fcnMin(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool createFromOgcWmsCrs(QString theCrs)
Set up this CRS from the given OGC CRS.
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...
NodeList * clone() const
Creates a deep copy of this list.
static QVariant fcnMinute(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
void acceptVisitor(Visitor &v) const
Entry function for the visitor pattern.
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object.
static QVariant fcnTrim(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool leftAssociative() const
bool contains(const QgsPoint *p) const
Test for containment of a point (uses GEOS)
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)
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...
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.
virtual QVariant eval(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
int toInt(bool *ok) const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
static QVariant fcnIntersects(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnColorHsv(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
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)
double xMaximum() const
Get the x maximum value (right side of rectangle)
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 *)
double z() const
Returns the point's z-coordinate.
virtual QString dump() const override
Abstract virtual dump method.
Line string geometry type, with support for z-dimension and m-values.
static QVariant fcnScale(const QVariantList &, const QgsExpressionContext *, QgsExpression *parent)
double convertAreaMeasurement(double area, QgsUnitTypes::AreaUnit toUnits) const
Takes an area measurement calculated by this QgsDistanceArea object and converts it to a different ar...
bool isEmpty() const
Returns true if the geometry is empty.
static QVariant fcnRowNumber(const QVariantList &, const QgsExpressionContext *context, QgsExpression *parent)
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)
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)
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
static void cleanRegisteredFunctions()
Deletes all registered functions whose ownership have been transferred to the expression engine...
bool overlaps(const QgsGeometry *geometry) const
Test for if geometry overlaps another (uses GEOS)
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 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)
double minutes()
interval length in minutus
const_iterator constEnd() const
static QVariant fcnRadians(const QVariantList &values, const QgsExpressionContext *, 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.
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.
double hours()
interval length in hours
void addInteriorRing(QgsCurveV2 *ring) override
Adds an interior ring to the geometry (takes ownership)
virtual QVariant eval(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual eval method Errors are reported to the parent.
QgsFeature feature() const
Convenience function for retrieving the feature for the context, if set.
static const QString AllAttributes
A special attribute that if set matches all attributes.
static QVariant fcnExp(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnPointOnSurface(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
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 QHash< QString, QString > gVariableHelpTexts
static QVariant fcnContains(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnToInterval(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QGis::GeometryType geometryType() const
Returns point, line or polygon.
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.
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)
QgsGeometry * centroid() const
Returns the center of mass of a geometry.
static QVariant fcnCrosses(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static const QString EXPR_FIELDS
Inbuilt variable name for fields storage.
QgsUnitTypes::AreaUnit areaUnits() const
Returns the desired areal units for calculations involving geomCalculator(), eg "$area".
virtual QString dump() const
QString name()
The name of the function.
Q_DECL_DEPRECATED void setCurrentRowNumber(int rowNumber)
Set the number for $rownum special column.
static QVariant tvl2variant(TVL v)
#define ENSURE_GEOM_TYPE(f, g, geomtype)
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)
bool operator==(QgsExpression::Interval other) const
compare two intervals
QList< HelpExample > mExamples
static QVariant fcnToString(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool isIntervalSafe(const QVariant &v)
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...
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)
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)
QList< QgsMapLayer * > mapLayersByName(const QString &layerName)
Retrieve a pointer to a loaded layer by name.
int translate(double dx, double dy)
Translate this geometry by dx, dy.
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
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 measureArea(const QgsGeometry *geometry) const
Measures the area of a geometry.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometryV2 *geometry)
Creates and returns a new geometry engine.
static QVariant fcnGeomFromGML(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool contains(QChar ch, Qt::CaseSensitivity cs) const
void setHslF(qreal h, qreal s, qreal l, qreal a)
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)
static QVariant fcnMakePointM(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
void setHsvF(qreal h, qreal s, qreal v, qreal a)
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
const QgsCurveV2 * interiorRing(int i) const
static QVariant fcnLeft(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QVariant fromValue(const T &value)
double length() const
Returns the length of geometry using GEOS.
static QString getStringValue(const QVariant &value, QgsExpression *)
The OrderByClause class represents an order by clause for a QgsFeatureRequest.
static QVariant fcnDegrees(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
double days()
interval length in days
static QVariant fcnSoundex(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QgsFeature getFeature(const QVariant &value, QgsExpression *parent)
virtual QStringList referencedColumns() const
static QVariant fcnRPad(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnLog(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static double getDoubleValue(const QVariant &value, QgsExpression *parent)
#define Q_NOWARN_DEPRECATED_POP
General purpose distance and area calculator.
static QVariant fcnAtlasCurrentFeature(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
QgsGeometry * intersection(const QgsGeometry *geometry) const
Returns a geometry representing the points shared by this geometry and other.
bool vertexIdFromVertexNr(int nr, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
virtual Node * clone() const override
Generate a clone of this node.
QgsGeometry * combine(const QgsGeometry *geometry) const
Returns a geometry representing all the points in this geometry and other (a union geometry operation...
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. ...
int numGeometries() const
Returns the number of geometries within the collection.
void addVertex(const QgsPointV2 &pt)
Adds a new vertex to the end of the line string.
double measureLength(const QgsGeometry *geometry) const
Measures the length of a geometry.
static QVariant fcnPointN(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnBounds(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
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.
static QVariant fcnOverlaps(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
QDateTime currentDateTime()
bool isIntSafe(const QVariant &v)
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QString mid(int position, int n) const
QgsGeometry shortestLine(const QgsGeometry &other) const
Returns the shortest line joining this geometry to another geometry.
bool isDateTimeSafe(const QVariant &v)
static const char * UnaryOperatorText[]
static QVariant fcnDay(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QgsExpression::Interval invalidInterVal()
return an invalid interval
QgsGeometry nearestPoint(const QgsGeometry &other) const
Returns the nearest point on this geometry to another geometry.
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 *)
static QVariant fcnLPad(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QgsExpression::Node * getNode(const QVariant &value, QgsExpression *parent)
double seconds()
interval length in seconds
QString escape(const QString &plain)
static QVariant fcnReplace(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QgsExpression::Interval fromString(const QString &string)
convert a string to an interval
qreal hsvSaturationF() const
virtual bool isClosed() const
Returns true if the curve is closed.
static QList< Function * > specialColumns()
Returns a list of special Column definitions.
int params()
The number of parameters this function takes.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
static QVariant fcnAtan(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
Class for storing a coordinate reference system (CRS)
virtual bool addGeometry(QgsAbstractGeometryV2 *g)
Adds a geometry and takes ownership.
QString translate(const char *context, const char *sourceText, const char *disambiguation, Encoding encoding)
static QVariant fcnAttribute(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
int count(const T &value) const
virtual QStringList referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node...
bool within(const QgsGeometry *geometry) const
Test for if geometry is within another (uses GEOS)
void setDistanceUnits(QGis::UnitType unit)
Sets the desired distance units for calculations involving geomCalculator(), eg "$length" and "$perim...
static QVariant fcnMakePolygon(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
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.
static QVariant fcnXMax(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
const QgsAbstractGeometryV2 * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
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.
double m() const
Returns the point's m value.
QString leftJustified(int width, QChar fill, bool truncate) const
int lastIndexOf(const QRegExp &rx, int from) const
UnitType
Map units that qgis supports.
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 QHash< QString, Help > gFunctionHelpTexts
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...
QString expression() const
Return the original, unmodified expression string.
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)
double y() const
Get the y value of the point.
static QVariant fcnSqrt(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnTitle(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QStringList gmBuiltinFunctions
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)
static QString variableHelpText(const QString &variableName, bool showValue=true, const QVariant &value=QVariant())
Returns the help text for a specified variable.
bool disjoint(const QgsGeometry *geometry) const
Test for if geometry is disjoint of another (uses GEOS)
iterator insert(const Key &key, const T &value)
bool contains(const Key &key) const
static QVariant fcnYMin(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
static QVariant fcnGeometry(const QVariantList &, const QgsExpressionContext *context, QgsExpression *)
static QVariant fcnUuid(const QVariantList &, const QgsExpressionContext *, QgsExpression *)
bool touches(const QgsGeometry *geometry) const
Test for if geometry touch another (uses GEOS)
static Q_DECL_DEPRECATED QVariant specialColumn(const QString &name)
Return the value of the given special column or a null QVariant if undefined.
Curve polygon geometry type.
static void initFunctionHelp()
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
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)
QgsExpression::Function * function(const QString &name) const
Fetches a matching function from the context.
QString exportToWkt(int precision=17) const
Exports the geometry to WKT.
void setValid(bool valid)
setter interval validity
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
int numInteriorRings() const
bool nextFeature(QgsFeature &f)
QDateTime computeDateTimeFromInterval(const QDateTime &d, QgsExpression::Interval *i)
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...
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)
Geometry is not required. It may still be returned if e.g. required for a filter condition.
void setScale(double scale)
double convertLengthMeasurement(double length, QGis::UnitType toUnits) const
Takes a length measurement calculated by this QgsDistanceArea object and converts it to a different d...
double width() const
Width of the rectangle.
QgsPoint asPoint() const
Return contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
static QVariant fcnRegexpReplace(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool intersects(const QgsRectangle &r) const
Test for intersection with a rectangle (uses GEOS)
Represents a vector layer which manages a vector based data sets.
int hslSaturation() const
int compare(const QString &other) const
void setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a)
QString parserErrorString() const
Returns parser error.
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
double xMinimum() const
Get the x minimum value (left side of rectangle)
virtual QStringList referencedColumns() const override
Abstract virtual method which returns a list of columns required to evaluate this node...
void detach()
Helper for implicit sharing.
QString evalErrorString() const
Returns evaluation error.
iterator find(const Key &key)
static QVariant fcnGeomM(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
bool isNull(const QVariant &v)
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.
virtual bool prepare(QgsExpression *parent, const QgsExpressionContext *context) override
Abstract virtual preparation method Errors are reported to the parent.
double area() const
Returns the area of the geometry using GEOS.
static QVariant fcnSubstr(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
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)
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.
double height() const
Height of the rectangle.
int numPoints() const override
Returns the number of points in the curve.
QList< QgsPointV2 > QgsPointSequenceV2
QColor fromHslF(qreal h, qreal s, qreal l, qreal a)
static QVariant fcnColorRgb(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fncColorRgba(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QgsExpression::Interval getInterval(const QVariant &value, QgsExpression *parent, bool report_error=false)
const T value(const Key &key) const
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 Q_DECL_DEPRECATED void unsetSpecialColumn(const QString &name)
Unset a special column.
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
static QVariant fcnSpecialColumn(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnLength(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static QVariant fcnLower(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
static const char * BinaryOperatorText[]
static QMap< QString, QVariant > gmSpecialColumns
bool mVariableLenArguments