68 QVariantList argValues;
72 const QList< QgsExpressionNode * > argList = args->
list();
79 v = QVariant::fromValue( n );
83 v = n->eval( parent, context );
85 bool defaultParamIsNull = mParameterList.count() > arg && mParameterList.at( arg ).optional() && !mParameterList.at( arg ).defaultValue().isValid();
86 if ( QgsExpressionUtils::isNull( v ) && !defaultParamIsNull && !
handlesNull() )
89 argValues.append( v );
94 return func( argValues, context, parent, node );
105 return QStringList();
132 return mGroups.isEmpty() ? false : mGroups.contains( QStringLiteral(
"deprecated" ) );
137 return ( QString::compare( mName, other.mName, Qt::CaseInsensitive ) == 0 );
149 const QString &
group,
159 , mUsesGeometry(
false )
173 if ( mUsesGeometryFunc )
174 return mUsesGeometryFunc( node );
176 return mUsesGeometry;
181 if ( mReferencedColumnsFunc )
182 return mReferencedColumnsFunc( node );
184 return mReferencedColumns;
190 return mIsStaticFunc( node, parent, context );
198 return mPrepareFunc( node, parent, context );
210 mIsStaticFunc =
nullptr;
216 mPrepareFunc = prepareFunc;
221 if ( node && node->
args() )
223 const QList< QgsExpressionNode * > argList = node->
args()->
list();
226 if ( !argNode->isStatic( parent, context ) )
236 double start = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
237 double stop = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
238 double step = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
240 if ( step == 0.0 || ( step > 0.0 && start > stop ) || ( step < 0.0 && start < stop ) )
247 double current = start + step;
248 while ( ( ( step > 0.0 && current <= stop ) || ( step < 0.0 && current >= stop ) ) && length <= 1000000 )
263 QString
name = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
272 QString expString = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
274 return expression.evaluate( context );
279 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
280 return QVariant( std::sqrt( x ) );
285 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
286 return QVariant( std::fabs( val ) );
291 double deg = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
292 return ( deg * M_PI ) / 180;
296 double rad = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
297 return ( 180 * rad ) / M_PI;
301 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
302 return QVariant( std::sin( x ) );
306 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
307 return QVariant( std::cos( x ) );
311 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
312 return QVariant( std::tan( x ) );
316 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
317 return QVariant( std::asin( x ) );
321 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
322 return QVariant( std::acos( x ) );
326 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
327 return QVariant( std::atan( x ) );
331 double y = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
332 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
333 return QVariant( std::atan2( y, x ) );
337 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
338 return QVariant( std::exp( x ) );
342 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
345 return QVariant( std::log( x ) );
349 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
352 return QVariant( log10( x ) );
356 double b = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
357 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
358 if ( x <= 0 || b <= 0 )
360 return QVariant( std::log( x ) / std::log( b ) );
364 double min = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
365 double max = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
370 double f =
static_cast< double >( qrand() ) / RAND_MAX;
371 return QVariant( min + f * ( max - min ) );
375 qlonglong min = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
376 qlonglong max = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
381 return QVariant( min + ( qrand() % static_cast< qlonglong >( max - min + 1 ) ) );
386 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
387 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
388 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
389 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
390 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
392 if ( domainMin >= domainMax )
394 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
399 if ( val >= domainMax )
403 else if ( val <= domainMin )
409 double m = ( rangeMax - rangeMin ) / ( domainMax - domainMin );
410 double c = rangeMin - ( domainMin * m );
413 return QVariant( m * val + c );
418 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
419 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
420 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
421 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
422 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
423 double exponent = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
425 if ( domainMin >= domainMax )
427 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
437 if ( val >= domainMax )
441 else if ( val <= domainMin )
447 return QVariant( ( ( rangeMax - rangeMin ) / std::pow( domainMax - domainMin, exponent ) ) * std::pow( val - domainMin, exponent ) + rangeMin );
452 QVariant result( QVariant::Double );
453 double maxVal = std::numeric_limits<double>::quiet_NaN();
454 for (
const QVariant &val : values )
456 double testVal = val.isNull() ? std::numeric_limits<double>::quiet_NaN() : QgsExpressionUtils::getDoubleValue( val, parent );
457 if ( std::isnan( maxVal ) )
461 else if ( !std::isnan( testVal ) )
463 maxVal = std::max( maxVal, testVal );
467 if ( !std::isnan( maxVal ) )
469 result = QVariant( maxVal );
476 QVariant result( QVariant::Double );
477 double minVal = std::numeric_limits<double>::quiet_NaN();
478 for (
const QVariant &val : values )
480 double testVal = val.isNull() ? std::numeric_limits<double>::quiet_NaN() : QgsExpressionUtils::getDoubleValue( val, parent );
481 if ( std::isnan( minVal ) )
485 else if ( !std::isnan( testVal ) )
487 minVal = std::min( minVal, testVal );
491 if ( !std::isnan( minVal ) )
493 result = QVariant( minVal );
505 QVariant value = node->
eval( parent, context );
507 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( value, parent );
510 parent->
setEvalErrorString( QObject::tr(
"Cannot find layer with name or ID '%1'" ).arg( value.toString() ) );
515 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
517 value = node->
eval( parent, context );
523 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
528 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
530 QString subExpression = node->
dump();
534 if ( values.count() > 3 )
536 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
539 if ( !nl || nl->
value().isValid() )
544 if ( values.count() > 4 )
546 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
548 value = node->
eval( parent, context );
564 cacheKey = QStringLiteral(
"aggfcn:%1:%2:%3:%4:%5%6" ).arg( vl->
id(), QString::number( aggregate ), subExpression, parameters.
filter,
569 cacheKey = QStringLiteral(
"aggfcn:%1:%2:%3:%4" ).arg( vl->
id(), QString::number( aggregate ), subExpression, parameters.
filter );
579 result = vl->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
585 result = vl->
aggregate( aggregate, subExpression, parameters,
nullptr, &ok );
589 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
600 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
605 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
608 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
617 QVariant value = node->
eval( parent, context );
619 QString relationId = value.toString();
626 if ( relations.isEmpty() || relations.at( 0 ).referencedLayer() != vl )
628 parent->
setEvalErrorString( QObject::tr(
"Cannot find relation with id '%1'" ).arg( relationId ) );
633 relation = relations.at( 0 );
640 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
642 value = node->
eval( parent, context );
648 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
653 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
655 QString subExpression = node->
dump();
659 if ( values.count() > 3 )
661 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
663 value = node->
eval( parent, context );
671 QString cacheKey = QStringLiteral(
"relagg:%1:%2:%3:%4" ).arg( vl->
id(),
672 QString::number( static_cast< int >( aggregate ) ),
683 result = childLayer->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
687 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
702 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
707 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
710 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
719 QString subExpression = node->
dump();
723 if ( values.count() > 1 )
725 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
728 if ( !nl || nl->
value().isValid() )
729 groupBy = node->
dump();
733 if ( values.count() > 2 )
735 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
738 if ( !nl || nl->
value().isValid() )
745 if ( !groupBy.isEmpty() )
748 QVariant groupByValue = groupByExp.
evaluate( context );
749 QString groupByClause = QStringLiteral(
"%1 %2 %3" ).arg( groupBy,
750 groupByValue.isNull() ? QStringLiteral(
"is" ) : QStringLiteral(
"=" ),
752 if ( !parameters.
filter.isEmpty() )
753 parameters.
filter = QStringLiteral(
"(%1) AND (%2)" ).arg( parameters.
filter, groupByClause );
755 parameters.
filter = groupByClause;
758 QString cacheKey = QStringLiteral(
"agg:%1:%2:%3:%4" ).arg( vl->
id(),
759 QString::number( static_cast< int >( aggregate ) ),
769 result = vl->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
773 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
879 if ( values.count() > 3 )
883 QVariant value = node->
eval( parent, context );
901 QVariant
scale = context->
variable( QStringLiteral(
"map_scale" ) );
903 if ( !scale.isValid() || scale.isNull() )
906 const double v = scale.toDouble( &ok );
914 double minValue = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
915 double testValue = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
916 double maxValue = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
919 if ( testValue <= minValue )
921 return QVariant( minValue );
923 else if ( testValue >= maxValue )
925 return QVariant( maxValue );
929 return QVariant( testValue );
935 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
936 return QVariant( std::floor( x ) );
941 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
942 return QVariant( std::ceil( x ) );
947 return QVariant( QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) );
951 return QVariant( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) );
955 return QVariant( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ) );
960 return QVariant( QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent ) );
965 for (
const QVariant &value : values )
967 if ( value.isNull() )
976 const QVariant val1 = values.at( 0 );
977 const QVariant val2 = values.at( 1 );
987 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
988 return QVariant( str.toLower() );
992 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
993 return QVariant( str.toUpper() );
997 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
998 QStringList elems = str.split(
' ' );
999 for (
int i = 0; i < elems.size(); i++ )
1001 if ( elems[i].size() > 1 )
1002 elems[i] = elems[i].at( 0 ).toUpper() + elems[i].mid( 1 ).toLower();
1004 return QVariant( elems.join( QStringLiteral(
" " ) ) );
1009 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1010 return QVariant( str.trimmed() );
1015 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1016 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1022 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1023 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1029 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1030 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1037 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1043 QChar character = QChar( QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent ) );
1044 return QVariant( QString( character ) );
1049 if ( values.length() == 2 || values.length() == 3 )
1051 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1052 qlonglong wrap = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1054 QString customdelimiter = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
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() ) );
1288 QgsRasterLayer *layer = QgsExpressionUtils::getRasterLayer( values.at( 0 ), parent );
1291 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster layer." ) );
1295 int bandNb = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1296 if ( bandNb < 1 || bandNb > layer->
bandCount() )
1298 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster band number." ) );
1302 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
1305 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid point geometry." ) );
1313 if ( multiPoint.count() == 1 )
1315 point = multiPoint[0];
1325 return std::isnan( value ) ? QVariant() : value;
1337 QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1338 QString attr = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1348 if ( values.isEmpty() )
1351 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1353 else if ( values.size() == 1 )
1355 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1356 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1358 else if ( values.size() == 2 )
1360 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1361 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
1365 parent->
setEvalErrorString( QObject::tr(
"Function `is_selected` requires no more than two parameters. %1 given." ).arg( values.length() ) );
1369 if ( !layer || !feature.
isValid() )
1371 return QVariant( QVariant::Bool );
1381 if ( values.isEmpty() )
1382 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1383 else if ( values.count() == 1 )
1384 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1387 parent->
setEvalErrorString( QObject::tr(
"Function `num_selected` requires no more than one parameter. %1 given." ).arg( values.length() ) );
1393 return QVariant( QVariant::LongLong );
1401 static QMap<QString, qlonglong> counterCache;
1402 QVariant functionResult;
1404 std::function<void()> fetchAndIncrementFunc = [ =, &functionResult ]()
1407 const QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1412 database = decodedUri.value( QStringLiteral(
"path" ) ).toString();
1413 if ( database.isEmpty() )
1415 parent->
setEvalErrorString( QObject::tr(
"Could not extract file path from layer `%1`." ).arg( layer->
name() ) );
1420 database = values.at( 0 ).toString();
1423 const QString table = values.at( 1 ).toString();
1424 const QString idColumn = values.at( 2 ).toString();
1425 const QString filterAttribute = values.at( 3 ).toString();
1426 const QVariant filterValue = values.at( 4 ).toString();
1427 const QVariantMap defaultValues = values.at( 5 ).toMap();
1433 if ( sqliteDb.
open_v2( database, SQLITE_OPEN_READWRITE,
nullptr ) != SQLITE_OK )
1436 functionResult = QVariant();
1440 QString errorMessage;
1441 QString currentValSql;
1444 bool cachedMode =
false;
1445 bool valueRetrieved =
false;
1447 QString cacheString = QStringLiteral(
"%1:%2:%3:%4:%5" ).arg( database, table, idColumn, filterAttribute, filterValue.toString() );
1454 auto cachedCounter = counterCache.find( cacheString );
1456 if ( cachedCounter != counterCache.end() )
1458 qlonglong &cachedValue = cachedCounter.value();
1459 nextId = cachedValue;
1461 cachedValue = nextId;
1462 valueRetrieved =
true;
1467 if ( !cachedMode || !valueRetrieved )
1469 int result = SQLITE_ERROR;
1472 if ( !filterAttribute.isNull() )
1477 sqliteStatement = sqliteDb.
prepare( currentValSql, result );
1479 if ( result == SQLITE_OK )
1482 if ( sqliteStatement.
step() == SQLITE_ROW )
1488 if ( cachedMode && result == SQLITE_OK )
1490 counterCache.insert( cacheString, nextId );
1494 counterCache.remove( cacheString );
1497 valueRetrieved =
true;
1501 if ( valueRetrieved )
1510 if ( !filterAttribute.isNull() )
1516 for ( QVariantMap::const_iterator iter = defaultValues.constBegin(); iter != defaultValues.constEnd(); ++iter )
1519 vals << iter.value().toString();
1522 upsertSql += QLatin1String(
" (" ) + cols.join(
',' ) +
')';
1523 upsertSql += QLatin1String(
" VALUES " );
1524 upsertSql +=
'(' + vals.join(
',' ) +
')';
1526 int result = SQLITE_ERROR;
1530 if ( transaction->
executeSql( upsertSql, errorMessage ) )
1537 result = sqliteDb.
exec( upsertSql, errorMessage );
1539 if ( result == SQLITE_OK )
1541 functionResult = QVariant( nextId );
1546 parent->
setEvalErrorString( QStringLiteral(
"Could not increment value: SQLite error: \"%1\" (%2)." ).arg( errorMessage, QString::number( result ) ) );
1547 functionResult = QVariant();
1552 functionResult = QVariant();
1557 return functionResult;
1563 for (
const QVariant &value : values )
1565 concat += QgsExpressionUtils::getStringValue( value, parent );
1572 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1573 return string.indexOf( QgsExpressionUtils::getStringValue( values.at( 1 ), parent ) ) + 1;
1578 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1579 qlonglong pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1580 return string.right( pos );
1585 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1586 qlonglong pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1587 return string.left( pos );
1592 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1593 qlonglong length = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1594 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1595 return string.leftJustified( length, fill.at( 0 ), true );
1600 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1601 qlonglong length = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1602 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1603 return string.rightJustified( length, fill.at( 0 ), true );
1608 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1609 for (
int n = 1; n < values.length(); n++ )
1611 string =
string.arg( QgsExpressionUtils::getStringValue( values.at( n ), parent ) );
1619 return QVariant( QDateTime::currentDateTime() );
1624 return QVariant( QgsExpressionUtils::getDateValue( values.at( 0 ), parent ) );
1629 return QVariant( QgsExpressionUtils::getTimeValue( values.at( 0 ), parent ) );
1634 return QVariant::fromValue( QgsExpressionUtils::getInterval( values.at( 0 ), parent ) );
1643 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1644 QString axis = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1645 int precision = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
1647 QString formatString;
1648 if ( values.count() > 3 )
1649 formatString = QgsExpressionUtils::getStringValue( values.at( 3 ), parent );
1651 QgsCoordinateFormatter::FormatFlags flags =
nullptr;
1652 if ( formatString.compare( QLatin1String(
"suffix" ), Qt::CaseInsensitive ) == 0 )
1656 else if ( formatString.compare( QLatin1String(
"aligned" ), Qt::CaseInsensitive ) == 0 )
1660 else if ( ! formatString.isEmpty() )
1662 parent->
setEvalErrorString( QObject::tr(
"Invalid formatting parameter: '%1'. It must be empty, or 'suffix' or 'aligned'." ).arg( formatString ) );
1666 if ( axis.compare( QLatin1String(
"x" ), Qt::CaseInsensitive ) == 0 )
1670 else if ( axis.compare( QLatin1String(
"y" ), Qt::CaseInsensitive ) == 0 )
1676 parent->
setEvalErrorString( QObject::tr(
"Invalid axis name: '%1'. It must be either 'x' or 'y'." ).arg( axis ) );
1684 return floatToDegreeFormat( format, values, context, parent, node );
1690 return floatToDegreeFormat( format, values, context, parent, node );
1695 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1696 QDateTime d2 = QgsExpressionUtils::getDateTimeValue( values.at( 1 ), parent );
1697 qint64 seconds = d2.secsTo( d1 );
1698 return QVariant::fromValue(
QgsInterval( seconds ) );
1703 if ( !values.at( 0 ).canConvert<QDate>() )
1706 QDate date = QgsExpressionUtils::getDateValue( values.at( 0 ), parent );
1707 if ( !date.isValid() )
1712 return date.dayOfWeek() % 7;
1717 QVariant value = values.at( 0 );
1718 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1721 return QVariant( inter.
days() );
1725 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1726 return QVariant( d1.date().day() );
1732 QVariant value = values.at( 0 );
1733 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1736 return QVariant( inter.
years() );
1740 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1741 return QVariant( d1.date().year() );
1747 QVariant value = values.at( 0 );
1748 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1751 return QVariant( inter.
months() );
1755 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1756 return QVariant( d1.date().month() );
1762 QVariant value = values.at( 0 );
1763 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1766 return QVariant( inter.
weeks() );
1770 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1771 return QVariant( d1.date().weekNumber() );
1777 QVariant value = values.at( 0 );
1778 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1781 return QVariant( inter.
hours() );
1785 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1786 return QVariant( t1.hour() );
1792 QVariant value = values.at( 0 );
1793 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1796 return QVariant( inter.
minutes() );
1800 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1801 return QVariant( t1.minute() );
1807 QVariant value = values.at( 0 );
1808 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1811 return QVariant( inter.
seconds() );
1815 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1816 return QVariant( t1.second() );
1822 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1825 return QVariant( dt.toMSecsSinceEpoch() );
1833 #define ENSURE_GEOM_TYPE(f, g, geomtype) \ 1834 if ( !(f).hasGeometry() ) \ 1835 return QVariant(); \ 1836 QgsGeometry g = (f).geometry(); \ 1837 if ( (g).type() != (geomtype) ) \ 1844 if ( g.isMultipart() )
1846 return g.asMultiPoint().at( 0 ).x();
1850 return g.asPoint().x();
1858 if ( g.isMultipart() )
1860 return g.asMultiPoint().at( 0 ).y();
1864 return g.asPoint().y();
1870 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1882 QVariant result( centroid.
asPoint().
x() );
1888 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1900 QVariant result( centroid.
asPoint().
y() );
1906 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1921 if ( collection->numGeometries() == 1 )
1923 if (
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( collection->geometryN( 0 ) ) )
1934 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1949 if ( collection->numGeometries() == 1 )
1951 if (
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( collection->geometryN( 0 ) ) )
1962 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1968 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
1983 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2000 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2017 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2022 bool ignoreClosing =
false;
2023 if ( values.length() > 1 )
2025 ignoreClosing = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
2035 bool skipLast =
false;
2036 if ( ignoreClosing && ring.count() > 2 && ring.first() == ring.last() )
2041 for (
int i = 0; i < ( skipLast ? ring.count() - 1 : ring.count() ); ++ i )
2043 mp->addGeometry( ring.at( i ).clone() );
2053 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2064 for (
int i = 0; i < line->numPoints() - 1; ++i )
2068 << line->pointN( i )
2069 << line->pointN( i + 1 ) );
2070 ml->addGeometry( segment );
2080 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2090 if ( collection->numGeometries() == 1 )
2097 if ( !curvePolygon )
2101 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
2107 QVariant result = curve ? QVariant::fromValue(
QgsGeometry( curve ) ) : QVariant();
2113 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2123 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
2129 QVariant result = part ? QVariant::fromValue(
QgsGeometry( part ) ) : QVariant();
2135 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2144 return QVariant::fromValue(
QgsGeometry( boundary ) );
2149 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2158 return QVariant::fromValue( merged );
2163 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2168 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2171 if ( simplified.isNull() )
2179 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2184 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2189 if ( simplified.
isNull() )
2197 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2202 int iterations = std::min( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), 10 );
2203 double offset = qBound( 0.0, QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ), 0.5 );
2204 double minLength = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2205 double maxAngle = qBound( 0.0, QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent ), 180.0 );
2216 if ( values.count() < 2 || values.count() > 4 )
2218 parent->
setEvalErrorString( QObject::tr(
"Function make_point requires 2-4 arguments" ) );
2222 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2223 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2224 double z = values.count() >= 3 ? QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) : 0.0;
2225 double m = values.count() >= 4 ? QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) : 0.0;
2226 switch ( values.count() )
2240 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2241 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2242 double m = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2248 if ( values.count() < 2 )
2254 lineString->
clear();
2256 for (
const QVariant &value : values )
2258 QgsGeometry geom = QgsExpressionUtils::getGeometry( value, parent );
2272 return QVariant::fromValue(
QgsGeometry( lineString ) );
2277 if ( values.count() < 1 )
2279 parent->
setEvalErrorString( QObject::tr(
"Function make_polygon requires an argument" ) );
2283 QgsGeometry outerRing = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2287 std::unique_ptr< QgsPolygon > polygon = qgis::make_unique< QgsPolygon >();
2294 if ( collection->numGeometries() == 1 )
2301 if ( !exteriorRing )
2304 polygon->setExteriorRing( exteriorRing->segmentize() );
2307 for (
int i = 1; i < values.count(); ++i )
2309 QgsGeometry ringGeom = QgsExpressionUtils::getGeometry( values.at( i ), parent );
2321 if ( collection->numGeometries() == 1 )
2331 polygon->addInteriorRing( ring->
segmentize() );
2334 return QVariant::fromValue(
QgsGeometry( std::move( polygon ) ) );
2339 std::unique_ptr<QgsTriangle> tr(
new QgsTriangle() );
2340 std::unique_ptr<QgsLineString> lineString(
new QgsLineString() );
2341 lineString->clear();
2343 for (
const QVariant &value : values )
2345 QgsGeometry geom = QgsExpressionUtils::getGeometry( value, parent );
2357 if ( collection->numGeometries() == 1 )
2367 lineString->addVertex( *point );
2370 tr->setExteriorRing( lineString.release() );
2372 return QVariant::fromValue(
QgsGeometry( tr.release() ) );
2377 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2384 double radius = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2385 double segment = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
2397 if ( collection->numGeometries() == 1 )
2412 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2419 double majorAxis = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2420 double minorAxis = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2421 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2422 double segment = QgsExpressionUtils::getIntValue( values.at( 4 ), parent );
2433 if ( collection->numGeometries() == 1 )
2442 QgsEllipse elp( *point, majorAxis, minorAxis, azimuth );
2449 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2456 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2463 unsigned int nbEdges =
static_cast<unsigned int>( QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) );
2466 parent->
setEvalErrorString( QObject::tr(
"Number of edges/sides must be greater than 2" ) );
2473 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (inscribed) or 1 (circumscribed)" ) );
2482 if ( collection->numGeometries() == 1 )
2496 if ( collection->numGeometries() == 1 )
2513 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2519 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2529 return QVariant::fromValue(
QgsGeometry( square.toPolygon() ) );
2534 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2540 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2546 QgsGeometry pt3 = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
2555 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (distance) or 1 (projected)" ) );
2562 return QVariant::fromValue(
QgsGeometry( rect.toPolygon() ) );
2568 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
2577 if ( idx < 0 || idx >= g.constGet()->nCoordinates() )
2584 return QVariant( QPointF( p.
x(), p.
y() ) );
2589 QVariant v = pointAt( values, f, parent );
2590 if ( v.type() == QVariant::PointF )
2591 return QVariant( v.toPointF().x() );
2597 QVariant v = pointAt( values, f, parent );
2598 if ( v.type() == QVariant::PointF )
2599 return QVariant( v.toPointF().y() );
2608 return QVariant::fromValue( geom );
2610 return QVariant( QVariant::UserType );
2614 QString wkt = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2616 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2621 QString gml = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2623 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2636 return QVariant( area );
2640 return QVariant( f.geometry().area() );
2646 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2651 return QVariant( geom.
area() );
2663 return QVariant( len );
2667 return QVariant( f.geometry().length() );
2680 return QVariant( len );
2684 return f.geometry().isNull() ? QVariant( 0 ) : QVariant( f.geometry().constGet()->perimeter() );
2690 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2696 return QVariant( geom.
length() );
2701 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2707 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2716 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2729 for (
int i = 0; i < collection->numGeometries(); ++i )
2732 if ( !curvePolygon )
2744 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2751 return QVariant( curvePolygon->
ringCount() );
2753 bool foundPoly =
false;
2762 if ( !curvePolygon )
2773 return QVariant( ringCount );
2778 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2780 QVariant result = !geomBounds.
isNull() ? QVariant::fromValue( geomBounds ) : QVariant();
2786 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2792 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2798 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2804 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2810 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2816 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2822 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2826 std::unique_ptr< QgsAbstractGeometry > flipped( geom.
constGet()->
clone() );
2828 return QVariant::fromValue(
QgsGeometry( std::move( flipped ) ) );
2833 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2842 if ( collection->numGeometries() == 1 )
2852 return QVariant::fromValue( curve->
isClosed() );
2857 if ( values.length() < 2 || values.length() > 3 )
2860 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2861 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2863 if ( fGeom.
isNull() || sGeom.isNull() )
2868 if ( values.length() == 2 )
2871 QString result = engine->relate( sGeom.constGet() );
2872 return QVariant::fromValue( result );
2877 QString pattern = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
2878 bool result = engine->relatePattern( sGeom.constGet(), pattern );
2879 return QVariant::fromValue( result );
2885 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2886 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2887 return fGeom.
intersects( sGeom.boundingBox() ) ? TVL_True : TVL_False;
2891 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2892 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2893 return fGeom.
disjoint( sGeom ) ? TVL_True : TVL_False;
2897 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2898 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2899 return fGeom.
intersects( sGeom ) ? TVL_True : TVL_False;
2903 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2904 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2905 return fGeom.
touches( sGeom ) ? TVL_True : TVL_False;
2909 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2910 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2911 return fGeom.
crosses( sGeom ) ? TVL_True : TVL_False;
2915 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2916 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2917 return fGeom.
contains( sGeom ) ? TVL_True : TVL_False;
2921 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2922 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2923 return fGeom.
overlaps( sGeom ) ? TVL_True : TVL_False;
2927 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2928 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2929 return fGeom.
within( sGeom ) ? TVL_True : TVL_False;
2933 if ( values.length() < 2 || values.length() > 3 )
2936 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2937 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2939 if ( values.length() == 3 )
2940 seg = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
2943 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2949 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2951 return !reoriented.
isNull() ? QVariant::fromValue( reoriented ) : QVariant();
2956 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2962 if ( collection->numGeometries() == 1 )
2971 parent->
setEvalErrorString( QObject::tr(
"Function `wedge_buffer` requires a point value for the center." ) );
2975 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2976 double width = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2977 double outerRadius = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2978 double innerRadius = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
2981 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2987 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2990 parent->
setEvalErrorString( QObject::tr(
"Function `tapered_buffer` requires a line geometry." ) );
2994 double startWidth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2995 double endWidth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2996 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) );
2999 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3005 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3008 parent->
setEvalErrorString( QObject::tr(
"Function `buffer_by_m` requires a line geometry." ) );
3012 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3015 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3021 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3022 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3023 qlonglong segments = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3027 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3030 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3036 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3037 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3038 qlonglong segments = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3042 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3045 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3051 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3052 double distStart = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3053 double distEnd = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3056 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3062 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3063 double dx = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3064 double dy = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3066 return QVariant::fromValue( fGeom );
3070 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3072 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3077 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3079 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3085 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3086 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3088 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3094 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3096 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3103 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3104 unsigned int segments = 36;
3105 if ( values.length() == 2 )
3106 segments = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3108 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3114 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3116 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3122 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3123 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3125 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3131 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3143 result = reversed ? QVariant::fromValue(
QgsGeometry( reversed ) ) : QVariant();
3151 if (
const QgsCurve *curve = qgsgeometry_cast<const QgsCurve * >( collection->
geometryN( i ) ) )
3160 result = reversed ? QVariant::fromValue(
QgsGeometry( std::move( reversed ) ) ) : QVariant();
3167 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3176 if ( collection->numGeometries() == 1 )
3187 QVariant result = exterior ? QVariant::fromValue(
QgsGeometry( exterior ) ) : QVariant();
3193 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3194 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3195 return QVariant( fGeom.
distance( sGeom ) );
3200 QgsGeometry g1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3201 QgsGeometry g2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3204 if ( values.length() == 3 && values.at( 2 ).isValid() )
3206 double densify = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3207 densify = qBound( 0.0, densify, 1.0 );
3215 return res > -1 ? QVariant( res ) : QVariant();
3220 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3221 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3223 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3228 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3229 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3231 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3236 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3237 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3239 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3244 if ( values.length() < 1 || values.length() > 2 )
3247 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3249 if ( values.length() == 2 )
3250 prec = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3251 QString wkt = fGeom.
asWkt( prec );
3252 return QVariant( wkt );
3257 if ( values.length() != 2 )
3259 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires exactly two parameters. %1 given." ).arg( values.length() ) );
3263 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3264 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3271 if ( collection->numGeometries() == 1 )
3279 if ( !pt2 && fGeom2.isMultipart() )
3281 if (
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( fGeom2.constGet() ) )
3283 if ( collection->numGeometries() == 1 )
3292 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires two points as arguments." ) );
3297 if ( pt1->x() == pt2->x() )
3299 if ( pt1->y() < pt2->y() )
3301 else if ( pt1->y() > pt2->y() )
3307 if ( pt1->y() == pt2->y() )
3309 if ( pt1->x() < pt2->x() )
3311 else if ( pt1->x() > pt2->x() )
3312 return M_PI + ( M_PI_2 );
3317 if ( pt1->x() < pt2->x() )
3319 if ( pt1->y() < pt2->y() )
3321 return std::atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) );
3325 return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
3332 if ( pt1->y() > pt2->y() )
3334 return std::atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) )
3339 return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
3340 + ( M_PI + ( M_PI_2 ) );
3347 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3351 parent->
setEvalErrorString( QStringLiteral(
"'project' requires a point geometry" ) );
3355 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3356 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3357 double inclination = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3360 QgsPoint newPoint = p->
project( distance, 180.0 * azimuth / M_PI, 180.0 * inclination / M_PI );
3367 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3368 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3375 if ( collection->numGeometries() == 1 )
3382 if ( !pt2 && fGeom2.isMultipart() )
3384 if (
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( fGeom2.constGet() ) )
3386 if ( collection->numGeometries() == 1 )
3396 parent->
setEvalErrorString( QStringLiteral(
"Function 'inclination' requires two points as arguments." ) );
3400 return pt1->inclination( *pt2 );
3406 if ( values.length() != 3 )
3409 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3410 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3411 double y = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3415 QVariant result = geom.
constGet() ? QVariant::fromValue( geom ) : QVariant();
3421 if ( values.length() < 2 )
3424 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3427 return values.at( 0 );
3429 QString expString = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3430 QVariant cachedExpression;
3435 if ( cachedExpression.isValid() )
3442 bool asc = values.value( 2 ).toBool();
3460 Q_ASSERT( collection );
3464 QgsExpressionSorter sorter( orderBy );
3466 QList<QgsFeature> partFeatures;
3467 partFeatures.reserve( collection->
partCount() );
3468 for (
int i = 0; i < collection->
partCount(); ++i )
3474 sorter.sortFeatures( partFeatures, unconstedContext );
3478 Q_ASSERT( orderedGeom );
3483 for (
const QgsFeature &feature : qgis::as_const( partFeatures ) )
3485 orderedGeom->
addGeometry( feature.geometry().constGet()->clone() );
3488 QVariant result = QVariant::fromValue(
QgsGeometry( orderedGeom ) );
3491 delete unconstedContext;
3498 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3499 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3503 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3509 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3510 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3514 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3520 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3521 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3525 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3531 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3534 parent->
setEvalErrorString( QObject::tr(
"line_substring requires a curve geometry input" ) );
3540 curve = qgsgeometry_cast< const QgsCurve * >( lineGeom.
constGet() );
3545 if ( collection->numGeometries() > 0 )
3554 double startDistance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3555 double endDistance = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3557 std::unique_ptr< QgsCurve > substring( curve->
curveSubstring( startDistance, endDistance ) );
3559 return !result.isNull() ? QVariant::fromValue( result ) : QVariant();
3564 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3565 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3572 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3573 qlonglong vertex = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3580 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3581 qlonglong vertex = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3588 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3589 QgsGeometry pointGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3593 return distance >= 0 ? distance : QVariant();
3598 if ( values.length() == 2 && values.at( 1 ).toInt() != 0 )
3600 double number = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
3601 return qgsRound( number, QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3604 if ( values.length() >= 1 )
3606 double number = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3607 return QVariant( qlonglong( std::round( number ) ) );
3622 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
3623 int places = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3629 QLocale locale = QLocale();
3630 locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
3631 return locale.toString( value,
'f', places );
3636 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
3637 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3638 return dt.toString( format );
3644 int avg = ( color.red() + color.green() + color.blue() ) / 3;
3645 int alpha = color.alpha();
3647 color.setRgb( avg, avg, avg, alpha );
3656 double ratio = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3661 else if ( ratio < 0 )
3666 int red = color1.red() * ( 1 - ratio ) + color2.red() * ratio;
3667 int green = color1.green() * ( 1 - ratio ) + color2.green() * ratio;
3668 int blue = color1.blue() * ( 1 - ratio ) + color2.blue() * ratio;
3669 int alpha = color1.alpha() * ( 1 - ratio ) + color2.alpha() * ratio;
3671 QColor newColor( red, green, blue, alpha );
3678 int red = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3679 int green = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3680 int blue = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3681 QColor color = QColor( red, green, blue );
3682 if ( ! color.isValid() )
3684 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( red ).arg( green ).arg( blue ) );
3685 color = QColor( 0, 0, 0 );
3688 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3693 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
3694 QVariant value = node->
eval( parent, context );
3698 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
3700 value = node->
eval( parent, context );
3708 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
3710 QVariant value = node->
eval( parent, context );
3712 if ( value.toBool() )
3714 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
3716 value = node->
eval( parent, context );
3721 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
3723 value = node->
eval( parent, context );
3731 int red = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3732 int green = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3733 int blue = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3734 int alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
3735 QColor color = QColor( red, green, blue, alpha );
3736 if ( ! color.isValid() )
3738 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( red ).arg( green ).arg( blue ).arg( alpha ) );
3739 color = QColor( 0, 0, 0 );
3750 expRamp = QgsExpressionUtils::getRamp( values.at( 0 ), parent );
3755 QString rampName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
3759 parent->
setEvalErrorString( QObject::tr(
"\"%1\" is not a valid color ramp" ).arg( rampName ) );
3764 double value = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3765 QColor color = ramp->
color( value );
3772 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3774 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3776 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3778 QColor color = QColor::fromHslF( hue, saturation, lightness );
3780 if ( ! color.isValid() )
3782 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( lightness ) );
3783 color = QColor( 0, 0, 0 );
3786 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3792 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3794 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3796 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3798 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
3800 QColor color = QColor::fromHslF( hue, saturation, lightness, alpha );
3801 if ( ! color.isValid() )
3803 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
3804 color = QColor( 0, 0, 0 );
3812 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3814 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3816 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3818 QColor color = QColor::fromHsvF( hue, saturation, value );
3820 if ( ! color.isValid() )
3822 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( value ) );
3823 color = QColor( 0, 0, 0 );
3826 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3832 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3834 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3836 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3838 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
3840 QColor color = QColor::fromHsvF( hue, saturation, value, alpha );
3841 if ( ! color.isValid() )
3843 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
3844 color = QColor( 0, 0, 0 );
3852 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
3854 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3856 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3858 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
3860 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black );
3862 if ( ! color.isValid() )
3864 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ) );
3865 color = QColor( 0, 0, 0 );
3868 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3874 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
3876 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3878 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3880 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
3882 double alpha = QgsExpressionUtils::getIntValue( values.at( 4 ), parent ) / 255.0;
3884 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
3885 if ( ! color.isValid() )
3887 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
3888 color = QColor( 0, 0, 0 );
3896 if ( ! color.isValid() )
3898 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
3902 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3903 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
3905 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
3906 return color.green();
3907 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
3908 return color.blue();
3909 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
3910 return color.alpha();
3911 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
3912 return color.hsvHueF() * 360;
3913 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
3914 return color.hsvSaturationF() * 100;
3915 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
3916 return color.valueF() * 100;
3917 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
3918 return color.hslHueF() * 360;
3919 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
3920 return color.hslSaturationF() * 100;
3921 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
3922 return color.lightnessF() * 100;
3923 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
3924 return color.cyanF() * 100;
3925 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
3926 return color.magentaF() * 100;
3927 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
3928 return color.yellowF() * 100;
3929 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
3930 return color.blackF() * 100;
3932 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
3938 const QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
3939 if ( map.count() < 1 )
3941 parent->
setEvalErrorString( QObject::tr(
"A minimum of two colors is required to create a ramp" ) );
3945 QList< QColor > colors;
3947 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
3950 if ( !colors.last().isValid() )
3952 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( it.value().toString() ) );
3956 double step = it.key().toDouble();
3957 if ( it == map.constBegin() )
3962 else if ( it == map.constEnd() )
3972 bool discrete = values.at( 1 ).toBool();
3974 return QVariant::fromValue(
QgsGradientColorRamp( colors.first(), colors.last(), discrete, stops ) );
3980 if ( ! color.isValid() )
3982 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
3986 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3987 int value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3988 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
3989 color.setRed( value );
3990 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
3991 color.setGreen( value );
3992 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
3993 color.setBlue( value );
3994 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
3995 color.setAlpha( value );
3996 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
3997 color.setHsv( value, color.hsvSaturation(), color.value(), color.alpha() );
3998 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
3999 color.setHsvF( color.hsvHueF(), value / 100.0, color.valueF(), color.alphaF() );
4000 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
4001 color.setHsvF( color.hsvHueF(), color.hsvSaturationF(), value / 100.0, color.alphaF() );
4002 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
4003 color.setHsl( value, color.hslSaturation(), color.lightness(), color.alpha() );
4004 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
4005 color.setHslF( color.hslHueF(), value / 100.0, color.lightnessF(), color.alphaF() );
4006 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
4007 color.setHslF( color.hslHueF(), color.hslSaturationF(), value / 100.0, color.alphaF() );
4008 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
4009 color.setCmykF( value / 100.0, color.magentaF(), color.yellowF(), color.blackF(), color.alphaF() );
4010 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
4011 color.setCmykF( color.cyanF(), value / 100.0, color.yellowF(), color.blackF(), color.alphaF() );
4012 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
4013 color.setCmykF( color.cyanF(), color.magentaF(), value / 100.0, color.blackF(), color.alphaF() );
4014 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
4015 color.setCmykF( color.cyanF(), color.magentaF(), color.yellowF(), value / 100.0, color.alphaF() );
4018 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
4027 if ( ! color.isValid() )
4029 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4033 color = color.darker( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
4041 if ( ! color.isValid() )
4043 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4047 color = color.lighter( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
4054 QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
4056 if ( !geom.isNull() )
4057 return QVariant::fromValue( geom );
4063 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4064 QString sAuthId = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4065 QString dAuthId = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4068 if ( ! s.isValid() )
4069 return QVariant::fromValue( fGeom );
4072 return QVariant::fromValue( fGeom );
4080 return QVariant::fromValue( fGeom );
4094 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
4097 QgsFeatureId fid = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4107 result = QVariant::fromValue( fet );
4117 std::unique_ptr<QgsVectorLayerFeatureSource> featureSource = QgsExpressionUtils::getFeatureSource( values.at( 0 ), parent );
4120 if ( !featureSource )
4125 QString attribute = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4126 int attributeId = featureSource->fields().lookupField( attribute );
4127 if ( attributeId == -1 )
4132 const QVariant &attVal = values.at( 2 );
4134 const QString cacheValueKey = QStringLiteral(
"getfeature:%1:%2:%3" ).arg( featureSource->id(), QString::number( attributeId ), attVal.toString() );
4156 res = QVariant::fromValue( fet );
4171 if ( !values.isEmpty() )
4174 if ( col && ( values.size() == 1 || !values.at( 1 ).isValid() ) )
4175 fieldName = col->
name();
4176 else if ( values.size() == 2 )
4177 fieldName = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4180 QVariant value = values.at( 0 );
4185 if ( fieldIndex == -1 )
4187 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: Field not found %2" ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
4191 QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
4193 const QString cacheValueKey = QStringLiteral(
"repvalfcnval:%1:%2:%3" ).arg( layer ? layer->
id() : QStringLiteral(
"[None]" ), fieldName, value.toString() );
4202 const QString cacheKey = QStringLiteral(
"repvalfcn:%1:%2" ).arg( layer ? layer->
id() : QStringLiteral(
"[None]" ), fieldName );
4220 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: function cannot be evaluated without a context." ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
4228 QgsMapLayer *layer = QgsExpressionUtils::getMapLayer( values.at( 0 ), parent );
4234 QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4235 if ( QString::compare( layerProperty, QStringLiteral(
"name" ), Qt::CaseInsensitive ) == 0 )
4236 return layer->
name();
4237 else if ( QString::compare( layerProperty, QStringLiteral(
"id" ), Qt::CaseInsensitive ) == 0 )
4239 else if ( QString::compare( layerProperty, QStringLiteral(
"title" ), Qt::CaseInsensitive ) == 0 )
4241 else if ( QString::compare( layerProperty, QStringLiteral(
"abstract" ), Qt::CaseInsensitive ) == 0 )
4243 else if ( QString::compare( layerProperty, QStringLiteral(
"keywords" ), Qt::CaseInsensitive ) == 0 )
4245 QStringList keywords;
4247 for (
auto it = keywordMap.constBegin(); it != keywordMap.constEnd(); ++it )
4249 keywords.append( it.value() );
4251 if ( !keywords.isEmpty() )
4255 else if ( QString::compare( layerProperty, QStringLiteral(
"data_url" ), Qt::CaseInsensitive ) == 0 )
4257 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution" ), Qt::CaseInsensitive ) == 0 )
4261 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution_url" ), Qt::CaseInsensitive ) == 0 )
4263 else if ( QString::compare( layerProperty, QStringLiteral(
"source" ), Qt::CaseInsensitive ) == 0 )
4265 else if ( QString::compare( layerProperty, QStringLiteral(
"min_scale" ), Qt::CaseInsensitive ) == 0 )
4267 else if ( QString::compare( layerProperty, QStringLiteral(
"max_scale" ), Qt::CaseInsensitive ) == 0 )
4269 else if ( QString::compare( layerProperty, QStringLiteral(
"crs" ), Qt::CaseInsensitive ) == 0 )
4271 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_definition" ), Qt::CaseInsensitive ) == 0 )
4273 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_description" ), Qt::CaseInsensitive ) == 0 )
4275 else if ( QString::compare( layerProperty, QStringLiteral(
"extent" ), Qt::CaseInsensitive ) == 0 )
4278 QVariant result = QVariant::fromValue( extentGeom );
4281 else if ( QString::compare( layerProperty, QStringLiteral(
"type" ), Qt::CaseInsensitive ) == 0 )
4283 switch ( layer->
type() )
4286 return QCoreApplication::translate(
"expressions",
"Vector" );
4288 return QCoreApplication::translate(
"expressions",
"Raster" );
4290 return QCoreApplication::translate(
"expressions",
"Mesh" );
4292 return QCoreApplication::translate(
"expressions",
"Plugin" );
4301 if ( QString::compare( layerProperty, QStringLiteral(
"storage_type" ), Qt::CaseInsensitive ) == 0 )
4303 else if ( QString::compare( layerProperty, QStringLiteral(
"geometry_type" ), Qt::CaseInsensitive ) == 0 )
4305 else if ( QString::compare( layerProperty, QStringLiteral(
"feature_count" ), Qt::CaseInsensitive ) == 0 )
4307 else if ( QString::compare( layerProperty, QStringLiteral(
"path" ), Qt::CaseInsensitive ) == 0 )
4312 return decodedUri.value( QStringLiteral(
"path" ) );
4323 QgsMapLayer *layer = QgsExpressionUtils::getMapLayer( values.at( 0 ), parent );
4326 parent->
setEvalErrorString( QObject::tr(
"Cannot find layer %1" ).arg( values.at( 0 ).toString() ) );
4336 const QString uriPart = values.at( 1 ).toString();
4340 if ( !uriPart.isNull() )
4342 return decodedUri.value( values.at( 1 ).toString() );
4352 QString layerIdOrName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4359 if ( !layersByName.isEmpty() )
4361 layer = layersByName.at( 0 );
4372 int band = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4373 if ( band < 1 || band > rl->
bandCount() )
4375 parent->
setEvalErrorString( QObject::tr(
"Invalid band number %1 for layer %2" ).arg( band ).arg( layerIdOrName ) );
4379 QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4382 if ( QString::compare( layerProperty, QStringLiteral(
"avg" ), Qt::CaseInsensitive ) == 0 )
4384 else if ( QString::compare( layerProperty, QStringLiteral(
"stdev" ), Qt::CaseInsensitive ) == 0 )
4386 else if ( QString::compare( layerProperty, QStringLiteral(
"min" ), Qt::CaseInsensitive ) == 0 )
4388 else if ( QString::compare( layerProperty, QStringLiteral(
"max" ), Qt::CaseInsensitive ) == 0 )
4390 else if ( QString::compare( layerProperty, QStringLiteral(
"range" ), Qt::CaseInsensitive ) == 0 )
4392 else if ( QString::compare( layerProperty, QStringLiteral(
"sum" ), Qt::CaseInsensitive ) == 0 )
4396 parent->
setEvalErrorString( QObject::tr(
"Invalid raster statistic: '%1'" ).arg( layerProperty ) );
4426 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4427 bool ascending = values.value( 1 ).toBool();
4434 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).length();
4439 return QVariant( QgsExpressionUtils::getListValue( values.at( 0 ), parent ).contains( values.at( 1 ) ) );
4444 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).indexOf( values.at( 1 ) );
4449 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4450 const qlonglong pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4451 if ( pos < 0 || pos >= list.length() )
return QVariant();
4452 return list.at( pos );
4457 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4458 return list.value( 0 );
4463 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4464 return list.value( list.size() - 1 );
4467 static QVariant convertToSameType(
const QVariant &value, QVariant::Type
type )
4469 QVariant result = value;
4470 result.convert( type );
4476 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4477 list.append( values.at( 1 ) );
4478 return convertToSameType( list, values.at( 0 ).type() );
4483 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4484 list.prepend( values.at( 1 ) );
4485 return convertToSameType( list, values.at( 0 ).type() );
4490 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4491 list.insert( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ), values.at( 2 ) );
4492 return convertToSameType( list, values.at( 0 ).type() );
4497 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4498 list.removeAt( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
4499 return convertToSameType( list, values.at( 0 ).type() );
4504 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4505 list.removeAll( values.at( 1 ) );
4506 return convertToSameType( list, values.at( 0 ).type() );
4512 for (
const QVariant &cur : values )
4514 list += QgsExpressionUtils::getListValue( cur, parent );
4516 return convertToSameType( list, values.at( 0 ).type() );
4521 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4522 qlonglong start_pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4523 const qlonglong end_pos = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
4524 qlonglong slice_length = 0;
4526 if ( start_pos < 0 )
4528 start_pos = list.length() + start_pos;
4532 slice_length = end_pos - start_pos + 1;
4536 slice_length = list.length() + end_pos - start_pos + 1;
4539 if ( slice_length < 0 )
4543 list = list.mid( start_pos, slice_length );
4549 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4550 std::reverse( list.begin(), list.end() );
4556 const QVariantList array1 = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4557 const QVariantList array2 = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
4558 for (
const QVariant &cur : array2 )
4560 if ( array1.contains( cur ) )
4561 return QVariant(
true );
4563 return QVariant(
false );
4568 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4570 QVariantList distinct;
4572 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
4574 if ( !distinct.contains( *it ) )
4576 distinct += ( *it );
4585 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4586 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4587 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4591 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
4593 str += ( !( *it ).toString().isEmpty() ) ? ( *it ).toString() : empty;
4594 if ( it != ( array.constEnd() - 1 ) )
4600 return QVariant( str );
4605 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4606 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4607 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4609 QStringList list = str.split( delimiter );
4612 for ( QStringList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
4614 array += ( !( *it ).isEmpty() ) ? *it : empty;
4622 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4623 QJsonDocument document = QJsonDocument::fromJson( str.toUtf8() );
4624 if ( document.isNull() )
4627 return document.toVariant();
4633 QJsonDocument document = QJsonDocument::fromVariant( values.at( 0 ) );
4634 return document.toJson( QJsonDocument::Compact );
4639 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4640 if ( str.isEmpty() )
4641 return QVariantMap();
4642 str = str.trimmed();
4649 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4656 for (
int i = 0; i + 1 < values.length(); i += 2 )
4658 result.insert( QgsExpressionUtils::getStringValue( values.at( i ), parent ), values.at( i + 1 ) );
4665 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).value( values.at( 1 ).toString() );
4670 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).contains( values.at( 1 ).toString() );
4675 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4676 map.remove( values.at( 1 ).toString() );
4682 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4683 map.insert( values.at( 1 ).toString(), values.at( 2 ) );
4690 for (
const QVariant &cur : values )
4692 const QVariantMap curMap = QgsExpressionUtils::getMapValue( cur, parent );
4693 for ( QVariantMap::const_iterator it = curMap.constBegin(); it != curMap.constEnd(); ++it )
4694 result.insert( it.key(), it.value() );
4701 return QStringList( QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).keys() );
4706 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).values();
4711 QString envVarName = values.at( 0 ).toString();
4712 return QProcessEnvironment::systemEnvironment().value( envVarName );
4721 static QMutex sFunctionsMutex( QMutex::Recursive );
4722 QMutexLocker locker( &sFunctionsMutex );
4724 if ( sFunctions.isEmpty() )
4754 sFunctions << randFunc;
4758 sFunctions << randfFunc;
4761 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max" ), -1, fcnMax, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4762 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min" ), -1, fcnMin, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4764 <<
new QgsStaticExpressionFunction( QStringLiteral(
"scale_linear" ), 5, fcnLinearScale, QStringLiteral(
"Math" ) )
4765 <<
new QgsStaticExpressionFunction( QStringLiteral(
"scale_exp" ), 6, fcnExpScale, QStringLiteral(
"Math" ) )
4766 <<
new QgsStaticExpressionFunction( QStringLiteral(
"floor" ), 1, fcnFloor, QStringLiteral(
"Math" ) )
4767 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ceil" ), 1, fcnCeil, QStringLiteral(
"Math" ) )
4768 <<
new QgsStaticExpressionFunction( QStringLiteral(
"pi" ), 0, fcnPi, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$pi" ) )
4771 <<
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" ) )
4772 <<
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" ) )
4773 <<
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" ) )
4774 <<
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" ) )
4775 <<
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" ) )
4778 <<
new QgsStaticExpressionFunction( QStringLiteral(
"coalesce" ), -1, fcnCoalesce, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4780 <<
new QgsStaticExpressionFunction( QStringLiteral(
"if" ), 3, fcnIf, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
true )
4783 <<
new QgsStaticExpressionFunction( QStringLiteral(
"aggregate" ),
4791 QStringLiteral(
"Aggregates" ),
4800 if ( !node->
args() )
4803 QSet<QString> referencedVars;
4815 return referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() );
4824 if ( !node->
args() )
4825 return QSet<QString>();
4827 QSet<QString> referencedCols;
4828 QSet<QString> referencedVars;
4843 if ( referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() ) )
4846 return referencedCols;
4854 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count" ), aggParams, fcnAggregateCount, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4855 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_distinct" ), aggParams, fcnAggregateCountDistinct, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4856 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_missing" ), aggParams, fcnAggregateCountMissing, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4857 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minimum" ), aggParams, fcnAggregateMin, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4858 <<
new QgsStaticExpressionFunction( QStringLiteral(
"maximum" ), aggParams, fcnAggregateMax, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4859 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sum" ), aggParams, fcnAggregateSum, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4860 <<
new QgsStaticExpressionFunction( QStringLiteral(
"mean" ), aggParams, fcnAggregateMean, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4861 <<
new QgsStaticExpressionFunction( QStringLiteral(
"median" ), aggParams, fcnAggregateMedian, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4862 <<
new QgsStaticExpressionFunction( QStringLiteral(
"stdev" ), aggParams, fcnAggregateStdev, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4863 <<
new QgsStaticExpressionFunction( QStringLiteral(
"range" ), aggParams, fcnAggregateRange, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4864 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minority" ), aggParams, fcnAggregateMinority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4865 <<
new QgsStaticExpressionFunction( QStringLiteral(
"majority" ), aggParams, fcnAggregateMajority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4866 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q1" ), aggParams, fcnAggregateQ1, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4867 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q3" ), aggParams, fcnAggregateQ3, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4868 <<
new QgsStaticExpressionFunction( QStringLiteral(
"iqr" ), aggParams, fcnAggregateIQR, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4869 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min_length" ), aggParams, fcnAggregateMinLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4870 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max_length" ), aggParams, fcnAggregateMaxLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4871 <<
new QgsStaticExpressionFunction( QStringLiteral(
"collect" ), aggParams, fcnAggregateCollectGeometry, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4872 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concatenate" ), aggParams <<
QgsExpressionFunction::Parameter( QStringLiteral(
"concatenator" ),
true ), fcnAggregateStringConcat, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4873 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_agg" ), aggParams, fcnAggregateArray, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4878 <<
new QgsStaticExpressionFunction( QStringLiteral(
"now" ), 0, fcnNow, QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$now" ) )
4879 <<
new QgsStaticExpressionFunction( QStringLiteral(
"age" ), 2, fcnAge, QStringLiteral(
"Date and Time" ) )
4880 <<
new QgsStaticExpressionFunction( QStringLiteral(
"year" ), 1, fcnYear, QStringLiteral(
"Date and Time" ) )
4881 <<
new QgsStaticExpressionFunction( QStringLiteral(
"month" ), 1, fcnMonth, QStringLiteral(
"Date and Time" ) )
4882 <<
new QgsStaticExpressionFunction( QStringLiteral(
"week" ), 1, fcnWeek, QStringLiteral(
"Date and Time" ) )
4883 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day" ), 1, fcnDay, QStringLiteral(
"Date and Time" ) )
4884 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hour" ), 1, fcnHour, QStringLiteral(
"Date and Time" ) )
4885 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minute" ), 1, fcnMinute, QStringLiteral(
"Date and Time" ) )
4886 <<
new QgsStaticExpressionFunction( QStringLiteral(
"second" ), 1, fcnSeconds, QStringLiteral(
"Date and Time" ) )
4888 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day_of_week" ), 1, fcnDayOfWeek, QStringLiteral(
"Date and Time" ) )
4889 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lower" ), 1, fcnLower, QStringLiteral(
"String" ) )
4890 <<
new QgsStaticExpressionFunction( QStringLiteral(
"upper" ), 1, fcnUpper, QStringLiteral(
"String" ) )
4891 <<
new QgsStaticExpressionFunction( QStringLiteral(
"title" ), 1, fcnTitle, QStringLiteral(
"String" ) )
4892 <<
new QgsStaticExpressionFunction( QStringLiteral(
"trim" ), 1, fcnTrim, QStringLiteral(
"String" ) )
4893 <<
new QgsStaticExpressionFunction( QStringLiteral(
"levenshtein" ), 2, fcnLevenshtein, QStringLiteral(
"Fuzzy Matching" ) )
4894 <<
new QgsStaticExpressionFunction( QStringLiteral(
"longest_common_substring" ), 2, fcnLCS, QStringLiteral(
"Fuzzy Matching" ) )
4895 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hamming_distance" ), 2, fcnHamming, QStringLiteral(
"Fuzzy Matching" ) )
4896 <<
new QgsStaticExpressionFunction( QStringLiteral(
"soundex" ), 1, fcnSoundex, QStringLiteral(
"Fuzzy Matching" ) )
4897 <<
new QgsStaticExpressionFunction( QStringLiteral(
"char" ), 1, fcnChar, QStringLiteral(
"String" ) )
4900 <<
new QgsStaticExpressionFunction( QStringLiteral(
"replace" ), -1, fcnReplace, QStringLiteral(
"String" ) )
4901 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_replace" ), 3, fcnRegexpReplace, QStringLiteral(
"String" ) )
4902 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_substr" ), 2, fcnRegexpSubstr, QStringLiteral(
"String" ) )
4904 false, QSet< QString >(),
false, QStringList(),
true )
4905 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concat" ), -1, fcnConcat, QStringLiteral(
"String" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4906 <<
new QgsStaticExpressionFunction( QStringLiteral(
"strpos" ), 2, fcnStrpos, QStringLiteral(
"String" ) )
4907 <<
new QgsStaticExpressionFunction( QStringLiteral(
"left" ), 2, fcnLeft, QStringLiteral(
"String" ) )
4908 <<
new QgsStaticExpressionFunction( QStringLiteral(
"right" ), 2, fcnRight, QStringLiteral(
"String" ) )
4909 <<
new QgsStaticExpressionFunction( QStringLiteral(
"rpad" ), 3, fcnRPad, QStringLiteral(
"String" ) )
4910 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lpad" ), 3, fcnLPad, QStringLiteral(
"String" ) )
4911 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format" ), -1, fcnFormatString, QStringLiteral(
"String" ) )
4912 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format_number" ), 2, fcnFormatNumber, QStringLiteral(
"String" ) )
4914 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_grayscale_average" ), 1, fcnColorGrayscaleAverage, QStringLiteral(
"Color" ) )
4915 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_mix_rgb" ), 3, fcnColorMixRgb, QStringLiteral(
"Color" ) )
4916 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_rgb" ), 3, fcnColorRgb, QStringLiteral(
"Color" ) )
4917 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_rgba" ), 4, fncColorRgba, QStringLiteral(
"Color" ) )
4918 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ramp_color" ), 2,
fcnRampColor, QStringLiteral(
"Color" ) )
4920 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_hsl" ), 3, fcnColorHsl, QStringLiteral(
"Color" ) )
4921 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_hsla" ), 4, fncColorHsla, QStringLiteral(
"Color" ) )
4922 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_hsv" ), 3, fcnColorHsv, QStringLiteral(
"Color" ) )
4923 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_hsva" ), 4, fncColorHsva, QStringLiteral(
"Color" ) )
4924 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_cmyk" ), 4, fcnColorCmyk, QStringLiteral(
"Color" ) )
4925 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_cmyka" ), 5, fncColorCmyka, QStringLiteral(
"Color" ) )
4926 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_part" ), 2, fncColorPart, QStringLiteral(
"Color" ) )
4927 <<
new QgsStaticExpressionFunction( QStringLiteral(
"darker" ), 2, fncDarker, QStringLiteral(
"Color" ) )
4928 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lighter" ), 2, fncLighter, QStringLiteral(
"Color" ) )
4929 <<
new QgsStaticExpressionFunction( QStringLiteral(
"set_color_part" ), 3, fncSetColorPart, QStringLiteral(
"Color" ) )
4934 QgsStaticExpressionFunction *geomFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$geometry" ), 0, fcnGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4936 sFunctions << geomFunc;
4938 QgsStaticExpressionFunction *areaFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$area" ), 0, fcnGeomArea, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4940 sFunctions << areaFunc;
4942 sFunctions <<
new QgsStaticExpressionFunction( QStringLiteral(
"area" ), 1, fcnArea, QStringLiteral(
"GeometryGroup" ) );
4944 QgsStaticExpressionFunction *lengthFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$length" ), 0, fcnGeomLength, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4946 sFunctions << lengthFunc;
4948 QgsStaticExpressionFunction *perimeterFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$perimeter" ), 0, fcnGeomPerimeter, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4950 sFunctions << perimeterFunc;
4952 sFunctions <<
new QgsStaticExpressionFunction( QStringLiteral(
"perimeter" ), 1, fcnPerimeter, QStringLiteral(
"GeometryGroup" ) );
4954 QgsStaticExpressionFunction *xFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$x" ), 0, fcnX, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4956 sFunctions << xFunc;
4958 QgsStaticExpressionFunction *yFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$y" ), 0, fcnY, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4960 sFunctions << yFunc;
4963 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x" ), 1, fcnGeomX, QStringLiteral(
"GeometryGroup" ) )
4964 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y" ), 1, fcnGeomY, QStringLiteral(
"GeometryGroup" ) )
4965 <<
new QgsStaticExpressionFunction( QStringLiteral(
"z" ), 1, fcnGeomZ, QStringLiteral(
"GeometryGroup" ) )
4966 <<
new QgsStaticExpressionFunction( QStringLiteral(
"m" ), 1, fcnGeomM, QStringLiteral(
"GeometryGroup" ) )
4967 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_n" ), 2, fcnPointN, QStringLiteral(
"GeometryGroup" ) )
4968 <<
new QgsStaticExpressionFunction( QStringLiteral(
"start_point" ), 1, fcnStartPoint, QStringLiteral(
"GeometryGroup" ) )
4969 <<
new QgsStaticExpressionFunction( QStringLiteral(
"end_point" ), 1, fcnEndPoint, QStringLiteral(
"GeometryGroup" ) )
4970 <<
new QgsStaticExpressionFunction( QStringLiteral(
"nodes_to_points" ), -1, fcnNodesToPoints, QStringLiteral(
"GeometryGroup" ) )
4971 <<
new QgsStaticExpressionFunction( QStringLiteral(
"segments_to_lines" ), 1, fcnSegmentsToLines, QStringLiteral(
"GeometryGroup" ) )
4972 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_point" ), -1, fcnMakePoint, QStringLiteral(
"GeometryGroup" ) )
4973 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_point_m" ), 3, fcnMakePointM, QStringLiteral(
"GeometryGroup" ) )
4974 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_line" ), -1, fcnMakeLine, QStringLiteral(
"GeometryGroup" ) )
4975 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_polygon" ), -1, fcnMakePolygon, QStringLiteral(
"GeometryGroup" ) )
4979 fcnMakeTriangle, QStringLiteral(
"GeometryGroup" ) )
4984 fcnMakeCircle, QStringLiteral(
"GeometryGroup" ) )
4991 fcnMakeEllipse, QStringLiteral(
"GeometryGroup" ) )
4997 fcnMakeRegularPolygon, QStringLiteral(
"GeometryGroup" ) )
5001 fcnMakeSquare, QStringLiteral(
"GeometryGroup" ) )
5007 fcnMakeRectangleFrom3Points, QStringLiteral(
"GeometryGroup" ) );
5008 QgsStaticExpressionFunction *xAtFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$x_at" ), 1, fcnXat, QStringLiteral(
"GeometryGroup" ), QString(),
true, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xat" ) << QStringLiteral(
"x_at" ) );
5010 sFunctions << xAtFunc;
5012 QgsStaticExpressionFunction *yAtFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$y_at" ), 1, fcnYat, QStringLiteral(
"GeometryGroup" ), QString(),
true, QSet<QString>(),
false, QStringList() << QStringLiteral(
"yat" ) << QStringLiteral(
"y_at" ) );
5014 sFunctions << yAtFunc;
5017 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_min" ), 1, fcnXMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmin" ) )
5018 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_max" ), 1, fcnXMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmax" ) )
5019 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_min" ), 1, fcnYMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymin" ) )
5020 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_max" ), 1, fcnYMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymax" ) )
5021 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_wkt" ), 1, fcnGeomFromWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromWKT" ) )
5022 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_gml" ), 1, fcnGeomFromGML, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromGML" ) )
5023 <<
new QgsStaticExpressionFunction( QStringLiteral(
"flip_coordinates" ), 1, fcnFlipCoordinates, QStringLiteral(
"GeometryGroup" ) )
5024 <<
new QgsStaticExpressionFunction( QStringLiteral(
"relate" ), -1, fcnRelate, QStringLiteral(
"GeometryGroup" ) )
5025 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersects_bbox" ), 2, fcnBbox, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"bbox" ) )
5026 <<
new QgsStaticExpressionFunction( QStringLiteral(
"disjoint" ), 2, fcnDisjoint, QStringLiteral(
"GeometryGroup" ) )
5027 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersects" ), 2, fcnIntersects, QStringLiteral(
"GeometryGroup" ) )
5028 <<
new QgsStaticExpressionFunction( QStringLiteral(
"touches" ), 2, fcnTouches, QStringLiteral(
"GeometryGroup" ) )
5029 <<
new QgsStaticExpressionFunction( QStringLiteral(
"crosses" ), 2, fcnCrosses, QStringLiteral(
"GeometryGroup" ) )
5030 <<
new QgsStaticExpressionFunction( QStringLiteral(
"contains" ), 2, fcnContains, QStringLiteral(
"GeometryGroup" ) )
5031 <<
new QgsStaticExpressionFunction( QStringLiteral(
"overlaps" ), 2, fcnOverlaps, QStringLiteral(
"GeometryGroup" ) )
5032 <<
new QgsStaticExpressionFunction( QStringLiteral(
"within" ), 2, fcnWithin, QStringLiteral(
"GeometryGroup" ) )
5033 <<
new QgsStaticExpressionFunction( QStringLiteral(
"translate" ), 3, fcnTranslate, QStringLiteral(
"GeometryGroup" ) )
5034 <<
new QgsStaticExpressionFunction( QStringLiteral(
"buffer" ), -1, fcnBuffer, QStringLiteral(
"GeometryGroup" ) )
5036 fcnForceRHR, QStringLiteral(
"GeometryGroup" ) )
5046 , fcnTaperedBuffer, QStringLiteral(
"GeometryGroup" ) )
5049 , fcnBufferByM, QStringLiteral(
"GeometryGroup" ) )
5055 fcnOffsetCurve, QStringLiteral(
"GeometryGroup" ) )
5061 fcnSingleSidedBuffer, QStringLiteral(
"GeometryGroup" ) )
5065 fcnExtend, QStringLiteral(
"GeometryGroup" ) )
5066 <<
new QgsStaticExpressionFunction( QStringLiteral(
"centroid" ), 1, fcnCentroid, QStringLiteral(
"GeometryGroup" ) )
5067 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_on_surface" ), 1, fcnPointOnSurface, QStringLiteral(
"GeometryGroup" ) )
5070 <<
new QgsStaticExpressionFunction( QStringLiteral(
"reverse" ), 1, fcnReverse, QStringLiteral(
"GeometryGroup" ) )
5071 <<
new QgsStaticExpressionFunction( QStringLiteral(
"exterior_ring" ), 1, fcnExteriorRing, QStringLiteral(
"GeometryGroup" ) )
5072 <<
new QgsStaticExpressionFunction( QStringLiteral(
"interior_ring_n" ), 2, fcnInteriorRingN, QStringLiteral(
"GeometryGroup" ) )
5073 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geometry_n" ), 2, fcnGeometryN, QStringLiteral(
"GeometryGroup" ) )
5076 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds" ), 1, fcnBounds, QStringLiteral(
"GeometryGroup" ) )
5083 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_points" ), 1, fcnGeomNumPoints, QStringLiteral(
"GeometryGroup" ) )
5084 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_interior_rings" ), 1, fcnGeomNumInteriorRings, QStringLiteral(
"GeometryGroup" ) )
5085 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_rings" ), 1, fcnGeomNumRings, QStringLiteral(
"GeometryGroup" ) )
5086 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_geometries" ), 1, fcnGeomNumGeometries, QStringLiteral(
"GeometryGroup" ) )
5087 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_width" ), 1, fcnBoundsWidth, QStringLiteral(
"GeometryGroup" ) )
5088 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_height" ), 1, fcnBoundsHeight, QStringLiteral(
"GeometryGroup" ) )
5089 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_closed" ), 1, fcnIsClosed, QStringLiteral(
"GeometryGroup" ) )
5090 <<
new QgsStaticExpressionFunction( QStringLiteral(
"convex_hull" ), 1, fcnConvexHull, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"convexHull" ) )
5093 fcnOrientedBBox, QStringLiteral(
"GeometryGroup" ) )
5097 fcnMinimalCircle, QStringLiteral(
"GeometryGroup" ) )
5098 <<
new QgsStaticExpressionFunction( QStringLiteral(
"difference" ), 2, fcnDifference, QStringLiteral(
"GeometryGroup" ) )
5099 <<
new QgsStaticExpressionFunction( QStringLiteral(
"distance" ), 2, fcnDistance, QStringLiteral(
"GeometryGroup" ) )
5102 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersection" ), 2, fcnIntersection, QStringLiteral(
"GeometryGroup" ) )
5103 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sym_difference" ), 2, fcnSymDifference, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"symDifference" ) )
5104 <<
new QgsStaticExpressionFunction( QStringLiteral(
"combine" ), 2, fcnCombine, QStringLiteral(
"GeometryGroup" ) )
5105 <<
new QgsStaticExpressionFunction( QStringLiteral(
"union" ), 2, fcnCombine, QStringLiteral(
"GeometryGroup" ) )
5106 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_to_wkt" ), -1, fcnGeomToWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomToWKT" ) )
5107 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geometry" ), 1, fcnGetGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true )
5108 <<
new QgsStaticExpressionFunction( QStringLiteral(
"transform" ), 3, fcnTransformGeometry, QStringLiteral(
"GeometryGroup" ) )
5109 <<
new QgsStaticExpressionFunction( QStringLiteral(
"extrude" ), 3, fcnExtrude, QStringLiteral(
"GeometryGroup" ), QString() );;
5111 QgsStaticExpressionFunction *orderPartsFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"order_parts" ), 3, fcnOrderParts, QStringLiteral(
"GeometryGroup" ), QString() );
5116 const QList< QgsExpressionNode *> argList = node->
args()->
list();
5119 if ( !argNode->isStatic( parent, context ) )
5127 QString expString = argNode->
eval( parent, context ).toString();
5143 QString expression = argNode->
eval( parent, context ).toString();
5151 sFunctions << orderPartsFunc;
5154 <<
new QgsStaticExpressionFunction( QStringLiteral(
"closest_point" ), 2, fcnClosestPoint, QStringLiteral(
"GeometryGroup" ) )
5155 <<
new QgsStaticExpressionFunction( QStringLiteral(
"shortest_line" ), 2, fcnShortestLine, QStringLiteral(
"GeometryGroup" ) )
5172 QgsStaticExpressionFunction *idFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$id" ), 0, fcnFeatureId, QStringLiteral(
"Record and Attributes" ) );
5174 sFunctions << idFunc;
5176 QgsStaticExpressionFunction *currentFeatureFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$currentfeature" ), 0, fcnFeature, QStringLiteral(
"Record and Attributes" ) );
5178 sFunctions << currentFeatureFunc;
5180 QgsStaticExpressionFunction *uuidFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"uuid" ), 0, fcnUuid, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$uuid" ) );
5182 sFunctions << uuidFunc;
5185 <<
new QgsStaticExpressionFunction( QStringLiteral(
"get_feature" ), 3, fcnGetFeature, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"QgsExpressionUtils::getFeature" ) )
5186 <<
new QgsStaticExpressionFunction( QStringLiteral(
"get_feature_by_id" ), 2, fcnGetFeatureById, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false );
5188 QgsStaticExpressionFunction *isSelectedFunc =
new QgsStaticExpressionFunction(
5189 QStringLiteral(
"is_selected" ),
5192 QStringLiteral(
"Record and Attributes" ),
5198 sFunctions << isSelectedFunc;
5201 <<
new QgsStaticExpressionFunction(
5202 QStringLiteral(
"num_selected" ),
5205 QStringLiteral(
"Record and Attributes" ),
5212 <<
new QgsStaticExpressionFunction(
5213 QStringLiteral(
"sqlite_fetch_and_increment" ),
5221 fcnSqliteFetchAndIncrement,
5222 QStringLiteral(
"Record and Attributes" )
5240 parent->
setEvalErrorString( tr(
"If represent_value is called with 1 parameter, it must be an attribute." ) );
5250 parent->
setEvalErrorString( tr(
"represent_value must be called with exactly 1 or 2 parameters." ) );
5256 sFunctions << representValueFunc;
5260 <<
new QgsStaticExpressionFunction( QStringLiteral(
"layer_property" ), 2, fcnGetLayerProperty, QStringLiteral(
"General" ) )
5261 <<
new QgsStaticExpressionFunction( QStringLiteral(
"decode_uri" ),
5265 fcnDecodeUri, QStringLiteral(
"Map Layers" ) )
5271 QgsStaticExpressionFunction *varFunction =
new QgsStaticExpressionFunction( QStringLiteral(
"var" ), 1, fcnGetVariable, QStringLiteral(
"General" ) );
5284 if ( !argNode->
isStatic( parent, context ) )
5287 QString varName = argNode->
eval( parent, context ).toString();
5290 return scope ? scope->
isStatic( varName ) :
false;
5298 QgsStaticExpressionFunction *evalFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"eval" ), 1, fcnEval, QStringLiteral(
"General" ), QString(),
true, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES );
5306 if ( argNode->
isStatic( parent, context ) )
5308 QString expString = argNode->
eval( parent, context ).toString();
5320 sFunctions << evalFunc;
5323 <<
new QgsStaticExpressionFunction( QStringLiteral(
"env" ), 1, fcnEnvVar, QStringLiteral(
"General" ), QString() )
5325 <<
new QgsStaticExpressionFunction( QStringLiteral(
"attribute" ), 2, fcnAttribute, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES )
5331 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array" ), -1, fcnArray, QStringLiteral(
"Arrays" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5333 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_length" ), 1, fcnArrayLength, QStringLiteral(
"Arrays" ) )
5344 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_cat" ), -1, fcnArrayCat, QStringLiteral(
"Arrays" ) )
5348 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_distinct" ), 1, fcnArrayDistinct, QStringLiteral(
"Arrays" ) )
5354 <<
new QgsStaticExpressionFunction( QStringLiteral(
"json_to_map" ), 1, fcnLoadJson, QStringLiteral(
"Maps" ) )
5356 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_to_json" ), 1, fcnWriteJson, QStringLiteral(
"Maps" ) )
5358 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hstore_to_map" ), 1, fcnHstoreToMap, QStringLiteral(
"Maps" ) )
5359 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_to_hstore" ), 1, fcnMapToHstore, QStringLiteral(
"Maps" ) )
5360 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map" ), -1, fcnMap, QStringLiteral(
"Maps" ) )
5365 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_concat" ), -1, fcnMapConcat, QStringLiteral(
"Maps" ) )
5375 sOwnedFunctions <<
func;
5376 sBuiltinFunctions << func->name();
5377 sBuiltinFunctions.append( func->aliases() );
5387 QStringLiteral(
"Arrays" ) )
5398 if ( args->
count() < 2 )
5401 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
5411 QVariantList result;
5413 if ( args->
count() < 2 )
5417 QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
5420 std::unique_ptr< QgsExpressionContext > tempContext;
5423 tempContext = qgis::make_unique< QgsExpressionContext >();
5424 subContext = tempContext.get();
5430 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
5433 result << args->
at( 1 )->
eval( parent, subContext );
5458 if ( args->
count() < 2 )
5462 args->
at( 0 )->
prepare( parent, context );
5466 subContext = *context;
5472 args->
at( 1 )->
prepare( parent, &subContext );
5481 QStringLiteral(
"Arrays" ) )
5492 if ( args->
count() < 2 )
5495 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
5505 QVariantList result;
5507 if ( args->
count() < 2 )
5511 const QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
5514 std::unique_ptr< QgsExpressionContext > tempContext;
5517 tempContext = qgis::make_unique< QgsExpressionContext >();
5518 subContext = tempContext.get();
5524 for (
const QVariant &value : array )
5527 if ( args->
at( 1 )->
eval( parent, subContext ).toBool() )
5553 if ( args->
count() < 2 )
5557 args->
at( 0 )->
prepare( parent, context );
5561 subContext = *context;
5567 args->
at( 1 )->
prepare( parent, &subContext );
5576 QStringLiteral(
"General" ) )
5587 if ( args->
count() < 3 )
5591 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
5593 QVariant
name = args->
at( 0 )->
eval( parent, context );
5594 QVariant value = args->
at( 1 )->
eval( parent, context );
5597 appendTemporaryVariable( context, name.toString(), value );
5598 if ( args->
at( 2 )->
isStatic( parent, context ) )
5600 popTemporaryVariable( context );
5611 if ( args->
count() < 3 )
5615 QVariant
name = args->
at( 0 )->
eval( parent, context );
5616 QVariant value = args->
at( 1 )->
eval( parent, context );
5619 std::unique_ptr< QgsExpressionContext > tempContext;
5620 if ( !updatedContext )
5622 tempContext = qgis::make_unique< QgsExpressionContext >();
5623 updatedContext = tempContext.get();
5626 appendTemporaryVariable( updatedContext, name.toString(), value );
5627 result = args->
at( 2 )->
eval( parent, updatedContext );
5630 popTemporaryVariable( updatedContext );
5651 if ( args->
count() < 3 )
5656 QVariant value = args->
at( 1 )->
prepare( parent, context );
5659 std::unique_ptr< QgsExpressionContext > tempContext;
5660 if ( !updatedContext )
5662 tempContext = qgis::make_unique< QgsExpressionContext >();
5663 updatedContext = tempContext.get();
5666 appendTemporaryVariable( updatedContext, name.toString(), value );
5667 args->
at( 2 )->
prepare( parent, updatedContext );
5670 popTemporaryVariable( updatedContext );
5675 void QgsWithVariableExpressionFunction::popTemporaryVariable(
const QgsExpressionContext *context )
const 5681 void QgsWithVariableExpressionFunction::appendTemporaryVariable(
const QgsExpressionContext *context,
const QString &
name,
const QVariant &value )
const int lookupField(const QString &fieldName) const
Looks 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").
static QgsQuadrilateral squareFromDiagonal(const QgsPoint &p1, const QgsPoint &p2)
Construct a QgsQuadrilateral as a square from a diagonal.
virtual double sample(const QgsPointXY &point, int band, bool *ok=nullptr, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Samples a raster value from the specified band found at the point position.
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...
Single variable definition for use within a QgsExpressionContextScope.
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)
static QString quotedValue(const QVariant &value)
Returns a properly quoted and escaped version of value for use in SQL strings.
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.
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).
virtual QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be null.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Returns result of evaluating the function.
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.
int type() const override
Multi point geometry collection.
static QString wordWrap(const QString &string, int length, bool useMaxLineLength=true, const QString &customDelimiter=QString())
Automatically wraps a string by inserting new line characters at appropriate locations in the string...
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.
Unique pointer for sqlite3 prepared statements, which automatically finalizes the statement when the ...
QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Returns result of evaluating the function.
QgsArrayFilterExpressionFunction()
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.
QString providerType() const
Returns the provider type (provider key) for this layer.
int exec(const QString &sql, QString &errorMessage) const
Executes the sql command in the database.
static QString quotedIdentifier(const QString &identifier)
Returns a properly quoted version of identifier.
Abstract base class for color ramps.
QgsVectorLayer referencingLayer
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
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 an interpolated point on the geometry at the specified 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.
Handles the array_foreach(array, expression) expression function.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QgsLayerMetadata metadata
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
QgsFields fields() const
Convenience function for retrieving the fields for the context, if set.
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
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...
Quadrilateral geometry type.
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...
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...
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.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
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.
virtual bool executeSql(const QString &sql, QString &error, bool isDirty=false, const QString &name=QString())=0
Execute the sql string.
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.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
QList< QgsGradientStop > QgsGradientStopsList
List of gradient stops.
QSet< QString > referencedVariables() const
Returns a list of all variables which are used in this expression.
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
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.
QString errorMessage() const
Returns the most recent error message encountered by the database.
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.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
CORE_EXPORT QString build(const QVariantMap &map)
Build a hstore-formatted string from a QVariantMap.
QgsRasterDataProvider * dataProvider() override
Returns the layer's data provider, it may be null.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
The RasterBandStats struct is a container for statistics about a single raster band.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
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.
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 ...
virtual QgsCurve * curveSubstring(double startDistance, double endDistance) const =0
Returns a new curve representing a substring of this curve.
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.
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.
int step()
Steps to the next record in the statement, returning the sqlite3 result code.
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)
virtual QgsPolygon * toPolygon(unsigned int segments=36) const
Returns a segmented polygon.
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).
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
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.
bool crosses(const QgsGeometry &geometry) const
Test for if geometry crosses another (uses GEOS)
static QgsQuadrilateral rectangleFrom3Points(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, ConstructionOption mode)
Construct a QgsQuadrilateral as a Rectangle from 3 points.
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.
ConstructionOption
A quadrilateral can be constructed from 3 points where the second distance can be determined by the t...
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any.
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)
sqlite3_statement_unique_ptr prepare(const QString &sql, int &resultCode) const
Prepares a sql statement, returning the result.
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.
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.
static bool runOnMainThread(const Func &func, QgsFeedback *feedback=nullptr)
Guarantees that func is executed on the main thread.
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.
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.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
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.
QgsArrayForeachExpressionFunction()
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.
Handles the array_filter(array, expression) expression function.
The OrderByClause class represents an order by clause for a QgsFeatureRequest.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
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.
QgsCurve * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
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)
int open_v2(const QString &path, int flags, const char *zVfs)
Opens the database at the specified file path.
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.
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 the contents of the geometry as a 2-dimensional point.
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.
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places...
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
This class allows including a set of layers in a database-side transaction, provided the layer data p...
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 scale() const
Returns the map scale.
QgsFeatureRequest & setTimeout(int timeout)
Sets the timeout (in milliseconds) for the maximum time we should wait during feature requests before...
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.
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...
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.
QgsGeometry forceRHR() const
Forces geometries to respect the Right-Hand-Rule, in which the area that is bounded by a polygon is t...
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
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.
QgsMultiPointXY asMultiPoint() const
Returns the contents of the geometry as a multi-point.
QgsWkbTypes::GeometryType type
QgsFeatureRequest & setRequestMayBeNested(bool requestMayBeNested)
In case this request may be run nested within another already running iteration on the same connectio...
Custom exception class for Coordinate Reference System related exceptions.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be null.
QgsPolygon * toPolygon() const
Returns as a polygon.
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
Returns the curve polygon's exterior ring.
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.
CORE_EXPORT QVariantMap parse(const QString &string)
Returns a QVariantMap object containing the key and values from a hstore-formatted string...
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
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.
qlonglong columnAsInt64(int column) const
Gets column value from the current statement row as a long long integer (64 bits).
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.
QgsCoordinateReferenceSystem 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...