56 QVariantList argValues;
60 const QList< QgsExpressionNode * > argList = args->
list();
67 v = QVariant::fromValue( n );
71 v = n->eval( parent, context );
73 bool defaultParamIsNull = mParameterList.count() > arg && mParameterList.at( arg ).optional() && !mParameterList.at( arg ).defaultValue().isValid();
74 if ( QgsExpressionUtils::isNull( v ) && !defaultParamIsNull && !
handlesNull() )
77 argValues.append( v );
82 return func( argValues, context, parent, node );
120 return mGroups.isEmpty() ? false : mGroups.contains( QStringLiteral(
"deprecated" ) );
125 return ( QString::compare( mName, other.mName, Qt::CaseInsensitive ) == 0 );
137 const QString &
group,
147 , mUsesGeometry(
false )
161 if ( mUsesGeometryFunc )
162 return mUsesGeometryFunc( node );
164 return mUsesGeometry;
169 if ( mReferencedColumnsFunc )
170 return mReferencedColumnsFunc( node );
172 return mReferencedColumns;
178 return mIsStaticFunc( node, parent, context );
186 return mPrepareFunc( node, parent, context );
198 mIsStaticFunc =
nullptr;
204 mPrepareFunc = prepareFunc;
209 if ( node && node->
args() )
211 const QList< QgsExpressionNode * > argList = node->
args()->
list();
214 if ( !argNode->isStatic( parent, context ) )
227 QString
name = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
236 QString expString = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
238 return expression.evaluate( context );
243 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
244 return QVariant( std::sqrt( x ) );
249 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
250 return QVariant( std::fabs( val ) );
255 double deg = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
256 return ( deg * M_PI ) / 180;
260 double rad = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
261 return ( 180 * rad ) / M_PI;
265 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
266 return QVariant( std::sin( x ) );
270 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
271 return QVariant( std::cos( x ) );
275 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
276 return QVariant( std::tan( x ) );
280 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
281 return QVariant( std::asin( x ) );
285 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
286 return QVariant( std::acos( x ) );
290 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
291 return QVariant( std::atan( x ) );
295 double y = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
296 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
297 return QVariant( std::atan2( y, x ) );
301 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
302 return QVariant( std::exp( x ) );
306 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
309 return QVariant( std::log( x ) );
313 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
316 return QVariant( log10( x ) );
320 double b = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
321 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
322 if ( x <= 0 || b <= 0 )
324 return QVariant( std::log( x ) / std::log( b ) );
328 double min = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
329 double max = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
334 double f =
static_cast< double >( qrand() ) / RAND_MAX;
335 return QVariant( min + f * ( max - min ) );
339 qlonglong min = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
340 qlonglong max = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
345 return QVariant( min + ( qrand() % static_cast< qlonglong >( max - min + 1 ) ) );
350 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
351 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
352 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
353 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
354 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
356 if ( domainMin >= domainMax )
358 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
363 if ( val >= domainMax )
367 else if ( val <= domainMin )
373 double m = ( rangeMax - rangeMin ) / ( domainMax - domainMin );
374 double c = rangeMin - ( domainMin * m );
377 return QVariant( m * val + c );
382 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
383 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
384 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
385 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
386 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
387 double exponent = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
389 if ( domainMin >= domainMax )
391 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
401 if ( val >= domainMax )
405 else if ( val <= domainMin )
411 return QVariant( ( ( rangeMax - rangeMin ) / std::pow( domainMax - domainMin, exponent ) ) * std::pow( val - domainMin, exponent ) + rangeMin );
416 QVariant result( QVariant::Double );
417 double maxVal = std::numeric_limits<double>::quiet_NaN();
418 for (
const QVariant &val : values )
420 double testVal = val.isNull() ? std::numeric_limits<double>::quiet_NaN() : QgsExpressionUtils::getDoubleValue( val, parent );
421 if ( std::isnan( maxVal ) )
425 else if ( !std::isnan( testVal ) )
427 maxVal = std::max( maxVal, testVal );
431 if ( !std::isnan( maxVal ) )
433 result = QVariant( maxVal );
440 QVariant result( QVariant::Double );
441 double minVal = std::numeric_limits<double>::quiet_NaN();
442 for (
const QVariant &val : values )
444 double testVal = val.isNull() ? std::numeric_limits<double>::quiet_NaN() : QgsExpressionUtils::getDoubleValue( val, parent );
445 if ( std::isnan( minVal ) )
449 else if ( !std::isnan( testVal ) )
451 minVal = std::min( minVal, testVal );
455 if ( !std::isnan( minVal ) )
457 result = QVariant( minVal );
469 QVariant value = node->
eval( parent, context );
471 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( value, parent );
474 parent->
setEvalErrorString( QObject::tr(
"Cannot find layer with name or ID '%1'" ).arg( value.toString() ) );
479 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
481 value = node->
eval( parent, context );
487 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
492 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
494 QString subExpression = node->
dump();
498 if ( values.count() > 3 )
500 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
503 if ( !nl || nl->
value().isValid() )
508 if ( values.count() > 4 )
510 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
512 value = node->
eval( parent, context );
528 cacheKey = QStringLiteral(
"aggfcn:%1:%2:%3:%4:%5%6" ).arg( vl->
id(), QString::number( aggregate ), subExpression, parameters.
filter,
533 cacheKey = QStringLiteral(
"aggfcn:%1:%2:%3:%4" ).arg( vl->
id(), QString::number( aggregate ), subExpression, parameters.
filter );
543 result = vl->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
549 result = vl->
aggregate( aggregate, subExpression, parameters,
nullptr, &ok );
553 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
564 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
569 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
572 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
581 QVariant value = node->
eval( parent, context );
583 QString relationId = value.toString();
590 if ( relations.isEmpty() || relations.at( 0 ).referencedLayer() != vl )
592 parent->
setEvalErrorString( QObject::tr(
"Cannot find relation with id '%1'" ).arg( relationId ) );
597 relation = relations.at( 0 );
604 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
606 value = node->
eval( parent, context );
612 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
617 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
619 QString subExpression = node->
dump();
623 if ( values.count() > 3 )
625 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
627 value = node->
eval( parent, context );
635 QString cacheKey = QStringLiteral(
"relagg:%1:%2:%3:%4" ).arg( vl->
id(),
636 QString::number( static_cast< int >( aggregate ) ),
647 result = childLayer->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
651 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
666 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
671 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
674 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
683 QString subExpression = node->
dump();
687 if ( values.count() > 1 )
689 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
692 if ( !nl || nl->
value().isValid() )
693 groupBy = node->
dump();
697 if ( values.count() > 2 )
699 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
702 if ( !nl || nl->
value().isValid() )
709 if ( !groupBy.isEmpty() )
712 QVariant groupByValue = groupByExp.
evaluate( context );
713 QString groupByClause = QStringLiteral(
"%1 %2 %3" ).arg( groupBy,
714 groupByValue.isNull() ? QStringLiteral(
"is" ) : QStringLiteral(
"=" ),
716 if ( !parameters.
filter.isEmpty() )
717 parameters.
filter = QStringLiteral(
"(%1) AND (%2)" ).arg( parameters.
filter, groupByClause );
719 parameters.
filter = groupByClause;
722 QString cacheKey = QStringLiteral(
"agg:%1:%2:%3:%4" ).arg( vl->
id(),
723 QString::number( static_cast< int >( aggregate ) ),
733 result = vl->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
737 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
843 if ( values.count() > 3 )
847 QVariant value = node->
eval( parent, context );
862 double minValue = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
863 double testValue = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
864 double maxValue = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
867 if ( testValue <= minValue )
869 return QVariant( minValue );
871 else if ( testValue >= maxValue )
873 return QVariant( maxValue );
877 return QVariant( testValue );
883 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
884 return QVariant( std::floor( x ) );
889 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
890 return QVariant( std::ceil( x ) );
895 return QVariant( QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) );
899 return QVariant( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) );
903 return QVariant( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ) );
908 return QVariant( QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent ) );
913 for (
const QVariant &value : values )
915 if ( value.isNull() )
923 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
924 return QVariant( str.toLower() );
928 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
929 return QVariant( str.toUpper() );
933 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
934 QStringList elems = str.split(
' ' );
935 for (
int i = 0; i < elems.size(); i++ )
937 if ( elems[i].size() > 1 )
938 elems[i] = elems[i].at( 0 ).toUpper() + elems[i].mid( 1 ).toLower();
940 return QVariant( elems.join( QStringLiteral(
" " ) ) );
945 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
946 return QVariant( str.trimmed() );
951 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
952 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
958 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
959 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
965 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
966 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
973 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
979 QChar character = QChar( QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent ) );
980 return QVariant( QString( character ) );
985 if ( values.length() == 2 || values.length() == 3 )
987 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
988 qlonglong wrap = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
990 if ( !str.isEmpty() && wrap != 0 )
994 QString customdelimiter = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
997 if ( customdelimiter.length() > 0 )
999 rx.setPatternSyntax( QRegExp::FixedString );
1000 rx.setPattern( customdelimiter );
1001 delimiterlength = customdelimiter.length();
1006 rx.setPattern( QStringLiteral(
"[\\s\\x200B]" ) );
1007 delimiterlength = 1;
1011 QStringList lines = str.split(
'\n' );
1012 int strlength, strcurrent, strhit, lasthit;
1014 for (
int i = 0; i < lines.size(); i++ )
1016 strlength = lines[i].length();
1021 while ( strcurrent < strlength )
1028 strhit = lines[i].lastIndexOf( rx, strcurrent + wrap );
1029 if ( strhit == lasthit || strhit == -1 )
1032 strhit = lines[i].indexOf( rx, strcurrent + std::labs( wrap ) );
1038 strhit = lines[i].indexOf( rx, strcurrent + std::labs( wrap ) );
1042 newstr.append( lines[i].midRef( strcurrent, strhit - strcurrent ) );
1043 newstr.append(
'\n' );
1044 strcurrent = strhit + delimiterlength;
1048 newstr.append( lines[i].midRef( strcurrent ) );
1049 strcurrent = strlength;
1052 if ( i < lines.size() - 1 ) newstr.append(
'\n' );
1055 return QVariant( newstr );
1068 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1072 return QVariant( geom.
length() );
1076 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1077 return QVariant( str.length() );
1082 if ( values.count() == 2 && values.at( 1 ).type() == QVariant::Map )
1084 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1085 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 1 ), parent );
1087 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
1089 str = str.replace( it.key(), it.value().toString() );
1092 return QVariant( str );
1094 else if ( values.count() == 3 )
1096 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1097 QVariantList before;
1099 bool isSingleReplacement =
false;
1101 if ( values.at( 1 ).type() != QVariant::List && values.at( 2 ).type() != QVariant::StringList )
1103 before = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1107 before = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
1110 if ( values.at( 2 ).type() != QVariant::List && values.at( 2 ).type() != QVariant::StringList )
1112 after = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1113 isSingleReplacement =
true;
1117 after = QgsExpressionUtils::getListValue( values.at( 2 ), parent );
1120 if ( !isSingleReplacement && before.length() != after.length() )
1122 parent->
setEvalErrorString( QObject::tr(
"Invalid pair of array, length not identical" ) );
1126 for (
int i = 0; i < before.length(); i++ )
1128 str = str.replace( before.at( i ).toString(), after.at( isSingleReplacement ? 0 : i ).toString() );
1131 return QVariant( str );
1135 parent->
setEvalErrorString( QObject::tr(
"Function replace requires 2 or 3 arguments" ) );
1141 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1142 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1143 QString after = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1145 QRegularExpression re( regexp );
1146 if ( !re.isValid() )
1148 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1151 return QVariant( str.replace( re, after ) );
1156 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1157 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1159 QRegularExpression re( regexp );
1160 if ( !re.isValid() )
1162 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1165 return QVariant( ( str.indexOf( re ) + 1 ) );
1170 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1171 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1172 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1174 QRegularExpression re( regexp );
1175 if ( !re.isValid() )
1177 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1181 QRegularExpressionMatch matches = re.match( str );
1182 if ( matches.hasMatch() )
1185 QStringList list = matches.capturedTexts();
1188 for ( QStringList::const_iterator it = ++list.constBegin(); it != list.constEnd(); ++it )
1190 array += ( !( *it ).isEmpty() ) ? *it : empty;
1193 return QVariant( array );
1203 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1204 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1206 QRegularExpression re( regexp );
1207 if ( !re.isValid() )
1209 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1214 QRegularExpressionMatch match = re.match( str );
1215 if ( match.hasMatch() )
1218 if ( match.lastCapturedIndex() > 0 )
1221 return QVariant( match.captured( 1 ) );
1226 return QVariant( match.captured( 0 ) );
1231 return QVariant(
"" );
1237 return QUuid::createUuid().toString();
1242 if ( !values.at( 0 ).isValid() || !values.at( 1 ).isValid() )
1245 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1246 qlonglong from = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1249 if ( values.at( 2 ).isValid() )
1250 len = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
1256 from = str.size() + from;
1262 else if ( from > 0 )
1270 len = str.size() + len - from;
1277 return QVariant( str.mid( from, len ) );
1283 return QVariant( static_cast< int >( f.id() ) );
1295 QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1296 QString attr = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1306 if ( values.isEmpty() )
1309 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1311 else if ( values.size() == 1 )
1313 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1314 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1316 else if ( values.size() == 2 )
1318 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1319 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
1323 parent->
setEvalErrorString( QObject::tr(
"Function `is_selected` requires no more than two parameters. %1 given." ).arg( values.length() ) );
1327 if ( !layer || !feature.
isValid() )
1329 return QVariant( QVariant::Bool );
1339 if ( values.isEmpty() )
1340 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1341 else if ( values.count() == 1 )
1342 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1345 parent->
setEvalErrorString( QObject::tr(
"Function `num_selected` requires no more than one parameter. %1 given." ).arg( values.length() ) );
1351 return QVariant( QVariant::LongLong );
1360 for (
const QVariant &value : values )
1362 concat += QgsExpressionUtils::getStringValue( value, parent );
1369 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1370 return string.indexOf( QgsExpressionUtils::getStringValue( values.at( 1 ), parent ) ) + 1;
1375 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1376 qlonglong pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1377 return string.right( pos );
1382 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1383 qlonglong pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1384 return string.left( pos );
1389 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1390 qlonglong length = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1391 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1392 return string.leftJustified( length, fill.at( 0 ), true );
1397 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1398 qlonglong length = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1399 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1400 return string.rightJustified( length, fill.at( 0 ), true );
1405 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1406 for (
int n = 1; n < values.length(); n++ )
1408 string =
string.arg( QgsExpressionUtils::getStringValue( values.at( n ), parent ) );
1416 return QVariant( QDateTime::currentDateTime() );
1421 return QVariant( QgsExpressionUtils::getDateValue( values.at( 0 ), parent ) );
1426 return QVariant( QgsExpressionUtils::getTimeValue( values.at( 0 ), parent ) );
1431 return QVariant::fromValue( QgsExpressionUtils::getInterval( values.at( 0 ), parent ) );
1436 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1437 QDateTime d2 = QgsExpressionUtils::getDateTimeValue( values.at( 1 ), parent );
1438 qint64 seconds = d2.secsTo( d1 );
1439 return QVariant::fromValue(
QgsInterval( seconds ) );
1444 if ( !values.at( 0 ).canConvert<QDate>() )
1447 QDate date = QgsExpressionUtils::getDateValue( values.at( 0 ), parent );
1448 if ( !date.isValid() )
1453 return date.dayOfWeek() % 7;
1458 QVariant value = values.at( 0 );
1459 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1462 return QVariant( inter.
days() );
1466 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1467 return QVariant( d1.date().day() );
1473 QVariant value = values.at( 0 );
1474 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1477 return QVariant( inter.
years() );
1481 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1482 return QVariant( d1.date().year() );
1488 QVariant value = values.at( 0 );
1489 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1492 return QVariant( inter.
months() );
1496 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1497 return QVariant( d1.date().month() );
1503 QVariant value = values.at( 0 );
1504 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1507 return QVariant( inter.
weeks() );
1511 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1512 return QVariant( d1.date().weekNumber() );
1518 QVariant value = values.at( 0 );
1519 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1522 return QVariant( inter.
hours() );
1526 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1527 return QVariant( t1.hour() );
1533 QVariant value = values.at( 0 );
1534 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1537 return QVariant( inter.
minutes() );
1541 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1542 return QVariant( t1.minute() );
1548 QVariant value = values.at( 0 );
1549 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1552 return QVariant( inter.
seconds() );
1556 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1557 return QVariant( t1.second() );
1563 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1566 return QVariant( dt.toMSecsSinceEpoch() );
1574 #define ENSURE_GEOM_TYPE(f, g, geomtype) \ 1575 if ( !(f).hasGeometry() ) \ 1576 return QVariant(); \ 1577 QgsGeometry g = (f).geometry(); \ 1578 if ( (g).type() != (geomtype) ) \ 1585 if ( g.isMultipart() )
1587 return g.asMultiPoint().at( 0 ).x();
1591 return g.asPoint().x();
1599 if ( g.isMultipart() )
1601 return g.asMultiPoint().at( 0 ).y();
1605 return g.asPoint().y();
1611 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1623 QVariant result( centroid.
asPoint().
x() );
1629 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1641 QVariant result( centroid.
asPoint().
y() );
1647 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1664 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1681 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1687 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
1702 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1719 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1736 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1741 bool ignoreClosing =
false;
1742 if ( values.length() > 1 )
1744 ignoreClosing = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1754 bool skipLast =
false;
1755 if ( ignoreClosing && ring.count() > 2 && ring.first() == ring.last() )
1760 for (
int i = 0; i < ( skipLast ? ring.count() - 1 : ring.count() ); ++ i )
1762 mp->addGeometry( ring.at( i ).clone() );
1772 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1783 for (
int i = 0; i < line->numPoints() - 1; ++i )
1787 << line->pointN( i )
1788 << line->pointN( i + 1 ) );
1789 ml->addGeometry( segment );
1799 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1805 if ( !curvePolygon )
1809 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
1815 QVariant result = curve ? QVariant::fromValue(
QgsGeometry( curve ) ) : QVariant();
1821 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1831 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
1837 QVariant result = part ? QVariant::fromValue(
QgsGeometry( part ) ) : QVariant();
1843 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1852 return QVariant::fromValue(
QgsGeometry( boundary ) );
1857 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1866 return QVariant::fromValue( merged );
1871 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1876 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
1879 if ( simplified.isNull() )
1887 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1892 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
1897 if ( simplified.
isNull() )
1905 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1910 int iterations = std::min( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), 10 );
1911 double offset = qBound( 0.0, QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ), 0.5 );
1912 double minLength = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
1913 double maxAngle = qBound( 0.0, QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent ), 180.0 );
1924 if ( values.count() < 2 || values.count() > 4 )
1926 parent->
setEvalErrorString( QObject::tr(
"Function make_point requires 2-4 arguments" ) );
1930 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1931 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
1932 double z = values.count() >= 3 ? QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) : 0.0;
1933 double m = values.count() >= 4 ? QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) : 0.0;
1934 switch ( values.count() )
1948 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1949 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
1950 double m = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
1956 if ( values.count() < 2 )
1962 lineString->
clear();
1964 for (
const QVariant &value : values )
1966 QgsGeometry geom = QgsExpressionUtils::getGeometry( value, parent );
1980 return QVariant::fromValue(
QgsGeometry( lineString ) );
1985 if ( values.count() < 1 )
1987 parent->
setEvalErrorString( QObject::tr(
"Function make_polygon requires an argument" ) );
1991 QgsGeometry outerRing = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1998 for (
int i = 1; i < values.count(); ++i )
2000 QgsGeometry ringGeom = QgsExpressionUtils::getGeometry( values.at( i ), parent );
2010 return QVariant::fromValue(
QgsGeometry( polygon ) );
2015 std::unique_ptr<QgsTriangle> tr(
new QgsTriangle() );
2016 std::unique_ptr<QgsLineString> lineString(
new QgsLineString() );
2017 lineString->clear();
2019 for (
const QVariant &value : values )
2021 QgsGeometry geom = QgsExpressionUtils::getGeometry( value, parent );
2032 lineString->addVertex( *point );
2035 tr->setExteriorRing( lineString.release() );
2037 return QVariant::fromValue(
QgsGeometry( tr.release() ) );
2042 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2049 double radius = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2050 double segment = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
2059 return QVariant::fromValue(
QgsGeometry( circ.toPolygon( segment ) ) );
2064 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2071 double majorAxis = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2072 double minorAxis = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2073 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2074 double segment = QgsExpressionUtils::getIntValue( values.at( 4 ), parent );
2081 QgsEllipse elp( *point, majorAxis, minorAxis, azimuth );
2082 return QVariant::fromValue(
QgsGeometry( elp.toPolygon( segment ) ) );
2088 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2095 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2102 unsigned int nbEdges =
static_cast<unsigned int>( QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) );
2105 parent->
setEvalErrorString( QObject::tr(
"Number of edges/sides must be greater than 2" ) );
2112 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (inscribed) or 1 (circumscribed)" ) );
2120 return QVariant::fromValue(
QgsGeometry( rp.toPolygon() ) );
2127 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
2136 if ( idx < 0 || idx >= g.constGet()->nCoordinates() )
2143 return QVariant( QPointF( p.
x(), p.
y() ) );
2148 QVariant v = pointAt( values, f, parent );
2149 if ( v.type() == QVariant::PointF )
2150 return QVariant( v.toPointF().x() );
2156 QVariant v = pointAt( values, f, parent );
2157 if ( v.type() == QVariant::PointF )
2158 return QVariant( v.toPointF().y() );
2167 return QVariant::fromValue( geom );
2169 return QVariant( QVariant::UserType );
2173 QString wkt = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2175 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2180 QString gml = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2182 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2195 return QVariant( area );
2199 return QVariant( f.geometry().area() );
2205 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2210 return QVariant( geom.
area() );
2222 return QVariant( len );
2226 return QVariant( f.geometry().length() );
2239 return QVariant( len );
2243 return f.geometry().isNull() ? QVariant( 0 ) : QVariant( f.geometry().constGet()->perimeter() );
2249 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2255 return QVariant( geom.
length() );
2260 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2266 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2275 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2288 for (
int i = 0; i < collection->numGeometries(); ++i )
2291 if ( !curvePolygon )
2303 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2310 return QVariant( curvePolygon->
ringCount() );
2312 bool foundPoly =
false;
2321 if ( !curvePolygon )
2332 return QVariant( ringCount );
2337 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2339 QVariant result = !geomBounds.
isNull() ? QVariant::fromValue( geomBounds ) : QVariant();
2345 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2351 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2357 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2363 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2369 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2375 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2381 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2385 std::unique_ptr< QgsAbstractGeometry > flipped( geom.
constGet()->
clone() );
2387 return QVariant::fromValue(
QgsGeometry( std::move( flipped ) ) );
2392 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2400 return QVariant::fromValue( curve->
isClosed() );
2405 if ( values.length() < 2 || values.length() > 3 )
2408 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2409 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2411 if ( fGeom.
isNull() || sGeom.isNull() )
2416 if ( values.length() == 2 )
2419 QString result = engine->relate( sGeom.constGet() );
2420 return QVariant::fromValue( result );
2425 QString pattern = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
2426 bool result = engine->relatePattern( sGeom.constGet(), pattern );
2427 return QVariant::fromValue( result );
2433 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2434 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2435 return fGeom.
intersects( sGeom.boundingBox() ) ? TVL_True : TVL_False;
2439 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2440 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2441 return fGeom.
disjoint( sGeom ) ? TVL_True : TVL_False;
2445 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2446 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2447 return fGeom.
intersects( sGeom ) ? TVL_True : TVL_False;
2451 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2452 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2453 return fGeom.
touches( sGeom ) ? TVL_True : TVL_False;
2457 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2458 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2459 return fGeom.
crosses( sGeom ) ? TVL_True : TVL_False;
2463 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2464 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2465 return fGeom.
contains( sGeom ) ? TVL_True : TVL_False;
2469 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2470 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2471 return fGeom.
overlaps( sGeom ) ? TVL_True : TVL_False;
2475 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2476 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2477 return fGeom.
within( sGeom ) ? TVL_True : TVL_False;
2481 if ( values.length() < 2 || values.length() > 3 )
2484 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2485 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2487 if ( values.length() == 3 )
2488 seg = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
2491 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2497 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2501 parent->
setEvalErrorString( QObject::tr(
"Function `wedge_buffer` requires a point value for the center." ) );
2505 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2506 double width = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2507 double outerRadius = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2508 double innerRadius = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
2511 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2517 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2520 parent->
setEvalErrorString( QObject::tr(
"Function `tapered_buffer` requires a line geometry." ) );
2524 double startWidth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2525 double endWidth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2526 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) );
2529 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2535 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2538 parent->
setEvalErrorString( QObject::tr(
"Function `buffer_by_m` requires a line geometry." ) );
2542 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
2545 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2551 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2552 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2553 qlonglong segments = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
2557 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2560 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2566 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2567 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2568 qlonglong segments = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
2572 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2575 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2581 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2582 double distStart = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2583 double distEnd = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2586 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2592 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2593 double dx = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2594 double dy = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2596 return QVariant::fromValue( fGeom );
2600 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2602 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2607 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2609 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2615 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2616 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2618 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2624 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2626 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2633 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2634 unsigned int segments = 36;
2635 if ( values.length() == 2 )
2636 segments = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2638 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2644 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2646 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2652 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2653 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2655 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2661 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2673 result = reversed ? QVariant::fromValue(
QgsGeometry( reversed ) ) : QVariant();
2681 if (
const QgsCurve *curve = qgsgeometry_cast<const QgsCurve * >( collection->
geometryN( i ) ) )
2690 result = reversed ? QVariant::fromValue(
QgsGeometry( std::move( reversed ) ) ) : QVariant();
2697 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2706 QVariant result = exterior ? QVariant::fromValue(
QgsGeometry( exterior ) ) : QVariant();
2712 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2713 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2714 return QVariant( fGeom.
distance( sGeom ) );
2719 QgsGeometry g1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2720 QgsGeometry g2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2723 if ( values.length() == 3 && values.at( 2 ).isValid() )
2725 double densify = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2726 densify = qBound( 0.0, densify, 1.0 );
2734 return res > -1 ? QVariant( res ) : QVariant();
2739 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2740 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2742 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2747 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2748 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2750 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2755 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2756 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2758 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2763 if ( values.length() < 1 || values.length() > 2 )
2766 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2768 if ( values.length() == 2 )
2769 prec = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
2770 QString wkt = fGeom.
asWkt( prec );
2771 return QVariant( wkt );
2776 if ( values.length() != 2 )
2778 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires exactly two parameters. %1 given." ).arg( values.length() ) );
2782 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2783 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2790 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires two points as arguments." ) );
2795 if ( pt1->x() == pt2->x() )
2797 if ( pt1->y() < pt2->y() )
2799 else if ( pt1->y() > pt2->y() )
2805 if ( pt1->y() == pt2->y() )
2807 if ( pt1->x() < pt2->x() )
2809 else if ( pt1->x() > pt2->x() )
2810 return M_PI + ( M_PI_2 );
2815 if ( pt1->x() < pt2->x() )
2817 if ( pt1->y() < pt2->y() )
2819 return std::atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) );
2823 return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
2830 if ( pt1->y() > pt2->y() )
2832 return std::atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) )
2837 return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
2838 + ( M_PI + ( M_PI_2 ) );
2845 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2849 parent->
setEvalErrorString( QStringLiteral(
"'project' requires a point geometry" ) );
2853 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2854 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2855 double inclination = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2858 QgsPoint newPoint = p->
project( distance, 180.0 * azimuth / M_PI, 180.0 * inclination / M_PI );
2865 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2866 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2874 parent->
setEvalErrorString( QStringLiteral(
"Function 'inclination' requires two points as arguments." ) );
2878 return pt1->inclination( *pt2 );
2884 if ( values.length() != 3 )
2887 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2888 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2889 double y = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2893 QVariant result = geom.
constGet() ? QVariant::fromValue( geom ) : QVariant();
2899 if ( values.length() < 2 )
2902 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2905 return values.at( 0 );
2907 QString expString = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
2908 QVariant cachedExpression;
2913 if ( cachedExpression.isValid() )
2920 bool asc = values.value( 2 ).toBool();
2938 Q_ASSERT( collection );
2942 QgsExpressionSorter sorter( orderBy );
2944 QList<QgsFeature> partFeatures;
2945 partFeatures.reserve( collection->
partCount() );
2946 for (
int i = 0; i < collection->
partCount(); ++i )
2952 sorter.sortFeatures( partFeatures, unconstedContext );
2956 Q_ASSERT( orderedGeom );
2961 for (
const QgsFeature &feature : qgis::as_const( partFeatures ) )
2963 orderedGeom->
addGeometry( feature.geometry().constGet()->clone() );
2966 QVariant result = QVariant::fromValue(
QgsGeometry( orderedGeom ) );
2969 delete unconstedContext;
2976 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2977 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2981 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2987 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2988 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2992 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2998 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2999 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3003 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3009 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3010 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3017 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3018 qlonglong vertex = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3025 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3026 qlonglong vertex = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3033 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3034 QgsGeometry pointGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3038 return distance >= 0 ? distance : QVariant();
3043 if ( values.length() == 2 && values.at( 1 ).toInt() != 0 )
3045 double number = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
3046 double scaler = std::pow( 10.0, QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3047 return QVariant( std::round( number * scaler ) / scaler );
3050 if ( values.length() >= 1 )
3052 double number = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3053 return QVariant( qlonglong( std::round( number ) ) );
3068 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
3069 int places = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3075 return QStringLiteral(
"%L1" ).arg( value, 0,
'f', places );
3080 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
3081 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3082 return dt.toString( format );
3088 int avg = ( color.red() + color.green() + color.blue() ) / 3;
3089 int alpha = color.alpha();
3091 color.setRgb( avg, avg, avg, alpha );
3100 double ratio = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3105 else if ( ratio < 0 )
3110 int red = color1.red() * ( 1 - ratio ) + color2.red() * ratio;
3111 int green = color1.green() * ( 1 - ratio ) + color2.green() * ratio;
3112 int blue = color1.blue() * ( 1 - ratio ) + color2.blue() * ratio;
3113 int alpha = color1.alpha() * ( 1 - ratio ) + color2.alpha() * ratio;
3115 QColor newColor( red, green, blue, alpha );
3122 int red = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3123 int green = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3124 int blue = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3125 QColor color = QColor( red, green, blue );
3126 if ( ! color.isValid() )
3128 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( red ).arg( green ).arg( blue ) );
3129 color = QColor( 0, 0, 0 );
3132 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3137 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
3139 QVariant value = node->
eval( parent, context );
3141 if ( value.toBool() )
3143 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
3145 value = node->
eval( parent, context );
3150 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
3152 value = node->
eval( parent, context );
3160 int red = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3161 int green = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3162 int blue = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3163 int alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
3164 QColor color = QColor( red, green, blue, alpha );
3165 if ( ! color.isValid() )
3167 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( red ).arg( green ).arg( blue ).arg( alpha ) );
3168 color = QColor( 0, 0, 0 );
3179 expRamp = QgsExpressionUtils::getRamp( values.at( 0 ), parent );
3184 QString rampName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
3188 parent->
setEvalErrorString( QObject::tr(
"\"%1\" is not a valid color ramp" ).arg( rampName ) );
3193 double value = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3194 QColor color = ramp->
color( value );
3201 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3203 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3205 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3207 QColor color = QColor::fromHslF( hue, saturation, lightness );
3209 if ( ! color.isValid() )
3211 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( lightness ) );
3212 color = QColor( 0, 0, 0 );
3215 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3221 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3223 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3225 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3227 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
3229 QColor color = QColor::fromHslF( hue, saturation, lightness, alpha );
3230 if ( ! color.isValid() )
3232 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
3233 color = QColor( 0, 0, 0 );
3241 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3243 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3245 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3247 QColor color = QColor::fromHsvF( hue, saturation, value );
3249 if ( ! color.isValid() )
3251 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( value ) );
3252 color = QColor( 0, 0, 0 );
3255 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3261 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3263 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3265 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3267 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
3269 QColor color = QColor::fromHsvF( hue, saturation, value, alpha );
3270 if ( ! color.isValid() )
3272 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
3273 color = QColor( 0, 0, 0 );
3281 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
3283 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3285 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3287 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
3289 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black );
3291 if ( ! color.isValid() )
3293 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ) );
3294 color = QColor( 0, 0, 0 );
3297 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3303 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
3305 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3307 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3309 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
3311 double alpha = QgsExpressionUtils::getIntValue( values.at( 4 ), parent ) / 255.0;
3313 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
3314 if ( ! color.isValid() )
3316 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
3317 color = QColor( 0, 0, 0 );
3325 if ( ! color.isValid() )
3327 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
3331 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3332 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
3334 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
3335 return color.green();
3336 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
3337 return color.blue();
3338 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
3339 return color.alpha();
3340 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
3341 return color.hsvHueF() * 360;
3342 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
3343 return color.hsvSaturationF() * 100;
3344 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
3345 return color.valueF() * 100;
3346 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
3347 return color.hslHueF() * 360;
3348 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
3349 return color.hslSaturationF() * 100;
3350 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
3351 return color.lightnessF() * 100;
3352 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
3353 return color.cyanF() * 100;
3354 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
3355 return color.magentaF() * 100;
3356 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
3357 return color.yellowF() * 100;
3358 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
3359 return color.blackF() * 100;
3361 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
3367 const QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
3368 if ( map.count() < 1 )
3370 parent->
setEvalErrorString( QObject::tr(
"A minimum of two colors is required to create a ramp" ) );
3374 QList< QColor > colors;
3376 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
3379 if ( !colors.last().isValid() )
3381 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( it.value().toString() ) );
3385 double step = it.key().toDouble();
3386 if ( it == map.constBegin() )
3391 else if ( it == map.constEnd() )
3401 bool discrete = values.at( 1 ).toBool();
3403 return QVariant::fromValue(
QgsGradientColorRamp( colors.first(), colors.last(), discrete, stops ) );
3409 if ( ! color.isValid() )
3411 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
3415 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3416 int value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3417 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
3418 color.setRed( value );
3419 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
3420 color.setGreen( value );
3421 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
3422 color.setBlue( value );
3423 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
3424 color.setAlpha( value );
3425 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
3426 color.setHsv( value, color.hsvSaturation(), color.value(), color.alpha() );
3427 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
3428 color.setHsvF( color.hsvHueF(), value / 100.0, color.valueF(), color.alphaF() );
3429 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
3430 color.setHsvF( color.hsvHueF(), color.hsvSaturationF(), value / 100.0, color.alphaF() );
3431 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
3432 color.setHsl( value, color.hslSaturation(), color.lightness(), color.alpha() );
3433 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
3434 color.setHslF( color.hslHueF(), value / 100.0, color.lightnessF(), color.alphaF() );
3435 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
3436 color.setHslF( color.hslHueF(), color.hslSaturationF(), value / 100.0, color.alphaF() );
3437 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
3438 color.setCmykF( value / 100.0, color.magentaF(), color.yellowF(), color.blackF(), color.alphaF() );
3439 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
3440 color.setCmykF( color.cyanF(), value / 100.0, color.yellowF(), color.blackF(), color.alphaF() );
3441 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
3442 color.setCmykF( color.cyanF(), color.magentaF(), value / 100.0, color.blackF(), color.alphaF() );
3443 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
3444 color.setCmykF( color.cyanF(), color.magentaF(), color.yellowF(), value / 100.0, color.alphaF() );
3447 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
3456 if ( ! color.isValid() )
3458 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
3462 color = color.darker( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3470 if ( ! color.isValid() )
3472 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
3476 color = color.lighter( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3483 QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
3485 if ( !geom.isNull() )
3486 return QVariant::fromValue( geom );
3492 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3493 QString sAuthId = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3494 QString dAuthId = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
3497 if ( ! s.isValid() )
3498 return QVariant::fromValue( fGeom );
3501 return QVariant::fromValue( fGeom );
3509 return QVariant::fromValue( fGeom );
3523 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
3526 QgsFeatureId fid = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3534 result = QVariant::fromValue( fet );
3543 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
3551 QString attribute = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3553 if ( attributeId == -1 )
3558 const QVariant &attVal = values.at( 2 );
3560 const QString cacheValueKey = QStringLiteral(
"getfeature:%1:%2:%3" ).arg( vl->
id(), QString::number( attributeId ), attVal.toString() );
3580 res = QVariant::fromValue( fet );
3595 if ( !values.isEmpty() )
3598 if ( col && ( values.size() == 1 || !values.at( 1 ).isValid() ) )
3599 fieldName = col->
name();
3600 else if ( values.size() == 2 )
3601 fieldName = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3604 QVariant value = values.at( 0 );
3609 if ( fieldIndex == -1 )
3611 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: Field not found %2" ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
3615 QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
3617 const QString cacheValueKey = QStringLiteral(
"repvalfcnval:%1:%2:%3" ).arg( layer ? layer->
id() : QStringLiteral(
"[None]" ), fieldName, value.toString() );
3626 const QString cacheKey = QStringLiteral(
"repvalfcn:%1:%2" ).arg( layer ? layer->
id() : QStringLiteral(
"[None]" ), fieldName );
3644 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: function cannot be evaluated without a context." ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
3652 QgsMapLayer *layer = QgsExpressionUtils::getMapLayer( values.at( 0 ), parent );
3657 QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3658 if ( QString::compare( layerProperty, QStringLiteral(
"name" ), Qt::CaseInsensitive ) == 0 )
3659 return layer->
name();
3660 else if ( QString::compare( layerProperty, QStringLiteral(
"id" ), Qt::CaseInsensitive ) == 0 )
3662 else if ( QString::compare( layerProperty, QStringLiteral(
"title" ), Qt::CaseInsensitive ) == 0 )
3663 return layer->
title();
3664 else if ( QString::compare( layerProperty, QStringLiteral(
"abstract" ), Qt::CaseInsensitive ) == 0 )
3666 else if ( QString::compare( layerProperty, QStringLiteral(
"keywords" ), Qt::CaseInsensitive ) == 0 )
3668 else if ( QString::compare( layerProperty, QStringLiteral(
"data_url" ), Qt::CaseInsensitive ) == 0 )
3670 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution" ), Qt::CaseInsensitive ) == 0 )
3672 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution_url" ), Qt::CaseInsensitive ) == 0 )
3674 else if ( QString::compare( layerProperty, QStringLiteral(
"source" ), Qt::CaseInsensitive ) == 0 )
3676 else if ( QString::compare( layerProperty, QStringLiteral(
"min_scale" ), Qt::CaseInsensitive ) == 0 )
3678 else if ( QString::compare( layerProperty, QStringLiteral(
"max_scale" ), Qt::CaseInsensitive ) == 0 )
3680 else if ( QString::compare( layerProperty, QStringLiteral(
"crs" ), Qt::CaseInsensitive ) == 0 )
3682 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_definition" ), Qt::CaseInsensitive ) == 0 )
3684 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_description" ), Qt::CaseInsensitive ) == 0 )
3686 else if ( QString::compare( layerProperty, QStringLiteral(
"extent" ), Qt::CaseInsensitive ) == 0 )
3689 QVariant result = QVariant::fromValue( extentGeom );
3692 else if ( QString::compare( layerProperty, QStringLiteral(
"type" ), Qt::CaseInsensitive ) == 0 )
3694 switch ( layer->
type() )
3697 return QCoreApplication::translate(
"expressions",
"Vector" );
3699 return QCoreApplication::translate(
"expressions",
"Raster" );
3701 return QCoreApplication::translate(
"expressions",
"Mesh" );
3703 return QCoreApplication::translate(
"expressions",
"Plugin" );
3712 if ( QString::compare( layerProperty, QStringLiteral(
"storage_type" ), Qt::CaseInsensitive ) == 0 )
3714 else if ( QString::compare( layerProperty, QStringLiteral(
"geometry_type" ), Qt::CaseInsensitive ) == 0 )
3716 else if ( QString::compare( layerProperty, QStringLiteral(
"feature_count" ), Qt::CaseInsensitive ) == 0 )
3726 QString layerIdOrName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
3733 if ( !layersByName.isEmpty() )
3735 layer = layersByName.at( 0 );
3746 int band = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3747 if ( band < 1 || band > rl->
bandCount() )
3749 parent->
setEvalErrorString( QObject::tr(
"Invalid band number %1 for layer %2" ).arg( band ).arg( layerIdOrName ) );
3753 QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
3756 if ( QString::compare( layerProperty, QStringLiteral(
"avg" ), Qt::CaseInsensitive ) == 0 )
3758 else if ( QString::compare( layerProperty, QStringLiteral(
"stdev" ), Qt::CaseInsensitive ) == 0 )
3760 else if ( QString::compare( layerProperty, QStringLiteral(
"min" ), Qt::CaseInsensitive ) == 0 )
3762 else if ( QString::compare( layerProperty, QStringLiteral(
"max" ), Qt::CaseInsensitive ) == 0 )
3764 else if ( QString::compare( layerProperty, QStringLiteral(
"range" ), Qt::CaseInsensitive ) == 0 )
3766 else if ( QString::compare( layerProperty, QStringLiteral(
"sum" ), Qt::CaseInsensitive ) == 0 )
3770 parent->
setEvalErrorString( QObject::tr(
"Invalid raster statistic: '%1'" ).arg( layerProperty ) );
3800 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).length();
3805 return QVariant( QgsExpressionUtils::getListValue( values.at( 0 ), parent ).contains( values.at( 1 ) ) );
3810 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).indexOf( values.at( 1 ) );
3815 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3816 const qlonglong pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3817 if ( pos < 0 || pos >= list.length() )
return QVariant();
3818 return list.at( pos );
3823 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3824 return list.value( 0 );
3829 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3830 return list.value( list.size() - 1 );
3833 static QVariant convertToSameType(
const QVariant &value, QVariant::Type type )
3835 QVariant result = value;
3836 result.convert( type );
3842 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3843 list.append( values.at( 1 ) );
3844 return convertToSameType( list, values.at( 0 ).type() );
3849 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3850 list.prepend( values.at( 1 ) );
3851 return convertToSameType( list, values.at( 0 ).type() );
3856 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3857 list.insert( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ), values.at( 2 ) );
3858 return convertToSameType( list, values.at( 0 ).type() );
3863 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3864 list.removeAt( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3865 return convertToSameType( list, values.at( 0 ).type() );
3870 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3871 list.removeAll( values.at( 1 ) );
3872 return convertToSameType( list, values.at( 0 ).type() );
3878 for (
const QVariant &cur : values )
3880 list += QgsExpressionUtils::getListValue( cur, parent );
3882 return convertToSameType( list, values.at( 0 ).type() );
3887 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3888 qlonglong start_pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3889 const qlonglong end_pos = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3890 qlonglong slice_length = 0;
3892 if ( start_pos < 0 )
3894 start_pos = list.length() + start_pos;
3898 slice_length = end_pos - start_pos + 1;
3902 slice_length = list.length() + end_pos - start_pos + 1;
3905 if ( slice_length < 0 )
3909 list = list.mid( start_pos, slice_length );
3915 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3916 std::reverse( list.begin(), list.end() );
3922 const QVariantList array1 = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3923 const QVariantList array2 = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
3924 for (
const QVariant &cur : array2 )
3926 if ( array1.contains( cur ) )
3927 return QVariant(
true );
3929 return QVariant(
false );
3934 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3936 QVariantList distinct;
3938 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
3940 if ( !distinct.contains( *it ) )
3942 distinct += ( *it );
3951 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3952 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3953 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
3957 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
3959 str += ( !( *it ).toString().isEmpty() ) ? ( *it ).toString() : empty;
3960 if ( it != ( array.constEnd() - 1 ) )
3966 return QVariant( str );
3971 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
3972 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3973 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
3975 QStringList list = str.split( delimiter );
3978 for ( QStringList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
3980 array += ( !( *it ).isEmpty() ) ? *it : empty;
3989 for (
int i = 0; i + 1 < values.length(); i += 2 )
3991 result.insert( QgsExpressionUtils::getStringValue( values.at( i ), parent ), values.at( i + 1 ) );
3998 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).value( values.at( 1 ).toString() );
4003 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).contains( values.at( 1 ).toString() );
4008 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4009 map.remove( values.at( 1 ).toString() );
4015 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4016 map.insert( values.at( 1 ).toString(), values.at( 2 ) );
4023 for (
const QVariant &cur : values )
4025 const QVariantMap curMap = QgsExpressionUtils::getMapValue( cur, parent );
4026 for ( QVariantMap::const_iterator it = curMap.constBegin(); it != curMap.constEnd(); ++it )
4027 result.insert( it.key(), it.value() );
4034 return QStringList( QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).keys() );
4039 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).values();
4044 QString envVarName = values.at( 0 ).toString();
4045 return QProcessEnvironment::systemEnvironment().value( envVarName );
4054 static QMutex sFunctionsMutex( QMutex::Recursive );
4055 QMutexLocker locker( &sFunctionsMutex );
4057 if ( sFunctions.isEmpty() )
4087 sFunctions << randFunc;
4091 sFunctions << randfFunc;
4094 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max" ), -1, fcnMax, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4095 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min" ), -1, fcnMin, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4097 <<
new QgsStaticExpressionFunction( QStringLiteral(
"scale_linear" ), 5, fcnLinearScale, QStringLiteral(
"Math" ) )
4098 <<
new QgsStaticExpressionFunction( QStringLiteral(
"scale_exp" ), 6, fcnExpScale, QStringLiteral(
"Math" ) )
4099 <<
new QgsStaticExpressionFunction( QStringLiteral(
"floor" ), 1, fcnFloor, QStringLiteral(
"Math" ) )
4100 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ceil" ), 1, fcnCeil, QStringLiteral(
"Math" ) )
4101 <<
new QgsStaticExpressionFunction( QStringLiteral(
"pi" ), 0, fcnPi, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$pi" ) )
4104 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_string" ),
QgsExpressionFunction::ParameterList() <<
QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToString, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"String" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"tostring" ) )
4105 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_datetime" ),
QgsExpressionFunction::ParameterList() <<
QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToDateTime, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todatetime" ) )
4106 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_date" ),
QgsExpressionFunction::ParameterList() <<
QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToDate, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todate" ) )
4107 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_time" ),
QgsExpressionFunction::ParameterList() <<
QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToTime, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"totime" ) )
4108 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_interval" ),
QgsExpressionFunction::ParameterList() <<
QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToInterval, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"tointerval" ) )
4109 <<
new QgsStaticExpressionFunction( QStringLiteral(
"coalesce" ), -1, fcnCoalesce, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4110 <<
new QgsStaticExpressionFunction( QStringLiteral(
"if" ), 3, fcnIf, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
true )
4112 <<
new QgsStaticExpressionFunction( QStringLiteral(
"aggregate" ),
4120 QStringLiteral(
"Aggregates" ),
4129 if ( !node->
args() )
4132 QSet<QString> referencedVars;
4144 return referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() );
4153 if ( !node->
args() )
4154 return QSet<QString>();
4156 QSet<QString> referencedCols;
4157 QSet<QString> referencedVars;
4172 if ( referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() ) )
4175 return referencedCols;
4183 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count" ), aggParams, fcnAggregateCount, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4184 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_distinct" ), aggParams, fcnAggregateCountDistinct, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4185 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_missing" ), aggParams, fcnAggregateCountMissing, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4186 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minimum" ), aggParams, fcnAggregateMin, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4187 <<
new QgsStaticExpressionFunction( QStringLiteral(
"maximum" ), aggParams, fcnAggregateMax, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4188 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sum" ), aggParams, fcnAggregateSum, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4189 <<
new QgsStaticExpressionFunction( QStringLiteral(
"mean" ), aggParams, fcnAggregateMean, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4190 <<
new QgsStaticExpressionFunction( QStringLiteral(
"median" ), aggParams, fcnAggregateMedian, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4191 <<
new QgsStaticExpressionFunction( QStringLiteral(
"stdev" ), aggParams, fcnAggregateStdev, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4192 <<
new QgsStaticExpressionFunction( QStringLiteral(
"range" ), aggParams, fcnAggregateRange, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4193 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minority" ), aggParams, fcnAggregateMinority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4194 <<
new QgsStaticExpressionFunction( QStringLiteral(
"majority" ), aggParams, fcnAggregateMajority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4195 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q1" ), aggParams, fcnAggregateQ1, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4196 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q3" ), aggParams, fcnAggregateQ3, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4197 <<
new QgsStaticExpressionFunction( QStringLiteral(
"iqr" ), aggParams, fcnAggregateIQR, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4198 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min_length" ), aggParams, fcnAggregateMinLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4199 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max_length" ), aggParams, fcnAggregateMaxLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4200 <<
new QgsStaticExpressionFunction( QStringLiteral(
"collect" ), aggParams, fcnAggregateCollectGeometry, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4201 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concatenate" ), aggParams <<
QgsExpressionFunction::Parameter( QStringLiteral(
"concatenator" ),
true ), fcnAggregateStringConcat, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4202 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_agg" ), aggParams, fcnAggregateArray, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4207 <<
new QgsStaticExpressionFunction( QStringLiteral(
"now" ), 0, fcnNow, QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$now" ) )
4208 <<
new QgsStaticExpressionFunction( QStringLiteral(
"age" ), 2, fcnAge, QStringLiteral(
"Date and Time" ) )
4209 <<
new QgsStaticExpressionFunction( QStringLiteral(
"year" ), 1, fcnYear, QStringLiteral(
"Date and Time" ) )
4210 <<
new QgsStaticExpressionFunction( QStringLiteral(
"month" ), 1, fcnMonth, QStringLiteral(
"Date and Time" ) )
4211 <<
new QgsStaticExpressionFunction( QStringLiteral(
"week" ), 1, fcnWeek, QStringLiteral(
"Date and Time" ) )
4212 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day" ), 1, fcnDay, QStringLiteral(
"Date and Time" ) )
4213 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hour" ), 1, fcnHour, QStringLiteral(
"Date and Time" ) )
4214 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minute" ), 1, fcnMinute, QStringLiteral(
"Date and Time" ) )
4215 <<
new QgsStaticExpressionFunction( QStringLiteral(
"second" ), 1, fcnSeconds, QStringLiteral(
"Date and Time" ) )
4217 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day_of_week" ), 1, fcnDayOfWeek, QStringLiteral(
"Date and Time" ) )
4218 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lower" ), 1, fcnLower, QStringLiteral(
"String" ) )
4219 <<
new QgsStaticExpressionFunction( QStringLiteral(
"upper" ), 1, fcnUpper, QStringLiteral(
"String" ) )
4220 <<
new QgsStaticExpressionFunction( QStringLiteral(
"title" ), 1, fcnTitle, QStringLiteral(
"String" ) )
4221 <<
new QgsStaticExpressionFunction( QStringLiteral(
"trim" ), 1, fcnTrim, QStringLiteral(
"String" ) )
4222 <<
new QgsStaticExpressionFunction( QStringLiteral(
"levenshtein" ), 2, fcnLevenshtein, QStringLiteral(
"Fuzzy Matching" ) )
4223 <<
new QgsStaticExpressionFunction( QStringLiteral(
"longest_common_substring" ), 2, fcnLCS, QStringLiteral(
"Fuzzy Matching" ) )
4224 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hamming_distance" ), 2, fcnHamming, QStringLiteral(
"Fuzzy Matching" ) )
4225 <<
new QgsStaticExpressionFunction( QStringLiteral(
"soundex" ), 1, fcnSoundex, QStringLiteral(
"Fuzzy Matching" ) )
4226 <<
new QgsStaticExpressionFunction( QStringLiteral(
"char" ), 1, fcnChar, QStringLiteral(
"String" ) )
4229 <<
new QgsStaticExpressionFunction( QStringLiteral(
"replace" ), -1, fcnReplace, QStringLiteral(
"String" ) )
4230 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_replace" ), 3, fcnRegexpReplace, QStringLiteral(
"String" ) )
4231 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_substr" ), 2, fcnRegexpSubstr, QStringLiteral(
"String" ) )
4233 false, QSet< QString >(),
false, QStringList(),
true )
4234 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concat" ), -1, fcnConcat, QStringLiteral(
"String" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4235 <<
new QgsStaticExpressionFunction( QStringLiteral(
"strpos" ), 2, fcnStrpos, QStringLiteral(
"String" ) )
4236 <<
new QgsStaticExpressionFunction( QStringLiteral(
"left" ), 2, fcnLeft, QStringLiteral(
"String" ) )
4237 <<
new QgsStaticExpressionFunction( QStringLiteral(
"right" ), 2, fcnRight, QStringLiteral(
"String" ) )
4238 <<
new QgsStaticExpressionFunction( QStringLiteral(
"rpad" ), 3, fcnRPad, QStringLiteral(
"String" ) )
4239 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lpad" ), 3, fcnLPad, QStringLiteral(
"String" ) )
4240 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format" ), -1, fcnFormatString, QStringLiteral(
"String" ) )
4241 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format_number" ), 2, fcnFormatNumber, QStringLiteral(
"String" ) )
4243 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_grayscale_average" ), 1, fcnColorGrayscaleAverage, QStringLiteral(
"Color" ) )
4244 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_mix_rgb" ), 3, fcnColorMixRgb, QStringLiteral(
"Color" ) )
4245 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_rgb" ), 3, fcnColorRgb, QStringLiteral(
"Color" ) )
4246 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_rgba" ), 4, fncColorRgba, QStringLiteral(
"Color" ) )
4247 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ramp_color" ), 2,
fcnRampColor, QStringLiteral(
"Color" ) )
4249 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_hsl" ), 3, fcnColorHsl, QStringLiteral(
"Color" ) )
4250 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_hsla" ), 4, fncColorHsla, QStringLiteral(
"Color" ) )
4251 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_hsv" ), 3, fcnColorHsv, QStringLiteral(
"Color" ) )
4252 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_hsva" ), 4, fncColorHsva, QStringLiteral(
"Color" ) )
4253 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_cmyk" ), 4, fcnColorCmyk, QStringLiteral(
"Color" ) )
4254 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_cmyka" ), 5, fncColorCmyka, QStringLiteral(
"Color" ) )
4255 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_part" ), 2, fncColorPart, QStringLiteral(
"Color" ) )
4256 <<
new QgsStaticExpressionFunction( QStringLiteral(
"darker" ), 2, fncDarker, QStringLiteral(
"Color" ) )
4257 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lighter" ), 2, fncLighter, QStringLiteral(
"Color" ) )
4258 <<
new QgsStaticExpressionFunction( QStringLiteral(
"set_color_part" ), 3, fncSetColorPart, QStringLiteral(
"Color" ) );
4260 QgsStaticExpressionFunction *geomFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$geometry" ), 0, fcnGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4262 sFunctions << geomFunc;
4264 QgsStaticExpressionFunction *areaFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$area" ), 0, fcnGeomArea, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4266 sFunctions << areaFunc;
4268 sFunctions <<
new QgsStaticExpressionFunction( QStringLiteral(
"area" ), 1, fcnArea, QStringLiteral(
"GeometryGroup" ) );
4270 QgsStaticExpressionFunction *lengthFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$length" ), 0, fcnGeomLength, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4272 sFunctions << lengthFunc;
4274 QgsStaticExpressionFunction *perimeterFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$perimeter" ), 0, fcnGeomPerimeter, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4276 sFunctions << perimeterFunc;
4278 sFunctions <<
new QgsStaticExpressionFunction( QStringLiteral(
"perimeter" ), 1, fcnPerimeter, QStringLiteral(
"GeometryGroup" ) );
4280 QgsStaticExpressionFunction *xFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$x" ), 0, fcnX, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4282 sFunctions << xFunc;
4284 QgsStaticExpressionFunction *yFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$y" ), 0, fcnY, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4286 sFunctions << yFunc;
4289 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x" ), 1, fcnGeomX, QStringLiteral(
"GeometryGroup" ) )
4290 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y" ), 1, fcnGeomY, QStringLiteral(
"GeometryGroup" ) )
4291 <<
new QgsStaticExpressionFunction( QStringLiteral(
"z" ), 1, fcnGeomZ, QStringLiteral(
"GeometryGroup" ) )
4292 <<
new QgsStaticExpressionFunction( QStringLiteral(
"m" ), 1, fcnGeomM, QStringLiteral(
"GeometryGroup" ) )
4293 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_n" ), 2, fcnPointN, QStringLiteral(
"GeometryGroup" ) )
4294 <<
new QgsStaticExpressionFunction( QStringLiteral(
"start_point" ), 1, fcnStartPoint, QStringLiteral(
"GeometryGroup" ) )
4295 <<
new QgsStaticExpressionFunction( QStringLiteral(
"end_point" ), 1, fcnEndPoint, QStringLiteral(
"GeometryGroup" ) )
4296 <<
new QgsStaticExpressionFunction( QStringLiteral(
"nodes_to_points" ), -1, fcnNodesToPoints, QStringLiteral(
"GeometryGroup" ) )
4297 <<
new QgsStaticExpressionFunction( QStringLiteral(
"segments_to_lines" ), 1, fcnSegmentsToLines, QStringLiteral(
"GeometryGroup" ) )
4298 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_point" ), -1, fcnMakePoint, QStringLiteral(
"GeometryGroup" ) )
4299 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_point_m" ), 3, fcnMakePointM, QStringLiteral(
"GeometryGroup" ) )
4300 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_line" ), -1, fcnMakeLine, QStringLiteral(
"GeometryGroup" ) )
4301 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_polygon" ), -1, fcnMakePolygon, QStringLiteral(
"GeometryGroup" ) )
4305 fcnMakeTriangle, QStringLiteral(
"GeometryGroup" ) )
4310 fcnMakeCircle, QStringLiteral(
"GeometryGroup" ) )
4317 fcnMakeEllipse, QStringLiteral(
"GeometryGroup" ) )
4323 fcnMakeRegularPolygon, QStringLiteral(
"GeometryGroup" ) );
4325 QgsStaticExpressionFunction *xAtFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$x_at" ), 1, fcnXat, QStringLiteral(
"GeometryGroup" ), QString(),
true, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xat" ) << QStringLiteral(
"x_at" ) );
4327 sFunctions << xAtFunc;
4329 QgsStaticExpressionFunction *yAtFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$y_at" ), 1, fcnYat, QStringLiteral(
"GeometryGroup" ), QString(),
true, QSet<QString>(),
false, QStringList() << QStringLiteral(
"yat" ) << QStringLiteral(
"y_at" ) );
4331 sFunctions << yAtFunc;
4334 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_min" ), 1, fcnXMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmin" ) )
4335 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_max" ), 1, fcnXMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmax" ) )
4336 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_min" ), 1, fcnYMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymin" ) )
4337 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_max" ), 1, fcnYMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymax" ) )
4338 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_wkt" ), 1, fcnGeomFromWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromWKT" ) )
4339 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_gml" ), 1, fcnGeomFromGML, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromGML" ) )
4340 <<
new QgsStaticExpressionFunction( QStringLiteral(
"flip_coordinates" ), 1, fcnFlipCoordinates, QStringLiteral(
"GeometryGroup" ) )
4341 <<
new QgsStaticExpressionFunction( QStringLiteral(
"relate" ), -1, fcnRelate, QStringLiteral(
"GeometryGroup" ) )
4342 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersects_bbox" ), 2, fcnBbox, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"bbox" ) )
4343 <<
new QgsStaticExpressionFunction( QStringLiteral(
"disjoint" ), 2, fcnDisjoint, QStringLiteral(
"GeometryGroup" ) )
4344 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersects" ), 2, fcnIntersects, QStringLiteral(
"GeometryGroup" ) )
4345 <<
new QgsStaticExpressionFunction( QStringLiteral(
"touches" ), 2, fcnTouches, QStringLiteral(
"GeometryGroup" ) )
4346 <<
new QgsStaticExpressionFunction( QStringLiteral(
"crosses" ), 2, fcnCrosses, QStringLiteral(
"GeometryGroup" ) )
4347 <<
new QgsStaticExpressionFunction( QStringLiteral(
"contains" ), 2, fcnContains, QStringLiteral(
"GeometryGroup" ) )
4348 <<
new QgsStaticExpressionFunction( QStringLiteral(
"overlaps" ), 2, fcnOverlaps, QStringLiteral(
"GeometryGroup" ) )
4349 <<
new QgsStaticExpressionFunction( QStringLiteral(
"within" ), 2, fcnWithin, QStringLiteral(
"GeometryGroup" ) )
4350 <<
new QgsStaticExpressionFunction( QStringLiteral(
"translate" ), 3, fcnTranslate, QStringLiteral(
"GeometryGroup" ) )
4351 <<
new QgsStaticExpressionFunction( QStringLiteral(
"buffer" ), -1, fcnBuffer, QStringLiteral(
"GeometryGroup" ) )
4361 , fcnTaperedBuffer, QStringLiteral(
"GeometryGroup" ) )
4364 , fcnBufferByM, QStringLiteral(
"GeometryGroup" ) )
4370 fcnOffsetCurve, QStringLiteral(
"GeometryGroup" ) )
4376 fcnSingleSidedBuffer, QStringLiteral(
"GeometryGroup" ) )
4380 fcnExtend, QStringLiteral(
"GeometryGroup" ) )
4381 <<
new QgsStaticExpressionFunction( QStringLiteral(
"centroid" ), 1, fcnCentroid, QStringLiteral(
"GeometryGroup" ) )
4382 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_on_surface" ), 1, fcnPointOnSurface, QStringLiteral(
"GeometryGroup" ) )
4385 <<
new QgsStaticExpressionFunction( QStringLiteral(
"reverse" ), 1, fcnReverse, QStringLiteral(
"GeometryGroup" ) )
4386 <<
new QgsStaticExpressionFunction( QStringLiteral(
"exterior_ring" ), 1, fcnExteriorRing, QStringLiteral(
"GeometryGroup" ) )
4387 <<
new QgsStaticExpressionFunction( QStringLiteral(
"interior_ring_n" ), 2, fcnInteriorRingN, QStringLiteral(
"GeometryGroup" ) )
4388 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geometry_n" ), 2, fcnGeometryN, QStringLiteral(
"GeometryGroup" ) )
4391 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds" ), 1, fcnBounds, QStringLiteral(
"GeometryGroup" ) )
4398 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_points" ), 1, fcnGeomNumPoints, QStringLiteral(
"GeometryGroup" ) )
4399 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_interior_rings" ), 1, fcnGeomNumInteriorRings, QStringLiteral(
"GeometryGroup" ) )
4400 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_rings" ), 1, fcnGeomNumRings, QStringLiteral(
"GeometryGroup" ) )
4401 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_geometries" ), 1, fcnGeomNumGeometries, QStringLiteral(
"GeometryGroup" ) )
4402 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_width" ), 1, fcnBoundsWidth, QStringLiteral(
"GeometryGroup" ) )
4403 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_height" ), 1, fcnBoundsHeight, QStringLiteral(
"GeometryGroup" ) )
4404 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_closed" ), 1, fcnIsClosed, QStringLiteral(
"GeometryGroup" ) )
4405 <<
new QgsStaticExpressionFunction( QStringLiteral(
"convex_hull" ), 1, fcnConvexHull, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"convexHull" ) )
4408 fcnOrientedBBox, QStringLiteral(
"GeometryGroup" ) )
4412 fcnMinimalCircle, QStringLiteral(
"GeometryGroup" ) )
4413 <<
new QgsStaticExpressionFunction( QStringLiteral(
"difference" ), 2, fcnDifference, QStringLiteral(
"GeometryGroup" ) )
4414 <<
new QgsStaticExpressionFunction( QStringLiteral(
"distance" ), 2, fcnDistance, QStringLiteral(
"GeometryGroup" ) )
4417 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersection" ), 2, fcnIntersection, QStringLiteral(
"GeometryGroup" ) )
4418 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sym_difference" ), 2, fcnSymDifference, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"symDifference" ) )
4419 <<
new QgsStaticExpressionFunction( QStringLiteral(
"combine" ), 2, fcnCombine, QStringLiteral(
"GeometryGroup" ) )
4420 <<
new QgsStaticExpressionFunction( QStringLiteral(
"union" ), 2, fcnCombine, QStringLiteral(
"GeometryGroup" ) )
4421 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_to_wkt" ), -1, fcnGeomToWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomToWKT" ) )
4422 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geometry" ), 1, fcnGetGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true )
4423 <<
new QgsStaticExpressionFunction( QStringLiteral(
"transform" ), 3, fcnTransformGeometry, QStringLiteral(
"GeometryGroup" ) )
4424 <<
new QgsStaticExpressionFunction( QStringLiteral(
"extrude" ), 3, fcnExtrude, QStringLiteral(
"GeometryGroup" ), QString() );;
4426 QgsStaticExpressionFunction *orderPartsFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"order_parts" ), 3, fcnOrderParts, QStringLiteral(
"GeometryGroup" ), QString() );
4431 const QList< QgsExpressionNode *> argList = node->
args()->
list();
4434 if ( !argNode->isStatic( parent, context ) )
4442 QString expString = argNode->
eval( parent, context ).toString();
4458 QString expression = argNode->
eval( parent, context ).toString();
4466 sFunctions << orderPartsFunc;
4469 <<
new QgsStaticExpressionFunction( QStringLiteral(
"closest_point" ), 2, fcnClosestPoint, QStringLiteral(
"GeometryGroup" ) )
4470 <<
new QgsStaticExpressionFunction( QStringLiteral(
"shortest_line" ), 2, fcnShortestLine, QStringLiteral(
"GeometryGroup" ) )
4485 QgsStaticExpressionFunction *idFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$id" ), 0, fcnFeatureId, QStringLiteral(
"Record and Attributes" ) );
4487 sFunctions << idFunc;
4489 QgsStaticExpressionFunction *currentFeatureFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$currentfeature" ), 0, fcnFeature, QStringLiteral(
"Record and Attributes" ) );
4491 sFunctions << currentFeatureFunc;
4493 QgsStaticExpressionFunction *uuidFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"uuid" ), 0, fcnUuid, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$uuid" ) );
4495 sFunctions << uuidFunc;
4498 <<
new QgsStaticExpressionFunction( QStringLiteral(
"get_feature" ), 3, fcnGetFeature, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"QgsExpressionUtils::getFeature" ) )
4499 <<
new QgsStaticExpressionFunction( QStringLiteral(
"get_feature_by_id" ), 2, fcnGetFeatureById, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false );
4501 QgsStaticExpressionFunction *isSelectedFunc =
new QgsStaticExpressionFunction(
4502 QStringLiteral(
"is_selected" ),
4505 QStringLiteral(
"Record and Attributes" ),
4511 sFunctions << isSelectedFunc;
4514 <<
new QgsStaticExpressionFunction(
4515 QStringLiteral(
"num_selected" ),
4518 QStringLiteral(
"Record and Attributes" ),
4539 parent->
setEvalErrorString( tr(
"If represent_value is called with 1 parameter, it must be an attribute." ) );
4549 parent->
setEvalErrorString( tr(
"represent_value must be called with exactly 1 or 2 parameters." ) );
4555 sFunctions << representValueFunc;
4559 <<
new QgsStaticExpressionFunction( QStringLiteral(
"layer_property" ), 2, fcnGetLayerProperty, QStringLiteral(
"General" ) )
4565 QgsStaticExpressionFunction *varFunction =
new QgsStaticExpressionFunction( QStringLiteral(
"var" ), 1, fcnGetVariable, QStringLiteral(
"General" ) );
4578 if ( !argNode->
isStatic( parent, context ) )
4581 QString varName = argNode->
eval( parent, context ).toString();
4584 return scope ? scope->
isStatic( varName ) :
false;
4592 QgsStaticExpressionFunction *evalFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"eval" ), 1, fcnEval, QStringLiteral(
"General" ), QString(),
true, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES );
4600 if ( argNode->
isStatic( parent, context ) )
4602 QString expString = argNode->
eval( parent, context ).toString();
4614 sFunctions << evalFunc;
4617 <<
new QgsStaticExpressionFunction( QStringLiteral(
"env" ), 1, fcnEnvVar, QStringLiteral(
"General" ), QString() )
4619 <<
new QgsStaticExpressionFunction( QStringLiteral(
"attribute" ), 2, fcnAttribute, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES )
4622 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array" ), -1, fcnArray, QStringLiteral(
"Arrays" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4623 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_length" ), 1, fcnArrayLength, QStringLiteral(
"Arrays" ) )
4634 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_cat" ), -1, fcnArrayCat, QStringLiteral(
"Arrays" ) )
4638 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_distinct" ), 1, fcnArrayDistinct, QStringLiteral(
"Arrays" ) )
4643 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map" ), -1, fcnMap, QStringLiteral(
"Maps" ) )
4648 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_concat" ), -1, fcnMapConcat, QStringLiteral(
"Maps" ) )
4658 sOwnedFunctions <<
func;
4659 sBuiltinFunctions << func->name();
4660 sBuiltinFunctions.append( func->aliases() );
4678 if ( args->
count() < 3 )
4682 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
4684 QVariant
name = args->
at( 0 )->
eval( parent, context );
4685 QVariant value = args->
at( 1 )->
eval( parent, context );
4688 appendTemporaryVariable( context, name.toString(), value );
4689 if ( args->
at( 2 )->
isStatic( parent, context ) )
4691 popTemporaryVariable( context );
4702 if ( args->
count() < 3 )
4706 QVariant
name = args->
at( 0 )->
eval( parent, context );
4707 QVariant value = args->
at( 1 )->
eval( parent, context );
4713 appendTemporaryVariable( updatedContext, name.toString(), value );
4714 result = args->
at( 2 )->
eval( parent, updatedContext );
4715 popTemporaryVariable( updatedContext );
4717 delete updatedContext;
4738 if ( args->
count() < 3 )
4743 QVariant value = args->
at( 1 )->
prepare( parent, context );
4745 appendTemporaryVariable( context, name.toString(), value );
4746 args->
at( 2 )->
prepare( parent, context );
4747 popTemporaryVariable( context );
4752 void QgsWithVariableExpressionFunction::popTemporaryVariable(
const QgsExpressionContext *context )
const 4758 void QgsWithVariableExpressionFunction::appendTemporaryVariable(
const QgsExpressionContext *context,
const QString &
name,
const QVariant &value )
const int lookupField(const QString &fieldName) const
Look up field's index from the field name.
QVariant run(QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Evaluates the function, first evaluating all required arguments before passing them to the function's...
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
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.
Class for parsing and evaluation of expressions (formerly called "search strings").
QVariant cachedValue(const QString &key) const
Returns the matching cached value, if set.
virtual QgsCurve * reversed() const =0
Returns a reversed copy of the curve, where the direction of the curve has been flipped.
Wrapper for iterator of features from vector data provider or vector layer.
virtual QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)=0
Returns result of evaluating the function.
Third quartile (numeric fields only)
virtual QVariant run(QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)
Evaluates the function, first evaluating all required arguments before passing them to the function's...
virtual bool removeGeometry(int nr)
Removes a geometry from the collection.
const QgsColorRamp * colorRampRef(const QString &name) const
Returns a const pointer to a symbol (doesn't create new instance)
Base class for all map layer types.
Inter quartile range (IQR) (numeric fields only)
void setCachedValue(const QString &key, const QVariant &value) const
Sets a value to cache within the expression context.
bool prepare(QgsExpression *parent, const QgsExpressionContext *context)
Prepare this node for evaluation.
QgsGeometry combine(const QgsGeometry &geometry) const
Returns a geometry representing all the points in this geometry and other (a union geometry operation...
virtual QString dump() const =0
Dump this node into a serialized (part) of an expression.
QgsExpressionNode::NodeList * args() const
Returns a list of arguments specified for the function.
void setPoints(const QgsPointSequence &points)
Resets the line string to match the specified list of points.
double hausdorffDistanceDensify(const QgsGeometry &geom, double densifyFraction) const
Returns the Hausdorff distance between this geometry and geom.
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
Median of values (numeric fields only)
double sum
The sum of all cells in the band. NO_DATA values are excluded.
QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Returns result of evaluating the function.
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
QgsExpressionNode * at(int i)
Gets the node at position i in the list.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
bool isValid() const
Returns true if the interval is valid.
Represents a color stop within a QgsGradientColorRamp color ramp.
int bandCount() const
Returns the number of bands in this layer.
int params() const
The number of parameters this function takes.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
double distance(const QgsGeometry &geom) const
Returns the minimum distance between this geometry and another geometry, using GEOS.
double months() const
Returns the interval duration in months (based on a 30 day month).
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
Multi point geometry collection.
QgsWithVariableExpressionFunction()
bool within(const QgsGeometry &geometry) const
Test for if geometry is within another (uses GEOS)
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
double angleAtVertex(int vertex) const
Returns the bisector angle for this geometry at the specified vertex.
void setPrepareFunction(const std::function< bool(const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext *)> &prepareFunc)
Set a function that will be called in the prepare step to determine if the function is static or not...
QVector< QgsRingSequence > QgsCoordinateSequence
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
QgsExpressionContextScope * activeScopeForVariable(const QString &name)
Returns the currently active scope from the context for a specified variable name.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
First quartile (numeric fields only)
Number of missing (null) values.
A class to represent a 2D point.
QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request. ...
bool hasCachedValue(const QString &key) const
Returns true if the expression context contains a cached value with a matching key.
int selectedFeatureCount() const
Returns the number of features that are selected in this layer.
Abstract base class for color ramps.
QgsVectorLayer referencingLayer
const QgsCurve * interiorRing(int i) const
QVariant evaluate()
Evaluate the feature and return the result.
#define Q_NOWARN_DEPRECATED_PUSH
QString toProj4() const
Returns a Proj4 string representation of this CRS.
double maximumValue
The maximum cell value in the raster band.
double seconds() const
Returns the interval duration in seconds.
Multi line string geometry collection.
QgsGeometry interpolate(double distance) const
Returns interpolated point on line at distance.
Curve polygon geometry type.
bool overlaps(const QgsGeometry &geometry) const
Test for if geometry overlaps another (uses GEOS)
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
virtual QSet< QString > referencedColumns(const QgsExpressionNodeFunction *node) const
Returns a set of field names which are required for this function.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
Handles the with_variable(name, value, node) expression function.
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 convertLengthMeasurement(double length, QgsUnitTypes::DistanceUnit toUnits) const
Takes a length measurement calculated by this QgsDistanceArea object and converts it to a different d...
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QgsFields fields() const
Convenience function for retrieving the fields for the context, if set.
bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
This will be called during the prepare step() of an expression if it is not static.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
QgsGeometry intersection(const QgsGeometry &geometry) const
Returns a geometry representing the points shared by this geometry and other.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
double distanceToVertex(int vertex) const
Returns the distance along this geometry from its first vertex to the specified vertex.
double convertAreaMeasurement(double area, QgsUnitTypes::AreaUnit toUnits) const
Takes an area measurement calculated by this QgsDistanceArea object and converts it to a different ar...
QgsStaticExpressionFunction(const QString &fnname, int params, FcnEval fcn, const QString &group, const QString &helpText=QString(), bool usesGeometry=false, const QSet< QString > &referencedColumns=QSet< QString >(), bool lazyEval=false, const QStringList &aliases=QStringList(), bool handlesNull=false)
Static function for evaluation against a QgsExpressionContext, using an unnamed list of parameter val...
QgsGeometry minimalEnclosingCircle(QgsPointXY ¢er, double &radius, unsigned int segments=36) const
Returns the minimal enclosing circle for the geometry.
QgsGeometry nearestPoint(const QgsGeometry &other) const
Returns the nearest point on this geometry to another geometry.
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
void clear() override
Clears the geometry, ie reset it to a null geometry.
QList< QgsExpressionFunction::Parameter > ParameterList
List of parameters, used for function definition.
QgsMapLayer::LayerType type() const
Returns the type of the layer.
QString delimiter
Delimiter to use for joining values with the StringConcatenate aggregate.
QString name() const
The name of the column.
static QString soundex(const QString &string)
Returns the Soundex representation of a string.
QVariant variable(const QString &name) const
Fetches a matching variable from the context.
QList< QgsGradientStop > QgsGradientStopsList
List of gradient stops.
QSet< QString > referencedVariables() const
Returns a list of all variables which are used in this expression.
static QgsStyle * defaultStyle()
Returns default application-wide style.
virtual QgsRectangle extent() const
Returns the extent of the layer.
void setEvalErrorString(const QString &str)
Sets evaluation error (used internally by evaluation functions)
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
static QString encodeColor(const QColor &color)
void setVariable(const QString &name, const QVariant &value, bool isStatic=false)
Convenience method for setting a variable in the context scope by name name and value.
QgsGeometry poleOfInaccessibility(double precision, double *distanceToBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QVariant(* FcnEval)(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)
Function definition for evaluation against an expression context, using a list of values as parameter...
QgsGeometry mergeLines() const
Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line ...
#define ENSURE_NO_EVAL_ERROR
QgsUnitTypes::AreaUnit areaUnits() const
Returns the desired areal units for calculations involving geomCalculator(), e.g., "$area".
double stdDev
The standard deviation of the cell values.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets feature ID that should be fetched.
void addInteriorRing(QgsCurve *ring) override
Adds an interior ring to the geometry (takes ownership)
int numInteriorRings() const
QgsRasterDataProvider * dataProvider() override
Returns the layer's data provider.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
The RasterBandStats struct is a container for statistics about a single raster band.
QgsDistanceArea * geomCalculator()
Returns calculator used for distance and area calculations (used by $length, $area and $perimeter fun...
double mean
The mean cell value for the band. NO_DATA values are excluded.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
QgsFields fields() const override
Returns the list of fields of this layer.
void addVertex(const QgsPoint &pt)
Adds a new vertex to the end of the line string.
virtual QSet< QString > referencedColumns() const =0
Abstract virtual method which returns a list of columns required to evaluate this node...
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer for a (multi)linestring geometry, where the width at each node is ...
Utility class for identifying a unique vertex within a geometry.
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a variable width buffer ("tapered buffer") for a (multi)curve geometry.
virtual QSet< QString > referencedVariables() const =0
Returns a set of all variables which are used in this expression.
virtual bool handlesNull() const
Returns true if the function handles NULL values in arguments by itself, and the default NULL value h...
static Aggregate stringToAggregate(const QString &string, bool *ok=nullptr)
Converts a string to a aggregate type.
int ringCount(int part=0) const override
Returns the number of rings of which this geometry is built.
QList< QgsRelation > relationsByName(const QString &name) const
Returns a list of relations with matching names.
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
Minimum length of string (string fields only)
const QgsExpressionFunction::ParameterList & parameters() const
Returns the list of named parameters for the function, if set.
QgsGeometry convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry. ...
static QString geometryDisplayString(GeometryType type)
Returns a display string for a geometry type.
double width() const
Returns the width of the rectangle.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
QgsGeometryCollection * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership...
QVariant fcnRampColor(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction *)
QgsGeometry extendLine(double startDistance, double endDistance) const
Extends a (multi)line geometry by extrapolating out the start or end of the line by a specified dista...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Regular Polygon geometry type.
The simplification gives each point in a line an importance weighting, so that least important points...
T qgsgeometry_cast(const QgsAbstractGeometry *geom)
QgsGeometry offsetCurve(double distance, int segments, JoinStyle joinStyle, double miterLimit) const
Returns an offset line at a given distance and side from an input line.
QString description() const
Returns the descriptive name of the CRS, e.g., "WGS 84" or "GDA 94 / Vicgrid94".
An expression node which takes it value from a feature's field.
QgsGeometry smooth(unsigned int iterations=1, double offset=0.25, double minimumDistance=-1.0, double maxAngle=180.0) const
Smooths a geometry by rounding off corners using the Chaikin algorithm.
QgsCoordinateReferenceSystem crs() const
Returns the layer's spatial reference system.
bool crosses(const QgsGeometry &geometry) const
Test for if geometry crosses another (uses GEOS)
static const QString ALL_ATTRIBUTES
A special attribute that if set matches all attributes.
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example...
ConstructionOption
A regular polygon can be constructed inscribed in a circle or circumscribed about a circle...
virtual bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const
Will be called during prepare to determine if the function is static.
QgsVectorLayer referencedLayer
Abstract base class for all nodes that can appear in an expression.
Abstract base class for curved geometry type.
Create a multipart geometry from aggregated geometries.
double measureLength(const QgsGeometry &geometry) const
Measures the length of a geometry.
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry.
bool touches(const QgsGeometry &geometry) const
Test for if geometry touch another (uses GEOS)
Single scope for storing variables and functions for use within a QgsExpressionContext.
Abstract base class for all geometries.
An expression node for expression functions.
double minimumScale() const
Returns the minimum map scale (i.e.
QgsGeometry geometry() const
Returns the geometry associated with this feature.
QgsRelationManager relationManager
static int levenshteinDistance(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the Levenshtein edit distance between two strings.
double maximumScale() const
Returns the maximum map scale (i.e.
static QVector< QgsLineString * > extractLineStrings(const QgsAbstractGeometry *geom)
Returns list of linestrings extracted from the passed geometry.
bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
This will be called during the prepare step() of an expression if it is not static.
Implementation of GeometrySimplifier using the "MapToPixel" algorithm.
static const QList< QgsExpressionFunction * > & Functions()
QgsPoint project(double distance, double azimuth, double inclination=90.0) const
Returns a new point which correspond to this point projected by a specified distance with specified a...
QList< QgsMapLayer * > mapLayersByName(const QString &layerName) const
Retrieve a list of matching registered layers by layer name.
QVariant eval(QgsExpression *parent, const QgsExpressionContext *context)
Evaluate this node with the given context and parent.
Point geometry type, with support for z-dimension and m-values.
virtual bool usesGeometry(const QgsExpressionNodeFunction *node) const
Does this function use a geometry object.
QgsWkbTypes::GeometryType type() const
Returns type of the geometry as a QgsWkbTypes::GeometryType.
Majority of values (numeric fields only)
bool lazyEval() const
True if this function should use lazy evaluation.
QString group() const
Returns the first group which the function belongs to.
double length() const
Returns the length of geometry using GEOS.
double measurePerimeter(const QgsGeometry &geometry) const
Measures the perimeter of a polygon geometry.
QgsGeometry extrude(double x, double y)
Returns an extruded version of this geometry.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
double weeks() const
Returns the interval duration in weeks.
int numGeometries() const
Returns the number of geometries within the collection.
QgsExpressionFunction(const QString &fnname, int params, const QString &group, const QString &helpText=QString(), bool lazyEval=false, bool handlesNull=false, bool isContextual=false)
Constructor for function which uses unnamed parameters.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override
Query the layer for features specified in request.
virtual bool isClosed() const
Returns true if the curve is closed.
uint qHash(const QVariant &variant)
Hash for QVariant.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsUnitTypes::DistanceUnit distanceUnits() const
Returns the desired distance units for calculations involving geomCalculator(), e.g., "$length" and "$perimeter".
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
Number of distinct values.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
QString name() const
The name of the function.
double interpolateAngle(double distance) const
Returns the angle parallel to the linestring or polygon boundary at the specified distance along the ...
A representation of the interval between two datetime values.
The OrderByClause class represents an order by clause for a QgsFeatureRequest.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
virtual QStringList aliases() const
Returns a list of possible aliases for the function.
QVector< QgsPoint > QgsPointSequence
double days() const
Returns the interval duration in days.
virtual QgsRasterBandStats bandStatistics(int bandNo, int stats=QgsRasterBandStats::All, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
Returns the band statistics.
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
#define Q_NOWARN_DEPRECATED_POP
virtual QgsCoordinateSequence coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations...
int partCount() const override
Returns count of parts contained in the geometry.
QVector< QgsPointSequence > QgsRingSequence
A abstract base class for defining QgsExpression functions.
A list of expression nodes.
QVariant aggregate(QgsAggregateCalculator::Aggregate aggregate, const QString &fieldOrExpression, const QgsAggregateCalculator::AggregateParameters ¶meters=QgsAggregateCalculator::AggregateParameters(), QgsExpressionContext *context=nullptr, bool *ok=nullptr) const
Calculates an aggregated value from the layer's features.
static void registerContextFunctions()
Registers all known core functions provided by QgsExpressionContextScope objects. ...
Maximum length of string (string fields only)
QgsGeometry simplify(double tolerance) const
Returns a simplified version of this geometry using a specified tolerance value.
static QgsGeometry geometryFromGML(const QString &xmlString)
Static method that creates geometry from GML.
static bool allParamsStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context)
This will return true if all the params for the provided function node are static within the constrai...
QList< QgsExpressionNode * > list()
Gets a list of all the nodes.
void setExteriorRing(QgsCurve *ring) override
Sets the exterior ring of the polygon.
QString getRelatedFeaturesFilter(const QgsFeature &feature) const
Returns a filter expression which returns all the features on the referencing (child) layer which hav...
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
QString filter
Optional filter for calculating aggregate over a subset of features, or an empty string to use all fe...
double years() const
Returns the interval duration in years (based on an average year length)
double hausdorffDistance(const QgsGeometry &geom) const
Returns the Hausdorff distance between this geometry and geom.
QgsPointXY asPoint() const
Returns contents of the geometry as a point if wkbType is WKBPoint, otherwise returns [0...
An expression node for literal values.
Mean of values (numeric fields only)
const QString helpText() const
The help text for the function.
c++ helper class for defining QgsExpression functions.
const QgsExpressionNode * rootNode() const
Returns root node of the expression. Root node is null is parsing has failed.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
void setIsStaticFunction(const std::function< bool(const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext *) > &isStatic)
Set a function that will be called in the prepare step to determine if the function is static or not...
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
double minutes() const
Returns the interval duration in minutes.
Line string geometry type, with support for z-dimension and m-values.
static QgsGeometry createWedgeBuffer(const QgsPoint ¢er, double azimuth, double angularWidth, double outerRadius, double innerRadius=0)
Creates a wedge shaped buffer from a center point.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
#define ENSURE_GEOM_TYPE(f, g, geomtype)
static QgsProject * instance()
Returns the QgsProject singleton instance.
Concatenate values with a joining string (string fields only). Specify the delimiter using setDelimit...
bool usesGeometry(const QgsExpressionNodeFunction *node) const override
Does this function use a geometry object.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QgsGeometry shortestLine(const QgsGeometry &other) const
Returns the shortest line joining this geometry to another geometry.
This class represents a coordinate reference system (CRS).
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
double hours() const
Returns the interval duration in hours.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
double range
The range is the distance between min & max.
bool isStatic(const QString &name) const
Tests whether the variable with the specified name is static and can be cached.
QgsFeatureRequest & setLimit(long limit)
Set the maximum number of features to request.
bool operator==(const QgsExpressionFunction &other) const
void setIsStatic(bool isStatic)
Tag this function as either static or not static.
QgsGeometry singleSidedBuffer(double distance, int segments, BufferSide side, JoinStyle joinStyle=JoinStyleRound, double miterLimit=2.0) const
Returns a single sided buffer for a (multi)line geometry.
static QString quotedString(QString text)
Returns a quoted version of a string (in single quotes)
double xMinimum() const
Returns the x minimum value (left side of rectangle).
double minimumValue
The minimum cell value in the raster band.
static QString helpText(QString name)
Returns the help text for a specified function.
OperationResult translate(double dx, double dy, double dz=0.0, double dm=0.0)
Translates this geometry by dx, dy, dz and dm.
QgsFeature feature() const
Convenience function for retrieving the feature for the context, if set.
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QgsGeometry orientedMinimumBoundingBox(double &area, double &angle, double &width, double &height) const
Returns the oriented minimum bounding box for the geometry, which is the smallest (by area) rotated r...
virtual bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const =0
Returns true if this node can be evaluated for a static value.
QSet< QString > referencedColumns(const QgsExpressionNodeFunction *node) const override
Returns a set of field names which are required for this function.
Represents a single parameter passed to a function.
Custom exception class for Coordinate Reference System related exceptions.
double area() const
Returns the area of the geometry using GEOS.
int count() const
Returns the number of nodes in the list.
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
The geometries can be simplified using the current map2pixel context state.
bool nextFeature(QgsFeature &f)
QStringList aliases() const override
Returns a list of possible aliases for the function.
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required...
Minority of values (numeric fields only)
bool vertexIdFromVertexNr(int number, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
JoinStyle
Join styles for buffers.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
const QgsCurve * exteriorRing() const
bool contains(const QgsPointXY *p) const
Tests for containment of a point (uses GEOS)
Q_INVOKABLE QgsRelation relation(const QString &id) const
Gets access to a relation by its id.
QgsGeometry symDifference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
Represents a vector layer which manages a vector based data sets.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
virtual bool isDeprecated() const
Returns true if the function is deprecated and should not be presented as a valid option to users in ...
Range of values (max - min) (numeric and datetime fields only)
bool isEmpty() const override
Returns true if the geometry is empty.
virtual bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const
This will be called during the prepare step() of an expression if it is not static.
double lineLocatePoint(const QgsGeometry &point) const
Returns a distance representing the location along this linestring of the closest point on this lines...
bool disjoint(const QgsGeometry &geometry) const
Tests for if geometry is disjoint of another (uses GEOS)
double measureArea(const QgsGeometry &geometry) const
Measures the area of a geometry.
QString authid() const
Returns the authority identifier for the CRS.
Sample standard deviation of values (numeric fields only)
Aggregate
Available aggregates to calculate.
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
static int hammingDistance(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the Hamming distance between two strings.
QVariant value() const
The value of the literal.
static QColor decodeColor(const QString &str)
Represents a list of OrderByClauses, with the most important first and the least important last...
virtual int partCount() const =0
Returns count of parts contained in the geometry.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
double height() const
Returns the height of the rectangle.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
#define FEAT_FROM_CONTEXT(c, f)
A bundle of parameters controlling aggregate calculation.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QgsGeometry difference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...