19 #include <QDomDocument> 55 #if QT_VERSION < 0x050000 56 #include <qtextdocument.h> 72 QRegExp rx(
"([-+]?\\d?\\.?\\d+\\s+\\S+)", Qt::CaseInsensitive );
76 while (( pos = rx.
indexIn(
string, pos ) ) != -1 )
83 map.
insert( 1,
QStringList() <<
"second" <<
"seconds" <<
tr(
"second|seconds",
"list of words separated by | which reference years" ).split(
'|' ) );
84 map.
insert( 0 + MINUTE,
QStringList() <<
"minute" <<
"minutes" <<
tr(
"minute|minutes",
"list of words separated by | which reference minutes" ).split(
'|' ) );
85 map.
insert( 0 + HOUR,
QStringList() <<
"hour" <<
"hours" <<
tr(
"hour|hours",
"list of words separated by | which reference minutes hours" ).split(
'|' ) );
86 map.
insert( 0 + DAY,
QStringList() <<
"day" <<
"days" <<
tr(
"day|days",
"list of words separated by | which reference days" ).split(
'|' ) );
87 map.
insert( 0 + WEEKS,
QStringList() <<
"week" <<
"weeks" <<
tr(
"week|weeks",
"wordlist separated by | which reference weeks" ).split(
'|' ) );
88 map.
insert( 0 + MONTHS,
QStringList() <<
"month" <<
"months" <<
tr(
"month|months",
"list of words separated by | which reference months" ).split(
'|' ) );
89 map.
insert( 0 + YEARS,
QStringList() <<
"year" <<
"years" <<
tr(
"year|years",
"list of words separated by | which reference years" ).split(
'|' ) );
91 Q_FOREACH (
const QString& match, list )
95 double value = split.
at( 0 ).toDouble( &ok );
101 bool matched =
false;
103 for ( ; it != map.
constEnd(); ++it )
105 int duration = it.
key();
108 if ( match.
contains( name, Qt::CaseInsensitive ) )
117 seconds += value * duration;
176 #define TVL_True QVariant(1) 177 #define TVL_False QVariant(0) 178 #define TVL_Unknown QVariant() 185 if ( v.
type() == QVariant::Int )
return true;
186 if ( v.
type() == QVariant::UInt )
return true;
187 if ( v.
type() == QVariant::LongLong )
return true;
188 if ( v.
type() == QVariant::ULongLong )
return true;
189 if ( v.
type() == QVariant::Double )
return false;
190 if ( v.
type() == QVariant::String ) {
bool ok; v.
toString().
toInt( &ok );
return ok; }
195 if ( v.
type() == QVariant::Double )
return true;
196 if ( v.
type() == QVariant::Int )
return true;
197 if ( v.
type() == QVariant::UInt )
return true;
198 if ( v.
type() == QVariant::LongLong )
return true;
199 if ( v.
type() == QVariant::ULongLong )
return true;
200 if ( v.
type() == QVariant::String )
204 ok = ok && qIsFinite( val ) && !qIsNaN( val );
212 return v.
type() == QVariant::DateTime || v.
type() == QVariant::Date ||
213 v.
type() == QVariant::Time;
223 if ( v.
type() == QVariant::String )
235 #define ENSURE_NO_EVAL_ERROR { if (parent->hasEvalError()) return QVariant(); } 236 #define SET_EVAL_ERROR(x) { parent->setEvalErrorString(x); return QVariant(); } 245 "=",
"<>",
"<=",
">=",
"<",
">",
"~",
"LIKE",
"NOT LIKE",
"ILIKE",
"NOT ILIKE",
"IS",
"IS NOT",
246 "+",
"-",
"*",
"/",
"//",
"%",
"^",
269 if ( !ok || qIsNaN( x ) || !qIsFinite( x ) )
346 if ( inter.isValid() )
405 if ( value.
type() == QVariant::Int )
436 return expression.evaluate( context );
454 return ( deg *
M_PI ) / 180;
459 return ( 180 * rad ) /
M_PI;
520 if ( x <= 0 || b <= 0 )
522 return QVariant( log( x ) / log( b ) );
532 double f =
static_cast< double >( qrand() ) / RAND_MAX;
533 return QVariant( min + f * ( max - min ) );
543 return QVariant( min + ( qrand() % static_cast< int >( max - min + 1 ) ) );
554 if ( domainMin >= domainMax )
561 if ( val >= domainMax )
565 else if ( val <= domainMin )
571 double m = ( rangeMax - rangeMin ) / ( domainMax - domainMin );
572 double c = rangeMin - ( domainMin * m );
587 if ( domainMin >= domainMax )
599 if ( val >= domainMax )
603 else if ( val <= domainMin )
609 return QVariant((( rangeMax - rangeMin ) / pow( domainMax - domainMin, exponent ) ) * pow( val - domainMin, exponent ) + rangeMin );
618 for (
int i = 1; i < values.length(); ++i )
621 if ( testVal > maxVal )
636 for (
int i = 1; i < values.length(); ++i )
639 if ( testVal < minVal )
655 if ( testValue <= minValue )
659 else if ( testValue >= maxValue )
701 Q_FOREACH (
const QVariant &value, values )
723 for (
int i = 0; i < elems.size(); i++ )
725 if ( elems[i].size() > 1 )
726 elems[i] = elems[i].left( 1 ).toUpper() + elems[i].
mid( 1 ).toLower();
728 return QVariant( elems.join(
" " ) );
767 if ( values.length() == 2 || values.length() == 3 )
772 if ( !str.
isEmpty() && wrap != 0 )
776 if ( values.length() == 3 ) delimiterstr =
getStringValue( values.at( 2 ), parent );
777 if ( delimiterstr.
isEmpty() ) delimiterstr =
' ';
778 int delimiterlength = delimiterstr.
length();
781 int strlength, strcurrent, strhit, lasthit;
783 for (
int i = 0; i < lines.
size(); i++ )
785 strlength = lines[i].
length();
790 while ( strcurrent < strlength )
797 strhit = lines[i].
lastIndexOf( delimiterstr, strcurrent + wrap );
798 if ( strhit == lasthit || strhit == -1 )
801 strhit = lines[i].
indexOf( delimiterstr, strcurrent + qAbs( wrap ) );
807 strhit = lines[i].
indexOf( delimiterstr, strcurrent + qAbs( wrap ) );
811 newstr.
append( lines[i].midRef( strcurrent, strhit - strcurrent ) );
813 strcurrent = strhit + delimiterlength;
817 newstr.
append( lines[i].midRef( strcurrent ) );
818 strcurrent = strlength;
821 if ( i < lines.
size() - 1 ) newstr.
append(
'\n' );
898 ( void )re.indexIn( str );
899 if ( re.captureCount() > 0 )
902 return QVariant( re.capturedTexts().at( 1 ) );
925 if ( context && context->
hasVariable(
"row_number" ) )
926 return context->
variable(
"row_number" );
937 return context->
variable(
"map_id" );
946 if ( context && context->
hasVariable(
"layout_numpages" ) )
947 return context->
variable(
"layout_numpages" );
956 if ( context && context->
hasVariable(
"layout_page" ) )
957 return context->
variable(
"layout_page" );
966 if ( context && context->
hasVariable(
"atlas_featurenumber" ) )
967 return context->
variable(
"atlas_featurenumber" );
976 if ( context && context->
hasVariable(
"atlas_featureid" ) )
977 return context->
variable(
"atlas_featureid" );
987 if ( context && context->
hasVariable(
"atlas_feature" ) )
988 return context->
variable(
"atlas_feature" );
997 if ( context && context->
hasVariable(
"atlas_geometry" ) )
998 return context->
variable(
"atlas_geometry" );
1007 if ( context && context->
hasVariable(
"atlas_totalfeatures" ) )
1008 return context->
variable(
"atlas_totalfeatures" );
1015 #define FEAT_FROM_CONTEXT(c, f) if (!c || !c->hasVariable(QgsExpressionContext::EXPR_FEATURE)) return QVariant(); \ 1016 QgsFeature f = qvariant_cast<QgsFeature>( c->variable( QgsExpressionContext::EXPR_FEATURE ) ); 1022 return QVariant( static_cast< int >( f.id() ) );
1042 Q_FOREACH (
const QVariant &value, values )
1059 return string.right( pos );
1066 return string.left( pos );
1072 int length =
getIntValue( values.at( 1 ), parent );
1080 int length =
getIntValue( values.at( 1 ), parent );
1088 for (
int n = 1; n < values.length(); n++ )
1120 int seconds = d2.secsTo( d1 );
1126 if ( !values.at( 0 ).canConvert<
QDate>() )
1244 #define ENSURE_GEOM_TYPE(f, g, geomtype) const QgsGeometry* g = f.constGeometry(); \ 1245 if (!g || g->type() != geomtype) return QVariant(); 1251 if ( g->isMultipart() )
1253 return g->asMultiPoint().at( 0 ).x();
1257 return g->asPoint().x();
1265 if ( g->isMultipart() )
1267 return g->asMultiPoint().at( 0 ).y();
1271 return g->asPoint().y();
1355 int idx =
getIntValue( values.at( 1 ), parent ) - 1;
1409 bool ignoreClosing =
false;
1410 if ( values.length() > 1 )
1412 ignoreClosing =
getIntValue( values.at( 1 ), parent );
1421 bool skipLast =
false;
1422 if ( ignoreClosing && ring.
count() > 2 && ring.
first() == ring.
last() )
1427 for (
int i = 0; i < ( skipLast ? ring.
count() - 1 : ring.
count() ); ++ i )
1429 mp->addGeometry( ring.
at( i ).clone() );
1450 for (
int i = 0; i < line->
numPoints() - 1; ++i )
1455 << line->
pointN( i + 1 ) );
1456 ml->addGeometry( segment );
1472 if ( !curvePolygon )
1476 int idx =
getIntValue( values.at( 1 ), parent ) - 1;
1498 int idx =
getIntValue( values.at( 1 ), parent ) - 1;
1510 if ( values.count() < 2 || values.count() > 4 )
1518 double z = values.count() >= 3 ?
getDoubleValue( values.at( 2 ), parent ) : 0.0;
1519 double m = values.count() >= 4 ?
getDoubleValue( values.at( 3 ), parent ) : 0.0;
1520 switch ( values.count() )
1542 if ( values.count() < 2 )
1548 lineString->
clear();
1550 Q_FOREACH (
const QVariant& value, values )
1571 if ( values.count() < 1 )
1584 for (
int i = 1; i < values.count(); ++i )
1604 if ( !g || g->isEmpty() )
1609 idx += g->geometry()->nCoordinates();
1611 if ( idx < 0 || idx >= g->geometry()->nCoordinates() )
1624 if ( v.
type() == QVariant::PointF )
1632 if ( v.
type() == QVariant::PointF )
1670 double area = calc->
measureArea( f.constGeometry() );
1676 return QVariant( f.constGeometry()->area() );
1703 return QVariant( f.constGeometry()->length() );
1720 return f.constGeometry()->isEmpty() ?
QVariant( 0 ) :
QVariant( f.constGeometry()->geometry()->perimeter() );
1765 for (
int i = 0; i < collection->numGeometries(); ++i )
1768 if ( !curvePolygon )
1789 bool foundPoly =
false;
1798 if ( !curvePolygon )
1872 if ( values.length() < 2 || values.length() > 3 )
1878 if ( fGeom.
isEmpty() || sGeom.isEmpty() )
1883 if ( values.length() == 2 )
1886 QString result = engine->relate( *sGeom.geometry() );
1893 bool result = engine->relatePattern( *sGeom.geometry(), pattern );
1948 if ( values.length() < 2 || values.length() > 3 )
1954 if ( values.length() == 3 )
2069 if ( values.length() < 1 || values.length() > 2 )
2074 if ( values.length() == 2 )
2082 if ( values.length() != 2 )
2101 if ( pt1->x() == pt2->
x() )
2103 if ( pt1->y() < pt2->
y() )
2105 else if ( pt1->y() > pt2->
y() )
2111 if ( pt1->y() == pt2->
y() )
2113 if ( pt1->x() < pt2->
x() )
2115 else if ( pt1->x() > pt2->
x() )
2121 if ( pt1->x() < pt2->
x() )
2123 if ( pt1->y() < pt2->
y() )
2125 return atan( fabs( pt1->x() - pt2->
x() ) / fabs( pt1->y() - pt2->
y() ) );
2129 return atan( fabs( pt1->y() - pt2->
y() ) / fabs( pt1->x() - pt2->
x() ) )
2136 if ( pt1->y() > pt2->
y() )
2138 return atan( fabs( pt1->x() - pt2->
x() ) / fabs( pt1->y() - pt2->
y() ) )
2143 return atan( fabs( pt1->y() - pt2->
y() ) / fabs( pt1->x() - pt2->
x() ) )
2151 if ( values.length() != 3 )
2166 if ( values.length() < 2 )
2172 return values.at( 0 );
2175 bool asc = values.value( 2 ).toBool();
2193 Q_ASSERT( collection );
2197 QgsExpressionSorter sorter( orderBy );
2200 for (
int i = 0; i < collection->
partCount(); ++i )
2206 sorter.sortFeatures( partFeatures, unconstedContext );
2210 Q_ASSERT( orderedGeom );
2215 Q_FOREACH (
const QgsFeature& feature, partFeatures )
2223 delete unconstedContext;
2252 if ( values.length() == 2 )
2255 double scaler = pow( 10.0,
getIntValue( values.at( 1 ), parent ) );
2256 return QVariant( qRound( number * scaler ) / scaler );
2259 if ( values.length() == 1 )
2261 double number =
getIntValue( values.at( 0 ), parent );
2283 int places =
getIntValue( values.at( 1 ), parent );
2289 return QString(
"%L1" ).
arg( value, 0,
'f', places );
2302 int green =
getIntValue( values.at( 1 ), parent );
2305 if ( ! color.isValid() )
2308 color =
QColor( 0, 0, 0 );
2311 return QString(
"%1,%2,%3" ).
arg( color.red() ).arg( color.green() ).arg( color.blue() );
2322 node =
getNode( values.at( 1 ), parent );
2324 value = node->
eval( parent, context );
2329 node =
getNode( values.at( 2 ), parent );
2331 value = node->
eval( parent, context );
2340 int green =
getIntValue( values.at( 1 ), parent );
2342 int alpha =
getIntValue( values.at( 3 ), parent );
2344 if ( ! color.isValid() )
2347 color =
QColor( 0, 0, 0 );
2362 QColor color = mRamp->color( value );
2369 double hue =
getIntValue( values.at( 0 ), parent ) / 360.0;
2371 double saturation =
getIntValue( values.at( 1 ), parent ) / 100.0;
2373 double lightness =
getIntValue( values.at( 2 ), parent ) / 100.0;
2377 if ( ! color.isValid() )
2380 color =
QColor( 0, 0, 0 );
2383 return QString(
"%1,%2,%3" ).
arg( color.red() ).arg( color.green() ).arg( color.blue() );
2389 double hue =
getIntValue( values.at( 0 ), parent ) / 360.0;
2391 double saturation =
getIntValue( values.at( 1 ), parent ) / 100.0;
2393 double lightness =
getIntValue( values.at( 2 ), parent ) / 100.0;
2395 double alpha =
getIntValue( values.at( 3 ), parent ) / 255.0;
2398 if ( ! color.isValid() )
2400 parent->
setEvalErrorString(
QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
2401 color =
QColor( 0, 0, 0 );
2409 double hue =
getIntValue( values.at( 0 ), parent ) / 360.0;
2411 double saturation =
getIntValue( values.at( 1 ), parent ) / 100.0;
2413 double value =
getIntValue( values.at( 2 ), parent ) / 100.0;
2417 if ( ! color.isValid() )
2420 color =
QColor( 0, 0, 0 );
2423 return QString(
"%1,%2,%3" ).
arg( color.red() ).arg( color.green() ).arg( color.blue() );
2429 double hue =
getIntValue( values.at( 0 ), parent ) / 360.0;
2431 double saturation =
getIntValue( values.at( 1 ), parent ) / 100.0;
2433 double value =
getIntValue( values.at( 2 ), parent ) / 100.0;
2435 double alpha =
getIntValue( values.at( 3 ), parent ) / 255.0;
2438 if ( ! color.isValid() )
2440 parent->
setEvalErrorString(
QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
2441 color =
QColor( 0, 0, 0 );
2449 double cyan =
getIntValue( values.at( 0 ), parent ) / 100.0;
2451 double magenta =
getIntValue( values.at( 1 ), parent ) / 100.0;
2453 double yellow =
getIntValue( values.at( 2 ), parent ) / 100.0;
2455 double black =
getIntValue( values.at( 3 ), parent ) / 100.0;
2459 if ( ! color.isValid() )
2462 color =
QColor( 0, 0, 0 );
2465 return QString(
"%1,%2,%3" ).
arg( color.red() ).arg( color.green() ).arg( color.blue() );
2471 double cyan =
getIntValue( values.at( 0 ), parent ) / 100.0;
2473 double magenta =
getIntValue( values.at( 1 ), parent ) / 100.0;
2475 double yellow =
getIntValue( values.at( 2 ), parent ) / 100.0;
2477 double black =
getIntValue( values.at( 3 ), parent ) / 100.0;
2479 double alpha =
getIntValue( values.at( 4 ), parent ) / 255.0;
2482 if ( ! color.isValid() )
2484 parent->
setEvalErrorString(
QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
2485 color =
QColor( 0, 0, 0 );
2503 return color.
green();
2505 return color.
blue();
2507 return color.
alpha();
2513 return color.
valueF() * 100;
2521 return color.
cyanF() * 100;
2527 return color.
blackF() * 100;
2543 int value =
getIntValue( values.at( 2 ), parent );
2632 if ( ! s.createFromOgcWmsCrs( sAuthId ) )
2660 if ( !layersByName.
isEmpty() )
2673 int attributeId = vl->fieldNameIndex( attribute );
2674 if ( attributeId == -1 )
2679 const QVariant& attVal = values.at( 2 );
2706 if ( !layersByName.
isEmpty() )
2708 layer = layersByName.
at( 0 );
2717 return layer->name();
2721 return layer->title();
2723 return layer->abstract();
2725 return layer->keywordList();
2727 return layer->dataUrl();
2729 return layer->attribution();
2731 return layer->attributionUrl();
2733 return layer->publicSource();
2735 return static_cast< double >( layer->minimumScale() );
2737 return static_cast< double >( layer->maximumScale() );
2739 return layer->crs().authid();
2741 return layer->crs().toProj4();
2751 switch ( layer->type() )
2787 if ( transferOwnership )
2821 <<
"abs" <<
"sqrt" <<
"cos" <<
"sin" <<
"tan" 2822 <<
"asin" <<
"acos" <<
"atan" <<
"atan2" 2823 <<
"exp" <<
"ln" <<
"log10" <<
"log" 2824 <<
"round" <<
"rand" <<
"randf" <<
"max" <<
"min" <<
"clamp" 2825 <<
"scale_linear" <<
"scale_exp" <<
"floor" <<
"ceil" <<
"$pi" 2826 <<
"toint" <<
"to_int" <<
"toreal" <<
"to_real" <<
"tostring" <<
"to_string" 2827 <<
"todatetime" <<
"to_datetime" <<
"todate" <<
"to_date" 2828 <<
"totime" <<
"to_time" <<
"tointerval" <<
"to_interval" 2829 <<
"coalesce" <<
"if" <<
"regexp_match" <<
"age" <<
"year" 2830 <<
"month" <<
"week" <<
"day" <<
"hour" <<
"day_of_week" 2831 <<
"minute" <<
"second" <<
"lower" <<
"upper" 2832 <<
"title" <<
"length" <<
"replace" <<
"trim" <<
"wordwrap" 2833 <<
"regexp_replace" <<
"regexp_substr" 2834 <<
"substr" <<
"concat" <<
"strpos" <<
"left" 2835 <<
"right" <<
"rpad" <<
"lpad" <<
"format" 2836 <<
"format_number" <<
"format_date" 2837 <<
"color_rgb" <<
"color_rgba" <<
"ramp_color" 2838 <<
"color_hsl" <<
"color_hsla" <<
"color_hsv" <<
"color_hsva" 2839 <<
"color_cmyk" <<
"color_cmyka" <<
"color_part" <<
"set_color_part" 2840 <<
"xat" <<
"yat" <<
"$area" <<
"area" <<
"perimeter" 2841 <<
"$length" <<
"$perimeter" <<
"x" <<
"y" <<
"$x" <<
"$y" <<
"z" <<
"m" <<
"num_points" 2842 <<
"num_interior_rings" <<
"num_rings" <<
"num_geometries" 2843 <<
"geometry_n" <<
"interior_ring_n" 2844 <<
"point_n" <<
"start_point" <<
"end_point" <<
"make_point" <<
"make_point_m" 2845 <<
"nodes_to_points" <<
"segments_to_lines" 2846 <<
"make_line" <<
"make_polygon" 2847 <<
"$x_at" <<
"x_at" <<
"xat" <<
"$y_at" <<
"y_at" <<
"yat" <<
"x_min" <<
"xmin" <<
"x_max" <<
"xmax" 2848 <<
"y_min" <<
"ymin" <<
"y_max" <<
"ymax" <<
"geom_from_wkt" <<
"geomFromWKT" 2849 <<
"geom_from_gml" <<
"geomFromGML" <<
"intersects_bbox" <<
"bbox" 2850 <<
"disjoint" <<
"intersects" <<
"touches" <<
"crosses" <<
"contains" 2852 <<
"overlaps" <<
"within" <<
"buffer" <<
"centroid" <<
"bounds" <<
"reverse" <<
"exterior_ring" 2853 <<
"bounds_width" <<
"bounds_height" <<
"is_closed" <<
"convex_hull" <<
"difference" 2854 <<
"distance" <<
"intersection" <<
"sym_difference" <<
"combine" 2855 <<
"extrude" <<
"azimuth" <<
"closest_point" <<
"shortest_line" 2856 <<
"union" <<
"geom_to_wkt" <<
"geomToWKT" <<
"geometry" 2857 <<
"transform" <<
"get_feature" <<
"getFeature" 2858 <<
"levenshtein" <<
"longest_common_substring" <<
"hamming_distance" 2860 <<
"attribute" <<
"var" <<
"layer_property" 2861 <<
"$id" <<
"$scale" <<
"_specialcol_";
2875 static QMutex sFunctionsMutex( QMutex::Recursive );
3118 return isValid( text, &context, errorMessage );
3135 if ( !
d->mExp.isNull() )
3180 case QVariant::LongLong:
3181 case QVariant::Double:
3184 case QVariant::Bool:
3185 return value.
toBool() ?
"TRUE" :
"FALSE";
3188 case QVariant::String:
3202 for (
int i = 0; i < count; i++ )
3222 :
d( new QgsExpressionPrivate )
3226 Q_ASSERT( !
d->mParserErrorString.isNull() ||
d->mRootNode );
3243 :
d( new QgsExpressionPrivate )
3250 if ( !
d->ref.deref() )
3260 if ( !
d->mRootNode )
3263 QStringList columns =
d->mRootNode->referencedColumns();
3266 for (
int i = 0; i < columns.
count(); i++ )
3269 for (
int j = i + 1; j < columns.
count(); j++ )
3284 if ( !
d->mRootNode )
3286 return d->mRootNode->needsGeometry();
3291 if (
d->mCalc.data() )
3296 d->mCalc->setEllipsoidalMode(
false );
3305 ( void )
d->ref.deref();
3307 d =
new QgsExpressionPrivate( *
d );
3327 if ( !
d->mRootNode )
3335 if ( !
d->mRootNode )
3337 d->mEvalErrorString =
tr(
"No root node! Parsing failed?" );
3341 return d->mRootNode->prepare(
this, context );
3347 if ( !
d->mRootNode )
3349 d->mEvalErrorString =
tr(
"No root node! Parsing failed?" );
3354 return d->mRootNode->eval(
this, &context );
3368 bool res =
prepare( &context );
3386 if ( !
d->mRootNode )
3388 d->mEvalErrorString =
tr(
"No root node! Parsing failed?" );
3392 return d->mRootNode->eval(
this, static_cast<const QgsExpressionContext*>(
nullptr ) );
3398 if ( !
d->mRootNode )
3400 d->mEvalErrorString =
tr(
"No root node! Parsing failed?" );
3404 return d->mRootNode->eval(
this, context );
3409 return !
d->mEvalErrorString.isNull();
3414 return d->mEvalErrorString;
3419 d->mEvalErrorString = str;
3424 d->mRowNumber = rowNumber;
3431 if ( !
d->mRootNode )
3432 return tr(
"(no root)" );
3434 return d->mRootNode->dump();
3439 return d->mCalc.data();
3444 return d->mDistanceUnit;
3449 d->mDistanceUnit = unit;
3454 return d->mAreaUnit;
3459 d->mAreaUnit = unit;
3465 d->mRootNode->accept( v );
3481 if ( substitutionMap )
3488 if ( !oldValue.isNull() )
3489 savedValues.
insert( sit.key(), oldValue );
3498 while ( index < action.
size() )
3502 int pos = rx.
indexIn( action, index );
3515 expr_action += action.
midRef( start, index - start );
3530 expr_action += action.
midRef( start, index - start );
3535 expr_action += action.
mid( start, pos - start ) + result.
toString();
3538 expr_action += action.
midRef( index );
3555 double convertedValue = text.
toDouble( &ok );
3558 return convertedValue;
3569 convertedValue = result.
toDouble( &ok );
3572 return fallbackValue;
3574 return convertedValue;
3584 Q_FOREACH (
Node* node, mList )
3596 Q_FOREACH (
Node* n, mList )
3598 if ( !first ) msg +=
", ";
3610 QVariant val = mOperand->eval( parent, context );
3630 Q_ASSERT( 0 &&
"unknown unary operation" );
3637 return mOperand->prepare( parent, context );
3654 QVariant vL = mOpLeft->eval( parent, context );
3656 QVariant vR = mOpRight->eval( parent, context );
3662 if ( vL.
type() == QVariant::String && vR.
type() == QVariant::String )
3687 if ( mOp ==
boMod && iR == 0 )
3690 return QVariant( computeInt( iL, iR ) );
3703 return QVariant( computeDateTimeFromInterval( dL, &iL ) );
3712 if (( mOp ==
boDiv || mOp ==
boMod ) && fR == 0. )
3714 return QVariant( computeDouble( fL, fR ) );
3726 return QVariant( qFloor( fL / fR ) );
3765 ( vL.
type() != QVariant::String || vR.
type() != QVariant::String ) )
3796 ( vL.
type() != QVariant::String || vR.
type() != QVariant::String ) )
3839 esc_regexp.
replace( 0, 1,
".*" );
3843 while (( pos = rx.
indexIn( esc_regexp, pos ) ) != -1 )
3845 esc_regexp.
replace( pos + 1, 1,
".*" );
3849 esc_regexp.
replace( rx,
"%" );
3852 esc_regexp.
replace( 0, 1,
"." );
3856 while (( pos = rx.
indexIn( esc_regexp, pos ) ) != -1 )
3858 esc_regexp.
replace( pos + 1, 1,
'.' );
3862 esc_regexp.
replace( rx,
"_" );
3966 return fmod( x, y );
3975 bool resL = mOpLeft->prepare( parent, context );
3976 bool resR = mOpRight->prepare( parent, context );
3977 return resL && resR;
4022 Q_ASSERT( 0 &&
"unexpected binary operator" );
4058 Q_ASSERT( 0 &&
"unexpected binary operator" );
4068 QString rdump( mOpRight->dump() );
4077 if ( leftAssociative() )
4079 fmt += lOp && ( lOp->
precedence() < precedence() ) ?
"(%1)" :
"%1";
4081 fmt += rOp && ( rOp->
precedence() <= precedence() ) ?
"(%3)" :
"%3";
4085 fmt += lOp && ( lOp->
precedence() <= precedence() ) ?
"(%1)" :
"%1";
4087 fmt += rOp && ( rOp->
precedence() < precedence() ) ?
"(%3)" :
"%3";
4102 if ( mList->count() == 0 )
4104 QVariant v1 = mNode->eval( parent, context );
4109 bool listHasNull =
false;
4111 Q_FOREACH (
Node* n, mList->list() )
4152 bool res = mNode->prepare( parent, context );
4153 Q_FOREACH (
Node* n, mList->list() )
4155 res = res && n->
prepare( parent, context );
4162 return QString(
"%1 %2 IN (%3)" ).
arg( mNode->dump(), mNotIn ?
"NOT" :
"", mList->dump() );
4167 return new NodeInOperator( mNode->clone(), mList->clone(), mNotIn );
4178 QVariantList argValues;
4181 Q_FOREACH (
Node* n, mArgs->list() )
4191 v = n->
eval( parent, context );
4196 argValues.append( v );
4213 Q_FOREACH (
Node* n, mArgs->list() )
4215 res = res && n->
prepare( parent, context );
4238 return functionColumns;
4241 Q_FOREACH (
Node* n, mArgs->list() )
4247 return functionColumns.
toSet().toList();
4252 return new NodeFunction( mFnIndex, mArgs ? mArgs->clone() : nullptr );
4259 Q_UNUSED( context );
4267 Q_UNUSED( context );
4274 if ( mValue.isNull() )
4277 switch ( mValue.type() )
4281 case QVariant::Double:
4283 case QVariant::String:
4285 case QVariant::Bool:
4286 return mValue.toBool() ?
"TRUE" :
"FALSE";
4288 return tr(
"[unsupported type;%1; value:%2]" ).arg( mValue.typeName(), mValue.toString() );
4322 return QVariant(
'[' + mName +
']' );
4339 parent->
d->mEvalErrorString =
tr(
"Column '%1' not found" ).arg( mName );
4359 Q_FOREACH (
WhenThen* cond, mConditions )
4374 QVariant vElse = mElseExp->eval( parent, context );
4386 Q_FOREACH (
WhenThen* cond, mConditions )
4390 if ( !res )
return false;
4394 return mElseExp->prepare( parent, context );
4402 Q_FOREACH (
WhenThen* cond, mConditions )
4407 msg +=
QString(
" ELSE %1" ).
arg( mElseExp->dump() );
4415 Q_FOREACH (
WhenThen* cond, mConditions )
4421 lst += mElseExp->referencedColumns();
4428 Q_FOREACH (
WhenThen* cond, mConditions )
4435 if ( mElseExp && mElseExp->needsGeometry() )
4444 Q_FOREACH (
WhenThen* wt, mConditions )
4446 return new NodeCondition( conditions, mElseExp ? mElseExp->clone() : nullptr );
4455 return tr(
"function help for %1 missing" ).arg( name );
4460 if ( f.
mType ==
tr(
"group" ) )
4461 name =
group( name );
4463 #if QT_VERSION < 0x050000 4466 name = name.toHtmlEscaped();
4469 QString helpContents(
QString(
"<h3>%1</h3>\n<div class=\"description\"><p>%2</p></div>" )
4470 .arg(
tr(
"%1 %2" ).arg( f.
mType, name ),
4481 helpContents +=
QString(
"<h4>%1</h4>\n<div class=\"syntax\">\n" ).
arg(
tr(
"Syntax" ) );
4483 if ( f.
mType ==
tr(
"operator" ) )
4487 helpContents +=
QString(
"<code><span class=\"functionname\">%1</span> <span class=\"argument\">%2</span></code>" )
4492 helpContents +=
QString(
"<code><span class=\"argument\">%1</span> <span class=\"functionname\">%2</span> <span class=\"argument\">%3</span></code>" )
4496 else if ( f.
mType !=
tr(
"group" ) && f.
mType !=
tr(
"expression" ) )
4498 helpContents +=
QString(
"<code><span class=\"functionname\">%1</span>" ).
arg( name );
4502 helpContents +=
'(';
4507 helpContents += delim;
4510 helpContents +=
QString(
"<span class=\"argument\">%1</span>" ).
arg( a.
mArg );
4515 helpContents +=
"...";
4518 helpContents +=
')';
4521 helpContents +=
"</code>";
4526 helpContents +=
QString(
"<h4>%1</h4>\n<div class=\"arguments\">\n<table>" ).
arg(
tr(
"Arguments" ) );
4536 helpContents +=
"</table>\n</div>\n";
4541 helpContents +=
QString(
"<h4>%1</h4>\n<div class=\"examples\">\n<ul>\n" ).
arg(
tr(
"Examples" ) );
4545 helpContents +=
"<li><code>" + e.
mExpression +
"</code> → <code>" + e.
mReturns +
"</code>";
4550 helpContents +=
"</li>\n";
4553 helpContents +=
"</ul>\n</div>\n";
4558 helpContents +=
QString(
"<h4>%1</h4>\n<div class=\"notes\"><p>%2</p></div>\n" ).
arg(
tr(
"Notes" ), v.
mNotes );
4562 return helpContents;
4689 return tr(
"<i><empty geometry></i>" );
4695 return tr(
"<i>NULL</i>" );
4701 return tr(
"<i><feature: %1></i>" ).arg( feat.
id() );
4707 return tr(
"<i><interval: %1 days></i>" ).arg( interval.
days() );
4709 else if ( value.
type() == QVariant::Date )
4712 return tr(
"<i><date: %1></i>" ).arg( dt.
toString(
"yyyy-MM-dd" ) );
4714 else if ( value.
type() == QVariant::Time )
4717 return tr(
"<i><time: %1></i>" ).arg( tm.
toString(
"hh:mm:ss" ) );
4719 else if ( value.
type() == QVariant::DateTime )
4722 return tr(
"<i><datetime: %1></i>" ).arg( dt.
toString(
"yyyy-MM-dd hh:mm:ss" ) );
4724 else if ( value.
type() == QVariant::String )
4727 if ( previewString.
length() > 63 )
4746 return func( values, &c, parent );
4757 return func( values, &f, parent );
4765 return eval( parent, &c );
4776 return eval( parent, &f );
4801 return mFnc ? mFnc( values, f, parent ) :
QVariant();
4807 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").
double years()
interval length in years
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)
Wrapper for iterator of features from vector data provider or vector layer.
QString toString(Qt::DateFormat format) const
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)
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 *)
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)
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)
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)
double months()
interval length in months
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)
bool lazyEval()
True if this function should use lazy evaluation.
double distance(const QgsGeometry &geom) const
Returns the minimum distance between this geometry and another geometry, using GEOS.
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)
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
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.
bool touches(const QgsGeometry *geometry) const
Test for if geometry touch another (uses GEOS)
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 computeDouble(double x, double y)
static QVariant fcnIf(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent)
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)
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)
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.
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 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)
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.
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...
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)
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 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
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)
static QString soundex(const QString &string)
Returns the Soundex representation of a string.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
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.
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)
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()
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)
QgsUnitTypes::AreaUnit areaUnits() const
Returns the desired areal units for calculations involving geomCalculator(), eg "$area".
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...
static QVariant fcnMinute(const QVariantList &values, const QgsExpressionContext *, 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. ...
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...
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
virtual bool isClosed() const
Returns true if the curve is closed.
static QVariant fcnIntersects(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent)
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.
Line string geometry type, with support for z-dimension and m-values.
static QVariant fcnScale(const QVariantList &, const QgsExpressionContext *, QgsExpression *parent)
bool operator==(QgsExpression::Interval other) const
compare two intervals
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)
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 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.
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.
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.
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.
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.
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)
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)
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)
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.
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.
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.
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
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)
QString expression() const
Return the original, unmodified expression string.
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
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 *)
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)
double days()
interval length in days
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 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.
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. ...
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)
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.
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
QString mid(int position, int n) const
virtual QString dump() const
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
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)
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
static QgsExpression::Interval fromString(const QString &string)
convert a string to an interval
qreal hsvSaturationF() const
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.
int params()
The number of parameters this function takes.
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)
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)
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 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.
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 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...
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 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 *)
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 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)
double area() const
Returns the area of the geometry using GEOS.
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.
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)
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
void setCmykF(qreal c, qreal m, qreal y, qreal k, qreal a)
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...
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 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)
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)
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)
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.
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