69#include <QCryptographicHash>
70#include <QMimeDatabase>
71#include <QProcessEnvironment>
72#include <QRegularExpression>
95 QVariantList argValues;
99 const QList< QgsExpressionNode * > argList = args->
list();
100 argValues.reserve( argList.size() );
107 v = QVariant::fromValue( n );
111 v = n->eval( parent, context );
113 bool defaultParamIsNull = mParameterList.count() > arg && mParameterList.at( arg ).optional() && !mParameterList.at( arg ).defaultValue().isValid();
114 if ( QgsExpressionUtils::isNull( v ) && !defaultParamIsNull && !
handlesNull() )
117 argValues.append( v );
122 return func( argValues, context, parent, node );
133 return QStringList();
160 return mGroups.isEmpty() ? false : mGroups.contains( QStringLiteral(
"deprecated" ) );
165 return ( QString::compare( mName, other.mName, Qt::CaseInsensitive ) == 0 );
177 const QString &group,
178 const QString &helpText,
182 const QStringList &aliases,
186 , mAliases( aliases )
187 , mUsesGeometry( false )
188 , mUsesGeometryFunc( usesGeometry )
189 , mReferencedColumnsFunc( referencedColumns )
201 if ( mUsesGeometryFunc )
202 return mUsesGeometryFunc( node );
204 return mUsesGeometry;
214 if ( mReferencedColumnsFunc )
215 return mReferencedColumnsFunc( node );
217 return mReferencedColumns;
223 return mIsStaticFunc( node, parent, context );
231 return mPrepareFunc( node, parent, context );
243 mIsStaticFunc =
nullptr;
249 mPrepareFunc = prepareFunc;
254 if ( node && node->
args() )
256 const QList< QgsExpressionNode * > argList = node->
args()->
list();
259 if ( !argNode->isStatic( parent, context ) )
269 double start = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
270 double stop = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
271 double step = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
273 if ( step == 0.0 || ( step > 0.0 && start > stop ) || ( step < 0.0 && start < stop ) )
280 double current = start + step;
281 while ( ( ( step > 0.0 && current <= stop ) || ( step < 0.0 && current >= stop ) ) && length <= 1000000 )
296 const QString name = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
298 if ( name == QLatin1String(
"feature" ) )
300 return context->
hasFeature() ? QVariant::fromValue( context->
feature() ) : QVariant();
302 else if ( name == QLatin1String(
"id" ) )
304 return context->
hasFeature() ? QVariant::fromValue( context->
feature().
id() ) : QVariant();
306 else if ( name == QLatin1String(
"geometry" ) )
322 QString templateString = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
331 QString expString = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
333 return expression.evaluate( context );
338 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
339 return QVariant( std::sqrt( x ) );
344 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
345 return QVariant( std::fabs( val ) );
350 double deg = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
351 return ( deg * M_PI ) / 180;
355 double rad = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
356 return ( 180 * rad ) / M_PI;
360 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
361 return QVariant( std::sin( x ) );
365 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
366 return QVariant( std::cos( x ) );
370 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
371 return QVariant( std::tan( x ) );
375 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
376 return QVariant( std::asin( x ) );
380 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
381 return QVariant( std::acos( x ) );
385 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
386 return QVariant( std::atan( x ) );
390 double y = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
391 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
392 return QVariant( std::atan2( y, x ) );
396 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
397 return QVariant( std::exp( x ) );
401 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
404 return QVariant( std::log( x ) );
408 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
411 return QVariant( log10( x ) );
415 double b = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
416 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
417 if ( x <= 0 || b <= 0 )
419 return QVariant( std::log( x ) / std::log( b ) );
423 double min = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
424 double max = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
428 std::random_device rd;
429 std::mt19937_64 generator( rd() );
431 if ( !QgsExpressionUtils::isNull( values.at( 2 ) ) )
434 if ( QgsExpressionUtils::isIntSafe( values.at( 2 ) ) )
437 seed = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
442 QString seedStr = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
443 std::hash<std::string> hasher;
444 seed = hasher( seedStr.toStdString() );
446 generator.seed( seed );
450 double f =
static_cast< double >( generator() ) /
static_cast< double >( std::mt19937_64::max() );
451 return QVariant( min + f * ( max - min ) );
455 qlonglong min = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
456 qlonglong max = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
460 std::random_device rd;
461 std::mt19937_64 generator( rd() );
463 if ( !QgsExpressionUtils::isNull( values.at( 2 ) ) )
466 if ( QgsExpressionUtils::isIntSafe( values.at( 2 ) ) )
469 seed = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
474 QString seedStr = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
475 std::hash<std::string> hasher;
476 seed = hasher( seedStr.toStdString() );
478 generator.seed( seed );
481 qint64 randomInteger = min + ( generator() % ( max - min + 1 ) );
482 if ( randomInteger > std::numeric_limits<int>::max() || randomInteger < -std::numeric_limits<int>::max() )
483 return QVariant( randomInteger );
486 return QVariant(
int( randomInteger ) );
491 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
492 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
493 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
494 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
495 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
497 if ( domainMin >= domainMax )
499 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
504 if ( val >= domainMax )
508 else if ( val <= domainMin )
514 double m = ( rangeMax - rangeMin ) / ( domainMax - domainMin );
515 double c = rangeMin - ( domainMin * m );
518 return QVariant( m * val +
c );
523 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
524 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
525 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
526 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
527 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
528 double exponent = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
530 if ( domainMin >= domainMax )
532 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
542 if ( val >= domainMax )
546 else if ( val <= domainMin )
552 return QVariant( ( ( rangeMax - rangeMin ) / std::pow( domainMax - domainMin, exponent ) ) * std::pow( val - domainMin, exponent ) + rangeMin );
557 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
558 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
559 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
560 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
561 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
562 double exponent = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
564 if ( domainMin >= domainMax )
566 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
576 if ( val >= domainMax )
580 else if ( val <= domainMin )
586 double ratio = ( std::pow( exponent, val - domainMin ) - 1 ) / ( std::pow( exponent, domainMax - domainMin ) - 1 );
587 return QVariant( ( rangeMax - rangeMin ) * ratio + rangeMin );
593 double maxVal = std::numeric_limits<double>::quiet_NaN();
594 for (
const QVariant &val : values )
597 if ( std::isnan( maxVal ) )
601 else if ( !std::isnan( testVal ) )
603 maxVal = std::max( maxVal, testVal );
607 if ( !std::isnan( maxVal ) )
609 result = QVariant( maxVal );
617 double minVal = std::numeric_limits<double>::quiet_NaN();
618 for (
const QVariant &val : values )
621 if ( std::isnan( minVal ) )
625 else if ( !std::isnan( testVal ) )
627 minVal = std::min( minVal, testVal );
631 if ( !std::isnan( minVal ) )
633 result = QVariant( minVal );
645 QVariant value = node->
eval( parent, context );
650 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( value, context, parent );
654 parent->
setEvalErrorString( QObject::tr(
"Cannot find layer with name or ID '%1'" ).arg( value.toString() ) );
659 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
661 value = node->
eval( parent, context );
667 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
672 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
674 QString subExpression = node->
dump();
678 if ( values.count() > 3 )
680 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
683 if ( !nl || nl->value().isValid() )
688 if ( values.count() > 4 )
690 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
692 value = node->
eval( parent, context );
699 if ( values.count() > 5 )
701 node = QgsExpressionUtils::getNode( values.at( 5 ), parent );
704 if ( !nl || nl->value().isValid() )
706 orderBy = node->
dump();
711 QString aggregateError;
719 const QSet< QString > filterVars = filterExp.referencedVariables();
720 const QSet< QString > subExpVars = subExp.referencedVariables();
721 QSet<QString> allVars = filterVars + subExpVars;
723 bool isStatic =
true;
724 if ( filterVars.contains( QStringLiteral(
"parent" ) )
725 || filterVars.contains( QString() )
726 || subExpVars.contains( QStringLiteral(
"parent" ) )
727 || subExpVars.contains( QString() ) )
733 for (
const QString &varName : allVars )
736 if ( scope && !scope->
isStatic( varName ) )
744 if ( isStatic && ! parameters.
orderBy.isEmpty() )
746 for (
const auto &orderByClause : std::as_const( parameters.
orderBy ) )
748 const QgsExpression &orderByExpression { orderByClause.expression() };
760 const QString contextHash = context->
uniqueHash( ok, allVars );
763 cacheKey = QStringLiteral(
"aggfcn:%1:%2:%3:%4:%5:%6" ).arg( vl->id(), QString::number(
static_cast< int >( aggregate ) ), subExpression, parameters.
filter,
764 orderBy, contextHash );
769 cacheKey = QStringLiteral(
"aggfcn:%1:%2:%3:%4:%5" ).arg( vl->id(), QString::number(
static_cast< int >( aggregate ) ), subExpression, parameters.
filter, orderBy );
780 subContext.appendScope( subScope );
781 result = vl->aggregate( aggregate, subExpression, parameters, &subContext, &ok,
nullptr, context->
feedback(), &aggregateError );
783 if ( ok && !cacheKey.isEmpty() )
793 result = vl->aggregate( aggregate, subExpression, parameters,
nullptr, &ok,
nullptr,
nullptr, &aggregateError );
797 if ( !aggregateError.isEmpty() )
798 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1 (%2)" ).arg( subExpression, aggregateError ) );
800 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
811 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
819 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), context, parent );
823 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
832 QVariant value = node->
eval( parent, context );
834 QString relationId = value.toString();
841 if ( relations.isEmpty() || relations.at( 0 ).referencedLayer() != vl )
843 parent->
setEvalErrorString( QObject::tr(
"Cannot find relation with id '%1'" ).arg( relationId ) );
848 relation = relations.at( 0 );
855 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
857 value = node->
eval( parent, context );
863 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
868 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
870 QString subExpression = node->
dump();
874 if ( values.count() > 3 )
876 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
878 value = node->
eval( parent, context );
885 if ( values.count() > 4 )
887 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
890 if ( !nl || nl->value().isValid() )
892 orderBy = node->
dump();
903 const QString cacheKey = QStringLiteral(
"relagg:%1%:%2:%3:%4:%5:%6" ).arg( relationId, vl->id(),
904 QString::number(
static_cast< int >( aggregate ) ),
917 result = childLayer->
aggregate( aggregate, subExpression, parameters, &subContext, &ok,
nullptr, context->
feedback(), &error );
921 if ( !error.isEmpty() )
922 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1 (%2)" ).arg( subExpression, error ) );
924 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
938 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
946 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), context, parent );
950 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
959 QString subExpression = node->
dump();
963 if ( values.count() > 1 )
965 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
968 if ( !nl || nl->value().isValid() )
969 groupBy = node->
dump();
973 if ( values.count() > 2 )
975 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
978 if ( !nl || nl->value().isValid() )
984 if ( orderByPos >= 0 && values.count() > orderByPos )
986 node = QgsExpressionUtils::getNode( values.at( orderByPos ), parent );
989 if ( !nl || nl->value().isValid() )
991 orderBy = node->
dump();
999 if ( !groupBy.isEmpty() )
1002 QVariant groupByValue = groupByExp.evaluate( context );
1003 QString groupByClause = QStringLiteral(
"%1 %2 %3" ).arg( groupBy,
1006 if ( !parameters.
filter.isEmpty() )
1007 parameters.
filter = QStringLiteral(
"(%1) AND (%2)" ).arg( parameters.
filter, groupByClause );
1009 parameters.
filter = groupByClause;
1015 bool isStatic =
true;
1016 const QSet<QString> refVars = filterExp.referencedVariables() + subExp.referencedVariables();
1017 for (
const QString &varName : refVars )
1020 if ( scope && !scope->
isStatic( varName ) )
1031 const QString contextHash = context->
uniqueHash( ok, refVars );
1034 cacheKey = QStringLiteral(
"agg:%1:%2:%3:%4:%5:%6" ).arg( vl->id(), QString::number(
static_cast< int >( aggregate ) ), subExpression, parameters.
filter,
1035 orderBy, contextHash );
1040 cacheKey = QStringLiteral(
"agg:%1:%2:%3:%4:%5" ).arg( vl->id(), QString::number(
static_cast< int >( aggregate ) ), subExpression, parameters.
filter, orderBy );
1052 subContext.appendScope( subScope );
1054 result = vl->aggregate( aggregate, subExpression, parameters, &subContext, &ok,
nullptr, context->
feedback(), &error );
1058 if ( !error.isEmpty() )
1059 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1 (%2)" ).arg( subExpression, error ) );
1061 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
1166 if ( values.count() > 3 )
1168 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
1170 QVariant value = node->
eval( parent, context );
1172 parameters.
delimiter = value.toString();
1183 if ( values.count() > 3 )
1185 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
1187 QVariant value = node->
eval( parent, context );
1189 parameters.
delimiter = value.toString();
1205 QVariant scale = context->
variable( QStringLiteral(
"map_scale" ) );
1210 const double v = scale.toDouble( &ok );
1218 double minValue = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1219 double testValue = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
1220 double maxValue = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
1223 if ( testValue <= minValue )
1225 return QVariant( minValue );
1227 else if ( testValue >= maxValue )
1229 return QVariant( maxValue );
1233 return QVariant( testValue );
1239 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1240 return QVariant( std::floor( x ) );
1245 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1246 return QVariant( std::ceil( x ) );
1251 const QVariant value = values.at( 0 );
1252 if ( QgsExpressionUtils::isNull( value.isValid() ) )
1254 return QVariant(
false );
1256 else if ( value.userType() == QMetaType::QString )
1259 return QVariant( !value.toString().isEmpty() );
1261 else if ( QgsExpressionUtils::isList( value ) )
1263 return !value.toList().isEmpty();
1265 return QVariant( value.toBool() );
1269 return QVariant( QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) );
1273 return QVariant( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) );
1277 return QVariant( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ) );
1282 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1283 QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1284 if ( format.isEmpty() && !language.isEmpty() )
1286 parent->
setEvalErrorString( QObject::tr(
"A format is required to convert to DateTime when the language is specified" ) );
1287 return QVariant( QDateTime() );
1290 if ( format.isEmpty() && language.isEmpty() )
1291 return QVariant( QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent ) );
1293 QString datetimestring = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1294 QLocale locale = QLocale();
1295 if ( !language.isEmpty() )
1297 locale = QLocale( language );
1300 QDateTime datetime = locale.toDateTime( datetimestring, format );
1301 if ( !datetime.isValid() )
1303 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to DateTime" ).arg( datetimestring ) );
1304 datetime = QDateTime();
1306 return QVariant( datetime );
1311 const int year = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
1312 const int month = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1313 const int day = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
1315 const QDate date( year, month, day );
1316 if ( !date.isValid() )
1318 parent->
setEvalErrorString( QObject::tr(
"'%1-%2-%3' is not a valid date" ).arg( year ).arg( month ).arg( day ) );
1321 return QVariant( date );
1326 const int hours = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
1327 const int minutes = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1328 const double seconds = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
1330 const QTime time( hours, minutes, std::floor( seconds ), ( seconds - std::floor( seconds ) ) * 1000 );
1331 if ( !time.isValid() )
1333 parent->
setEvalErrorString( QObject::tr(
"'%1-%2-%3' is not a valid time" ).arg( hours ).arg( minutes ).arg( seconds ) );
1336 return QVariant( time );
1341 const int year = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
1342 const int month = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1343 const int day = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
1344 const int hours = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
1345 const int minutes = QgsExpressionUtils::getIntValue( values.at( 4 ), parent );
1346 const double seconds = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
1348 const QDate date( year, month, day );
1349 if ( !date.isValid() )
1351 parent->
setEvalErrorString( QObject::tr(
"'%1-%2-%3' is not a valid date" ).arg( year ).arg( month ).arg( day ) );
1354 const QTime time( hours, minutes, std::floor( seconds ), ( seconds - std::floor( seconds ) ) * 1000 );
1355 if ( !time.isValid() )
1357 parent->
setEvalErrorString( QObject::tr(
"'%1-%2-%3' is not a valid time" ).arg( hours ).arg( minutes ).arg( seconds ) );
1360 return QVariant( QDateTime( date, time ) );
1365 const QString timeZoneId = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1369#if QT_FEATURE_timezone > 0
1370 if ( !timeZoneId.isEmpty() )
1372 tz = QTimeZone( timeZoneId.toUtf8() );
1375 if ( !tz.isValid() )
1377 parent->
setEvalErrorString( QObject::tr(
"'%1' is not a valid time zone ID" ).arg( timeZoneId ) );
1382 parent->
setEvalErrorString( QObject::tr(
"Qt is built without Qt timezone support, cannot use fcnTimeZoneFromId" ) );
1384 return QVariant::fromValue( tz );
1389#if QT_FEATURE_timezone > 0
1390 const QDateTime datetime = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1391 if ( datetime.isValid() )
1393 return QVariant::fromValue( datetime.timeZone() );
1397 parent->
setEvalErrorString( QObject::tr(
"Qt is built without Qt timezone support, cannot use fcnGetTimeZone" ) );
1404#if QT_FEATURE_timezone > 0
1405 QDateTime datetime = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1406 const QTimeZone tz = QgsExpressionUtils::getTimeZoneValue( values.at( 1 ), parent );
1407 if ( datetime.isValid() && tz.isValid() )
1409 datetime.setTimeZone( tz );
1410 return QVariant::fromValue( datetime );
1414 parent->
setEvalErrorString( QObject::tr(
"Qt is built without Qt timezone support, cannot use fcnSetTimeZone" ) );
1421#if QT_FEATURE_timezone > 0
1422 const QDateTime datetime = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1423 const QTimeZone tz = QgsExpressionUtils::getTimeZoneValue( values.at( 1 ), parent );
1424 if ( datetime.isValid() && tz.isValid() )
1426 return QVariant::fromValue( datetime.toTimeZone( tz ) );
1430 parent->
setEvalErrorString( QObject::tr(
"Qt is built without Qt timezone support, cannot use fcnConvertTimeZone" ) );
1437#if QT_FEATURE_timezone > 0
1438 const QTimeZone timeZone = QgsExpressionUtils::getTimeZoneValue( values.at( 0 ), parent );
1439 if ( timeZone.isValid() )
1441 return QString( timeZone.id() );
1445 parent->
setEvalErrorString( QObject::tr(
"Qt is built without Qt timezone support, cannot use fcnTimeZoneToId" ) );
1452 const double years = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1453 const double months = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
1454 const double weeks = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
1455 const double days = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
1456 const double hours = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
1457 const double minutes = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
1458 const double seconds = QgsExpressionUtils::getDoubleValue( values.at( 6 ), parent );
1460 return QVariant::fromValue(
QgsInterval( years, months, weeks, days, hours, minutes, seconds ) );
1465 for (
const QVariant &value : values )
1476 const QVariant val1 = values.at( 0 );
1477 const QVariant val2 = values.at( 1 );
1487 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1488 return QVariant( str.toLower() );
1492 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1493 return QVariant( str.toUpper() );
1497 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1498 QStringList elems = str.split(
' ' );
1499 for (
int i = 0; i < elems.size(); i++ )
1501 if ( elems[i].size() > 1 )
1502 elems[i] = elems[i].at( 0 ).toUpper() + elems[i].mid( 1 ).toLower();
1504 return QVariant( elems.join( QLatin1Char(
' ' ) ) );
1509 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1510 return QVariant( str.trimmed() );
1515 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1517 const QString characters = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1519 const QRegularExpression re( QStringLiteral(
"^([%1]*)" ).arg( QRegularExpression::escape( characters ) ) );
1520 str.replace( re, QString() );
1521 return QVariant( str );
1526 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1528 const QString characters = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1530 const QRegularExpression re( QStringLiteral(
"([%1]*)$" ).arg( QRegularExpression::escape( characters ) ) );
1531 str.replace( re, QString() );
1532 return QVariant( str );
1537 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1538 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1544 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1545 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1551 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1552 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1559 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1565 QChar character = QChar( QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent ) );
1566 return QVariant( QString( character ) );
1571 QString value = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1573 if ( value.isEmpty() )
1578 int res = value.at( 0 ).unicode();
1579 return QVariant( res );
1584 if ( values.length() == 2 || values.length() == 3 )
1586 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1587 qlonglong wrap = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1589 QString customdelimiter = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1602 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent,
true );
1606 return QVariant( geom.
length() );
1612 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1613 return QVariant( str.length() );
1618 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1623 double totalLength = 0;
1628 totalLength += line->length3D();
1633 totalLength += segmentized->length3D();
1643 const QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1644 const qlonglong number = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1645 return string.repeated( std::max(
static_cast< int >( number ), 0 ) );
1650 if ( values.count() == 2 && values.at( 1 ).userType() == QMetaType::Type::QVariantMap )
1652 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1653 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 1 ), parent );
1654 QVector< QPair< QString, QString > > mapItems;
1656 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
1658 mapItems.append( qMakePair( it.key(), it.value().toString() ) );
1662 std::sort( mapItems.begin(),
1664 [](
const QPair< QString, QString > &pair1,
1665 const QPair< QString, QString > &pair2 )
1667 return ( pair1.first.length() > pair2.first.length() );
1670 for (
auto it = mapItems.constBegin(); it != mapItems.constEnd(); ++it )
1672 str = str.replace( it->first, it->second );
1675 return QVariant( str );
1677 else if ( values.count() == 3 )
1679 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1680 QVariantList before;
1682 bool isSingleReplacement =
false;
1684 if ( !QgsExpressionUtils::isList( values.at( 1 ) ) && values.at( 2 ).userType() != QMetaType::Type::QStringList )
1686 before = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1690 before = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
1693 if ( !QgsExpressionUtils::isList( values.at( 2 ) ) )
1695 after = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1696 isSingleReplacement =
true;
1700 after = QgsExpressionUtils::getListValue( values.at( 2 ), parent );
1703 if ( !isSingleReplacement && before.length() != after.length() )
1705 parent->
setEvalErrorString( QObject::tr(
"Invalid pair of array, length not identical" ) );
1709 for (
int i = 0; i < before.length(); i++ )
1711 str = str.replace( before.at( i ).toString(), after.at( isSingleReplacement ? 0 : i ).toString() );
1714 return QVariant( str );
1718 parent->
setEvalErrorString( QObject::tr(
"Function replace requires 2 or 3 arguments" ) );
1725 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1726 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1727 QString after = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1729 QRegularExpression re( regexp, QRegularExpression::UseUnicodePropertiesOption );
1730 if ( !re.isValid() )
1732 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1735 return QVariant( str.replace( re, after ) );
1740 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1741 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1743 QRegularExpression re( regexp, QRegularExpression::UseUnicodePropertiesOption );
1744 if ( !re.isValid() )
1746 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1749 return QVariant( ( str.indexOf( re ) + 1 ) );
1754 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1755 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1756 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1758 QRegularExpression re( regexp, QRegularExpression::UseUnicodePropertiesOption );
1759 if ( !re.isValid() )
1761 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1765 QRegularExpressionMatch matches = re.match( str );
1766 if ( matches.hasMatch() )
1769 QStringList list = matches.capturedTexts();
1772 for ( QStringList::const_iterator it = ++list.constBegin(); it != list.constEnd(); ++it )
1774 array += ( !( *it ).isEmpty() ) ? *it : empty;
1777 return QVariant( array );
1787 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1788 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1790 QRegularExpression re( regexp, QRegularExpression::UseUnicodePropertiesOption );
1791 if ( !re.isValid() )
1793 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1798 QRegularExpressionMatch match = re.match( str );
1799 if ( match.hasMatch() )
1802 if ( match.lastCapturedIndex() > 0 )
1805 return QVariant( match.captured( 1 ) );
1810 return QVariant( match.captured( 0 ) );
1815 return QVariant(
"" );
1821 QString uuid = QUuid::createUuid().toString();
1822 if ( values.at( 0 ).toString().compare( QStringLiteral(
"WithoutBraces" ), Qt::CaseInsensitive ) == 0 )
1823 uuid = QUuid::createUuid().toString( QUuid::StringFormat::WithoutBraces );
1824 else if ( values.at( 0 ).toString().compare( QStringLiteral(
"Id128" ), Qt::CaseInsensitive ) == 0 )
1825 uuid = QUuid::createUuid().toString( QUuid::StringFormat::Id128 );
1831 if ( !values.at( 0 ).isValid() || !values.at( 1 ).isValid() )
1834 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1835 int from = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1838 if ( values.at( 2 ).isValid() )
1839 len = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
1845 from = str.size() + from;
1851 else if ( from > 0 )
1859 len = str.size() + len - from;
1866 return QVariant( str.mid( from, len ) );
1871 return QVariant( f.
id() );
1876 const int bandNb = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1877 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
1878 bool foundLayer =
false;
1879 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe( values.at( 0 ), context, parent, [parent, bandNb, geom](
QgsMapLayer * mapLayer )
1881 QgsRasterLayer *layer = qobject_cast< QgsRasterLayer * >( mapLayer );
1882 if ( !layer || !layer->dataProvider() )
1884 parent->setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster layer." ) );
1888 if ( bandNb < 1 || bandNb > layer->bandCount() )
1890 parent->setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster band number." ) );
1896 parent->setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid point geometry." ) );
1903 QgsMultiPointXY multiPoint = geom.asMultiPoint();
1904 if ( multiPoint.count() == 1 )
1906 point = multiPoint[0];
1915 double value = layer->dataProvider()->sample( point, bandNb );
1916 return std::isnan( value ) ? QVariant() : value;
1922 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster layer." ) );
1933 const int bandNb = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1934 const double value = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
1936 bool foundLayer =
false;
1937 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe( values.at( 0 ), context, parent, [parent, bandNb, value](
QgsMapLayer * mapLayer )-> QVariant
1939 QgsRasterLayer *layer = qobject_cast< QgsRasterLayer *>( mapLayer );
1940 if ( !layer || !layer->dataProvider() )
1942 parent->setEvalErrorString( QObject::tr(
"Function `raster_attributes` requires a valid raster layer." ) );
1946 if ( bandNb < 1 || bandNb > layer->bandCount() )
1948 parent->setEvalErrorString( QObject::tr(
"Function `raster_attributes` requires a valid raster band number." ) );
1952 if ( std::isnan( value ) )
1954 parent->
setEvalErrorString( QObject::tr(
"Function `raster_attributes` requires a valid raster value." ) );
1958 if ( ! layer->dataProvider()->attributeTable( bandNb ) )
1963 const QVariantList data = layer->dataProvider()->attributeTable( bandNb )->row( value );
1964 if ( data.isEmpty() )
1970 const QList<QgsRasterAttributeTable::Field> fields { layer->dataProvider()->attributeTable( bandNb )->fields() };
1971 for (
int idx = 0; idx < static_cast<int>( fields.count( ) ) && idx < static_cast<int>( data.count() ); ++idx )
1978 result.insert( fields.at( idx ).name, data.at( idx ) );
1986 parent->
setEvalErrorString( QObject::tr(
"Function `raster_attributes` requires a valid raster layer." ) );
2007 if ( values.size() == 1 )
2009 attr = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2012 else if ( values.size() == 2 )
2014 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
2015 attr = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
2019 parent->
setEvalErrorString( QObject::tr(
"Function `attribute` requires one or two parameters. %n given.",
nullptr, values.length() ) );
2028 QString table { R
"html(
2031 <tr><th>%1</th></tr>
2034 <tr><td>%2</td></tr>
2038 if ( values.size() == 1 )
2040 dict = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
2044 parent->
setEvalErrorString( QObject::tr(
"Function `map_to_html_table` requires one parameter. %n given.",
nullptr, values.length() ) );
2048 if ( dict.isEmpty() )
2053 QStringList headers;
2056 for (
auto it = dict.cbegin(); it != dict.cend(); ++it )
2058 headers.push_back( it.key().toHtmlEscaped() );
2059 cells.push_back( it.value().toString( ).toHtmlEscaped() );
2062 return table.arg( headers.join( QLatin1String(
"</th><th>" ) ), cells.join( QLatin1String(
"</td><td>" ) ) );
2067 QString table { R
"html(
2072 if ( values.size() == 1 )
2074 dict = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
2078 parent->
setEvalErrorString( QObject::tr(
"Function `map_to_html_dl` requires one parameter. %n given.",
nullptr, values.length() ) );
2082 if ( dict.isEmpty() )
2089 for (
auto it = dict.cbegin(); it != dict.cend(); ++it )
2091 rows.append( QStringLiteral(
"<dt>%1</dt><dd>%2</dd>" ).arg( it.key().toHtmlEscaped(), it.value().toString().toHtmlEscaped() ) );
2094 return table.arg( rows );
2102 layer = context->
variable( QStringLiteral(
"layer" ) );
2107 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
2109 layer = node->
eval( parent, context );
2120 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
2124 const QString strength = QgsExpressionUtils::getStringValue( values.at( 2 ), parent ).toLower();
2125 if ( strength == QLatin1String(
"hard" ) )
2129 else if ( strength == QLatin1String(
"soft" ) )
2134 bool foundLayer =
false;
2135 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe( layer, context, parent, [parent, feature, constraintStrength](
QgsMapLayer * mapLayer ) -> QVariant
2137 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( mapLayer );
2140 parent->
setEvalErrorString( QObject::tr(
"No layer provided to conduct constraints checks" ) );
2146 for (
int i = 0; i < fields.
size(); i++ )
2161 parent->
setEvalErrorString( QObject::tr(
"No layer provided to conduct constraints checks" ) );
2173 layer = context->
variable( QStringLiteral(
"layer" ) );
2178 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
2180 layer = node->
eval( parent, context );
2191 feature = QgsExpressionUtils::getFeature( values.at( 2 ), parent );
2195 const QString strength = QgsExpressionUtils::getStringValue( values.at( 3 ), parent ).toLower();
2196 if ( strength == QLatin1String(
"hard" ) )
2200 else if ( strength == QLatin1String(
"soft" ) )
2205 const QString attributeName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2207 bool foundLayer =
false;
2208 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe( layer, context, parent, [parent, feature, attributeName, constraintStrength](
QgsMapLayer * mapLayer ) -> QVariant
2210 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( mapLayer );
2217 if ( fieldIndex == -1 )
2219 parent->
setEvalErrorString( QObject::tr(
"The attribute name did not match any field for the given feature" ) );
2230 parent->
setEvalErrorString( QObject::tr(
"No layer provided to conduct constraints checks" ) );
2246 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
2251 for (
int i = 0; i < fields.
count(); ++i )
2265 if ( values.isEmpty() )
2268 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), context, parent );
2270 else if ( values.size() == 1 )
2272 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), context, parent );
2273 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
2275 else if ( values.size() == 2 )
2277 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), context, parent );
2278 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
2282 parent->
setEvalErrorString( QObject::tr(
"Function `represent_attributes` requires no more than two parameters. %n given.",
nullptr, values.length() ) );
2289 parent->
setEvalErrorString( QObject::tr(
"Cannot use represent attributes function: layer could not be resolved." ) );
2295 parent->
setEvalErrorString( QObject::tr(
"Cannot use represent attributes function: feature could not be resolved." ) );
2301 for (
int fieldIndex = 0; fieldIndex < fields.
count(); ++fieldIndex )
2303 const QString fieldName { fields.
at( fieldIndex ).
name() };
2304 const QVariant attributeVal = feature.
attribute( fieldIndex );
2305 const QString cacheValueKey = QStringLiteral(
"repvalfcnval:%1:%2:%3" ).arg( layer->
id(), fieldName, attributeVal.toString() );
2308 result.insert( fieldName, context->
cachedValue( cacheValueKey ) );
2317 const QString cacheKey = QStringLiteral(
"repvalfcn:%1:%2" ).arg( layer->
id(), fieldName );
2329 QString value( fieldFormatter->
representValue( layer, fieldIndex, setup.
config(), cache, attributeVal ) );
2331 result.insert( fields.
at( fieldIndex ).
name(), value );
2347 bool evaluate =
true;
2351 if ( values.isEmpty() )
2354 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), context, parent );
2356 else if ( values.size() == 1 )
2358 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), context, parent );
2359 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
2361 else if ( values.size() == 2 )
2363 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), context, parent );
2364 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
2366 else if ( values.size() == 3 )
2368 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), context, parent );
2369 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
2370 evaluate = values.value( 2 ).toBool();
2376 parent->
setEvalErrorString( QObject::tr(
"Function `maptip` requires no more than three parameters. %n given.",
nullptr, values.length() ) );
2380 parent->
setEvalErrorString( QObject::tr(
"Function `display` requires no more than three parameters. %n given.",
nullptr, values.length() ) );
2412 subContext.setFeature( feature );
2421 exp.prepare( &subContext );
2422 return exp.evaluate( &subContext ).toString();
2428 return fcnCoreFeatureMaptipDisplay( values, context, parent,
false );
2433 return fcnCoreFeatureMaptipDisplay( values, context, parent,
true );
2440 if ( values.isEmpty() )
2443 layer = context->
variable( QStringLiteral(
"layer" ) );
2445 else if ( values.size() == 1 )
2447 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
2448 layer = context->
variable( QStringLiteral(
"layer" ) );
2450 else if ( values.size() == 2 )
2452 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
2453 layer = values.at( 0 );
2457 parent->
setEvalErrorString( QObject::tr(
"Function `is_selected` requires no more than two parameters. %n given.",
nullptr, values.length() ) );
2461 bool foundLayer =
false;
2462 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe( layer, context, parent, [feature](
QgsMapLayer * mapLayer ) -> QVariant
2464 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( mapLayer );
2465 if ( !layer || !feature.
isValid() )
2482 if ( values.isEmpty() )
2483 layer = context->
variable( QStringLiteral(
"layer" ) );
2484 else if ( values.count() == 1 )
2485 layer = values.at( 0 );
2488 parent->
setEvalErrorString( QObject::tr(
"Function `num_selected` requires no more than one parameter. %n given.",
nullptr, values.length() ) );
2492 bool foundLayer =
false;
2493 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe( layer, context, parent, [](
QgsMapLayer * mapLayer ) -> QVariant
2495 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( mapLayer );
2511 static QMap<QString, qlonglong> counterCache;
2512 QVariant functionResult;
2514 auto fetchAndIncrementFunc = [ values, parent, &functionResult ](
QgsMapLayer * mapLayer,
const QString & databaseArgument )
2518 const QgsVectorLayer *layer = qobject_cast< QgsVectorLayer *>( mapLayer );
2523 database = decodedUri.value( QStringLiteral(
"path" ) ).toString();
2524 if ( database.isEmpty() )
2526 parent->
setEvalErrorString( QObject::tr(
"Could not extract file path from layer `%1`." ).arg( layer->
name() ) );
2531 database = databaseArgument;
2534 const QString table = values.at( 1 ).toString();
2535 const QString idColumn = values.at( 2 ).toString();
2536 const QString filterAttribute = values.at( 3 ).toString();
2537 const QVariant filterValue = values.at( 4 ).toString();
2538 const QVariantMap defaultValues = values.at( 5 ).toMap();
2544 if ( sqliteDb.
open_v2( database, SQLITE_OPEN_READWRITE,
nullptr ) != SQLITE_OK )
2547 functionResult = QVariant();
2551 QString errorMessage;
2552 QString currentValSql;
2554 qlonglong nextId = 0;
2555 bool cachedMode =
false;
2556 bool valueRetrieved =
false;
2558 QString cacheString = QStringLiteral(
"%1:%2:%3:%4:%5" ).arg( database, table, idColumn, filterAttribute, filterValue.toString() );
2565 auto cachedCounter = counterCache.find( cacheString );
2567 if ( cachedCounter != counterCache.end() )
2569 qlonglong &cachedValue = cachedCounter.value();
2570 nextId = cachedValue;
2572 cachedValue = nextId;
2573 valueRetrieved =
true;
2578 if ( !cachedMode || !valueRetrieved )
2580 int result = SQLITE_ERROR;
2583 if ( !filterAttribute.isNull() )
2588 sqliteStatement = sqliteDb.
prepare( currentValSql, result );
2590 if ( result == SQLITE_OK )
2593 if ( sqliteStatement.
step() == SQLITE_ROW )
2599 if ( cachedMode && result == SQLITE_OK )
2601 counterCache.insert( cacheString, nextId );
2605 counterCache.remove( cacheString );
2608 valueRetrieved =
true;
2612 if ( valueRetrieved )
2621 if ( !filterAttribute.isNull() )
2627 for ( QVariantMap::const_iterator iter = defaultValues.constBegin(); iter != defaultValues.constEnd(); ++iter )
2630 vals << iter.value().toString();
2633 upsertSql += QLatin1String(
" (" ) + cols.join(
',' ) +
')';
2634 upsertSql += QLatin1String(
" VALUES " );
2635 upsertSql +=
'(' + vals.join(
',' ) +
')';
2637 int result = SQLITE_ERROR;
2641 if ( transaction->
executeSql( upsertSql, errorMessage ) )
2648 result = sqliteDb.
exec( upsertSql, errorMessage );
2650 if ( result == SQLITE_OK )
2652 functionResult = QVariant( nextId );
2657 parent->
setEvalErrorString( QStringLiteral(
"Could not increment value: SQLite error: \"%1\" (%2)." ).arg( errorMessage, QString::number( result ) ) );
2658 functionResult = QVariant();
2663 functionResult = QVariant();
2666 bool foundLayer =
false;
2667 QgsExpressionUtils::executeLambdaForMapLayer( values.at( 0 ), context, parent, [&fetchAndIncrementFunc](
QgsMapLayer * layer )
2669 fetchAndIncrementFunc( layer, QString() );
2673 const QString databasePath = values.at( 0 ).toString();
2676 fetchAndIncrementFunc(
nullptr, databasePath );
2680 return functionResult;
2693 QString definition = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2698 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to coordinate reference system" ).arg( definition ) );
2701 return QVariant::fromValue( crs );
2707 for (
const QVariant &value : values )
2710 concat += QgsExpressionUtils::getStringValue( value, parent );
2717 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2718 return string.indexOf( QgsExpressionUtils::getStringValue( values.at( 1 ), parent ) ) + 1;
2723 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2724 int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
2725 return string.right( pos );
2730 if ( values.length() < 2 || values.length() > 3 )
2733 const QString input = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2734 const QString substring = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
2736 bool overlapping =
false;
2737 if ( values.length() == 3 )
2739 overlapping = values.at( 2 ).toBool();
2742 if ( substring.isEmpty() )
2743 return QVariant( 0 );
2748 count = input.count( substring );
2753 while ( ( pos = input.indexOf( substring, pos ) ) != -1 )
2756 pos += substring.length();
2760 return QVariant( count );
2765 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2766 int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
2767 return string.left( pos );
2772 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2773 int length = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
2774 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
2775 return string.leftJustified( length, fill.at( 0 ),
true );
2780 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2781 int length = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
2782 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
2783 return string.rightJustified( length, fill.at( 0 ),
true );
2788 if ( values.size() < 1 )
2790 parent->
setEvalErrorString( QObject::tr(
"Function format requires at least 1 argument" ) );
2794 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2795 for (
int n = 1; n < values.length(); n++ )
2797 string =
string.arg( QgsExpressionUtils::getStringValue( values.at( n ), parent ) );
2805 return QVariant( QDateTime::currentDateTime() );
2810 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
2811 QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
2812 if ( format.isEmpty() && !language.isEmpty() )
2814 parent->
setEvalErrorString( QObject::tr(
"A format is required to convert to Date when the language is specified" ) );
2815 return QVariant( QDate() );
2818 if ( format.isEmpty() && language.isEmpty() )
2819 return QVariant( QgsExpressionUtils::getDateValue( values.at( 0 ), parent ) );
2821 QString datestring = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2822 QLocale locale = QLocale();
2823 if ( !language.isEmpty() )
2825 locale = QLocale( language );
2828 QDate date = locale.toDate( datestring, format );
2829 if ( !date.isValid() )
2831 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to Date" ).arg( datestring ) );
2834 return QVariant( date );
2839 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
2840 QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
2841 if ( format.isEmpty() && !language.isEmpty() )
2843 parent->
setEvalErrorString( QObject::tr(
"A format is required to convert to Time when the language is specified" ) );
2844 return QVariant( QTime() );
2847 if ( format.isEmpty() && language.isEmpty() )
2848 return QVariant( QgsExpressionUtils::getTimeValue( values.at( 0 ), parent ) );
2850 QString timestring = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2851 QLocale locale = QLocale();
2852 if ( !language.isEmpty() )
2854 locale = QLocale( language );
2857 QTime time = locale.toTime( timestring, format );
2858 if ( !time.isValid() )
2860 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to Time" ).arg( timestring ) );
2863 return QVariant( time );
2868 return QVariant::fromValue( QgsExpressionUtils::getInterval( values.at( 0 ), parent ) );
2877 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2878 QString axis = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
2879 int precision = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
2881 QString formatString;
2882 if ( values.count() > 3 )
2883 formatString = QgsExpressionUtils::getStringValue( values.at( 3 ), parent );
2886 if ( formatString.compare( QLatin1String(
"suffix" ), Qt::CaseInsensitive ) == 0 )
2890 else if ( formatString.compare( QLatin1String(
"aligned" ), Qt::CaseInsensitive ) == 0 )
2894 else if ( ! formatString.isEmpty() )
2896 parent->
setEvalErrorString( QObject::tr(
"Invalid formatting parameter: '%1'. It must be empty, or 'suffix' or 'aligned'." ).arg( formatString ) );
2900 if ( axis.compare( QLatin1String(
"x" ), Qt::CaseInsensitive ) == 0 )
2904 else if ( axis.compare( QLatin1String(
"y" ), Qt::CaseInsensitive ) == 0 )
2910 parent->
setEvalErrorString( QObject::tr(
"Invalid axis name: '%1'. It must be either 'x' or 'y'." ).arg( axis ) );
2918 return floatToDegreeFormat( format, values, context, parent, node );
2925 value = QgsCoordinateUtils::dmsToDecimal( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), &ok );
2927 return ok ? QVariant( value ) : QVariant();
2933 return floatToDegreeFormat( format, values, context, parent, node );
2938 const double decimalDegrees = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2939 return static_cast< int >( decimalDegrees );
2944 const double absoluteDecimalDegrees = std::abs( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) );
2945 const double remainder = absoluteDecimalDegrees -
static_cast<int>( absoluteDecimalDegrees );
2946 return static_cast< int >( remainder * 60 );
2951 const double absoluteDecimalDegrees = std::abs( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) );
2952 const double remainder = absoluteDecimalDegrees -
static_cast<int>( absoluteDecimalDegrees );
2953 const double remainderInMinutes = remainder * 60;
2954 const double remainderSecondsFraction = remainderInMinutes -
static_cast< int >( remainderInMinutes );
2956 return remainderSecondsFraction * 60;
2961 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
2962 QDateTime d2 = QgsExpressionUtils::getDateTimeValue( values.at( 1 ), parent );
2963 qint64 seconds = d2.secsTo( d1 );
2964 return QVariant::fromValue(
QgsInterval( seconds ) );
2969 if ( !values.at( 0 ).canConvert<QDate>() )
2972 QDate date = QgsExpressionUtils::getDateValue( values.at( 0 ), parent );
2973 if ( !date.isValid() )
2978 return date.dayOfWeek() % 7;
2983 QVariant value = values.at( 0 );
2984 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
2987 return QVariant( inter.
days() );
2991 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
2992 return QVariant( d1.date().day() );
2998 QVariant value = values.at( 0 );
2999 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3002 return QVariant( inter.
years() );
3006 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
3007 return QVariant( d1.date().year() );
3013 QVariant value = values.at( 0 );
3014 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3017 return QVariant( inter.
months() );
3021 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
3022 return QVariant( d1.date().month() );
3028 QVariant value = values.at( 0 );
3029 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3032 return QVariant( inter.
weeks() );
3036 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
3037 return QVariant( d1.date().weekNumber() );
3043 QVariant value = values.at( 0 );
3044 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3047 return QVariant( inter.
hours() );
3051 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
3052 return QVariant( t1.hour() );
3058 QVariant value = values.at( 0 );
3059 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3062 return QVariant( inter.
minutes() );
3066 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
3067 return QVariant( t1.minute() );
3073 QVariant value = values.at( 0 );
3074 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3077 return QVariant( inter.
seconds() );
3081 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
3082 return QVariant( t1.second() );
3088 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
3091 return QVariant( dt.toMSecsSinceEpoch() );
3101 long long millisecs_since_epoch = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3103 return QVariant( QDateTime::fromMSecsSinceEpoch( millisecs_since_epoch ) );
3108 const QString filepath = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
3111 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg( QLatin1String(
"exif" ) ) );
3114 QString tag = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3120 const QString filepath = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
3123 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg( QLatin1String(
"exif_geotag" ) ) );
3130#define ENSURE_GEOM_TYPE(f, g, geomtype) \
3131 if ( !(f).hasGeometry() ) \
3132 return QVariant(); \
3133 QgsGeometry g = (f).geometry(); \
3134 if ( (g).type() != (geomtype) ) \
3141 if ( g.isMultipart() )
3143 return g.asMultiPoint().at( 0 ).x();
3147 return g.asPoint().x();
3155 if ( g.isMultipart() )
3157 return g.asMultiPoint().at( 0 ).y();
3161 return g.asPoint().y();
3175 if ( g.isEmpty() || !abGeom->
is3D() )
3188 if ( collection->numGeometries() > 0 )
3201 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3207 return QVariant( isValid );
3212 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3216 const QString methodString = QgsExpressionUtils::getStringValue( values.at( 1 ), parent ).trimmed();
3217#if GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR<10
3222 if ( methodString.compare( QLatin1String(
"linework" ), Qt::CaseInsensitive ) == 0 )
3224 else if ( methodString.compare( QLatin1String(
"structure" ), Qt::CaseInsensitive ) == 0 )
3227 const bool keepCollapsed = values.value( 2 ).toBool();
3232 valid = geom.
makeValid( method, keepCollapsed );
3236 parent->
setEvalErrorString( QObject::tr(
"The make_valid parameters require a newer GEOS library version" ) );
3240 return QVariant::fromValue( valid );
3245 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3251 for (
int i = 0; i < multiGeom.size(); ++i )
3253 array += QVariant::fromValue( multiGeom.at( i ) );
3261 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3273 QVariant result( centroid.
asPoint().
x() );
3279 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3291 QVariant result( centroid.
asPoint().
y() );
3297 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3315 if ( collection->numGeometries() == 1 )
3328 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3346 if ( collection->numGeometries() == 1 )
3359 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3364 int idx = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3391 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3408 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3425 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3430 bool ignoreClosing =
false;
3431 if ( values.length() > 1 )
3433 ignoreClosing = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3443 bool skipLast =
false;
3444 if ( ignoreClosing && ring.count() > 2 && ring.first() == ring.last() )
3449 for (
int i = 0; i < ( skipLast ? ring.count() - 1 : ring.count() ); ++ i )
3461 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3472 for (
int i = 0; i < line->numPoints() - 1; ++i )
3476 << line->pointN( i )
3477 << line->pointN( i + 1 ) );
3488 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3498 if ( collection->numGeometries() == 1 )
3505 if ( !curvePolygon )
3509 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
3515 QVariant result = curve ? QVariant::fromValue(
QgsGeometry( curve ) ) : QVariant();
3521 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3531 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
3537 QVariant result = part ? QVariant::fromValue(
QgsGeometry( part ) ) : QVariant();
3543 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3552 return QVariant::fromValue(
QgsGeometry( boundary ) );
3557 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3566 return QVariant::fromValue( merged );
3571 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3575 const QgsGeometry geom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3580 if ( sharedPaths.
isNull() )
3583 return QVariant::fromValue( sharedPaths );
3589 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3594 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3597 if ( simplified.
isNull() )
3605 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3610 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3615 if ( simplified.
isNull() )
3623 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3628 int iterations = std::min( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), 10 );
3629 double offset = std::clamp( QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ), 0.0, 0.5 );
3630 double minLength = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3631 double maxAngle = std::clamp( QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent ), 0.0, 180.0 );
3633 QgsGeometry smoothed = geom.
smooth(
static_cast<unsigned int>( iterations ), offset, minLength, maxAngle );
3642 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3647 const double wavelength = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3648 const double amplitude = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3649 const bool strict = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
3660 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3665 const double minWavelength = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3666 const double maxWavelength = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3667 const double minAmplitude = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3668 const double maxAmplitude = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
3669 const long long seed = QgsExpressionUtils::getIntValue( values.at( 5 ), parent );
3672 minAmplitude, maxAmplitude, seed );
3681 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3686 const double wavelength = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3687 const double amplitude = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3688 const bool strict = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
3699 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3704 const double minWavelength = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3705 const double maxWavelength = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3706 const double minAmplitude = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3707 const double maxAmplitude = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
3708 const long long seed = QgsExpressionUtils::getIntValue( values.at( 5 ), parent );
3711 minAmplitude, maxAmplitude, seed );
3720 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3725 const double wavelength = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3726 const double amplitude = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3727 const bool strict = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
3738 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3743 const double minWavelength = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3744 const double maxWavelength = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3745 const double minAmplitude = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3746 const double maxAmplitude = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
3747 const long long seed = QgsExpressionUtils::getIntValue( values.at( 5 ), parent );
3750 minAmplitude, maxAmplitude, seed );
3759 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3764 const QVariantList pattern = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
3765 QVector< double > dashPattern;
3766 dashPattern.reserve( pattern.size() );
3767 for (
const QVariant &value : std::as_const( pattern ) )
3770 double v = value.toDouble( &ok );
3777 parent->
setEvalErrorString( QStringLiteral(
"Dash pattern must be an array of numbers" ) );
3782 if ( dashPattern.size() % 2 != 0 )
3784 parent->
setEvalErrorString( QStringLiteral(
"Dash pattern must contain an even number of elements" ) );
3788 const QString startRuleString = QgsExpressionUtils::getStringValue( values.at( 2 ), parent ).trimmed();
3790 if ( startRuleString.compare( QLatin1String(
"no_rule" ), Qt::CaseInsensitive ) == 0 )
3792 else if ( startRuleString.compare( QLatin1String(
"full_dash" ), Qt::CaseInsensitive ) == 0 )
3794 else if ( startRuleString.compare( QLatin1String(
"half_dash" ), Qt::CaseInsensitive ) == 0 )
3796 else if ( startRuleString.compare( QLatin1String(
"full_gap" ), Qt::CaseInsensitive ) == 0 )
3798 else if ( startRuleString.compare( QLatin1String(
"half_gap" ), Qt::CaseInsensitive ) == 0 )
3802 parent->
setEvalErrorString( QStringLiteral(
"'%1' is not a valid dash pattern rule" ).arg( startRuleString ) );
3806 const QString endRuleString = QgsExpressionUtils::getStringValue( values.at( 3 ), parent ).trimmed();
3808 if ( endRuleString.compare( QLatin1String(
"no_rule" ), Qt::CaseInsensitive ) == 0 )
3810 else if ( endRuleString.compare( QLatin1String(
"full_dash" ), Qt::CaseInsensitive ) == 0 )
3812 else if ( endRuleString.compare( QLatin1String(
"half_dash" ), Qt::CaseInsensitive ) == 0 )
3814 else if ( endRuleString.compare( QLatin1String(
"full_gap" ), Qt::CaseInsensitive ) == 0 )
3816 else if ( endRuleString.compare( QLatin1String(
"half_gap" ), Qt::CaseInsensitive ) == 0 )
3820 parent->
setEvalErrorString( QStringLiteral(
"'%1' is not a valid dash pattern rule" ).arg( endRuleString ) );
3824 const QString adjustString = QgsExpressionUtils::getStringValue( values.at( 4 ), parent ).trimmed();
3826 if ( adjustString.compare( QLatin1String(
"both" ), Qt::CaseInsensitive ) == 0 )
3828 else if ( adjustString.compare( QLatin1String(
"dash" ), Qt::CaseInsensitive ) == 0 )
3830 else if ( adjustString.compare( QLatin1String(
"gap" ), Qt::CaseInsensitive ) == 0 )
3834 parent->
setEvalErrorString( QStringLiteral(
"'%1' is not a valid dash pattern size adjustment" ).arg( adjustString ) );
3838 const double patternOffset = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
3849 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3854 const long long count = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3856 if ( densified.
isNull() )
3864 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3869 const double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3871 if ( densified.
isNull() )
3880 if ( values.size() == 1 && QgsExpressionUtils::isList( values.at( 0 ) ) )
3882 list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
3889 QVector< QgsGeometry > parts;
3890 parts.reserve( list.size() );
3891 for (
const QVariant &value : std::as_const( list ) )
3893 QgsGeometry part = QgsExpressionUtils::getGeometry( value, parent );
3904 if ( values.count() < 2 || values.count() > 4 )
3906 parent->
setEvalErrorString( QObject::tr(
"Function make_point requires 2-4 arguments" ) );
3910 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
3911 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3912 double z = values.count() >= 3 ? QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) : 0.0;
3913 double m = values.count() >= 4 ? QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) : 0.0;
3914 switch ( values.count() )
3928 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
3929 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3930 double m = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3936 if ( values.empty() )
3941 QVector<QgsPoint> points;
3942 points.reserve( values.count() );
3944 auto addPoint = [&points](
const QgsGeometry & geom )
3959 for (
const QVariant &value : values )
3961 if ( value.userType() == QMetaType::Type::QVariantList )
3963 const QVariantList list = value.toList();
3964 for (
const QVariant &v : list )
3966 addPoint( QgsExpressionUtils::getGeometry( v, parent ) );
3971 addPoint( QgsExpressionUtils::getGeometry( value, parent ) );
3975 if ( points.count() < 2 )
3983 if ( values.count() < 1 )
3985 parent->
setEvalErrorString( QObject::tr(
"Function make_polygon requires an argument" ) );
3989 QgsGeometry outerRing = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3997 auto polygon = std::make_unique< QgsPolygon >();
4011 if ( !exteriorRing )
4014 polygon->setExteriorRing( exteriorRing->
segmentize() );
4017 for (
int i = 1; i < values.count(); ++i )
4019 QgsGeometry ringGeom = QgsExpressionUtils::getGeometry( values.at( i ), parent );
4041 polygon->addInteriorRing( ring->
segmentize() );
4044 return QVariant::fromValue(
QgsGeometry( std::move( polygon ) ) );
4049 auto tr = std::make_unique<QgsTriangle>();
4050 auto lineString = std::make_unique<QgsLineString>();
4051 lineString->clear();
4053 for (
const QVariant &value : values )
4055 QgsGeometry geom = QgsExpressionUtils::getGeometry( value, parent );
4077 lineString->addVertex( *point );
4080 tr->setExteriorRing( lineString.release() );
4082 return QVariant::fromValue(
QgsGeometry( tr.release() ) );
4087 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4094 double radius = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
4095 int segment = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
4117 return QVariant::fromValue(
QgsGeometry( circ.toPolygon(
static_cast<unsigned int>(
segment ) ) ) );
4122 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4129 double majorAxis = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
4130 double minorAxis = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
4131 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
4132 int segment = QgsExpressionUtils::getNativeIntValue( values.at( 4 ), parent );
4152 QgsEllipse elp( *point, majorAxis, minorAxis, azimuth );
4153 return QVariant::fromValue(
QgsGeometry( elp.toPolygon(
static_cast<unsigned int>(
segment ) ) ) );
4159 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4166 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
4173 unsigned int nbEdges =
static_cast<unsigned int>( QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) );
4176 parent->
setEvalErrorString( QObject::tr(
"Number of edges/sides must be greater than 2" ) );
4183 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (inscribed) or 1 (circumscribed)" ) );
4223 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4229 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
4244 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4250 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
4256 QgsGeometry pt3 = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
4265 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (distance) or 1 (projected)" ) );
4289 return QVariant::fromValue( geom.
vertexAt( idx ) );
4297 const int idx = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
4299 const QVariant v = pointAt( geom, idx, parent );
4302 return QVariant( v.value<
QgsPoint>().
x() );
4308 if ( values.at( 1 ).isNull() && !values.at( 0 ).isNull() )
4310 return fcnOldXat( values, f, parent, node );
4312 else if ( values.at( 0 ).isNull() && !values.at( 1 ).isNull() )
4314 return fcnOldXat( QVariantList() << values[1], f, parent, node );
4317 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4323 const int vertexNumber = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4325 const QVariant v = pointAt( geom, vertexNumber, parent );
4327 return QVariant( v.value<
QgsPoint>().
x() );
4337 const int idx = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
4339 const QVariant v = pointAt( geom, idx, parent );
4342 return QVariant( v.value<
QgsPoint>().
y() );
4348 if ( values.at( 1 ).isNull() && !values.at( 0 ).isNull() )
4350 return fcnOldYat( values, f, parent, node );
4352 else if ( values.at( 0 ).isNull() && !values.at( 1 ).isNull() )
4354 return fcnOldYat( QVariantList() << values[1], f, parent, node );
4357 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4363 const int vertexNumber = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4365 const QVariant v = pointAt( geom, vertexNumber, parent );
4367 return QVariant( v.value<
QgsPoint>().
y() );
4374 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4380 const int vertexNumber = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4382 const QVariant v = pointAt( geom, vertexNumber, parent );
4384 return QVariant( v.value<
QgsPoint>().
z() );
4391 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4397 const int vertexNumber = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4399 const QVariant v = pointAt( geom, vertexNumber, parent );
4401 return QVariant( v.value<
QgsPoint>().
m() );
4420 return QVariant::fromValue( geom );
4428 QString wkt = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4430 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
4436 const QByteArray wkb = QgsExpressionUtils::getBinaryValue( values.at( 0 ), parent );
4442 return !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
4447 QString gml = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4454 ogcContext.
layer = mapLayerPtr.data();
4459 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
4474 return QVariant( area );
4478 parent->
setEvalErrorString( QObject::tr(
"An error occurred while calculating area" ) );
4490 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4495 return QVariant( geom.
area() );
4509 return QVariant( len );
4513 parent->
setEvalErrorString( QObject::tr(
"An error occurred while calculating length" ) );
4534 return QVariant( len );
4538 parent->
setEvalErrorString( QObject::tr(
"An error occurred while calculating perimeter" ) );
4544 return f.
geometry().
isNull() ? QVariant( 0 ) : QVariant( f.geometry().constGet()->perimeter() );
4550 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4556 return QVariant( geom.
length() );
4561 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4567 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4576 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4585 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4601 if ( !curvePolygon )
4613 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4620 return QVariant( curvePolygon->
ringCount() );
4622 bool foundPoly =
false;
4631 if ( !curvePolygon )
4642 return QVariant( ringCount );
4647 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4649 QVariant result = !geomBounds.
isNull() ? QVariant::fromValue( geomBounds ) : QVariant();
4655 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4661 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4667 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4676 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4682 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4688 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4694 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4700 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4708 double max = std::numeric_limits< double >::lowest();
4712 double z = ( *it ).z();
4718 if ( max == std::numeric_limits< double >::lowest() )
4721 return QVariant( max );
4726 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4734 double min = std::numeric_limits< double >::max();
4738 double z = ( *it ).z();
4744 if ( min == std::numeric_limits< double >::max() )
4747 return QVariant( min );
4752 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4760 double min = std::numeric_limits< double >::max();
4764 double m = ( *it ).m();
4770 if ( min == std::numeric_limits< double >::max() )
4773 return QVariant( min );
4778 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4786 double max = std::numeric_limits< double >::lowest();
4790 double m = ( *it ).m();
4796 if ( max == std::numeric_limits< double >::lowest() )
4799 return QVariant( max );
4804 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4808 parent->
setEvalErrorString( QObject::tr(
"Function `sinuosity` requires a line geometry." ) );
4817 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4821 parent->
setEvalErrorString( QObject::tr(
"Function `straight_distance_2d` requires a line geometry or a multi line geometry with a single part." ) );
4830 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4835 parent->
setEvalErrorString( QObject::tr(
"Function `roundness` requires a polygon geometry or a multi polygon geometry with a single part." ) );
4846 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4850 std::unique_ptr< QgsAbstractGeometry > flipped( geom.
constGet()->
clone() );
4852 return QVariant::fromValue(
QgsGeometry( std::move( flipped ) ) );
4857 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4876 return QVariant::fromValue( curve->
isClosed() );
4881 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4894 std::unique_ptr< QgsLineString > closedLine( line->
clone() );
4895 closedLine->close();
4897 result = QVariant::fromValue(
QgsGeometry( std::move( closedLine ) ) );
4911 std::unique_ptr< QgsLineString > closedLine( line->
clone() );
4912 closedLine->close();
4914 closed->addGeometry( closedLine.release() );
4917 result = QVariant::fromValue(
QgsGeometry( std::move( closed ) ) );
4925 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4929 return QVariant::fromValue( fGeom.
isEmpty() );
4935 return QVariant::fromValue(
true );
4937 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4938 return QVariant::fromValue( fGeom.
isNull() || fGeom.
isEmpty() );
4943 if ( values.length() < 2 || values.length() > 3 )
4946 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4947 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
4954 if ( values.length() == 2 )
4957 QString result = engine->relate( sGeom.
constGet() );
4958 return QVariant::fromValue( result );
4963 QString pattern = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4964 bool result = engine->relatePattern( sGeom.
constGet(), pattern );
4965 return QVariant::fromValue( result );
4971 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4972 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
4977 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4978 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
4979 return fGeom.
disjoint( sGeom ) ? TVL_True : TVL_False;
4983 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4984 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
4985 return fGeom.
intersects( sGeom ) ? TVL_True : TVL_False;
4989 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4990 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
4991 return fGeom.
touches( sGeom ) ? TVL_True : TVL_False;
4995 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4996 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
4997 return fGeom.
crosses( sGeom ) ? TVL_True : TVL_False;
5001 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5002 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5003 return fGeom.
contains( sGeom ) ? TVL_True : TVL_False;
5007 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5008 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5009 return fGeom.
overlaps( sGeom ) ? TVL_True : TVL_False;
5013 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5014 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5015 return fGeom.
within( sGeom ) ? TVL_True : TVL_False;
5020 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5021 const double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5022 const int seg = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
5023 const QString endCapString = QgsExpressionUtils::getStringValue( values.at( 3 ), parent ).trimmed();
5024 const QString joinString = QgsExpressionUtils::getStringValue( values.at( 4 ), parent ).trimmed();
5025 const double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
5028 if ( endCapString.compare( QLatin1String(
"flat" ), Qt::CaseInsensitive ) == 0 )
5030 else if ( endCapString.compare( QLatin1String(
"square" ), Qt::CaseInsensitive ) == 0 )
5034 if ( joinString.compare( QLatin1String(
"miter" ), Qt::CaseInsensitive ) == 0 )
5036 else if ( joinString.compare( QLatin1String(
"bevel" ), Qt::CaseInsensitive ) == 0 )
5040 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5046 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5048 return !reoriented.
isNull() ? QVariant::fromValue( reoriented ) : QVariant();
5053 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5055 return !reoriented.
isNull() ? QVariant::fromValue( reoriented ) : QVariant();
5060 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5062 return !reoriented.
isNull() ? QVariant::fromValue( reoriented ) : QVariant();
5067 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5082 parent->
setEvalErrorString( QObject::tr(
"Function `wedge_buffer` requires a point value for the center." ) );
5086 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5087 double width = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5088 double outerRadius = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
5089 double innerRadius = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
5092 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5098 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5101 parent->
setEvalErrorString( QObject::tr(
"Function `tapered_buffer` requires a line geometry." ) );
5105 double startWidth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5106 double endWidth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5107 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) );
5110 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5116 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5119 parent->
setEvalErrorString( QObject::tr(
"Function `buffer_by_m` requires a line geometry." ) );
5123 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
5126 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5132 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5133 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5134 int segments = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
5135 const int joinInt = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
5136 if ( joinInt < 1 || joinInt > 3 )
5140 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
5143 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5149 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5150 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5151 int segments = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
5153 const int joinInt = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
5154 if ( joinInt < 1 || joinInt > 3 )
5158 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
5161 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5167 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5168 double distStart = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5169 double distEnd = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5172 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5178 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5179 double dx = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5180 double dy = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5182 return QVariant::fromValue( fGeom );
5187 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5188 const double rotation = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5189 const QgsGeometry center = values.at( 2 ).
isValid() ? QgsExpressionUtils::getGeometry( values.at( 2 ), parent )
5191 const bool perPart = values.value( 3 ).toBool();
5198 std::unique_ptr< QgsGeometryCollection > collection( qgsgeometry_cast< QgsGeometryCollection * >( fGeom.constGet()->clone() ) );
5199 for ( auto it = collection->parts_begin(); it != collection->parts_end(); ++it )
5201 const QgsPointXY partCenter = ( *it )->boundingBox().center();
5202 QTransform t = QTransform::fromTranslate( partCenter.x(), partCenter.y() );
5203 t.rotate( -rotation );
5204 t.translate( -partCenter.x(), -partCenter.y() );
5205 ( *it )->transform( t );
5207 return QVariant::fromValue(
QgsGeometry( std::move( collection ) ) );
5219 parent->
setEvalErrorString( QObject::tr(
"Function 'rotate' requires a point value for the center" ) );
5227 fGeom.
rotate( rotation, pt );
5228 return QVariant::fromValue( fGeom );
5234 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5235 const double xScale = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5236 const double yScale = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5237 const QgsGeometry center = values.at( 3 ).isValid() ? QgsExpressionUtils::getGeometry( values.at( 3 ), parent )
5244 pt = fGeom.boundingBox().center();
5248 parent->setEvalErrorString( QObject::tr(
"Function 'scale' requires a point value for the center" ) );
5253 pt = center.asPoint();
5256 QTransform t = QTransform::fromTranslate( pt.
x(), pt.
y() );
5257 t.scale( xScale, yScale );
5258 t.translate( -pt.
x(), -pt.
y() );
5260 return QVariant::fromValue( fGeom );
5265 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5271 const double deltaX = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5272 const double deltaY = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5274 const double rotationZ = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
5276 const double scaleX = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
5277 const double scaleY = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
5279 const double deltaZ = QgsExpressionUtils::getDoubleValue( values.at( 6 ), parent );
5280 const double deltaM = QgsExpressionUtils::getDoubleValue( values.at( 7 ), parent );
5281 const double scaleZ = QgsExpressionUtils::getDoubleValue( values.at( 8 ), parent );
5282 const double scaleM = QgsExpressionUtils::getDoubleValue( values.at( 9 ), parent );
5293 QTransform transform;
5294 transform.translate( deltaX, deltaY );
5295 transform.rotate( rotationZ );
5296 transform.scale( scaleX, scaleY );
5297 fGeom.
transform( transform, deltaZ, scaleZ, deltaM, scaleM );
5299 return QVariant::fromValue( fGeom );
5305 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5307 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5312 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5314 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5320 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5321 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5323 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5329 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5331 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5335#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=11 )
5340 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5341 const double targetPercent = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5342 const bool allowHoles = values.value( 2 ).toBool();
5344 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5357 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5359 if ( values.length() == 2 )
5360 segments = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
5368 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5374 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5376 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5382 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5388 double area,
angle, width, height;
5401 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5402 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5404 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5415 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent,
true );
5426 result = reversed ? QVariant::fromValue(
QgsGeometry( reversed ) ) : QVariant();
5436 reversed->addGeometry( curve->
reversed() );
5443 result = reversed ? QVariant::fromValue(
QgsGeometry( std::move( reversed ) ) ) : QVariant();
5449 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5450 std::reverse(
string.begin(),
string.end() );
5456 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5476 QVariant result = exterior ? QVariant::fromValue(
QgsGeometry( exterior ) ) : QVariant();
5482 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5483 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5484 return QVariant( fGeom.
distance( sGeom ) );
5489 QgsGeometry g1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5490 QgsGeometry g2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5493 if ( values.length() == 3 && values.at( 2 ).isValid() )
5495 double densify = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5496 densify = std::clamp( densify, 0.0, 1.0 );
5504 return res > -1 ? QVariant( res ) : QVariant();
5509 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5510 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5512 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5517 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5518 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5520 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5525 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5526 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5528 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5534 if ( values.length() < 1 || values.length() > 2 )
5537 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5539 if ( values.length() == 2 )
5540 prec = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
5541 QString wkt = fGeom.
asWkt( prec );
5542 return QVariant( wkt );
5547 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5548 return fGeom.
isNull() ? QVariant() : QVariant( fGeom.asWkb() );
5553 if ( values.length() != 2 )
5555 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires exactly two parameters. %n given.",
nullptr, values.length() ) );
5559 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5560 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5588 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires two points as arguments." ) );
5595 if ( pt1->
y() < pt2->
y() )
5597 else if ( pt1->
y() > pt2->
y() )
5605 if ( pt1->
x() < pt2->
x() )
5607 else if ( pt1->
x() > pt2->
x() )
5608 return M_PI + ( M_PI_2 );
5613 if ( pt1->
x() < pt2->
x() )
5615 if ( pt1->
y() < pt2->
y() )
5617 return std::atan( std::fabs( pt1->
x() - pt2->
x() ) / std::fabs( pt1->
y() - pt2->
y() ) );
5621 return std::atan( std::fabs( pt1->
y() - pt2->
y() ) / std::fabs( pt1->
x() - pt2->
x() ) )
5628 if ( pt1->
y() > pt2->
y() )
5630 return std::atan( std::fabs( pt1->
x() - pt2->
x() ) / std::fabs( pt1->
y() - pt2->
y() ) )
5635 return std::atan( std::fabs( pt1->
y() - pt2->
y() ) / std::fabs( pt1->
x() - pt2->
x() ) )
5636 + ( M_PI + ( M_PI_2 ) );
5643 const QgsGeometry geom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5644 const QgsGeometry geom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5646 QString ellipsoid = QgsExpressionUtils::getStringValue( values.at( 3 ), parent );
5650 parent->
setEvalErrorString( QObject::tr(
"Function `bearing` requires two valid point geometries." ) );
5658 parent->
setEvalErrorString( QObject::tr(
"Function `bearing` requires point geometries or multi point geometries with a single part." ) );
5672 if ( ellipsoid.isEmpty() )
5674 ellipsoid = context->
variable( QStringLiteral(
"project_ellipsoid" ) ).toString();
5680 parent->
setEvalErrorString( QObject::tr(
"Function `bearing` requires a valid source CRS." ) );
5688 parent->
setEvalErrorString( QObject::tr(
"Function `bearing` requires a valid ellipsoid acronym or ellipsoid authority ID." ) );
5694 const double bearing = da.
bearing( point1, point2 );
5695 if ( std::isfinite( bearing ) )
5697 return std::fmod( bearing + 2 * M_PI, 2 * M_PI );
5710 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5714 parent->
setEvalErrorString( QStringLiteral(
"'project' requires a point geometry" ) );
5718 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5719 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5720 double inclination = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
5723 QgsPoint newPoint = p->
project( distance, 180.0 * azimuth / M_PI, 180.0 * inclination / M_PI );
5730 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5731 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5759 parent->
setEvalErrorString( QStringLiteral(
"Function 'inclination' requires two points as arguments." ) );
5769 if ( values.length() != 3 )
5772 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5773 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5774 double y = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5778 QVariant result = geom.
constGet() ? QVariant::fromValue( geom ) : QVariant();
5784 if ( values.length() < 2 )
5787 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5790 return values.at( 0 );
5792 QString expString = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
5793 QVariant cachedExpression;
5798 if ( cachedExpression.isValid() )
5805 bool asc = values.value( 2 ).toBool();
5823 Q_ASSERT( collection );
5827 QgsExpressionSorter sorter( orderBy );
5829 QList<QgsFeature> partFeatures;
5830 partFeatures.reserve( collection->
partCount() );
5831 for (
int i = 0; i < collection->
partCount(); ++i )
5837 sorter.sortFeatures( partFeatures, unconstedContext );
5841 Q_ASSERT( orderedGeom );
5846 for (
const QgsFeature &feature : std::as_const( partFeatures ) )
5851 QVariant result = QVariant::fromValue(
QgsGeometry( orderedGeom ) );
5854 delete unconstedContext;
5861 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5862 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5866 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5872 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5873 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5877 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5883 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5884 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5888 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5894 const QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5895 const double m = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5896 const bool use3DDistance = values.at( 2 ).toBool();
5898 double x, y, z, distance;
5921 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5924 parent->
setEvalErrorString( QObject::tr(
"line_substring requires a curve geometry input" ) );
5944 double startDistance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5945 double endDistance = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5947 std::unique_ptr< QgsCurve > substring( curve->
curveSubstring( startDistance, endDistance ) );
5949 return !result.isNull() ? QVariant::fromValue( result ) : QVariant();
5954 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5955 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5962 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5963 int vertex = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
5968 vertex = count + vertex;
5976 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5977 int vertex = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
5982 vertex = count + vertex;
5990 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5991 QgsGeometry pointGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5995 return distance >= 0 ? distance : QVariant();
6000 const QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6001 const double m = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
6002 const bool use3DDistance = values.at( 2 ).toBool();
6004 double x, y, z, distance;
6013 return found ? distance : QVariant();
6018 if ( values.length() == 2 && values.at( 1 ).toInt() != 0 )
6020 double number = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
6021 return qgsRound( number, QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
6024 if ( values.length() >= 1 )
6026 double number = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
6027 return QVariant( qlonglong( std::round( number ) ) );
6042 const double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
6043 const int places = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
6044 const QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
6051 const bool omitGroupSeparator = values.value( 3 ).toBool();
6052 const bool trimTrailingZeros = values.value( 4 ).toBool();
6054 QLocale locale = !language.isEmpty() ? QLocale( language ) : QLocale();
6055 if ( !omitGroupSeparator )
6056 locale.setNumberOptions( locale.numberOptions() & ~QLocale::NumberOption::OmitGroupSeparator );
6058 locale.setNumberOptions( locale.numberOptions() | QLocale::NumberOption::OmitGroupSeparator );
6060 QString res = locale.toString( value,
'f', places );
6062 if ( trimTrailingZeros )
6064#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
6065 const QChar decimal = locale.decimalPoint();
6066 const QChar zeroDigit = locale.zeroDigit();
6068 const QChar decimal = locale.decimalPoint().at( 0 );
6069 const QChar zeroDigit = locale.zeroDigit().at( 0 );
6072 if ( res.contains( decimal ) )
6074 int trimPoint = res.length() - 1;
6076 while ( res.at( trimPoint ) == zeroDigit )
6079 if ( res.at( trimPoint ) == decimal )
6082 res.truncate( trimPoint + 1 );
6091 QDateTime datetime = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
6092 const QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
6093 const QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
6096 if ( format.indexOf(
"Z" ) > 0 )
6097 datetime = datetime.toUTC();
6099 QLocale locale = !language.isEmpty() ? QLocale( language ) : QLocale();
6100 return locale.toString( datetime, format );
6105 const QVariant variant = values.at( 0 );
6107 QColor color = QgsExpressionUtils::getColorValue( variant, parent, isQColor );
6108 if ( !color.isValid() )
6111 const float alpha = color.alphaF();
6112 if ( color.spec() == QColor::Spec::Cmyk )
6114 const float avg = ( color.cyanF() + color.magentaF() + color.yellowF() ) / 3;
6115 color = QColor::fromCmykF( avg, avg, avg, color.blackF(), alpha );
6119 const float avg = ( color.redF() + color.greenF() + color.blueF() ) / 3;
6120 color.setRgbF( avg, avg, avg, alpha );
6123 return isQColor ? QVariant( color ) : QVariant(
QgsSymbolLayerUtils::encodeColor( color ) );
6130 double ratio = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
6135 else if ( ratio < 0 )
6140 int red =
static_cast<int>( color1.red() * ( 1 - ratio ) + color2.red() * ratio );
6141 int green =
static_cast<int>( color1.green() * ( 1 - ratio ) + color2.green() * ratio );
6142 int blue =
static_cast<int>( color1.blue() * ( 1 - ratio ) + color2.blue() * ratio );
6143 int alpha =
static_cast<int>( color1.alpha() * ( 1 - ratio ) + color2.alpha() * ratio );
6145 QColor newColor( red, green, blue, alpha );
6152 const QVariant variant1 = values.at( 0 );
6153 const QVariant variant2 = values.at( 1 );
6155 if ( variant1.userType() != variant2.userType() )
6157 parent->
setEvalErrorString( QObject::tr(
"Both color arguments must have the same type (string or color object)" ) );
6162 const QColor color1 = QgsExpressionUtils::getColorValue( variant1, parent, isQColor );
6163 if ( !color1.isValid() )
6166 const QColor color2 = QgsExpressionUtils::getColorValue( variant2, parent, isQColor );
6167 if ( !color2.isValid() )
6170 if ( ( color1.spec() == QColor::Cmyk ) != ( color2.spec() == QColor::Cmyk ) )
6172 parent->
setEvalErrorString( QObject::tr(
"Both color arguments must have compatible color type (CMYK or RGB/HSV/HSL)" ) );
6176 const float ratio =
static_cast<float>( std::clamp( QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ), 0., 1. ) );
6182 const float alpha = color1.alphaF() * ( 1 - ratio ) + color2.alphaF() * ratio;
6183 if ( color1.spec() == QColor::Spec::Cmyk )
6185 float cyan = color1.cyanF() * ( 1 - ratio ) + color2.cyanF() * ratio;
6186 float magenta = color1.magentaF() * ( 1 - ratio ) + color2.magentaF() * ratio;
6187 float yellow = color1.yellowF() * ( 1 - ratio ) + color2.yellowF() * ratio;
6188 float black = color1.blackF() * ( 1 - ratio ) + color2.blackF() * ratio;
6189 newColor = QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
6193 float red = color1.redF() * ( 1 - ratio ) + color2.redF() * ratio;
6194 float green = color1.greenF() * ( 1 - ratio ) + color2.greenF() * ratio;
6195 float blue = color1.blueF() * ( 1 - ratio ) + color2.blueF() * ratio;
6196 newColor = QColor::fromRgbF( red, green, blue, alpha );
6201 return isQColor ? QVariant( newColor ) : QVariant(
QgsSymbolLayerUtils::encodeColor( newColor ) );
6206 int red = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
6207 int green = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
6208 int blue = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
6209 QColor color = QColor( red, green, blue );
6210 if ( ! color.isValid() )
6212 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( red ).arg( green ).arg( blue ) );
6213 color = QColor( 0, 0, 0 );
6216 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
6221 const float red = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) ), 0.f, 1.f );
6222 const float green = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent ) ), 0.f, 1.f );
6223 const float blue = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) ), 0.f, 1.f );
6224 const float alpha = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) ), 0.f, 1.f );
6225 QColor color = QColor::fromRgbF( red, green, blue, alpha );
6226 if ( ! color.isValid() )
6228 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( red ).arg( green ).arg( blue ).arg( alpha ) );
6237 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
6238 QVariant value = node->
eval( parent, context );
6242 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
6244 value = node->
eval( parent, context );
6252 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
6254 QVariant value = node->
eval( parent, context );
6256 if ( value.toBool() )
6258 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
6260 value = node->
eval( parent, context );
6265 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
6267 value = node->
eval( parent, context );
6275 int red = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
6276 int green = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
6277 int blue = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
6278 int alpha = QgsExpressionUtils::getNativeIntValue( values.at( 3 ), parent );
6279 QColor color = QColor( red, green, blue, alpha );
6280 if ( ! color.isValid() )
6282 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( red ).arg( green ).arg( blue ).arg( alpha ) );
6283 color = QColor( 0, 0, 0 );
6292 if ( values.at( 0 ).userType() == qMetaTypeId< QgsGradientColorRamp>() )
6294 expRamp = QgsExpressionUtils::getRamp( values.at( 0 ), parent );
6299 QString rampName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
6303 parent->
setEvalErrorString( QObject::tr(
"\"%1\" is not a valid color ramp" ).arg( rampName ) );
6308 double value = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
6309 QColor color = ramp->
color( value );
6322 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
6324 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
6326 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
6328 QColor color = QColor::fromHslF( hue, saturation, lightness );
6330 if ( ! color.isValid() )
6332 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( lightness ) );
6333 color = QColor( 0, 0, 0 );
6336 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
6342 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
6344 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
6346 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
6348 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
6350 QColor color = QColor::fromHslF( hue, saturation, lightness, alpha );
6351 if ( ! color.isValid() )
6353 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
6354 color = QColor( 0, 0, 0 );
6361 float hue = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) ), 0.f, 1.f );
6362 float saturation = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent ) ), 0.f, 1.f );
6363 float lightness = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) ), 0.f, 1.f );
6364 float alpha = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) ), 0.f, 1.f );
6366 QColor color = QColor::fromHslF( hue, saturation, lightness, alpha );
6367 if ( ! color.isValid() )
6369 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
6379 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
6381 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
6383 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
6385 QColor color = QColor::fromHsvF( hue, saturation, value );
6387 if ( ! color.isValid() )
6389 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( value ) );
6390 color = QColor( 0, 0, 0 );
6393 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
6399 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
6401 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
6403 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
6405 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
6407 QColor color = QColor::fromHsvF( hue, saturation, value, alpha );
6408 if ( ! color.isValid() )
6410 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
6411 color = QColor( 0, 0, 0 );
6418 float hue = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) ), 0.f, 1.f );
6419 float saturation = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent ) ), 0.f, 1.f );
6420 float value = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) ), 0.f, 1.f );
6421 float alpha = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) ), 0.f, 1.f );
6422 QColor color = QColor::fromHsvF( hue, saturation, value, alpha );
6424 if ( ! color.isValid() )
6426 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
6435 const float cyan = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) ), 0.f, 1.f );
6436 const float magenta = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent ) ), 0.f, 1.f );
6437 const float yellow = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) ), 0.f, 1.f );
6438 const float black = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) ), 0.f, 1.f );
6439 const float alpha = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent ) ), 0.f, 1.f );
6441 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
6442 if ( ! color.isValid() )
6444 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
6454 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
6456 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
6458 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
6460 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
6462 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black );
6464 if ( ! color.isValid() )
6466 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ) );
6467 color = QColor( 0, 0, 0 );
6470 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
6476 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
6478 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
6480 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
6482 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
6484 double alpha = QgsExpressionUtils::getIntValue( values.at( 4 ), parent ) / 255.0;
6486 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
6487 if ( ! color.isValid() )
6489 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
6490 color = QColor( 0, 0, 0 );
6497 const QVariant variant = values.at( 0 );
6499 const QColor color = QgsExpressionUtils::getColorValue( variant, parent, isQColor );
6500 if ( !color.isValid() )
6503 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
6504 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
6506 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
6507 return color.green();
6508 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
6509 return color.blue();
6510 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
6511 return color.alpha();
6512 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
6513 return static_cast< double >( color.hsvHueF() * 360 );
6514 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
6515 return static_cast< double >( color.hsvSaturationF() * 100 );
6516 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
6517 return static_cast< double >( color.valueF() * 100 );
6518 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
6519 return static_cast< double >( color.hslHueF() * 360 );
6520 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
6521 return static_cast< double >( color.hslSaturationF() * 100 );
6522 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
6523 return static_cast< double >( color.lightnessF() * 100 );
6524 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
6525 return static_cast< double >( color.cyanF() * 100 );
6526 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
6527 return static_cast< double >( color.magentaF() * 100 );
6528 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
6529 return static_cast< double >( color.yellowF() * 100 );
6530 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
6531 return static_cast< double >( color.blackF() * 100 );
6533 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
6539 const QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
6542 parent->
setEvalErrorString( QObject::tr(
"A minimum of two colors is required to create a ramp" ) );
6546 QList< QColor > colors;
6548 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
6551 if ( !colors.last().isValid() )
6553 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( it.value().toString() ) );
6557 double step = it.key().toDouble();
6558 if ( it == map.constBegin() )
6563 else if ( it == map.constEnd() )
6573 bool discrete = values.at( 1 ).toBool();
6575 if ( colors.empty() )
6578 return QVariant::fromValue(
QgsGradientColorRamp( colors.first(), colors.last(), discrete, stops ) );
6583 const QVariant variant = values.at( 0 );
6585 QColor color = QgsExpressionUtils::getColorValue( variant, parent, isQColor );
6586 if ( !color.isValid() )
6589 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
6590 int value = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
6591 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
6592 color.setRed( std::clamp( value, 0, 255 ) );
6593 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
6594 color.setGreen( std::clamp( value, 0, 255 ) );
6595 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
6596 color.setBlue( std::clamp( value, 0, 255 ) );
6597 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
6598 color.setAlpha( std::clamp( value, 0, 255 ) );
6599 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
6600 color.setHsv( std::clamp( value, 0, 359 ), color.hsvSaturation(), color.value(), color.alpha() );
6601 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
6602 color.setHsvF( color.hsvHueF(), std::clamp( value, 0, 100 ) / 100.0, color.valueF(), color.alphaF() );
6603 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
6604 color.setHsvF( color.hsvHueF(), color.hsvSaturationF(), std::clamp( value, 0, 100 ) / 100.0, color.alphaF() );
6605 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
6606 color.setHsl( std::clamp( value, 0, 359 ), color.hslSaturation(), color.lightness(), color.alpha() );
6607 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
6608 color.setHslF( color.hslHueF(), std::clamp( value, 0, 100 ) / 100.0, color.lightnessF(), color.alphaF() );
6609 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
6610 color.setHslF( color.hslHueF(), color.hslSaturationF(), std::clamp( value, 0, 100 ) / 100.0, color.alphaF() );
6611 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
6612 color.setCmykF( std::clamp( value, 0, 100 ) / 100.0, color.magentaF(), color.yellowF(), color.blackF(), color.alphaF() );
6613 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
6614 color.setCmykF( color.cyanF(), std::clamp( value, 0, 100 ) / 100.0, color.yellowF(), color.blackF(), color.alphaF() );
6615 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
6616 color.setCmykF( color.cyanF(), color.magentaF(), std::clamp( value, 0, 100 ) / 100.0, color.blackF(), color.alphaF() );
6617 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
6618 color.setCmykF( color.cyanF(), color.magentaF(), color.yellowF(), std::clamp( value, 0, 100 ) / 100.0, color.alphaF() );
6621 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
6624 return isQColor ? QVariant( color ) : QVariant(
QgsSymbolLayerUtils::encodeColor( color ) );
6629 const QVariant variant = values.at( 0 );
6631 QColor color = QgsExpressionUtils::getColorValue( variant, parent, isQColor );
6632 if ( !color.isValid() )
6635 color = color.darker( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
6637 return isQColor ? QVariant( color ) : QVariant(
QgsSymbolLayerUtils::encodeColor( color ) );
6642 const QVariant variant = values.at( 0 );
6644 QColor color = QgsExpressionUtils::getColorValue( variant, parent, isQColor );
6645 if ( !color.isValid() )
6648 color = color.lighter( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
6650 return isQColor ? QVariant( color ) : QVariant(
QgsSymbolLayerUtils::encodeColor( color ) );
6655 QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
6658 return QVariant::fromValue( geom );
6664 const QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
6672 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6677 return QVariant::fromValue( fGeom );
6680 return QVariant::fromValue( fGeom );
6689 return QVariant::fromValue( fGeom );
6702 bool foundLayer =
false;
6703 std::unique_ptr<QgsVectorLayerFeatureSource> featureSource = QgsExpressionUtils::getFeatureSource( values.at( 0 ), context, parent, foundLayer );
6706 if ( !featureSource || !foundLayer )
6711 const QgsFeatureId fid = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
6724 result = QVariant::fromValue( fet );
6732 bool foundLayer =
false;
6733 std::unique_ptr<QgsVectorLayerFeatureSource> featureSource = QgsExpressionUtils::getFeatureSource( values.at( 0 ), context, parent, foundLayer );
6736 if ( !featureSource || !foundLayer )
6741 QString cacheValueKey;
6742 if ( values.at( 1 ).userType() == QMetaType::Type::QVariantMap )
6744 QVariantMap attributeMap = QgsExpressionUtils::getMapValue( values.at( 1 ), parent );
6746 QMap <QString, QVariant>::const_iterator i = attributeMap.constBegin();
6747 QString filterString;
6748 for ( ; i != attributeMap.constEnd(); ++i )
6750 if ( !filterString.isEmpty() )
6752 filterString.append(
" AND " );
6756 cacheValueKey = QStringLiteral(
"getfeature:%1:%2" ).arg( featureSource->id(), filterString );
6765 QString attribute = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
6766 int attributeId = featureSource->fields().lookupField( attribute );
6767 if ( attributeId == -1 )
6772 const QVariant &attVal = values.at( 2 );
6774 cacheValueKey = QStringLiteral(
"getfeature:%1:%2:%3" ).arg( featureSource->id(), QString::number( attributeId ), attVal.toString() );
6797 res = QVariant::fromValue( fet );
6812 if ( !values.isEmpty() )
6815 if ( col && ( values.size() == 1 || !values.at( 1 ).isValid() ) )
6816 fieldName = col->
name();
6817 else if ( values.size() == 2 )
6818 fieldName = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
6821 QVariant value = values.at( 0 );
6826 if ( fieldIndex == -1 )
6828 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: Field not found %2" ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
6834 QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), context, parent );
6837 const QString cacheValueKey = QStringLiteral(
"repvalfcnval:%1:%2:%3" ).arg( layer ? layer->id() : QStringLiteral(
"[None]" ), fieldName, value.toString() );
6846 const QString cacheKey = QStringLiteral(
"repvalfcn:%1:%2" ).arg( layer ? layer->id() : QStringLiteral(
"[None]" ), fieldName );
6864 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: function cannot be evaluated without a context." ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
6872 const QVariant data = values.at( 0 );
6873 const QMimeDatabase db;
6874 return db.mimeTypeForData( data.toByteArray() ).name();
6879 const QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
6881 bool foundLayer =
false;
6882 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe( values.at( 0 ), context, parent, [layerProperty](
QgsMapLayer * layer )-> QVariant
6888 if ( QString::compare( layerProperty, QStringLiteral(
"name" ), Qt::CaseInsensitive ) == 0 )
6889 return layer->name();
6890 else if ( QString::compare( layerProperty, QStringLiteral(
"id" ), Qt::CaseInsensitive ) == 0 )
6892 else if ( QString::compare( layerProperty, QStringLiteral(
"title" ), Qt::CaseInsensitive ) == 0 )
6893 return !layer->metadata().title().isEmpty() ? layer->metadata().title() : layer->serverProperties()->title();
6894 else if ( QString::compare( layerProperty, QStringLiteral(
"abstract" ), Qt::CaseInsensitive ) == 0 )
6895 return !layer->metadata().abstract().isEmpty() ? layer->metadata().abstract() : layer->serverProperties()->abstract();
6896 else if ( QString::compare( layerProperty, QStringLiteral(
"keywords" ), Qt::CaseInsensitive ) == 0 )
6898 QStringList keywords;
6899 const QgsAbstractMetadataBase::KeywordMap keywordMap = layer->metadata().keywords();
6900 for ( auto it = keywordMap.constBegin(); it != keywordMap.constEnd(); ++it )
6902 keywords.append( it.value() );
6904 if ( !keywords.isEmpty() )
6906 return layer->serverProperties()->keywordList();
6908 else if ( QString::compare( layerProperty, QStringLiteral(
"data_url" ), Qt::CaseInsensitive ) == 0 )
6910 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution" ), Qt::CaseInsensitive ) == 0 )
6912 return !layer->
metadata().
rights().isEmpty() ? QVariant( layer->
metadata().
rights() ) : QVariant( layer->serverProperties()->attribution() );
6914 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution_url" ), Qt::CaseInsensitive ) == 0 )
6916 else if ( QString::compare( layerProperty, QStringLiteral(
"source" ), Qt::CaseInsensitive ) == 0 )
6918 else if ( QString::compare( layerProperty, QStringLiteral(
"min_scale" ), Qt::CaseInsensitive ) == 0 )
6920 else if ( QString::compare( layerProperty, QStringLiteral(
"max_scale" ), Qt::CaseInsensitive ) == 0 )
6922 else if ( QString::compare( layerProperty, QStringLiteral(
"is_editable" ), Qt::CaseInsensitive ) == 0 )
6924 else if ( QString::compare( layerProperty, QStringLiteral(
"crs" ), Qt::CaseInsensitive ) == 0 )
6926 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_definition" ), Qt::CaseInsensitive ) == 0 )
6928 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_description" ), Qt::CaseInsensitive ) == 0 )
6930 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_ellipsoid" ), Qt::CaseInsensitive ) == 0 )
6932 else if ( QString::compare( layerProperty, QStringLiteral(
"extent" ), Qt::CaseInsensitive ) == 0 )
6935 QVariant result = QVariant::fromValue( extentGeom );
6938 else if ( QString::compare( layerProperty, QStringLiteral(
"distance_units" ), Qt::CaseInsensitive ) == 0 )
6940 else if ( QString::compare( layerProperty, QStringLiteral(
"path" ), Qt::CaseInsensitive ) == 0 )
6943 return decodedUri.value( QStringLiteral(
"path" ) );
6945 else if ( QString::compare( layerProperty, QStringLiteral(
"type" ), Qt::CaseInsensitive ) == 0 )
6947 switch ( layer->
type() )
6950 return QCoreApplication::translate(
"expressions",
"Vector" );
6952 return QCoreApplication::translate(
"expressions",
"Raster" );
6954 return QCoreApplication::translate(
"expressions",
"Mesh" );
6956 return QCoreApplication::translate(
"expressions",
"Vector Tile" );
6958 return QCoreApplication::translate(
"expressions",
"Plugin" );
6960 return QCoreApplication::translate(
"expressions",
"Annotation" );
6962 return QCoreApplication::translate(
"expressions",
"Point Cloud" );
6964 return QCoreApplication::translate(
"expressions",
"Group" );
6966 return QCoreApplication::translate(
"expressions",
"Tiled Scene" );
6972 QgsVectorLayer *vLayer = qobject_cast< QgsVectorLayer * >( layer );
6975 if ( QString::compare( layerProperty, QStringLiteral(
"storage_type" ), Qt::CaseInsensitive ) == 0 )
6977 else if ( QString::compare( layerProperty, QStringLiteral(
"geometry_type" ), Qt::CaseInsensitive ) == 0 )
6979 else if ( QString::compare( layerProperty, QStringLiteral(
"feature_count" ), Qt::CaseInsensitive ) == 0 )
6995 const QString uriPart = values.at( 1 ).toString();
6997 bool foundLayer =
false;
6999 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe( values.at( 0 ), context, parent, [parent, uriPart](
QgsMapLayer * layer )-> QVariant
7001 if ( !layer->dataProvider() )
7003 parent->setEvalErrorString( QObject::tr(
"Layer %1 has invalid data provider" ).arg( layer->name() ) );
7009 if ( !uriPart.isNull() )
7011 return decodedUri.value( uriPart );
7021 parent->
setEvalErrorString( QObject::tr(
"Function `decode_uri` requires a valid layer." ) );
7032 const int band = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
7033 const QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
7035 bool foundLayer =
false;
7036 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe( values.at( 0 ), context, parent, [parent, band, layerProperty](
QgsMapLayer * layer )-> QVariant
7038 QgsRasterLayer *rl = qobject_cast< QgsRasterLayer * >( layer );
7042 if ( band < 1 || band > rl->bandCount() )
7044 parent->setEvalErrorString( QObject::tr(
"Invalid band number %1 for layer" ).arg( band ) );
7050 if ( QString::compare( layerProperty, QStringLiteral(
"avg" ), Qt::CaseInsensitive ) == 0 )
7052 else if ( QString::compare( layerProperty, QStringLiteral(
"stdev" ), Qt::CaseInsensitive ) == 0 )
7054 else if ( QString::compare( layerProperty, QStringLiteral(
"min" ), Qt::CaseInsensitive ) == 0 )
7056 else if ( QString::compare( layerProperty, QStringLiteral(
"max" ), Qt::CaseInsensitive ) == 0 )
7058 else if ( QString::compare( layerProperty, QStringLiteral(
"range" ), Qt::CaseInsensitive ) == 0 )
7060 else if ( QString::compare( layerProperty, QStringLiteral(
"sum" ), Qt::CaseInsensitive ) == 0 )
7064 parent->
setEvalErrorString( QObject::tr(
"Invalid raster statistic: '%1'" ).arg( layerProperty ) );
7092 parent->
setEvalErrorString( QObject::tr(
"Function `raster_statistic` requires a valid raster layer." ) );
7109 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7110 bool ascending = values.value( 1 ).toBool();
7111 std::sort( list.begin(), list.end(), [ascending]( QVariant a, QVariant b ) ->
bool { return ( !ascending ? qgsVariantLessThan( b, a ) : qgsVariantLessThan( a, b ) ); } );
7117 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).length();
7122 return QVariant( QgsExpressionUtils::getListValue( values.at( 0 ), parent ).contains( values.at( 1 ) ) );
7127 return QVariant( QgsExpressionUtils::getListValue( values.at( 0 ), parent ).count( values.at( 1 ) ) );
7132 QVariantList listA = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7133 QVariantList listB = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
7135 for (
const auto &item : listB )
7137 if ( listA.contains( item ) )
7141 return QVariant( match == listB.count() );
7146 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).indexOf( values.at( 1 ) );
7151 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7152 const int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
7153 if ( pos < list.length() && pos >= 0 )
return list.at( pos );
7154 else if ( pos < 0 && ( list.length() + pos ) >= 0 )
7155 return list.at( list.length() + pos );
7161 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7162 return list.value( 0 );
7167 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7168 return list.value( list.size() - 1 );
7173 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7174 return list.isEmpty() ? QVariant() : *std::min_element( list.constBegin(), list.constEnd(), []( QVariant a, QVariant b ) -> bool { return (
qgsVariantLessThan( a, b ) ); } );
7179 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7180 return list.isEmpty() ? QVariant() : *std::max_element( list.constBegin(), list.constEnd(), []( QVariant a, QVariant b ) -> bool { return (
qgsVariantLessThan( a, b ) ); } );
7185 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7188 for (
const QVariant &item : list )
7190 switch ( item.userType() )
7192 case QMetaType::Int:
7193 case QMetaType::UInt:
7194 case QMetaType::LongLong:
7195 case QMetaType::ULongLong:
7196 case QMetaType::Float:
7197 case QMetaType::Double:
7198 total += item.toDouble();
7203 return i == 0 ? QVariant() : total / i;
7208 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7209 QVariantList numbers;
7210 for (
const auto &item : list )
7212 switch ( item.userType() )
7214 case QMetaType::Int:
7215 case QMetaType::UInt:
7216 case QMetaType::LongLong:
7217 case QMetaType::ULongLong:
7218 case QMetaType::Float:
7219 case QMetaType::Double:
7220 numbers.append( item );
7224 std::sort( numbers.begin(), numbers.end(), []( QVariant a, QVariant b ) ->
bool { return ( qgsVariantLessThan( a, b ) ); } );
7225 const int count = numbers.count();
7230 else if ( count % 2 )
7232 return numbers.at( count / 2 );
7236 return ( numbers.at( count / 2 - 1 ).toDouble() + numbers.at( count / 2 ).toDouble() ) / 2;
7242 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7245 for (
const QVariant &item : list )
7247 switch ( item.userType() )
7249 case QMetaType::Int:
7250 case QMetaType::UInt:
7251 case QMetaType::LongLong:
7252 case QMetaType::ULongLong:
7253 case QMetaType::Float:
7254 case QMetaType::Double:
7255 total += item.toDouble();
7260 return i == 0 ? QVariant() : total;
7263static QVariant convertToSameType(
const QVariant &value, QMetaType::Type type )
7265 QVariant result = value;
7266 result.convert(
static_cast<int>( type ) );
7272 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7273 QHash< QVariant, int > hash;
7274 for (
const auto &item : list )
7278 const QList< int > occurrences = hash.values();
7279 if ( occurrences.empty() )
7280 return QVariantList();
7282 const int maxValue = *std::max_element( occurrences.constBegin(), occurrences.constEnd() );
7284 const QString option = values.at( 1 ).toString();
7285 if ( option.compare( QLatin1String(
"all" ), Qt::CaseInsensitive ) == 0 )
7287 return convertToSameType( hash.keys( maxValue ),
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7289 else if ( option.compare( QLatin1String(
"any" ), Qt::CaseInsensitive ) == 0 )
7291 if ( hash.isEmpty() )
7294 return QVariant( hash.key( maxValue ) );
7296 else if ( option.compare( QLatin1String(
"median" ), Qt::CaseInsensitive ) == 0 )
7298 return fcnArrayMedian( QVariantList() << convertToSameType( hash.keys( maxValue ),
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) ), context, parent, node );
7300 else if ( option.compare( QLatin1String(
"real_majority" ), Qt::CaseInsensitive ) == 0 )
7302 if ( maxValue * 2 <= list.size() )
7305 return QVariant( hash.key( maxValue ) );
7316 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7317 QHash< QVariant, int > hash;
7318 for (
const auto &item : list )
7322 const QList< int > occurrences = hash.values();
7323 if ( occurrences.empty() )
7324 return QVariantList();
7326 const int minValue = *std::min_element( occurrences.constBegin(), occurrences.constEnd() );
7328 const QString option = values.at( 1 ).toString();
7329 if ( option.compare( QLatin1String(
"all" ), Qt::CaseInsensitive ) == 0 )
7331 return convertToSameType( hash.keys( minValue ),
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7333 else if ( option.compare( QLatin1String(
"any" ), Qt::CaseInsensitive ) == 0 )
7335 if ( hash.isEmpty() )
7338 return QVariant( hash.key( minValue ) );
7340 else if ( option.compare( QLatin1String(
"median" ), Qt::CaseInsensitive ) == 0 )
7342 return fcnArrayMedian( QVariantList() << convertToSameType( hash.keys( minValue ),
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) ), context, parent, node );
7344 else if ( option.compare( QLatin1String(
"real_minority" ), Qt::CaseInsensitive ) == 0 )
7346 if ( hash.isEmpty() )
7350 const int maxValue = *std::max_element( occurrences.constBegin(), occurrences.constEnd() );
7351 if ( maxValue * 2 > list.size() )
7352 hash.remove( hash.key( maxValue ) );
7354 return convertToSameType( hash.keys(),
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7365 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7366 list.append( values.at( 1 ) );
7367 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7372 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7373 list.prepend( values.at( 1 ) );
7374 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7379 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7380 list.insert( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), values.at( 2 ) );
7381 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7386 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7387 int position = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
7389 position = position + list.length();
7390 if ( position >= 0 && position < list.length() )
7391 list.removeAt( position );
7392 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7400 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7402 const QVariant toRemove = values.at( 1 );
7405 list.erase( std::remove_if( list.begin(), list.end(), [](
const QVariant & element )
7407 return QgsVariantUtils::isNull( element );
7412 list.removeAll( toRemove );
7414 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7419 if ( values.count() == 2 && values.at( 1 ).userType() == QMetaType::Type::QVariantMap )
7421 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 1 ), parent );
7423 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7424 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
7426 int index = list.indexOf( it.key() );
7427 while ( index >= 0 )
7429 list.replace( index, it.value() );
7430 index = list.indexOf( it.key() );
7434 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7436 else if ( values.count() == 3 )
7438 QVariantList before;
7440 bool isSingleReplacement =
false;
7442 if ( !QgsExpressionUtils::isList( values.at( 1 ) ) && values.at( 2 ).userType() != QMetaType::Type::QStringList )
7444 before = QVariantList() << values.at( 1 );
7448 before = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
7451 if ( !QgsExpressionUtils::isList( values.at( 2 ) ) )
7453 after = QVariantList() << values.at( 2 );
7454 isSingleReplacement =
true;
7458 after = QgsExpressionUtils::getListValue( values.at( 2 ), parent );
7461 if ( !isSingleReplacement && before.length() != after.length() )
7463 parent->
setEvalErrorString( QObject::tr(
"Invalid pair of array, length not identical" ) );
7467 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7468 for (
int i = 0; i < before.length(); i++ )
7470 int index = list.indexOf( before.at( i ) );
7471 while ( index >= 0 )
7473 list.replace( index, after.at( isSingleReplacement ? 0 : i ) );
7474 index = list.indexOf( before.at( i ) );
7478 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7482 parent->
setEvalErrorString( QObject::tr(
"Function array_replace requires 2 or 3 arguments" ) );
7489 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7490 QVariantList list_new;
7492 for (
const QVariant &cur : QgsExpressionUtils::getListValue( values.at( 1 ), parent ) )
7494 while ( list.removeOne( cur ) )
7496 list_new.append( cur );
7500 list_new.append( list );
7502 return convertToSameType( list_new,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7508 for (
const QVariant &cur : values )
7510 list += QgsExpressionUtils::getListValue( cur, parent );
7512 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7517 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7518 int start_pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
7519 const int end_pos = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
7520 int slice_length = 0;
7522 if ( start_pos < 0 )
7524 start_pos = list.length() + start_pos;
7528 slice_length = end_pos - start_pos + 1;
7532 slice_length = list.length() + end_pos - start_pos + 1;
7535 if ( slice_length < 0 )
7539 list = list.mid( start_pos, slice_length );
7545 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7546 std::reverse( list.begin(), list.end() );
7552 const QVariantList array1 = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7553 const QVariantList array2 = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
7554 for (
const QVariant &cur : array2 )
7556 if ( array1.contains( cur ) )
7557 return QVariant(
true );
7559 return QVariant(
false );
7564 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7566 QVariantList distinct;
7568 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
7570 if ( !distinct.contains( *it ) )
7572 distinct += ( *it );
7581 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7582 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
7583 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
7587 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
7589 str += ( !( *it ).toString().isEmpty() ) ? ( *it ).toString() : empty;
7590 if ( it != ( array.constEnd() - 1 ) )
7596 return QVariant( str );
7601 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
7602 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
7603 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
7605 QStringList list = str.split( delimiter );
7608 for ( QStringList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
7610 array += ( !( *it ).isEmpty() ) ? *it : empty;
7618 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
7619 QJsonDocument document = QJsonDocument::fromJson( str.toUtf8() );
7620 if ( document.isNull() )
7623 return document.toVariant();
7629 QJsonDocument document = QJsonDocument::fromVariant( values.at( 0 ) );
7630 return QString( document.toJson( QJsonDocument::Compact ) );
7635 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
7636 if ( str.isEmpty() )
7637 return QVariantMap();
7638 str = str.trimmed();
7645 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
7652 for (
int i = 0; i + 1 < values.length(); i += 2 )
7654 result.insert( QgsExpressionUtils::getStringValue( values.at( i ), parent ), values.at( i + 1 ) );
7661 const QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
7662 const QString prefix = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
7663 QVariantMap resultMap;
7665 for (
auto it = map.cbegin(); it != map.cend(); it++ )
7667 resultMap.insert( QString( it.key() ).prepend( prefix ), it.value() );
7675 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).value( values.at( 1 ).toString() );
7680 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).contains( values.at( 1 ).toString() );
7685 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
7686 map.remove( values.at( 1 ).toString() );
7692 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
7693 map.insert( values.at( 1 ).toString(), values.at( 2 ) );
7700 for (
const QVariant &cur : values )
7702 const QVariantMap curMap = QgsExpressionUtils::getMapValue( cur, parent );
7703 for ( QVariantMap::const_iterator it = curMap.constBegin(); it != curMap.constEnd(); ++it )
7704 result.insert( it.key(), it.value() );
7711 return QStringList( QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).keys() );
7716 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).values();
7721 const QString envVarName = values.at( 0 ).toString();
7722 if ( !QProcessEnvironment::systemEnvironment().contains( envVarName ) )
7725 return QProcessEnvironment::systemEnvironment().value( envVarName );
7730 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
7733 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg( QLatin1String(
"base_file_name" ) ) );
7736 return QFileInfo( file ).completeBaseName();
7741 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
7744 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg( QLatin1String(
"file_suffix" ) ) );
7747 return QFileInfo( file ).completeSuffix();
7752 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
7755 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg( QLatin1String(
"file_exists" ) ) );
7758 return QFileInfo::exists( file );
7763 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
7766 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg( QLatin1String(
"file_name" ) ) );
7769 return QFileInfo( file ).fileName();
7774 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
7777 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg( QLatin1String(
"is_file" ) ) );
7780 return QFileInfo( file ).isFile();
7785 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
7788 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg( QLatin1String(
"is_directory" ) ) );
7791 return QFileInfo( file ).isDir();
7796 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
7799 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg( QLatin1String(
"file_path" ) ) );
7802 return QDir::toNativeSeparators( QFileInfo( file ).path() );
7807 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
7810 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg( QLatin1String(
"file_size" ) ) );
7813 return QFileInfo( file ).size();
7816static QVariant fcnHash(
const QString &str,
const QCryptographicHash::Algorithm
algorithm )
7818 return QString( QCryptographicHash::hash( str.toUtf8(),
algorithm ).toHex() );
7824 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
7825 QString method = QgsExpressionUtils::getStringValue( values.at( 1 ), parent ).toLower();
7827 if ( method == QLatin1String(
"md4" ) )
7829 hash = fcnHash( str, QCryptographicHash::Md4 );
7831 else if ( method == QLatin1String(
"md5" ) )
7833 hash = fcnHash( str, QCryptographicHash::Md5 );
7835 else if ( method == QLatin1String(
"sha1" ) )
7837 hash = fcnHash( str, QCryptographicHash::Sha1 );
7839 else if ( method == QLatin1String(
"sha224" ) )
7841 hash = fcnHash( str, QCryptographicHash::Sha224 );
7843 else if ( method == QLatin1String(
"sha256" ) )
7845 hash = fcnHash( str, QCryptographicHash::Sha256 );
7847 else if ( method == QLatin1String(
"sha384" ) )
7849 hash = fcnHash( str, QCryptographicHash::Sha384 );
7851 else if ( method == QLatin1String(
"sha512" ) )
7853 hash = fcnHash( str, QCryptographicHash::Sha512 );
7855 else if ( method == QLatin1String(
"sha3_224" ) )
7857 hash = fcnHash( str, QCryptographicHash::Sha3_224 );
7859 else if ( method == QLatin1String(
"sha3_256" ) )
7861 hash = fcnHash( str, QCryptographicHash::Sha3_256 );
7863 else if ( method == QLatin1String(
"sha3_384" ) )
7865 hash = fcnHash( str, QCryptographicHash::Sha3_384 );
7867 else if ( method == QLatin1String(
"sha3_512" ) )
7869 hash = fcnHash( str, QCryptographicHash::Sha3_512 );
7871 else if ( method == QLatin1String(
"keccak_224" ) )
7873 hash = fcnHash( str, QCryptographicHash::Keccak_224 );
7875 else if ( method == QLatin1String(
"keccak_256" ) )
7877 hash = fcnHash( str, QCryptographicHash::Keccak_256 );
7879 else if ( method == QLatin1String(
"keccak_384" ) )
7881 hash = fcnHash( str, QCryptographicHash::Keccak_384 );
7883 else if ( method == QLatin1String(
"keccak_512" ) )
7885 hash = fcnHash( str, QCryptographicHash::Keccak_512 );
7889 parent->
setEvalErrorString( QObject::tr(
"Hash method %1 is not available on this system." ).arg( str ) );
7896 return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Md5 );
7901 return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Sha256 );
7906 const QByteArray input = values.at( 0 ).toByteArray();
7907 return QVariant( QString( input.toBase64() ) );
7912 const QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
7914 for (
auto it = map.cbegin(); it != map.cend(); it++ )
7916 query.addQueryItem( it.key(), it.value().toString() );
7918 return query.toString( QUrl::ComponentFormattingOption::FullyEncoded );
7923 const QString value = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
7924 const QByteArray base64 = value.toLocal8Bit();
7925 const QByteArray decoded = QByteArray::fromBase64( base64 );
7926 return QVariant( decoded );
7931static QVariant executeGeomOverlay(
const QVariantList &values,
const QgsExpressionContext *context,
QgsExpression *parent,
const RelationFunction &relationFunction,
bool invert =
false,
double bboxGrow = 0,
bool isNearestFunc =
false,
bool isIntersectsFunc =
false )
7936 parent->
setEvalErrorString( QStringLiteral(
"This function was called without an expression context." ) );
7940 const QVariant sourceLayerRef = context->
variable( QStringLiteral(
"layer" ) );
7943 QgsVectorLayer *sourceLayer = QgsExpressionUtils::getVectorLayer( sourceLayerRef, context, parent );
7952 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
7955 const bool layerCanBeCached = node->
isStatic( parent, context );
7956 QVariant targetLayerValue = node->
eval( parent, context );
7960 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
7962 QString subExpString = node->dump();
7964 bool testOnly = ( subExpString ==
"NULL" );
7967 QgsVectorLayer *targetLayer = QgsExpressionUtils::getVectorLayer( targetLayerValue, context, parent );
7971 parent->
setEvalErrorString( QObject::tr(
"Layer '%1' could not be loaded." ).arg( targetLayerValue.toString() ) );
7976 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
7978 QString filterString = node->dump();
7979 if ( filterString !=
"NULL" )
7981 request.setFilterExpression( filterString );
7985 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
7987 QVariant limitValue = node->eval( parent, context );
7989 qlonglong limit = QgsExpressionUtils::getIntValue( limitValue, parent );
7992 double max_distance = 0;
7993 if ( isNearestFunc )
7995 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
7997 QVariant distanceValue = node->eval( parent, context );
7999 max_distance = QgsExpressionUtils::getDoubleValue( distanceValue, parent );
8003 node = QgsExpressionUtils::getNode( values.at( isNearestFunc ? 5 : 4 ), parent );
8005 QVariant cacheValue = node->eval( parent, context );
8007 bool cacheEnabled = cacheValue.toBool();
8013 double minOverlap { -1 };
8014 double minInscribedCircleRadius { -1 };
8015 bool returnDetails =
false;
8016 bool sortByMeasure =
false;
8017 bool sortAscending =
false;
8018 bool requireMeasures =
false;
8019 bool overlapOrRadiusFilter =
false;
8020 if ( isIntersectsFunc )
8023 node = QgsExpressionUtils::getNode( values.at( 5 ), parent );
8025 const QVariant minOverlapValue = node->eval( parent, context );
8027 minOverlap = QgsExpressionUtils::getDoubleValue( minOverlapValue, parent );
8028 node = QgsExpressionUtils::getNode( values.at( 6 ), parent );
8030 const QVariant minInscribedCircleRadiusValue = node->eval( parent, context );
8032 minInscribedCircleRadius = QgsExpressionUtils::getDoubleValue( minInscribedCircleRadiusValue, parent );
8033 node = QgsExpressionUtils::getNode( values.at( 7 ), parent );
8035 returnDetails = !testOnly && node->eval( parent, context ).toBool();
8036 node = QgsExpressionUtils::getNode( values.at( 8 ), parent );
8038 const QString sorting { node->eval( parent, context ).toString().toLower() };
8039 sortByMeasure = !testOnly && ( sorting.startsWith(
"asc" ) || sorting.startsWith(
"des" ) );
8040 sortAscending = sorting.startsWith(
"asc" );
8041 requireMeasures = sortByMeasure || returnDetails;
8042 overlapOrRadiusFilter = minInscribedCircleRadius != -1 || minOverlap != -1;
8049 if ( sourceLayer && targetLayer->crs() != sourceLayer->crs() )
8052 request.setDestinationCrs( sourceLayer->crs(), TransformContext );
8055 bool sameLayers = ( sourceLayer && sourceLayer->id() == targetLayer->id() );
8058 if ( bboxGrow != 0 )
8060 intDomain.
grow( bboxGrow );
8063 const QString cacheBase { QStringLiteral(
"%1:%2:%3" ).arg( targetLayer->id(), subExpString, filterString ) };
8069 QList<QgsFeature> features;
8070 if ( isNearestFunc || ( layerCanBeCached && cacheEnabled ) )
8074 const QString cacheLayer { QStringLiteral(
"ovrlaylyr:%1" ).arg( cacheBase ) };
8075 const QString cacheIndex { QStringLiteral(
"ovrlayidx:%1" ).arg( cacheBase ) };
8079 cachedTarget = targetLayer->
materialize( request );
8080 if ( layerCanBeCached )
8081 context->
setCachedValue( cacheLayer, QVariant::fromValue( cachedTarget ) );
8091 if ( layerCanBeCached )
8092 context->
setCachedValue( cacheIndex, QVariant::fromValue( spatialIndex ) );
8099 QList<QgsFeatureId> fidsList;
8100 if ( isNearestFunc )
8102 fidsList = spatialIndex.
nearestNeighbor( geometry, sameLayers ? limit + 1 : limit, max_distance );
8106 fidsList = spatialIndex.
intersects( intDomain );
8109 QListIterator<QgsFeatureId> i( fidsList );
8110 while ( i.hasNext() )
8113 if ( sameLayers && feat.
id() == fId2 )
8115 features.append( cachedTarget->
getFeature( fId2 ) );
8123 request.setFilterRect( intDomain );
8128 if ( sameLayers && feat.
id() == feat2.
id() )
8130 features.append( feat2 );
8138 const QString expCacheKey { QStringLiteral(
"exp:%1" ).arg( cacheBase ) };
8139 const QString ctxCacheKey { QStringLiteral(
"ctx:%1" ).arg( cacheBase ) };
8145 subExpression.
prepare( &subContext );
8158 auto testLinestring = [minOverlap, requireMeasures](
const QgsGeometry intersection,
double & overlapValue ) ->
bool
8160 bool testResult {
false };
8162 QVector<double> overlapValues;
8163 const QgsGeometry merged { intersection.mergeLines() };
8168 if ( minOverlap != -1 || requireMeasures )
8170 overlapValue = geom->
length();
8171 overlapValues.append( overlapValue );
8172 if ( minOverlap != -1 )
8174 if ( overlapValue >= minOverlap )
8186 if ( ! overlapValues.isEmpty() )
8188 overlapValue = *std::max_element( overlapValues.cbegin(), overlapValues.cend() );
8195 auto testPolygon = [minOverlap, requireMeasures, minInscribedCircleRadius](
const QgsGeometry intersection,
double & radiusValue,
double & overlapValue ) ->
bool
8198 bool testResult {
false };
8200 QVector<double> overlapValues;
8201 QVector<double> radiusValues;
8202 for (
auto it = intersection.const_parts_begin(); ( ! testResult || requireMeasures ) && it != intersection.const_parts_end(); ++it )
8206 if ( minOverlap != -1 || requireMeasures )
8208 overlapValue = geom->
area();
8209 overlapValues.append( geom->
area() );
8210 if ( minOverlap != - 1 )
8212 if ( overlapValue >= minOverlap )
8224 if ( minInscribedCircleRadius != -1 || requireMeasures )
8227 const double width = bbox.
width();
8228 const double height = bbox.
height();
8229 const double size = width > height ? width : height;
8230 const double tolerance = size / 100.0;
8232 testResult = radiusValue >= minInscribedCircleRadius;
8233 radiusValues.append( radiusValues );
8238 if ( !radiusValues.isEmpty() )
8240 radiusValue = *std::max_element( radiusValues.cbegin(), radiusValues.cend() );
8243 if ( ! overlapValues.isEmpty() )
8245 overlapValue = *std::max_element( overlapValues.cbegin(), overlapValues.cend() );
8255 QVariantList results;
8257 QListIterator<QgsFeature> i( features );
8258 while ( i.hasNext() && ( sortByMeasure || limit == -1 || foundCount < limit ) )
8264 if ( ! relationFunction || ( geometry.*relationFunction )( feat2.
geometry() ) )
8267 double overlapValue = -1;
8268 double radiusValue = -1;
8270 if ( isIntersectsFunc && ( requireMeasures || overlapOrRadiusFilter ) )
8283 for (
const auto &geom : std::as_const( geometries ) )
8285 switch ( geom.type() )
8289 poly.append( geom.asPolygon() );
8294 line.append( geom.asPolyline() );
8299 point.append( geom.asPoint() );
8310 switch ( geometry.
type() )
8338 switch ( intersection.
type() )
8345 bool testResult { testPolygon( intersection, radiusValue, overlapValue ) };
8347 if ( ! testResult && overlapOrRadiusFilter )
8360 if ( minInscribedCircleRadius != -1 )
8366 const bool testResult { testLinestring( intersection, overlapValue ) };
8368 if ( ! testResult && overlapOrRadiusFilter )
8381 if ( minInscribedCircleRadius != -1 )
8386 bool testResult {
false };
8387 if ( minOverlap != -1 || requireMeasures )
8407 testResult = testLinestring( feat2.
geometry(), overlapValue );
8412 testResult = testPolygon( feat2.
geometry(), radiusValue, overlapValue );
8418 if ( ! testResult && overlapOrRadiusFilter )
8446 const QVariant expResult = subExpression.
evaluate( &subContext );
8448 if ( requireMeasures )
8450 QVariantMap resultRecord;
8451 resultRecord.insert( QStringLiteral(
"id" ), feat2.
id() );
8452 resultRecord.insert( QStringLiteral(
"result" ), expResult );
8454 resultRecord.insert( QStringLiteral(
"overlap" ), overlapValue );
8456 if ( radiusValue != -1 )
8458 resultRecord.insert( QStringLiteral(
"radius" ), radiusValue );
8460 results.append( resultRecord );
8464 results.append( expResult );
8470 results.append( feat2.
id() );
8484 if ( requireMeasures )
8486 if ( sortByMeasure )
8488 std::sort( results.begin(), results.end(), [ sortAscending ](
const QVariant & recordA,
const QVariant & recordB ) ->
bool
8490 return sortAscending ?
8491 recordB.toMap().value( QStringLiteral(
"overlap" ) ).toDouble() > recordA.toMap().value( QStringLiteral(
"overlap" ) ).toDouble()
8492 : recordA.toMap().value( QStringLiteral(
"overlap" ) ).toDouble() > recordB.toMap().value( QStringLiteral(
"overlap" ) ).toDouble();
8496 if ( limit > 0 && results.size() > limit )
8498 results.erase( results.begin() + limit );
8501 if ( ! returnDetails )
8503 QVariantList expResults;
8504 for (
auto it = results.constBegin(); it != results.constEnd(); ++it )
8506 expResults.append( it->toMap().value( QStringLiteral(
"result" ) ) );
8516 QVariantList disjoint_results;
8525 if ( !results.contains( feat2.
id() ) )
8528 disjoint_results.append( subExpression.
evaluate( &subContext ) );
8531 return disjoint_results;
8574 return executeGeomOverlay( values, context, parent,
nullptr,
false, 0,
true );
8583 QMutexLocker locker( &sFunctionsMutex );
8585 QList<QgsExpressionFunction *> &functions = *sFunctions();
8587 if ( functions.isEmpty() )
8590 << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ) )
8591 << QgsExpressionFunction::Parameter( QStringLiteral(
"group_by" ),
true )
8592 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter" ),
true );
8595 aggParamsConcat << QgsExpressionFunction::Parameter( QStringLiteral(
"concatenator" ),
true )
8596 << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true );
8599 aggParamsArray << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true );
8602 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sqrt" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnSqrt, QStringLiteral(
"Math" ) )
8603 <<
new QgsStaticExpressionFunction( QStringLiteral(
"radians" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"degrees" ) ), fcnRadians, QStringLiteral(
"Math" ) )
8604 <<
new QgsStaticExpressionFunction( QStringLiteral(
"degrees" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"radians" ) ), fcnDegrees, QStringLiteral(
"Math" ) )
8605 <<
new QgsStaticExpressionFunction( QStringLiteral(
"azimuth" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point_b" ) ), fcnAzimuth, QStringLiteral(
"GeometryGroup" ) )
8606 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bearing" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point_b" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"source_crs" ),
true, QVariant() ) << QgsExpressionFunction::Parameter( QStringLiteral(
"ellipsoid" ),
true, QVariant() ), fcnBearing, QStringLiteral(
"GeometryGroup" ) )
8607 <<
new QgsStaticExpressionFunction( QStringLiteral(
"inclination" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point_b" ) ), fcnInclination, QStringLiteral(
"GeometryGroup" ) )
8608 <<
new QgsStaticExpressionFunction( QStringLiteral(
"project" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"point" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"azimuth" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"elevation" ),
true, M_PI_2 ), fcnProject, QStringLiteral(
"GeometryGroup" ) )
8609 <<
new QgsStaticExpressionFunction( QStringLiteral(
"abs" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnAbs, QStringLiteral(
"Math" ) )
8610 <<
new QgsStaticExpressionFunction( QStringLiteral(
"cos" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"angle" ) ), fcnCos, QStringLiteral(
"Math" ) )
8611 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sin" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"angle" ) ), fcnSin, QStringLiteral(
"Math" ) )
8612 <<
new QgsStaticExpressionFunction( QStringLiteral(
"tan" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"angle" ) ), fcnTan, QStringLiteral(
"Math" ) )
8613 <<
new QgsStaticExpressionFunction( QStringLiteral(
"asin" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnAsin, QStringLiteral(
"Math" ) )
8614 <<
new QgsStaticExpressionFunction( QStringLiteral(
"acos" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnAcos, QStringLiteral(
"Math" ) )
8615 <<
new QgsStaticExpressionFunction( QStringLiteral(
"atan" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnAtan, QStringLiteral(
"Math" ) )
8616 <<
new QgsStaticExpressionFunction( QStringLiteral(
"atan2" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"dx" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"dy" ) ), fcnAtan2, QStringLiteral(
"Math" ) )
8617 <<
new QgsStaticExpressionFunction( QStringLiteral(
"exp" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnExp, QStringLiteral(
"Math" ) )
8618 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ln" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnLn, QStringLiteral(
"Math" ) )
8619 <<
new QgsStaticExpressionFunction( QStringLiteral(
"log10" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnLog10, QStringLiteral(
"Math" ) )
8620 <<
new QgsStaticExpressionFunction( QStringLiteral(
"log" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"base" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnLog, QStringLiteral(
"Math" ) )
8621 <<
new QgsStaticExpressionFunction( QStringLiteral(
"round" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"places" ),
true, 0 ), fcnRound, QStringLiteral(
"Math" ) );
8623 QgsStaticExpressionFunction *randFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"rand" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"max" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"seed" ),
true ), fcnRnd, QStringLiteral(
"Math" ) );
8625 functions << randFunc;
8627 QgsStaticExpressionFunction *randfFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"randf" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"min" ),
true, 0.0 ) << QgsExpressionFunction::Parameter( QStringLiteral(
"max" ),
true, 1.0 ) << QgsExpressionFunction::Parameter( QStringLiteral(
"seed" ),
true ), fcnRndF, QStringLiteral(
"Math" ) );
8629 functions << randfFunc;
8632 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max" ), -1, fcnMax, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
8633 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min" ), -1, fcnMin, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
8634 <<
new QgsStaticExpressionFunction( QStringLiteral(
"clamp" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"max" ) ), fcnClamp, QStringLiteral(
"Math" ) )
8635 <<
new QgsStaticExpressionFunction( QStringLiteral(
"scale_linear" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"domain_min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"domain_max" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"range_min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"range_max" ) ), fcnLinearScale, QStringLiteral(
"Math" ) )
8636 <<
new QgsStaticExpressionFunction( QStringLiteral(
"scale_polynomial" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"domain_min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"domain_max" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"range_min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"range_max" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"exponent" ) ), fcnPolynomialScale, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"scale_exp" ) )
8637 <<
new QgsStaticExpressionFunction( QStringLiteral(
"scale_exponential" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"domain_min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"domain_max" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"range_min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"range_max" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"exponent" ) ), fcnExponentialScale, QStringLiteral(
"Math" ) )
8638 <<
new QgsStaticExpressionFunction( QStringLiteral(
"floor" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnFloor, QStringLiteral(
"Math" ) )
8639 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ceil" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnCeil, QStringLiteral(
"Math" ) )
8640 <<
new QgsStaticExpressionFunction( QStringLiteral(
"pi" ), 0, fcnPi, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$pi" ) )
8641 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_bool" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToBool, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"tobool" ),
true )
8642 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_int" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToInt, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"toint" ) )
8643 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_real" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToReal, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"toreal" ) )
8644 <<
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" ) )
8645 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_datetime" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ),
true, QVariant() ) << QgsExpressionFunction::Parameter( QStringLiteral(
"language" ),
true, QVariant() ), fcnToDateTime, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todatetime" ) )
8646 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_date" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ),
true, QVariant() ) << QgsExpressionFunction::Parameter( QStringLiteral(
"language" ),
true, QVariant() ), fcnToDate, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todate" ) )
8647 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_time" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ),
true, QVariant() ) << QgsExpressionFunction::Parameter( QStringLiteral(
"language" ),
true, QVariant() ), fcnToTime, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"totime" ) )
8648 <<
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" ) )
8649 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_dm" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"axis" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"precision" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"formatting" ),
true ), fcnToDegreeMinute, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todm" ) )
8650 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_dms" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"axis" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"precision" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"formatting" ),
true ), fcnToDegreeMinuteSecond, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todms" ) )
8651 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_decimal" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToDecimal, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todecimal" ) )
8652 <<
new QgsStaticExpressionFunction( QStringLiteral(
"extract_degrees" ), { QgsExpressionFunction::Parameter{ QStringLiteral(
"value" ) } }, fcnExtractDegrees, QStringLiteral(
"Conversions" ) )
8653 <<
new QgsStaticExpressionFunction( QStringLiteral(
"extract_minutes" ), { QgsExpressionFunction::Parameter{ QStringLiteral(
"value" ) } }, fcnExtractMinutes, QStringLiteral(
"Conversions" ) )
8654 <<
new QgsStaticExpressionFunction( QStringLiteral(
"extract_seconds" ), { QgsExpressionFunction::Parameter{ QStringLiteral(
"value" ) } }, fcnExtractSeconds, QStringLiteral(
"Conversions" ) )
8655 <<
new QgsStaticExpressionFunction( QStringLiteral(
"coalesce" ), -1, fcnCoalesce, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
8656 <<
new QgsStaticExpressionFunction( QStringLiteral(
"nullif" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value2" ) ), fcnNullIf, QStringLiteral(
"Conditionals" ) )
8657 <<
new QgsStaticExpressionFunction( QStringLiteral(
"if" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"condition" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"result_when_true" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"result_when_false" ) ), fcnIf, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
true )
8658 <<
new QgsStaticExpressionFunction( QStringLiteral(
"try" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"alternative" ),
true, QVariant() ), fcnTry, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
true )
8660 <<
new QgsStaticExpressionFunction( QStringLiteral(
"aggregate" ),
8662 << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
8663 << QgsExpressionFunction::Parameter( QStringLiteral(
"aggregate" ) )
8664 << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ),
false, QVariant(),
true )
8665 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter" ),
true, QVariant(),
true )
8666 << QgsExpressionFunction::Parameter( QStringLiteral(
"concatenator" ),
true )
8667 << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true ),
8669 QStringLiteral(
"Aggregates" ),
8678 if ( !node->
args() )
8681 QSet<QString> referencedVars;
8684 QgsExpressionNode *subExpressionNode = node->
args()->
at( 2 );
8690 QgsExpressionNode *filterNode = node->
args()->
at( 3 );
8693 return referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() );
8702 if ( !node->
args() )
8703 return QSet<QString>();
8705 QSet<QString> referencedCols;
8706 QSet<QString> referencedVars;
8710 QgsExpressionNode *subExpressionNode = node->
args()->
at( 2 );
8716 QgsExpressionNode *filterNode = node->
args()->
at( 3 );
8721 if ( referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() ) )
8724 return referencedCols;
8730 << QgsExpressionFunction::Parameter( QStringLiteral(
"relation" ) )
8731 << QgsExpressionFunction::Parameter( QStringLiteral(
"aggregate" ) )
8732 << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ),
false, QVariant(),
true )
8733 << QgsExpressionFunction::Parameter( QStringLiteral(
"concatenator" ),
true )
8734 << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true ),
8737 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count" ), aggParams, fcnAggregateCount, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8738 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_distinct" ), aggParams, fcnAggregateCountDistinct, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8739 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_missing" ), aggParams, fcnAggregateCountMissing, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8740 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minimum" ), aggParams, fcnAggregateMin, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8741 <<
new QgsStaticExpressionFunction( QStringLiteral(
"maximum" ), aggParams, fcnAggregateMax, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8742 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sum" ), aggParams, fcnAggregateSum, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8743 <<
new QgsStaticExpressionFunction( QStringLiteral(
"mean" ), aggParams, fcnAggregateMean, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8744 <<
new QgsStaticExpressionFunction( QStringLiteral(
"median" ), aggParams, fcnAggregateMedian, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8745 <<
new QgsStaticExpressionFunction( QStringLiteral(
"stdev" ), aggParams, fcnAggregateStdev, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8746 <<
new QgsStaticExpressionFunction( QStringLiteral(
"range" ), aggParams, fcnAggregateRange, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8747 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minority" ), aggParams, fcnAggregateMinority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8748 <<
new QgsStaticExpressionFunction( QStringLiteral(
"majority" ), aggParams, fcnAggregateMajority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8749 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q1" ), aggParams, fcnAggregateQ1, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8750 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q3" ), aggParams, fcnAggregateQ3, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8751 <<
new QgsStaticExpressionFunction( QStringLiteral(
"iqr" ), aggParams, fcnAggregateIQR, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8752 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min_length" ), aggParams, fcnAggregateMinLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8753 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max_length" ), aggParams, fcnAggregateMaxLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8754 <<
new QgsStaticExpressionFunction( QStringLiteral(
"collect" ), aggParams, fcnAggregateCollectGeometry, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8755 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concatenate" ), aggParamsConcat, fcnAggregateStringConcat, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8756 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concatenate_unique" ), aggParamsConcat, fcnAggregateStringConcatUnique, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8757 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_agg" ), aggParamsArray, fcnAggregateArray, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
8759 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_match" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) ), fcnRegexpMatch, QStringList() << QStringLiteral(
"Conditionals" ) << QStringLiteral(
"String" ) )
8760 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_matches" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"emptyvalue" ),
true,
"" ), fcnRegexpMatches, QStringLiteral(
"Arrays" ) )
8762 <<
new QgsStaticExpressionFunction( QStringLiteral(
"now" ), 0, fcnNow, QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$now" ) )
8764 << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime2" ) ),
8765 fcnAge, QStringLiteral(
"Date and Time" ) )
8766 <<
new QgsStaticExpressionFunction( QStringLiteral(
"year" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnYear, QStringLiteral(
"Date and Time" ) )
8767 <<
new QgsStaticExpressionFunction( QStringLiteral(
"month" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnMonth, QStringLiteral(
"Date and Time" ) )
8768 <<
new QgsStaticExpressionFunction( QStringLiteral(
"week" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnWeek, QStringLiteral(
"Date and Time" ) )
8769 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnDay, QStringLiteral(
"Date and Time" ) )
8770 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hour" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), fcnHour, QStringLiteral(
"Date and Time" ) )
8771 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minute" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), fcnMinute, QStringLiteral(
"Date and Time" ) )
8772 <<
new QgsStaticExpressionFunction( QStringLiteral(
"second" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), fcnSeconds, QStringLiteral(
"Date and Time" ) )
8773 <<
new QgsStaticExpressionFunction( QStringLiteral(
"epoch" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnEpoch, QStringLiteral(
"Date and Time" ) )
8774 <<
new QgsStaticExpressionFunction( QStringLiteral(
"datetime_from_epoch" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"long" ) ), fcnDateTimeFromEpoch, QStringLiteral(
"Date and Time" ) )
8775 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day_of_week" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnDayOfWeek, QStringLiteral(
"Date and Time" ) )
8777 << QgsExpressionFunction::Parameter( QStringLiteral(
"month" ) )
8778 << QgsExpressionFunction::Parameter( QStringLiteral(
"day" ) ),
8779 fcnMakeDate, QStringLiteral(
"Date and Time" ) )
8781 << QgsExpressionFunction::Parameter( QStringLiteral(
"minute" ) )
8782 << QgsExpressionFunction::Parameter( QStringLiteral(
"second" ) ),
8783 fcnMakeTime, QStringLiteral(
"Date and Time" ) )
8785 << QgsExpressionFunction::Parameter( QStringLiteral(
"month" ) )
8786 << QgsExpressionFunction::Parameter( QStringLiteral(
"day" ) )
8787 << QgsExpressionFunction::Parameter( QStringLiteral(
"hour" ) )
8788 << QgsExpressionFunction::Parameter( QStringLiteral(
"minute" ) )
8789 << QgsExpressionFunction::Parameter( QStringLiteral(
"second" ) ),
8790 fcnMakeDateTime, QStringLiteral(
"Date and Time" ) )
8791 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_interval" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"years" ),
true, 0 )
8792 << QgsExpressionFunction::Parameter( QStringLiteral(
"months" ),
true, 0 )
8793 << QgsExpressionFunction::Parameter( QStringLiteral(
"weeks" ),
true, 0 )
8794 << QgsExpressionFunction::Parameter( QStringLiteral(
"days" ),
true, 0 )
8795 << QgsExpressionFunction::Parameter( QStringLiteral(
"hours" ),
true, 0 )
8796 << QgsExpressionFunction::Parameter( QStringLiteral(
"minutes" ),
true, 0 )
8797 << QgsExpressionFunction::Parameter( QStringLiteral(
"seconds" ),
true, 0 ),
8798 fcnMakeInterval, QStringLiteral(
"Date and Time" ) )
8799 <<
new QgsStaticExpressionFunction( QStringLiteral(
"timezone_from_id" ), { QgsExpressionFunction::Parameter( QStringLiteral(
"id" ) ) }, fcnTimeZoneFromId, QStringLiteral(
"Date and Time" ) )
8800 <<
new QgsStaticExpressionFunction( QStringLiteral(
"timezone_id" ), { QgsExpressionFunction::Parameter( QStringLiteral(
"timezone" ) ) }, fcnTimeZoneToId, QStringLiteral(
"Date and Time" ) )
8801 <<
new QgsStaticExpressionFunction( QStringLiteral(
"get_timezone" ), { QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ) }, fcnGetTimeZone, QStringLiteral(
"Date and Time" ) )
8802 <<
new QgsStaticExpressionFunction( QStringLiteral(
"set_timezone" ), { QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), QgsExpressionFunction::Parameter( QStringLiteral(
"timezone" ) ) }, fcnSetTimeZone, QStringLiteral(
"Date and Time" ) )
8803 <<
new QgsStaticExpressionFunction( QStringLiteral(
"convert_timezone" ), { QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), QgsExpressionFunction::Parameter( QStringLiteral(
"timezone" ) ) }, fcnConvertTimeZone, QStringLiteral(
"Date and Time" ) )
8804 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lower" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnLower, QStringLiteral(
"String" ) )
8806 << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) )
8807 << QgsExpressionFunction::Parameter( QStringLiteral(
"substring" ) )
8808 << QgsExpressionFunction::Parameter( QStringLiteral(
"overlapping" ),
true,
false ),
8810 QStringLiteral(
"String" ) )
8811 <<
new QgsStaticExpressionFunction( QStringLiteral(
"upper" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnUpper, QStringLiteral(
"String" ) )
8812 <<
new QgsStaticExpressionFunction( QStringLiteral(
"title" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnTitle, QStringLiteral(
"String" ) )
8813 <<
new QgsStaticExpressionFunction( QStringLiteral(
"trim" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnTrim, QStringLiteral(
"String" ) )
8815 << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) )
8816 << QgsExpressionFunction::Parameter( QStringLiteral(
"characters" ),
true, QStringLiteral(
" " ) ), fcnLTrim, QStringLiteral(
"String" ) )
8818 << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) )
8819 << QgsExpressionFunction::Parameter( QStringLiteral(
"characters" ),
true, QStringLiteral(
" " ) ), fcnRTrim, QStringLiteral(
"String" ) )
8820 <<
new QgsStaticExpressionFunction( QStringLiteral(
"levenshtein" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"string2" ) ), fcnLevenshtein, QStringLiteral(
"Fuzzy Matching" ) )
8821 <<
new QgsStaticExpressionFunction( QStringLiteral(
"longest_common_substring" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"string2" ) ), fcnLCS, QStringLiteral(
"Fuzzy Matching" ) )
8822 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hamming_distance" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"string2" ) ), fcnHamming, QStringLiteral(
"Fuzzy Matching" ) )
8823 <<
new QgsStaticExpressionFunction( QStringLiteral(
"soundex" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnSoundex, QStringLiteral(
"Fuzzy Matching" ) )
8824 <<
new QgsStaticExpressionFunction( QStringLiteral(
"char" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"code" ) ), fcnChar, QStringLiteral(
"String" ) )
8825 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ascii" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnAscii, QStringLiteral(
"String" ) )
8826 <<
new QgsStaticExpressionFunction( QStringLiteral(
"wordwrap" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"text" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"delimiter" ),
true,
"" ), fcnWordwrap, QStringLiteral(
"String" ) )
8827 <<
new QgsStaticExpressionFunction( QStringLiteral(
"length" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"text" ),
true,
"" ), fcnLength, QStringList() << QStringLiteral(
"String" ) << QStringLiteral(
"GeometryGroup" ) )
8828 <<
new QgsStaticExpressionFunction( QStringLiteral(
"length3D" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnLength3D, QStringLiteral(
"GeometryGroup" ) )
8829 <<
new QgsStaticExpressionFunction( QStringLiteral(
"repeat" ), { QgsExpressionFunction::Parameter( QStringLiteral(
"text" ) ), QgsExpressionFunction::Parameter( QStringLiteral(
"number" ) )}, fcnRepeat, QStringLiteral(
"String" ) )
8830 <<
new QgsStaticExpressionFunction( QStringLiteral(
"replace" ), -1, fcnReplace, QStringLiteral(
"String" ) )
8831 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_replace" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"input_string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) )
8832 << QgsExpressionFunction::Parameter( QStringLiteral(
"replacement" ) ), fcnRegexpReplace, QStringLiteral(
"String" ) )
8833 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_substr" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"input_string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) ), fcnRegexpSubstr, QStringLiteral(
"String" ) )
8834 <<
new QgsStaticExpressionFunction( QStringLiteral(
"substr" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"start" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ),
true ), fcnSubstr, QStringLiteral(
"String" ), QString(),
8835 false, QSet< QString >(),
false, QStringList(),
true )
8836 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concat" ), -1, fcnConcat, QStringLiteral(
"String" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
8837 <<
new QgsStaticExpressionFunction( QStringLiteral(
"strpos" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"haystack" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"needle" ) ), fcnStrpos, QStringLiteral(
"String" ) )
8838 <<
new QgsStaticExpressionFunction( QStringLiteral(
"left" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ) ), fcnLeft, QStringLiteral(
"String" ) )
8839 <<
new QgsStaticExpressionFunction( QStringLiteral(
"right" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ) ), fcnRight, QStringLiteral(
"String" ) )
8840 <<
new QgsStaticExpressionFunction( QStringLiteral(
"rpad" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"width" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"fill" ) ), fcnRPad, QStringLiteral(
"String" ) )
8841 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lpad" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"width" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"fill" ) ), fcnLPad, QStringLiteral(
"String" ) )
8842 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format" ), -1, fcnFormatString, QStringLiteral(
"String" ) )
8844 << QgsExpressionFunction::Parameter( QStringLiteral(
"number" ) )
8845 << QgsExpressionFunction::Parameter( QStringLiteral(
"places" ),
true, 0 )
8846 << QgsExpressionFunction::Parameter( QStringLiteral(
"language" ),
true, QVariant() )
8847 << QgsExpressionFunction::Parameter( QStringLiteral(
"omit_group_separators" ),
true,
false )
8848 << QgsExpressionFunction::Parameter( QStringLiteral(
"trim_trailing_zeroes" ),
true,
false ), fcnFormatNumber, QStringLiteral(
"String" ) )
8849 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format_date" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"language" ),
true, QVariant() ), fcnFormatDate, QStringList() << QStringLiteral(
"String" ) << QStringLiteral(
"Date and Time" ) )
8850 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_grayscale_average" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"color" ) ), fcnColorGrayscaleAverage, QStringLiteral(
"Color" ) )
8851 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_mix_rgb" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"color1" ) )
8852 << QgsExpressionFunction::Parameter( QStringLiteral(
"color2" ) )
8853 << QgsExpressionFunction::Parameter( QStringLiteral(
"ratio" ) ),
8854 fcnColorMixRgb, QStringLiteral(
"Color" ) )
8856 << QgsExpressionFunction::Parameter( QStringLiteral(
"color2" ) )
8857 << QgsExpressionFunction::Parameter( QStringLiteral(
"ratio" ) ),
8858 fcnColorMix, QStringLiteral(
"Color" ) )
8860 << QgsExpressionFunction::Parameter( QStringLiteral(
"green" ) )
8861 << QgsExpressionFunction::Parameter( QStringLiteral(
"blue" ) ),
8862 fcnColorRgb, QStringLiteral(
"Color" ) )
8864 << QgsExpressionFunction::Parameter( QStringLiteral(
"green" ) )
8865 << QgsExpressionFunction::Parameter( QStringLiteral(
"blue" ) )
8866 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ),
true, 1. ),
8867 fcnColorRgbF, QStringLiteral(
"Color" ) )
8869 << QgsExpressionFunction::Parameter( QStringLiteral(
"green" ) )
8870 << QgsExpressionFunction::Parameter( QStringLiteral(
"blue" ) )
8871 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
8872 fncColorRgba, QStringLiteral(
"Color" ) )
8873 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ramp_color" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"ramp_name" ) )
8874 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ),
8876 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ramp_color_object" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"ramp_name" ) )
8877 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ),
8880 << QgsExpressionFunction::Parameter( QStringLiteral(
"discrete" ),
true,
false ),
8881 fcnCreateRamp, QStringLiteral(
"Color" ) )
8883 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
8884 << QgsExpressionFunction::Parameter( QStringLiteral(
"lightness" ) ),
8885 fcnColorHsl, QStringLiteral(
"Color" ) )
8887 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
8888 << QgsExpressionFunction::Parameter( QStringLiteral(
"lightness" ) )
8889 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
8890 fncColorHsla, QStringLiteral(
"Color" ) )
8892 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
8893 << QgsExpressionFunction::Parameter( QStringLiteral(
"lightness" ) )
8894 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ),
true, 1. ),
8895 fcnColorHslF, QStringLiteral(
"Color" ) )
8897 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
8898 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ),
8899 fcnColorHsv, QStringLiteral(
"Color" ) )
8901 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
8902 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) )
8903 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
8904 fncColorHsva, QStringLiteral(
"Color" ) )
8906 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
8907 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) )
8908 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ),
true, 1. ),
8909 fcnColorHsvF, QStringLiteral(
"Color" ) )
8911 << QgsExpressionFunction::Parameter( QStringLiteral(
"magenta" ) )
8912 << QgsExpressionFunction::Parameter( QStringLiteral(
"yellow" ) )
8913 << QgsExpressionFunction::Parameter( QStringLiteral(
"black" ) ),
8914 fcnColorCmyk, QStringLiteral(
"Color" ) )
8916 << QgsExpressionFunction::Parameter( QStringLiteral(
"magenta" ) )
8917 << QgsExpressionFunction::Parameter( QStringLiteral(
"yellow" ) )
8918 << QgsExpressionFunction::Parameter( QStringLiteral(
"black" ) )
8919 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
8920 fncColorCmyka, QStringLiteral(
"Color" ) )
8922 << QgsExpressionFunction::Parameter( QStringLiteral(
"magenta" ) )
8923 << QgsExpressionFunction::Parameter( QStringLiteral(
"yellow" ) )
8924 << QgsExpressionFunction::Parameter( QStringLiteral(
"black" ) )
8925 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ),
true, 1. ),
8926 fcnColorCmykF, QStringLiteral(
"Color" ) )
8928 << QgsExpressionFunction::Parameter( QStringLiteral(
"component" ) ),
8929 fncColorPart, QStringLiteral(
"Color" ) )
8931 << QgsExpressionFunction::Parameter( QStringLiteral(
"factor" ) ),
8932 fncDarker, QStringLiteral(
"Color" ) )
8934 << QgsExpressionFunction::Parameter( QStringLiteral(
"factor" ) ),
8935 fncLighter, QStringLiteral(
"Color" ) )
8936 <<
new QgsStaticExpressionFunction( QStringLiteral(
"set_color_part" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"color" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"component" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fncSetColorPart, QStringLiteral(
"Color" ) )
8939 <<
new QgsStaticExpressionFunction( QStringLiteral(
"base_file_name" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"path" ) ),
8940 fcnBaseFileName, QStringLiteral(
"Files and Paths" ) )
8942 fcnFileSuffix, QStringLiteral(
"Files and Paths" ) )
8944 fcnFileExists, QStringLiteral(
"Files and Paths" ) )
8946 fcnFileName, QStringLiteral(
"Files and Paths" ) )
8948 fcnPathIsFile, QStringLiteral(
"Files and Paths" ) )
8950 fcnPathIsDir, QStringLiteral(
"Files and Paths" ) )
8952 fcnFilePath, QStringLiteral(
"Files and Paths" ) )
8954 fcnFileSize, QStringLiteral(
"Files and Paths" ) )
8956 <<
new QgsStaticExpressionFunction( QStringLiteral(
"exif" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"path" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"tag" ),
true ),
8957 fcnExif, QStringLiteral(
"Files and Paths" ) )
8959 fcnExifGeoTag, QStringLiteral(
"GeometryGroup" ) )
8962 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hash" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"method" ) ),
8963 fcnGenericHash, QStringLiteral(
"Conversions" ) )
8965 fcnHashMd5, QStringLiteral(
"Conversions" ) )
8967 fcnHashSha256, QStringLiteral(
"Conversions" ) )
8971 fcnToBase64, QStringLiteral(
"Conversions" ) )
8973 fcnFromBase64, QStringLiteral(
"Conversions" ) )
8978 QgsStaticExpressionFunction *geomFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$geometry" ), 0, fcnGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true );
8980 functions << geomFunc;
8982 QgsStaticExpressionFunction *areaFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$area" ), 0, fcnGeomArea, QStringLiteral(
"GeometryGroup" ), QString(),
true );
8984 functions << areaFunc;
8986 functions <<
new QgsStaticExpressionFunction( QStringLiteral(
"area" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnArea, QStringLiteral(
"GeometryGroup" ) );
8988 QgsStaticExpressionFunction *lengthFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$length" ), 0, fcnGeomLength, QStringLiteral(
"GeometryGroup" ), QString(),
true );
8990 functions << lengthFunc;
8992 QgsStaticExpressionFunction *perimeterFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$perimeter" ), 0, fcnGeomPerimeter, QStringLiteral(
"GeometryGroup" ), QString(),
true );
8994 functions << perimeterFunc;
8996 functions <<
new QgsStaticExpressionFunction( QStringLiteral(
"perimeter" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnPerimeter, QStringLiteral(
"GeometryGroup" ) );
8998 functions <<
new QgsStaticExpressionFunction( QStringLiteral(
"roundness" ),
9000 fcnRoundness, QStringLiteral(
"GeometryGroup" ) );
9002 QgsStaticExpressionFunction *xFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$x" ), 0, fcnX, QStringLiteral(
"GeometryGroup" ), QString(),
true );
9006 QgsStaticExpressionFunction *yFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$y" ), 0, fcnY, QStringLiteral(
"GeometryGroup" ), QString(),
true );
9010 QgsStaticExpressionFunction *zFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$z" ), 0, fcnZ, QStringLiteral(
"GeometryGroup" ), QString(),
true );
9014 QMap< QString, QgsExpressionFunction::FcnEval > geometry_overlay_definitions
9016 { QStringLiteral(
"overlay_intersects" ), fcnGeomOverlayIntersects },
9017 { QStringLiteral(
"overlay_contains" ), fcnGeomOverlayContains },
9018 { QStringLiteral(
"overlay_crosses" ), fcnGeomOverlayCrosses },
9019 { QStringLiteral(
"overlay_equals" ), fcnGeomOverlayEquals },
9020 { QStringLiteral(
"overlay_touches" ), fcnGeomOverlayTouches },
9021 { QStringLiteral(
"overlay_disjoint" ), fcnGeomOverlayDisjoint },
9022 { QStringLiteral(
"overlay_within" ), fcnGeomOverlayWithin },
9024 QMapIterator< QString, QgsExpressionFunction::FcnEval > i( geometry_overlay_definitions );
9025 while ( i.hasNext() )
9029 << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
9030 << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ),
true, QVariant(),
true )
9031 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter" ),
true, QVariant(),
true )
9032 << QgsExpressionFunction::Parameter( QStringLiteral(
"limit" ),
true, QVariant( -1 ),
true )
9033 << QgsExpressionFunction::Parameter( QStringLiteral(
"cache" ),
true, QVariant(
false ),
false )
9034 << QgsExpressionFunction::Parameter( QStringLiteral(
"min_overlap" ),
true, QVariant( -1 ),
false )
9035 << QgsExpressionFunction::Parameter( QStringLiteral(
"min_inscribed_circle_radius" ),
true, QVariant( -1 ),
false )
9036 << QgsExpressionFunction::Parameter( QStringLiteral(
"return_details" ),
true,
false,
false )
9037 << QgsExpressionFunction::Parameter( QStringLiteral(
"sort_by_intersection_size" ),
true, QString(),
false ),
9042 functions << fcnGeomOverlayFunc;
9046 << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
9047 << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ),
true, QVariant(),
true )
9048 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter" ),
true, QVariant(),
true )
9049 << QgsExpressionFunction::Parameter( QStringLiteral(
"limit" ),
true, QVariant( 1 ),
true )
9050 << QgsExpressionFunction::Parameter( QStringLiteral(
"max_distance" ),
true, 0 )
9051 << QgsExpressionFunction::Parameter( QStringLiteral(
"cache" ),
true, QVariant(
false ),
false ),
9055 functions << fcnGeomOverlayNearestFunc;
9058 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_valid" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomIsValid, QStringLiteral(
"GeometryGroup" ) )
9059 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomX, QStringLiteral(
"GeometryGroup" ) )
9060 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomY, QStringLiteral(
"GeometryGroup" ) )
9061 <<
new QgsStaticExpressionFunction( QStringLiteral(
"z" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomZ, QStringLiteral(
"GeometryGroup" ) )
9062 <<
new QgsStaticExpressionFunction( QStringLiteral(
"m" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomM, QStringLiteral(
"GeometryGroup" ) )
9063 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_n" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"index" ) ), fcnPointN, QStringLiteral(
"GeometryGroup" ) )
9064 <<
new QgsStaticExpressionFunction( QStringLiteral(
"start_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnStartPoint, QStringLiteral(
"GeometryGroup" ) )
9065 <<
new QgsStaticExpressionFunction( QStringLiteral(
"end_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnEndPoint, QStringLiteral(
"GeometryGroup" ) )
9066 <<
new QgsStaticExpressionFunction( QStringLiteral(
"nodes_to_points" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9067 << QgsExpressionFunction::Parameter( QStringLiteral(
"ignore_closing_nodes" ),
true,
false ),
9068 fcnNodesToPoints, QStringLiteral(
"GeometryGroup" ) )
9069 <<
new QgsStaticExpressionFunction( QStringLiteral(
"segments_to_lines" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnSegmentsToLines, QStringLiteral(
"GeometryGroup" ) )
9070 <<
new QgsStaticExpressionFunction( QStringLiteral(
"collect_geometries" ), -1, fcnCollectGeometries, QStringLiteral(
"GeometryGroup" ) )
9071 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_point" ), -1, fcnMakePoint, QStringLiteral(
"GeometryGroup" ) )
9073 << QgsExpressionFunction::Parameter( QStringLiteral(
"y" ) )
9074 << QgsExpressionFunction::Parameter( QStringLiteral(
"m" ) ),
9075 fcnMakePointM, QStringLiteral(
"GeometryGroup" ) )
9076 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_line" ), -1, fcnMakeLine, QStringLiteral(
"GeometryGroup" ) )
9077 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_polygon" ), -1, fcnMakePolygon, QStringLiteral(
"GeometryGroup" ) )
9078 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_triangle" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"point1" ) )
9079 << QgsExpressionFunction::Parameter( QStringLiteral(
"point2" ) )
9080 << QgsExpressionFunction::Parameter( QStringLiteral(
"point3" ) ),
9081 fcnMakeTriangle, QStringLiteral(
"GeometryGroup" ) )
9083 << QgsExpressionFunction::Parameter( QStringLiteral(
"center" ) )
9084 << QgsExpressionFunction::Parameter( QStringLiteral(
"radius" ) )
9085 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 36 ),
9086 fcnMakeCircle, QStringLiteral(
"GeometryGroup" ) )
9088 << QgsExpressionFunction::Parameter( QStringLiteral(
"center" ) )
9089 << QgsExpressionFunction::Parameter( QStringLiteral(
"semi_major_axis" ) )
9090 << QgsExpressionFunction::Parameter( QStringLiteral(
"semi_minor_axis" ) )
9091 << QgsExpressionFunction::Parameter( QStringLiteral(
"azimuth" ) )
9092 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 36 ),
9093 fcnMakeEllipse, QStringLiteral(
"GeometryGroup" ) )
9095 << QgsExpressionFunction::Parameter( QStringLiteral(
"center" ) )
9096 << QgsExpressionFunction::Parameter( QStringLiteral(
"radius" ) )
9097 << QgsExpressionFunction::Parameter( QStringLiteral(
"number_sides" ) )
9098 << QgsExpressionFunction::Parameter( QStringLiteral(
"circle" ),
true, 0 ),
9099 fcnMakeRegularPolygon, QStringLiteral(
"GeometryGroup" ) )
9101 << QgsExpressionFunction::Parameter( QStringLiteral(
"point1" ) )
9102 << QgsExpressionFunction::Parameter( QStringLiteral(
"point2" ) ),
9103 fcnMakeSquare, QStringLiteral(
"GeometryGroup" ) )
9105 << QgsExpressionFunction::Parameter( QStringLiteral(
"point1" ) )
9106 << QgsExpressionFunction::Parameter( QStringLiteral(
"point2" ) )
9107 << QgsExpressionFunction::Parameter( QStringLiteral(
"point3" ) )
9108 << QgsExpressionFunction::Parameter( QStringLiteral(
"option" ),
true, 0 ),
9109 fcnMakeRectangleFrom3Points, QStringLiteral(
"GeometryGroup" ) )
9112 QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9113#if GEOS_VERSION_MAJOR==3 && GEOS_VERSION_MINOR<10
9114 QgsExpressionFunction::Parameter( QStringLiteral(
"method" ),
true, QStringLiteral(
"linework" ) ),
9116 QgsExpressionFunction::Parameter( QStringLiteral(
"method" ),
true, QStringLiteral(
"structure" ) ),
9118 QgsExpressionFunction::Parameter( QStringLiteral(
"keep_collapsed" ),
true,
false )
9119 }, fcnGeomMakeValid, QStringLiteral(
"GeometryGroup" ) );
9121 functions <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_at" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ),
true ) << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ),
true ), fcnXat, QStringLiteral(
"GeometryGroup" ) );
9122 functions <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_at" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ),
true ) << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ),
true ), fcnYat, QStringLiteral(
"GeometryGroup" ) );
9123 functions <<
new QgsStaticExpressionFunction( QStringLiteral(
"z_at" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ),
true ), fcnZat, QStringLiteral(
"GeometryGroup" ) );
9124 functions <<
new QgsStaticExpressionFunction( QStringLiteral(
"m_at" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ),
true ), fcnMat, QStringLiteral(
"GeometryGroup" ) );
9126 QgsStaticExpressionFunction *xAtFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$x_at" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ) ), fcnOldXat, QStringLiteral(
"GeometryGroup" ), QString(),
true, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xat" ) );
9128 functions << xAtFunc;
9131 QgsStaticExpressionFunction *yAtFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$y_at" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ) ), fcnOldYat, QStringLiteral(
"GeometryGroup" ), QString(),
true, QSet<QString>(),
false, QStringList() << QStringLiteral(
"yat" ) );
9133 functions << yAtFunc;
9136 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geometry_type" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeometryType, QStringLiteral(
"GeometryGroup" ) )
9137 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_min" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnXMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmin" ) )
9138 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_max" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnXMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmax" ) )
9139 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_min" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnYMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymin" ) )
9140 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_max" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnYMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymax" ) )
9141 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_wkt" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"text" ) ), fcnGeomFromWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromWKT" ) )
9142 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_wkb" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"binary" ) ), fcnGeomFromWKB, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false )
9143 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_gml" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"gml" ) ), fcnGeomFromGML, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromGML" ) )
9144 <<
new QgsStaticExpressionFunction( QStringLiteral(
"flip_coordinates" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnFlipCoordinates, QStringLiteral(
"GeometryGroup" ) )
9145 <<
new QgsStaticExpressionFunction( QStringLiteral(
"relate" ), -1, fcnRelate, QStringLiteral(
"GeometryGroup" ) )
9146 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersects_bbox" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ), fcnBbox, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"bbox" ) )
9148 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9149 fcnDisjoint, QStringLiteral(
"GeometryGroup" ) )
9150 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersects" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
9151 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9152 fcnIntersects, QStringLiteral(
"GeometryGroup" ) )
9154 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9155 fcnTouches, QStringLiteral(
"GeometryGroup" ) )
9157 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9158 fcnCrosses, QStringLiteral(
"GeometryGroup" ) )
9160 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9161 fcnContains, QStringLiteral(
"GeometryGroup" ) )
9163 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9164 fcnOverlaps, QStringLiteral(
"GeometryGroup" ) )
9166 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9167 fcnWithin, QStringLiteral(
"GeometryGroup" ) )
9169 << QgsExpressionFunction::Parameter( QStringLiteral(
"dx" ) )
9170 << QgsExpressionFunction::Parameter( QStringLiteral(
"dy" ) ),
9171 fcnTranslate, QStringLiteral(
"GeometryGroup" ) )
9173 << QgsExpressionFunction::Parameter( QStringLiteral(
"rotation" ) )
9174 << QgsExpressionFunction::Parameter( QStringLiteral(
"center" ),
true )
9175 << QgsExpressionFunction::Parameter( QStringLiteral(
"per_part" ),
true,
false ),
9176 fcnRotate, QStringLiteral(
"GeometryGroup" ) )
9178 << QgsExpressionFunction::Parameter( QStringLiteral(
"x_scale" ) )
9179 << QgsExpressionFunction::Parameter( QStringLiteral(
"y_scale" ) )
9180 << QgsExpressionFunction::Parameter( QStringLiteral(
"center" ),
true ),
9181 fcnScale, QStringLiteral(
"GeometryGroup" ) )
9182 <<
new QgsStaticExpressionFunction( QStringLiteral(
"affine_transform" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9183 << QgsExpressionFunction::Parameter( QStringLiteral(
"delta_x" ) )
9184 << QgsExpressionFunction::Parameter( QStringLiteral(
"delta_y" ) )
9185 << QgsExpressionFunction::Parameter( QStringLiteral(
"rotation_z" ) )
9186 << QgsExpressionFunction::Parameter( QStringLiteral(
"scale_x" ) )
9187 << QgsExpressionFunction::Parameter( QStringLiteral(
"scale_y" ) )
9188 << QgsExpressionFunction::Parameter( QStringLiteral(
"delta_z" ),
true, 0 )
9189 << QgsExpressionFunction::Parameter( QStringLiteral(
"delta_m" ),
true, 0 )
9190 << QgsExpressionFunction::Parameter( QStringLiteral(
"scale_z" ),
true, 1 )
9191 << QgsExpressionFunction::Parameter( QStringLiteral(
"scale_m" ),
true, 1 ),
9192 fcnAffineTransform, QStringLiteral(
"GeometryGroup" ) )
9194 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) )
9195 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8 )
9196 << QgsExpressionFunction::Parameter( QStringLiteral(
"cap" ),
true, QStringLiteral(
"round" ) )
9197 << QgsExpressionFunction::Parameter( QStringLiteral(
"join" ),
true, QStringLiteral(
"round" ) )
9198 << QgsExpressionFunction::Parameter( QStringLiteral(
"miter_limit" ),
true, 2 ),
9199 fcnBuffer, QStringLiteral(
"GeometryGroup" ) )
9201 fcnForceRHR, QStringLiteral(
"GeometryGroup" ) )
9202 <<
new QgsStaticExpressionFunction( QStringLiteral(
"force_polygon_cw" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9203 fcnForcePolygonCW, QStringLiteral(
"GeometryGroup" ) )
9204 <<
new QgsStaticExpressionFunction( QStringLiteral(
"force_polygon_ccw" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9205 fcnForcePolygonCCW, QStringLiteral(
"GeometryGroup" ) )
9207 << QgsExpressionFunction::Parameter( QStringLiteral(
"azimuth" ) )
9208 << QgsExpressionFunction::Parameter( QStringLiteral(
"width" ) )
9209 << QgsExpressionFunction::Parameter( QStringLiteral(
"outer_radius" ) )
9210 << QgsExpressionFunction::Parameter( QStringLiteral(
"inner_radius" ),
true, 0.0 ), fcnWedgeBuffer, QStringLiteral(
"GeometryGroup" ) )
9211 <<
new QgsStaticExpressionFunction( QStringLiteral(
"tapered_buffer" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9212 << QgsExpressionFunction::Parameter( QStringLiteral(
"start_width" ) )
9213 << QgsExpressionFunction::Parameter( QStringLiteral(
"end_width" ) )
9214 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
9215 , fcnTaperedBuffer, QStringLiteral(
"GeometryGroup" ) )
9216 <<
new QgsStaticExpressionFunction( QStringLiteral(
"buffer_by_m" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9217 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
9218 , fcnBufferByM, QStringLiteral(
"GeometryGroup" ) )
9219 <<
new QgsStaticExpressionFunction( QStringLiteral(
"offset_curve" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9220 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) )
9221 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
9222 << QgsExpressionFunction::Parameter( QStringLiteral(
"join" ),
true,
static_cast< int >(
Qgis::JoinStyle::Round ) )
9223 << QgsExpressionFunction::Parameter( QStringLiteral(
"miter_limit" ),
true, 2.0 ),
9224 fcnOffsetCurve, QStringLiteral(
"GeometryGroup" ) )
9225 <<
new QgsStaticExpressionFunction( QStringLiteral(
"single_sided_buffer" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9226 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) )
9227 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
9228 << QgsExpressionFunction::Parameter( QStringLiteral(
"join" ),
true,
static_cast< int >(
Qgis::JoinStyle::Round ) )
9229 << QgsExpressionFunction::Parameter( QStringLiteral(
"miter_limit" ),
true, 2.0 ),
9230 fcnSingleSidedBuffer, QStringLiteral(
"GeometryGroup" ) )
9232 << QgsExpressionFunction::Parameter( QStringLiteral(
"start_distance" ) )
9233 << QgsExpressionFunction::Parameter( QStringLiteral(
"end_distance" ) ),
9234 fcnExtend, QStringLiteral(
"GeometryGroup" ) )
9235 <<
new QgsStaticExpressionFunction( QStringLiteral(
"centroid" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnCentroid, QStringLiteral(
"GeometryGroup" ) )
9236 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_on_surface" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnPointOnSurface, QStringLiteral(
"GeometryGroup" ) )
9237 <<
new QgsStaticExpressionFunction( QStringLiteral(
"pole_of_inaccessibility" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9238 << QgsExpressionFunction::Parameter( QStringLiteral(
"tolerance" ) ), fcnPoleOfInaccessibility, QStringLiteral(
"GeometryGroup" ) )
9239 <<
new QgsStaticExpressionFunction( QStringLiteral(
"reverse" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnReverse, { QStringLiteral(
"String" ), QStringLiteral(
"GeometryGroup" ) } )
9240 <<
new QgsStaticExpressionFunction( QStringLiteral(
"exterior_ring" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnExteriorRing, QStringLiteral(
"GeometryGroup" ) )
9241 <<
new QgsStaticExpressionFunction( QStringLiteral(
"interior_ring_n" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9242 << QgsExpressionFunction::Parameter( QStringLiteral(
"index" ) ),
9243 fcnInteriorRingN, QStringLiteral(
"GeometryGroup" ) )
9245 << QgsExpressionFunction::Parameter( QStringLiteral(
"index" ) ),
9246 fcnGeometryN, QStringLiteral(
"GeometryGroup" ) )
9247 <<
new QgsStaticExpressionFunction( QStringLiteral(
"boundary" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnBoundary, QStringLiteral(
"GeometryGroup" ) )
9248 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_merge" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnLineMerge, QStringLiteral(
"GeometryGroup" ) )
9251 QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) ),
9252 QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) )
9253 }, fcnSharedPaths, QStringLiteral(
"GeometryGroup" ) )
9254 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnBounds, QStringLiteral(
"GeometryGroup" ) )
9255 <<
new QgsStaticExpressionFunction( QStringLiteral(
"simplify" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"tolerance" ) ), fcnSimplify, QStringLiteral(
"GeometryGroup" ) )
9256 <<
new QgsStaticExpressionFunction( QStringLiteral(
"simplify_vw" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"tolerance" ) ), fcnSimplifyVW, QStringLiteral(
"GeometryGroup" ) )
9257 <<
new QgsStaticExpressionFunction( QStringLiteral(
"smooth" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"iterations" ),
true, 1 )
9258 << QgsExpressionFunction::Parameter( QStringLiteral(
"offset" ),
true, 0.25 )
9259 << QgsExpressionFunction::Parameter( QStringLiteral(
"min_length" ),
true, -1 )
9260 << QgsExpressionFunction::Parameter( QStringLiteral(
"max_angle" ),
true, 180 ), fcnSmooth, QStringLiteral(
"GeometryGroup" ) )
9261 <<
new QgsStaticExpressionFunction( QStringLiteral(
"triangular_wave" ),
9263 QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9264 QgsExpressionFunction::Parameter( QStringLiteral(
"wavelength" ) ),
9265 QgsExpressionFunction::Parameter( QStringLiteral(
"amplitude" ) ),
9266 QgsExpressionFunction::Parameter( QStringLiteral(
"strict" ),
true,
false )
9267 }, fcnTriangularWave, QStringLiteral(
"GeometryGroup" ) )
9268 <<
new QgsStaticExpressionFunction( QStringLiteral(
"triangular_wave_randomized" ),
9270 QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9271 QgsExpressionFunction::Parameter( QStringLiteral(
"min_wavelength" ) ),
9272 QgsExpressionFunction::Parameter( QStringLiteral(
"max_wavelength" ) ),
9273 QgsExpressionFunction::Parameter( QStringLiteral(
"min_amplitude" ) ),
9274 QgsExpressionFunction::Parameter( QStringLiteral(
"max_amplitude" ) ),
9275 QgsExpressionFunction::Parameter( QStringLiteral(
"seed" ),
true, 0 )
9276 }, fcnTriangularWaveRandomized, QStringLiteral(
"GeometryGroup" ) )
9277 <<
new QgsStaticExpressionFunction( QStringLiteral(
"square_wave" ),
9279 QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9280 QgsExpressionFunction::Parameter( QStringLiteral(
"wavelength" ) ),
9281 QgsExpressionFunction::Parameter( QStringLiteral(
"amplitude" ) ),
9282 QgsExpressionFunction::Parameter( QStringLiteral(
"strict" ),
true,
false )
9283 }, fcnSquareWave, QStringLiteral(
"GeometryGroup" ) )
9284 <<
new QgsStaticExpressionFunction( QStringLiteral(
"square_wave_randomized" ),
9286 QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9287 QgsExpressionFunction::Parameter( QStringLiteral(
"min_wavelength" ) ),
9288 QgsExpressionFunction::Parameter( QStringLiteral(
"max_wavelength" ) ),
9289 QgsExpressionFunction::Parameter( QStringLiteral(
"min_amplitude" ) ),
9290 QgsExpressionFunction::Parameter( QStringLiteral(
"max_amplitude" ) ),
9291 QgsExpressionFunction::Parameter( QStringLiteral(
"seed" ),
true, 0 )
9292 }, fcnSquareWaveRandomized, QStringLiteral(
"GeometryGroup" ) )
9293 <<
new QgsStaticExpressionFunction( QStringLiteral(
"wave" ),
9295 QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9296 QgsExpressionFunction::Parameter( QStringLiteral(
"wavelength" ) ),
9297 QgsExpressionFunction::Parameter( QStringLiteral(
"amplitude" ) ),
9298 QgsExpressionFunction::Parameter( QStringLiteral(
"strict" ),
true,
false )
9299 }, fcnRoundWave, QStringLiteral(
"GeometryGroup" ) )
9300 <<
new QgsStaticExpressionFunction( QStringLiteral(
"wave_randomized" ),
9302 QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9303 QgsExpressionFunction::Parameter( QStringLiteral(
"min_wavelength" ) ),
9304 QgsExpressionFunction::Parameter( QStringLiteral(
"max_wavelength" ) ),
9305 QgsExpressionFunction::Parameter( QStringLiteral(
"min_amplitude" ) ),
9306 QgsExpressionFunction::Parameter( QStringLiteral(
"max_amplitude" ) ),
9307 QgsExpressionFunction::Parameter( QStringLiteral(
"seed" ),
true, 0 )
9308 }, fcnRoundWaveRandomized, QStringLiteral(
"GeometryGroup" ) )
9309 <<
new QgsStaticExpressionFunction( QStringLiteral(
"apply_dash_pattern" ),
9311 QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9312 QgsExpressionFunction::Parameter( QStringLiteral(
"pattern" ) ),
9313 QgsExpressionFunction::Parameter( QStringLiteral(
"start_rule" ),
true, QStringLiteral(
"no_rule" ) ),
9314 QgsExpressionFunction::Parameter( QStringLiteral(
"end_rule" ),
true, QStringLiteral(
"no_rule" ) ),
9315 QgsExpressionFunction::Parameter( QStringLiteral(
"adjustment" ),
true, QStringLiteral(
"both" ) ),
9316 QgsExpressionFunction::Parameter( QStringLiteral(
"pattern_offset" ),
true, 0 ),
9317 }, fcnApplyDashPattern, QStringLiteral(
"GeometryGroup" ) )
9318 <<
new QgsStaticExpressionFunction( QStringLiteral(
"densify_by_count" ),
9320 QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9321 QgsExpressionFunction::Parameter( QStringLiteral(
"vertices" ) )
9322 }, fcnDensifyByCount, QStringLiteral(
"GeometryGroup" ) )
9323 <<
new QgsStaticExpressionFunction( QStringLiteral(
"densify_by_distance" ),
9325 QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9326 QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) )
9327 }, fcnDensifyByDistance, QStringLiteral(
"GeometryGroup" ) )
9328 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_points" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumPoints, QStringLiteral(
"GeometryGroup" ) )
9329 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_interior_rings" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumInteriorRings, QStringLiteral(
"GeometryGroup" ) )
9330 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_rings" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumRings, QStringLiteral(
"GeometryGroup" ) )
9331 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_geometries" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumGeometries, QStringLiteral(
"GeometryGroup" ) )
9332 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_width" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnBoundsWidth, QStringLiteral(
"GeometryGroup" ) )
9333 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_height" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnBoundsHeight, QStringLiteral(
"GeometryGroup" ) )
9334 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_closed" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnIsClosed, QStringLiteral(
"GeometryGroup" ) )
9335 <<
new QgsStaticExpressionFunction( QStringLiteral(
"close_line" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnCloseLine, QStringLiteral(
"GeometryGroup" ) )
9336 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_empty" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnIsEmpty, QStringLiteral(
"GeometryGroup" ) )
9337 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_empty_or_null" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnIsEmptyOrNull, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
9338 <<
new QgsStaticExpressionFunction( QStringLiteral(
"convex_hull" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnConvexHull, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"convexHull" ) )
9339#if GEOS_VERSION_MAJOR>3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR>=11 )
9340 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concave_hull" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9341 << QgsExpressionFunction::Parameter( QStringLiteral(
"target_percent" ) )
9342 << QgsExpressionFunction::Parameter( QStringLiteral(
"allow_holes" ),
true,
false ), fcnConcaveHull, QStringLiteral(
"GeometryGroup" ) )
9345 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9346 fcnOrientedBBox, QStringLiteral(
"GeometryGroup" ) )
9348 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9349 fcnMainAngle, QStringLiteral(
"GeometryGroup" ) )
9351 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9352 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 36 ),
9353 fcnMinimalCircle, QStringLiteral(
"GeometryGroup" ) )
9354 <<
new QgsStaticExpressionFunction( QStringLiteral(
"difference" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
9355 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9356 fcnDifference, QStringLiteral(
"GeometryGroup" ) )
9358 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9359 fcnDistance, QStringLiteral(
"GeometryGroup" ) )
9360 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hausdorff_distance" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) )
9361 << QgsExpressionFunction::Parameter( QStringLiteral(
"densify_fraction" ),
true ),
9362 fcnHausdorffDistance, QStringLiteral(
"GeometryGroup" ) )
9363 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersection" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
9364 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9365 fcnIntersection, QStringLiteral(
"GeometryGroup" ) )
9366 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sym_difference" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
9367 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9368 fcnSymDifference, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"symDifference" ) )
9370 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9371 fcnCombine, QStringLiteral(
"GeometryGroup" ) )
9373 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9374 fcnCombine, QStringLiteral(
"GeometryGroup" ) )
9375 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_to_wkt" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9376 << QgsExpressionFunction::Parameter( QStringLiteral(
"precision" ),
true, 8.0 ),
9377 fcnGeomToWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomToWKT" ) )
9378 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_to_wkb" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9379 fcnGeomToWKB, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false )
9380 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geometry" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"feature" ) ), fcnGetGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true )
9382 << QgsExpressionFunction::Parameter( QStringLiteral(
"source_auth_id" ) )
9383 << QgsExpressionFunction::Parameter( QStringLiteral(
"dest_auth_id" ) ),
9384 fcnTransformGeometry, QStringLiteral(
"GeometryGroup" ) )
9386 << QgsExpressionFunction::Parameter( QStringLiteral(
"x" ) )
9387 << QgsExpressionFunction::Parameter( QStringLiteral(
"y" ) ),
9388 fcnExtrude, QStringLiteral(
"GeometryGroup" ), QString() )
9389 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_multipart" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9390 fcnGeomIsMultipart, QStringLiteral(
"GeometryGroup" ) )
9392 fcnZMax, QStringLiteral(
"GeometryGroup" ) )
9394 fcnZMin, QStringLiteral(
"GeometryGroup" ) )
9396 fcnMMax, QStringLiteral(
"GeometryGroup" ) )
9398 fcnMMin, QStringLiteral(
"GeometryGroup" ) )
9400 fcnSinuosity, QStringLiteral(
"GeometryGroup" ) )
9401 <<
new QgsStaticExpressionFunction( QStringLiteral(
"straight_distance_2d" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
9402 fcnStraightDistance2d, QStringLiteral(
"GeometryGroup" ) );
9405 QgsStaticExpressionFunction *orderPartsFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"order_parts" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9406 << QgsExpressionFunction::Parameter( QStringLiteral(
"orderby" ) )
9407 << QgsExpressionFunction::Parameter( QStringLiteral(
"ascending" ),
true,
true ),
9408 fcnOrderParts, QStringLiteral(
"GeometryGroup" ), QString() );
9413 const QList< QgsExpressionNode *> argList = node->
args()->
list();
9414 for ( QgsExpressionNode *argNode : argList )
9416 if ( !argNode->isStatic( parent, context ) )
9422 QgsExpressionNode *argNode = node->
args()->
at( 1 );
9424 QString expString = argNode->
eval( parent, context ).toString();
9428 if ( e.rootNode() && e.rootNode()->isStatic( parent, context ) )
9439 QgsExpressionNode *argNode = node->
args()->
at( 1 );
9440 QString
expression = argNode->
eval( parent, context ).toString();
9442 e.prepare( context );
9448 functions << orderPartsFunc;
9451 <<
new QgsStaticExpressionFunction( QStringLiteral(
"closest_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
9452 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9453 fcnClosestPoint, QStringLiteral(
"GeometryGroup" ) )
9454 <<
new QgsStaticExpressionFunction( QStringLiteral(
"shortest_line" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
9455 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
9456 fcnShortestLine, QStringLiteral(
"GeometryGroup" ) )
9457 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_interpolate_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9458 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) ), fcnLineInterpolatePoint, QStringLiteral(
"GeometryGroup" ) )
9459 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_interpolate_point_by_m" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9460 << QgsExpressionFunction::Parameter( QStringLiteral(
"m" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"use_3d_distance" ),
true,
false ),
9461 fcnLineInterpolatePointByM, QStringLiteral(
"GeometryGroup" ) )
9462 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_interpolate_angle" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9463 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) ), fcnLineInterpolateAngle, QStringLiteral(
"GeometryGroup" ) )
9464 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_locate_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9465 << QgsExpressionFunction::Parameter( QStringLiteral(
"point" ) ), fcnLineLocatePoint, QStringLiteral(
"GeometryGroup" ) )
9466 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_locate_m" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9467 << QgsExpressionFunction::Parameter( QStringLiteral(
"m" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"use_3d_distance" ),
true,
false ),
9468 fcnLineLocateM, QStringLiteral(
"GeometryGroup" ) )
9469 <<
new QgsStaticExpressionFunction( QStringLiteral(
"angle_at_vertex" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9470 << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ) ), fcnAngleAtVertex, QStringLiteral(
"GeometryGroup" ) )
9471 <<
new QgsStaticExpressionFunction( QStringLiteral(
"distance_to_vertex" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9472 << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ) ), fcnDistanceToVertex, QStringLiteral(
"GeometryGroup" ) )
9473 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_substring" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
9474 << QgsExpressionFunction::Parameter( QStringLiteral(
"start_distance" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"end_distance" ) ), fcnLineSubset, QStringLiteral(
"GeometryGroup" ) );
9479 QgsStaticExpressionFunction *idFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$id" ), 0, fcnFeatureId, QStringLiteral(
"Record and Attributes" ) );
9481 functions << idFunc;
9483 QgsStaticExpressionFunction *currentFeatureFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$currentfeature" ), 0, fcnFeature, QStringLiteral(
"Record and Attributes" ) );
9485 functions << currentFeatureFunc;
9487 QgsStaticExpressionFunction *uuidFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"uuid" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ),
true, QStringLiteral(
"WithBraces" ) ), fcnUuid, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$uuid" ) );
9489 functions << uuidFunc;
9492 <<
new QgsStaticExpressionFunction( QStringLiteral(
"feature_id" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"feature" ) ), fcnGetFeatureId, QStringLiteral(
"Record and Attributes" ), QString(),
true )
9494 << QgsExpressionFunction::Parameter( QStringLiteral(
"attribute" ) )
9495 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ),
true ),
9496 fcnGetFeature, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"QgsExpressionUtils::getFeature" ) )
9497 <<
new QgsStaticExpressionFunction( QStringLiteral(
"get_feature_by_id" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
9498 << QgsExpressionFunction::Parameter( QStringLiteral(
"feature_id" ) ),
9499 fcnGetFeatureById, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false );
9501 QgsStaticExpressionFunction *attributesFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"attributes" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"feature" ),
true ),
9504 functions << attributesFunc;
9505 QgsStaticExpressionFunction *representAttributesFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"represent_attributes" ), -1,
9508 functions << representAttributesFunc;
9510 QgsStaticExpressionFunction *validateFeature =
new QgsStaticExpressionFunction( QStringLiteral(
"is_feature_valid" ),
9512 << QgsExpressionFunction::Parameter( QStringLiteral(
"feature" ),
true )
9513 << QgsExpressionFunction::Parameter( QStringLiteral(
"strength" ),
true ),
9516 functions << validateFeature;
9518 QgsStaticExpressionFunction *validateAttribute =
new QgsStaticExpressionFunction( QStringLiteral(
"is_attribute_valid" ),
9521 << QgsExpressionFunction::Parameter( QStringLiteral(
"feature" ),
true )
9522 << QgsExpressionFunction::Parameter( QStringLiteral(
"strength" ),
true ),
9525 functions << validateAttribute;
9527 QgsStaticExpressionFunction *maptipFunc =
new QgsStaticExpressionFunction(
9528 QStringLiteral(
"maptip" ),
9531 QStringLiteral(
"Record and Attributes" ),
9537 functions << maptipFunc;
9539 QgsStaticExpressionFunction *displayFunc =
new QgsStaticExpressionFunction(
9540 QStringLiteral(
"display_expression" ),
9542 fcnFeatureDisplayExpression,
9543 QStringLiteral(
"Record and Attributes" ),
9549 functions << displayFunc;
9551 QgsStaticExpressionFunction *isSelectedFunc =
new QgsStaticExpressionFunction(
9552 QStringLiteral(
"is_selected" ),
9555 QStringLiteral(
"Record and Attributes" ),
9561 functions << isSelectedFunc;
9564 <<
new QgsStaticExpressionFunction(
9565 QStringLiteral(
"num_selected" ),
9568 QStringLiteral(
"Record and Attributes" ),
9575 <<
new QgsStaticExpressionFunction(
9576 QStringLiteral(
"sqlite_fetch_and_increment" ),
9578 << QgsExpressionFunction::Parameter( QStringLiteral(
"database" ) )
9579 << QgsExpressionFunction::Parameter( QStringLiteral(
"table" ) )
9580 << QgsExpressionFunction::Parameter( QStringLiteral(
"id_field" ) )
9581 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter_attribute" ) )
9582 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter_value" ) )
9583 << QgsExpressionFunction::Parameter( QStringLiteral(
"default_values" ),
true ),
9584 fcnSqliteFetchAndIncrement,
9585 QStringLiteral(
"Record and Attributes" )
9590 <<
new QgsStaticExpressionFunction( QStringLiteral(
"crs_to_authid" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"crs" ) ), fcnCrsToAuthid, QStringLiteral(
"CRS" ), QString(),
true )
9591 <<
new QgsStaticExpressionFunction( QStringLiteral(
"crs_from_text" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"definition" ) ), fcnCrsFromText, QStringLiteral(
"CRS" ) );
9595 QgsStaticExpressionFunction *representValueFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"represent_value" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"attribute" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"field_name" ),
true ), fcnRepresentValue, QStringLiteral(
"Record and Attributes" ) );
9602 QgsExpressionNodeColumnRef *colRef =
dynamic_cast<QgsExpressionNodeColumnRef *
>( node->
args()->at( 0 ) );
9609 parent->
setEvalErrorString( tr(
"If represent_value is called with 1 parameter, it must be an attribute." ) );
9619 parent->
setEvalErrorString( tr(
"represent_value must be called with exactly 1 or 2 parameters." ) );
9625 functions << representValueFunc;
9629 <<
new QgsStaticExpressionFunction( QStringLiteral(
"layer_property" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
9630 << QgsExpressionFunction::Parameter( QStringLiteral(
"property" ) ),
9631 fcnGetLayerProperty, QStringLiteral(
"Map Layers" ) )
9632 <<
new QgsStaticExpressionFunction( QStringLiteral(
"decode_uri" ),
9634 << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
9635 << QgsExpressionFunction::Parameter( QStringLiteral(
"part" ),
true ),
9636 fcnDecodeUri, QStringLiteral(
"Map Layers" ) )
9637 <<
new QgsStaticExpressionFunction( QStringLiteral(
"mime_type" ),
9639 << QgsExpressionFunction::Parameter( QStringLiteral(
"binary_data" ) ),
9640 fcnMimeType, QStringLiteral(
"General" ) )
9641 <<
new QgsStaticExpressionFunction( QStringLiteral(
"raster_statistic" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
9642 << QgsExpressionFunction::Parameter( QStringLiteral(
"band" ) )
9643 << QgsExpressionFunction::Parameter( QStringLiteral(
"statistic" ) ), fcnGetRasterBandStat, QStringLiteral(
"Rasters" ) );
9646 QgsStaticExpressionFunction *varFunction =
new QgsStaticExpressionFunction( QStringLiteral(
"var" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"name" ) ), fcnGetVariable, QStringLiteral(
"General" ) );
9657 QgsExpressionNode *argNode = node->
args()->
at( 0 );
9659 if ( !argNode->
isStatic( parent, context ) )
9662 const QString varName = argNode->
eval( parent, context ).toString();
9663 if ( varName == QLatin1String(
"feature" ) || varName == QLatin1String(
"id" ) || varName == QLatin1String(
"geometry" ) )
9667 return scope ? scope->
isStatic( varName ) :
false;
9675 if ( node && node->
args()->
count() > 0 )
9677 QgsExpressionNode *argNode = node->
args()->
at( 0 );
9678 if ( QgsExpressionNodeLiteral *literal =
dynamic_cast<QgsExpressionNodeLiteral *
>( argNode ) )
9680 if ( literal->value() == QLatin1String(
"geometry" ) || literal->value() == QLatin1String(
"feature" ) )
9691 QgsStaticExpressionFunction *evalTemplateFunction =
new QgsStaticExpressionFunction( QStringLiteral(
"eval_template" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"template" ) ), fcnEvalTemplate, QStringLiteral(
"General" ), QString(),
true, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES );
9697 QgsExpressionNode *argNode = node->
args()->
at( 0 );
9699 if ( argNode->
isStatic( parent, context ) )
9701 QString expString = argNode->
eval( parent, context ).toString();
9705 if ( e.rootNode() && e.rootNode()->isStatic( parent, context ) )
9712 functions << evalTemplateFunction;
9720 QgsExpressionNode *argNode = node->
args()->
at( 0 );
9722 if ( argNode->
isStatic( parent, context ) )
9724 QString expString = argNode->
eval( parent, context ).toString();
9728 if ( e.rootNode() && e.rootNode()->isStatic( parent, context ) )
9736 functions << evalFunc;
9738 QgsStaticExpressionFunction *attributeFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"attribute" ), -1, fcnAttribute, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES );
9742 const QList< QgsExpressionNode *> argList = node->
args()->
list();
9743 for ( QgsExpressionNode *argNode : argList )
9745 if ( !argNode->
isStatic( parent, context ) )
9757 functions << attributeFunc;
9760 <<
new QgsStaticExpressionFunction( QStringLiteral(
"env" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"name" ) ), fcnEnvVar, QStringLiteral(
"General" ), QString() )
9761 <<
new QgsWithVariableExpressionFunction()
9762 <<
new QgsStaticExpressionFunction( QStringLiteral(
"raster_value" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"band" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point" ) ), fcnRasterValue, QStringLiteral(
"Rasters" ) )
9763 <<
new QgsStaticExpressionFunction( QStringLiteral(
"raster_attributes" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"band" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point" ) ), fcnRasterAttributes, QStringLiteral(
"Rasters" ) )
9766 <<
new QgsArrayForeachExpressionFunction()
9767 <<
new QgsArrayFilterExpressionFunction()
9768 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array" ), -1, fcnArray, QStringLiteral(
"Arrays" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
9769 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_sort" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"ascending" ),
true,
true ), fcnArraySort, QStringLiteral(
"Arrays" ) )
9770 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_length" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayLength, QStringLiteral(
"Arrays" ) )
9771 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_contains" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayContains, QStringLiteral(
"Arrays" ) )
9772 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_count" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayCount, QStringLiteral(
"Arrays" ) )
9773 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_all" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"array_b" ) ), fcnArrayAll, QStringLiteral(
"Arrays" ) )
9774 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_find" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayFind, QStringLiteral(
"Arrays" ) )
9775 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_get" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"pos" ) ), fcnArrayGet, QStringLiteral(
"Arrays" ) )
9776 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_first" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayFirst, QStringLiteral(
"Arrays" ) )
9777 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_last" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayLast, QStringLiteral(
"Arrays" ) )
9778 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_min" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayMinimum, QStringLiteral(
"Arrays" ) )
9779 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_max" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayMaximum, QStringLiteral(
"Arrays" ) )
9780 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_mean" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayMean, QStringLiteral(
"Arrays" ) )
9781 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_median" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayMedian, QStringLiteral(
"Arrays" ) )
9782 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_majority" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"option" ),
true, QVariant(
"all" ) ), fcnArrayMajority, QStringLiteral(
"Arrays" ) )
9783 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_minority" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"option" ),
true, QVariant(
"all" ) ), fcnArrayMinority, QStringLiteral(
"Arrays" ) )
9784 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_sum" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArraySum, QStringLiteral(
"Arrays" ) )
9785 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_append" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayAppend, QStringLiteral(
"Arrays" ) )
9786 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_prepend" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayPrepend, QStringLiteral(
"Arrays" ) )
9787 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_insert" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"pos" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayInsert, QStringLiteral(
"Arrays" ) )
9788 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_remove_at" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"pos" ) ), fcnArrayRemoveAt, QStringLiteral(
"Arrays" ) )
9789 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_remove_all" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayRemoveAll, QStringLiteral(
"Arrays" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
9790 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_replace" ), -1, fcnArrayReplace, QStringLiteral(
"Arrays" ) )
9791 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_prioritize" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"array_prioritize" ) ), fcnArrayPrioritize, QStringLiteral(
"Arrays" ) )
9792 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_cat" ), -1, fcnArrayCat, QStringLiteral(
"Arrays" ) )
9793 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_slice" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"start_pos" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"end_pos" ) ), fcnArraySlice, QStringLiteral(
"Arrays" ) )
9794 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_reverse" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayReverse, QStringLiteral(
"Arrays" ) )
9795 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_intersect" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"array2" ) ), fcnArrayIntersect, QStringLiteral(
"Arrays" ) )
9796 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_distinct" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayDistinct, QStringLiteral(
"Arrays" ) )
9797 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_to_string" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"delimiter" ),
true,
"," ) << QgsExpressionFunction::Parameter( QStringLiteral(
"emptyvalue" ),
true,
"" ), fcnArrayToString, QStringLiteral(
"Arrays" ) )
9798 <<
new QgsStaticExpressionFunction( QStringLiteral(
"string_to_array" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"delimiter" ),
true,
"," ) << QgsExpressionFunction::Parameter( QStringLiteral(
"emptyvalue" ),
true,
"" ), fcnStringToArray, QStringLiteral(
"Arrays" ) )
9799 <<
new QgsStaticExpressionFunction( QStringLiteral(
"generate_series" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"start" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"stop" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"step" ),
true, 1.0 ), fcnGenerateSeries, QStringLiteral(
"Arrays" ) )
9800 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geometries_to_array" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometries" ) ), fcnGeometryCollectionAsArray, QStringLiteral(
"Arrays" ) )
9803 <<
new QgsStaticExpressionFunction( QStringLiteral(
"from_json" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnLoadJson, QStringLiteral(
"Maps" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"json_to_map" ) )
9804 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_json" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"json_string" ) ), fcnWriteJson, QStringLiteral(
"Maps" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"map_to_json" ) )
9805 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hstore_to_map" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnHstoreToMap, QStringLiteral(
"Maps" ) )
9806 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_to_hstore" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnMapToHstore, QStringLiteral(
"Maps" ) )
9807 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map" ), -1, fcnMap, QStringLiteral(
"Maps" ) )
9808 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_get" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ), fcnMapGet, QStringLiteral(
"Maps" ) )
9809 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_exist" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ), fcnMapExist, QStringLiteral(
"Maps" ) )
9810 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_delete" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ), fcnMapDelete, QStringLiteral(
"Maps" ) )
9811 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_insert" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnMapInsert, QStringLiteral(
"Maps" ) )
9812 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_concat" ), -1, fcnMapConcat, QStringLiteral(
"Maps" ) )
9813 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_akeys" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnMapAKeys, QStringLiteral(
"Maps" ) )
9814 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_avals" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnMapAVals, QStringLiteral(
"Maps" ) )
9816 << QgsExpressionFunction::Parameter( QStringLiteral(
"prefix" ) ),
9817 fcnMapPrefixKeys, QStringLiteral(
"Maps" ) )
9818 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_to_html_table" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ),
9819 fcnMapToHtmlTable, QStringLiteral(
"Maps" ) )
9821 fcnMapToHtmlDefinitionList, QStringLiteral(
"Maps" ) )
9823 fcnToFormUrlEncode, QStringLiteral(
"Maps" ) )
9832 *sOwnedFunctions() << func;
9833 *sBuiltinFunctions() << func->name();
9834 sBuiltinFunctions()->append( func->aliases() );
9848 QMutexLocker locker( &sFunctionsMutex );
9849 sFunctions()->append( function );
9850 if ( transferOwnership )
9851 sOwnedFunctions()->append( function );
9866 QMutexLocker locker( &sFunctionsMutex );
9867 sFunctions()->removeAt( fnIdx );
9868 sFunctionIndexMap.clear();
9876 qDeleteAll( *sOwnedFunctions() );
9877 sOwnedFunctions()->clear();
9882 if ( sBuiltinFunctions()->isEmpty() )
9886 return *sBuiltinFunctions();
9893 QStringLiteral(
"Arrays" ) )
9902 QgsExpressionNode::NodeList *args = node->
args();
9904 if ( args->
count() < 2 )
9907 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
9917 QVariantList result;
9919 if ( args->
count() < 2 )
9923 QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
9925 QgsExpressionContext *subContext =
const_cast<QgsExpressionContext *
>( context );
9926 std::unique_ptr< QgsExpressionContext > tempContext;
9929 tempContext = std::make_unique< QgsExpressionContext >();
9930 subContext = tempContext.get();
9933 QgsExpressionContextScope *subScope =
new QgsExpressionContextScope();
9937 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it, ++i )
9941 result << args->
at( 1 )->
eval( parent, subContext );
9966 if ( args->
count() < 2 )
9970 args->
at( 0 )->
prepare( parent, context );
9974 subContext = *context;
9981 args->
at( 1 )->
prepare( parent, &subContext );
9991 QStringLiteral(
"Arrays" ) )
10002 if ( args->
count() < 2 )
10005 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
10015 QVariantList result;
10017 if ( args->
count() < 2 )
10021 const QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
10023 QgsExpressionContext *subContext =
const_cast<QgsExpressionContext *
>( context );
10024 std::unique_ptr< QgsExpressionContext > tempContext;
10027 tempContext = std::make_unique< QgsExpressionContext >();
10028 subContext = tempContext.get();
10031 QgsExpressionContextScope *subScope =
new QgsExpressionContextScope();
10035 if ( args->
count() >= 3 )
10037 const QVariant limitVar = args->
at( 2 )->
eval( parent, context );
10039 if ( QgsExpressionUtils::isIntSafe( limitVar ) )
10041 limit = limitVar.toInt();
10049 for (
const QVariant &value : array )
10051 subScope->
addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral(
"element" ), value,
true ) );
10052 if ( args->
at( 1 )->
eval( parent, subContext ).toBool() )
10056 if ( limit > 0 && limit == result.size() )
10071 Q_UNUSED( context )
10083 if ( args->
count() < 2 )
10087 args->
at( 0 )->
prepare( parent, context );
10091 subContext = *context;
10097 args->
at( 1 )->
prepare( parent, &subContext );
10106 QStringLiteral(
"General" ) )
10115 QgsExpressionNode::NodeList *args = node->
args();
10117 if ( args->
count() < 3 )
10121 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
10123 QVariant
name = args->
at( 0 )->
eval( parent, context );
10124 QVariant value = args->
at( 1 )->
eval( parent, context );
10127 appendTemporaryVariable( context,
name.toString(), value );
10128 if ( args->
at( 2 )->
isStatic( parent, context ) )
10130 popTemporaryVariable( context );
10141 if ( args->
count() < 3 )
10145 QVariant
name = args->
at( 0 )->
eval( parent, context );
10146 QVariant value = args->
at( 1 )->
eval( parent, context );
10148 const QgsExpressionContext *updatedContext = context;
10149 std::unique_ptr< QgsExpressionContext > tempContext;
10150 if ( !updatedContext )
10152 tempContext = std::make_unique< QgsExpressionContext >();
10153 updatedContext = tempContext.get();
10156 appendTemporaryVariable( updatedContext,
name.toString(), value );
10157 result = args->
at( 2 )->
eval( parent, updatedContext );
10160 popTemporaryVariable( updatedContext );
10169 Q_UNUSED( context )
10181 if ( args->
count() < 3 )
10186 QVariant value = args->
at( 1 )->
prepare( parent, context );
10189 std::unique_ptr< QgsExpressionContext > tempContext;
10190 if ( !updatedContext )
10192 tempContext = std::make_unique< QgsExpressionContext >();
10193 updatedContext = tempContext.get();
10196 appendTemporaryVariable( updatedContext,
name.toString(), value );
10197 args->
at( 2 )->
prepare( parent, updatedContext );
10200 popTemporaryVariable( updatedContext );
10205void QgsWithVariableExpressionFunction::popTemporaryVariable(
const QgsExpressionContext *context )
const
10207 QgsExpressionContext *updatedContext =
const_cast<QgsExpressionContext *
>( context );
10208 delete updatedContext->
popScope();
10211void QgsWithVariableExpressionFunction::appendTemporaryVariable(
const QgsExpressionContext *context,
const QString &name,
const QVariant &value )
const
10213 QgsExpressionContextScope *scope =
new QgsExpressionContextScope();
10214 scope->
addVariable( QgsExpressionContextScope::StaticVariable(
name, value,
true ) );
10216 QgsExpressionContext *updatedContext =
const_cast<QgsExpressionContext *
>( context );
@ Left
Buffer to left of line.
DashPatternSizeAdjustment
Dash pattern size adjustment options.
@ ScaleDashOnly
Only dash lengths are adjusted.
@ ScaleBothDashAndGap
Both the dash and gap lengths are adjusted equally.
@ ScaleGapOnly
Only gap lengths are adjusted.
@ Success
Operation succeeded.
@ Visvalingam
The simplification gives each point in a line an importance weighting, so that least important points...
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
JoinStyle
Join styles for buffers.
@ Bevel
Use beveled joins.
@ Round
Use rounded joins.
@ Miter
Use mitered joins.
RasterBandStatistic
Available raster band statistics.
@ StdDev
Standard deviation.
@ NoStatistic
No statistic.
@ Group
Composite group layer. Added in QGIS 3.24.
@ Plugin
Plugin based layer.
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Mesh
Mesh layer. Added in QGIS 3.2.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
EndCapStyle
End cap styles for buffers.
@ Flat
Flat cap (in line with start/end of line).
@ Square
Square cap (extends past start/end of line by buffer distance).
Aggregate
Available aggregates to calculate.
@ StringMinimumLength
Minimum length of string (string fields only).
@ FirstQuartile
First quartile (numeric fields only).
@ Mean
Mean of values (numeric fields only).
@ Median
Median of values (numeric fields only).
@ StringMaximumLength
Maximum length of string (string fields only).
@ Range
Range of values (max - min) (numeric and datetime fields only).
@ StringConcatenateUnique
Concatenate unique values with a joining string (string fields only). Specify the delimiter using set...
@ Minority
Minority of values.
@ CountMissing
Number of missing (null) values.
@ ArrayAggregate
Create an array of values.
@ Majority
Majority of values.
@ StDevSample
Sample standard deviation of values (numeric fields only).
@ ThirdQuartile
Third quartile (numeric fields only).
@ CountDistinct
Number of distinct values.
@ StringConcatenate
Concatenate values with a joining string (string fields only). Specify the delimiter using setDelimit...
@ GeometryCollect
Create a multipart geometry from aggregated geometries.
@ InterQuartileRange
Inter quartile range (IQR) (numeric fields only).
DashPatternLineEndingRule
Dash pattern line ending rules.
@ HalfDash
Start or finish the pattern with a half length dash.
@ HalfGap
Start or finish the pattern with a half length gap.
@ FullGap
Start or finish the pattern with a full gap.
@ FullDash
Start or finish the pattern with a full dash.
MakeValidMethod
Algorithms to use when repairing invalid geometries.
@ Linework
Combines all rings into a set of noded lines and then extracts valid polygons from that linework.
@ Structure
Structured method, first makes all rings valid and then merges shells and subtracts holes from shells...
@ GeometryCollection
GeometryCollection.
Abstract base class for all geometries.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
virtual const QgsAbstractGeometry * simplifiedTypeRef() const
Returns a reference to the simplest lossless representation of this geometry, e.g.
bool isMeasure() const
Returns true if the geometry contains m values.
virtual QgsRectangle boundingBox() const
Returns the minimal bounding box for the geometry.
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
virtual double length() const
Returns the planar, 2-dimensional length of the geometry.
virtual QgsCoordinateSequence coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
virtual int partCount() const =0
Returns count of parts contained in the geometry.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
static Qgis::Aggregate stringToAggregate(const QString &string, bool *ok=nullptr)
Converts a string to a aggregate type.
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
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.
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 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...
QgsArrayFilterExpressionFunction()
QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Returns result of evaluating the function.
QgsArrayForeachExpressionFunction()
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 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...
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.
Abstract base class for color ramps.
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
Represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString toProj() const
Returns a Proj string representation of this CRS.
QString ellipsoidAcronym() const
Returns the ellipsoid acronym for the ellipsoid used by the CRS.
Qgis::DistanceUnit mapUnits
Contains information about the context in which a coordinate transform is executed.
Custom exception class for Coordinate Reference System related exceptions.
Curve polygon geometry type.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
bool isEmpty() const override
Returns true if the geometry is empty.
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
double area() const override
Returns the planar, 2-dimensional area of the geometry.
double roundness() const
Returns the roundness of the curve polygon.
int ringCount(int part=0) const override
Returns the number of rings of which this geometry is built.
Abstract base class for curved geometry type.
double sinuosity() const
Returns the curve sinuosity, which is the ratio of the curve length() to curve straightDistance2d().
QgsCurve * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
virtual QgsCurve * curveSubstring(double startDistance, double endDistance) const =0
Returns a new curve representing a substring of this curve.
virtual bool isClosed() const
Returns true if the curve is closed.
double straightDistance2d() const
Returns the straight distance of the curve, i.e.
virtual QgsCurve * reversed() const =0
Returns a reversed copy of the curve, where the direction of the curve has been flipped.
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations.
double measureArea(const QgsGeometry &geometry) const
Measures the area of a geometry.
double convertLengthMeasurement(double length, Qgis::DistanceUnit toUnits) const
Takes a length measurement calculated by this QgsDistanceArea object and converts it to a different d...
double measurePerimeter(const QgsGeometry &geometry) const
Measures the perimeter of a polygon geometry.
double measureLength(const QgsGeometry &geometry) const
Measures the length of a geometry.
double bearing(const QgsPointXY &p1, const QgsPointXY &p2) const
Computes the bearing (in radians) between two points.
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
double convertAreaMeasurement(double area, Qgis::AreaUnit toUnits) const
Takes an area measurement calculated by this QgsDistanceArea object and converts it to a different ar...
Single scope for storing variables and functions for use within a QgsExpressionContext.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
bool isStatic(const QString &name) const
Tests whether the variable with the specified name is static and can be cached.
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.
static void registerContextFunctions()
Registers all known core functions provided by QgsExpressionContextScope objects.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
void setCachedValue(const QString &key, const QVariant &value) const
Sets a value to cache within the expression context.
QString uniqueHash(bool &ok, const QSet< QString > &variables=QSet< QString >()) const
Returns a unique hash representing the current state of the context.
QgsGeometry geometry() const
Convenience function for retrieving the geometry for the context, if set.
QgsFeature feature() const
Convenience function for retrieving the feature for the context, if set.
QgsExpressionContextScope * activeScopeForVariable(const QString &name)
Returns the currently active scope from the context for a specified variable name.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
QgsFeedback * feedback() const
Returns the feedback object that can be queried regularly by the expression to check if evaluation sh...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
bool hasGeometry() const
Returns true if the context has a geometry associated with it.
bool hasCachedValue(const QString &key) const
Returns true if the expression context contains a cached value with a matching key.
QVariant variable(const QString &name) const
Fetches a matching variable from the context.
QVariant cachedValue(const QString &key) const
Returns the matching cached value, if set.
bool hasFeature() const
Returns true if the context has a feature associated with it.
QgsFields fields() const
Convenience function for retrieving the fields for the context, if set.
Represents a single parameter passed to a function.
An abstract base class for defining QgsExpression functions.
QList< QgsExpressionFunction::Parameter > ParameterList
List of parameters, used for function definition.
bool operator==(const QgsExpressionFunction &other) const
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.
virtual bool isDeprecated() const
Returns true if the function is deprecated and should not be presented as a valid option to users in ...
virtual bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const
Will be called during prepare to determine if the function is static.
virtual QStringList aliases() const
Returns a list of possible aliases for the function.
bool lazyEval() const
true if this function should use lazy evaluation.
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...
QString name() const
The name of the function.
virtual QVariant run(QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)
Evaluates the function, first evaluating all required arguments before passing them to the function's...
virtual QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)=0
Returns result of evaluating the function.
virtual QSet< QString > referencedColumns(const QgsExpressionNodeFunction *node) const
Returns a set of field names which are required for this function.
virtual bool handlesNull() const
Returns true if the function handles NULL values in arguments by itself, and the default NULL value h...
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.
const QString helpText() const
The help text for the function.
virtual bool usesGeometry(const QgsExpressionNodeFunction *node) const
Does this function use a geometry object.
An expression node which takes its value from a feature's field.
QString name() const
The name of the column.
An expression node for expression functions.
QgsExpressionNode::NodeList * args() const
Returns a list of arguments specified for the function.
An expression node for literal values.
A list of expression nodes.
QList< QgsExpressionNode * > list()
Gets a list of all the nodes.
QgsExpressionNode * at(int i)
Gets the node at position i in the list.
int count() const
Returns the number of nodes in the list.
Abstract base class for all nodes that can appear in an expression.
virtual QString dump() const =0
Dump this node into a serialized (part) of an expression.
QVariant eval(QgsExpression *parent, const QgsExpressionContext *context)
Evaluate this node with the given context and parent.
virtual bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const =0
Returns true if this node can be evaluated for a static value.
bool prepare(QgsExpression *parent, const QgsExpressionContext *context)
Prepare this node for evaluation.
virtual QSet< QString > referencedColumns() const =0
Abstract virtual method which returns a list of columns required to evaluate this node.
virtual QSet< QString > referencedVariables() const =0
Returns a set of all variables which are used in this expression.
A set of expression-related functions.
Handles parsing and evaluation of expressions (formerly called "search strings").
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
static const QList< QgsExpressionFunction * > & Functions()
QString expression() const
Returns the original, unmodified expression string.
static void cleanRegisteredFunctions()
Deletes all registered functions whose ownership have been transferred to the expression engine.
Qgis::DistanceUnit distanceUnits() const
Returns the desired distance units for calculations involving geomCalculator(), e....
static bool registerFunction(QgsExpressionFunction *function, bool transferOwnership=false)
Registers a function to the expression engine.
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required.
static int functionIndex(const QString &name)
Returns index of the function in Functions array.
static const QStringList & BuiltinFunctions()
QSet< QString > referencedVariables() const
Returns a list of all variables which are used in this expression.
static QString replaceExpressionText(const QString &action, const QgsExpressionContext *context, const QgsDistanceArea *distanceArea=nullptr)
This function replaces each expression between [% and %] in the string with the result of its evaluat...
static PRIVATE QString helpText(QString name)
Returns the help text for a specified function.
static QString createFieldEqualityExpression(const QString &fieldName, const QVariant &value, QMetaType::Type fieldType=QMetaType::Type::UnknownType)
Create an expression allowing to evaluate if a field is equal to a value.
static bool unregisterFunction(const QString &name)
Unregisters a function from the expression engine.
Qgis::AreaUnit areaUnits() const
Returns the desired areal units for calculations involving geomCalculator(), e.g.,...
void setEvalErrorString(const QString &str)
Sets evaluation error (used internally by evaluation functions).
friend class QgsExpressionNodeFunction
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
QgsExpression(const QString &expr)
Creates a new expression based on the provided string.
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
QVariant evaluate()
Evaluate the feature and return the result.
QgsDistanceArea * geomCalculator()
Returns calculator used for distance and area calculations (used by $length, $area and $perimeter fun...
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
The OrderByClause class represents an order by clause for a QgsFeatureRequest.
Represents a list of OrderByClauses, with the most important first and the least important last.
Wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setFlags(Qgis::FeatureRequestFlags flags)
Sets flags that affect how features will be fetched.
QgsFeatureRequest & setLimit(long long limit)
Set the maximum number of features to request.
QgsFeatureRequest & setRequestMayBeNested(bool requestMayBeNested)
In case this request may be run nested within another already running iteration on the same connectio...
QgsFeatureRequest & setTimeout(int timeout)
Sets the timeout (in milliseconds) for the maximum time we should wait during feature requests before...
static const QString ALL_ATTRIBUTES
A special attribute that if set matches all attributes.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
void setFeedback(QgsFeedback *feedback)
Attach a feedback object that can be queried regularly by the iterator to check if it should be cance...
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets the feature ID that should be fetched.
QgsVectorLayer * materialize(const QgsFeatureRequest &request, QgsFeedback *feedback=nullptr)
Materializes a request (query) made against this feature source, by running it over the source and re...
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool hasGeometry() const
Returns true if the feature has an associated geometry.
bool isValid() const
Returns the validity of this feature.
Q_INVOKABLE QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
ConstraintStrength
Strength of constraints.
@ ConstraintStrengthNotSet
Constraint is not set.
@ ConstraintStrengthSoft
User is warned if constraint is violated but feature can still be accepted.
@ ConstraintStrengthHard
Constraint must be honored before feature can be accepted.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
Container of fields for a vector layer.
Q_INVOKABLE int indexFromName(const QString &fieldName) const
Gets the field index from the field name.
int size() const
Returns number of items.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
virtual bool removeGeometry(int nr)
Removes a geometry from the collection.
QgsGeometryCollection * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
int partCount() const override
Returns count of parts contained in the geometry.
int numGeometries() const
Returns the number of geometries within the collection.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
static QVector< QgsLineString * > extractLineStrings(const QgsAbstractGeometry *geom)
Returns list of linestrings extracted from the passed geometry.
A geometry is the spatial representation of a feature.
double hausdorffDistanceDensify(const QgsGeometry &geom, double densifyFraction) const
Returns the Hausdorff distance between this geometry and geom.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
double lineLocatePoint(const QgsGeometry &point) const
Returns a distance representing the location along this linestring of the closest point on this lines...
QgsGeometry difference(const QgsGeometry &geometry, const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const
Returns a geometry representing the points making up this geometry that do not make up other.
double length() const
Returns the planar, 2-dimensional length of geometry.
QgsGeometry offsetCurve(double distance, int segments, Qgis::JoinStyle joinStyle, double miterLimit) const
Returns an offset line at a given distance and side from an input line.
QgsGeometry densifyByDistance(double distance) const
Densifies the geometry by adding regularly placed extra nodes inside each segment so that the maximum...
QgsGeometry poleOfInaccessibility(double precision, double *distanceToBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
QgsAbstractGeometry::const_part_iterator const_parts_begin() const
Returns STL-style const iterator pointing to the first part of the geometry.
QgsGeometry squareWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs square waves along the boundary of the geometry, with the specified wavelength and amplitu...
QgsGeometry triangularWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs triangular waves along the boundary of the geometry, with the specified wavelength and amp...
bool vertexIdFromVertexNr(int number, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry.
bool touches(const QgsGeometry &geometry) const
Returns true if the geometry touches another geometry.
QgsGeometry applyDashPattern(const QVector< double > &pattern, Qgis::DashPatternLineEndingRule startRule=Qgis::DashPatternLineEndingRule::NoRule, Qgis::DashPatternLineEndingRule endRule=Qgis::DashPatternLineEndingRule::NoRule, Qgis::DashPatternSizeAdjustment adjustment=Qgis::DashPatternSizeAdjustment::ScaleBothDashAndGap, double patternOffset=0) const
Applies a dash pattern to a geometry, returning a MultiLineString geometry which is the input geometr...
QgsGeometry roundWaves(double wavelength, double amplitude, bool strictWavelength=false) const
Constructs rounded (sine-like) waves along the boundary of the geometry, with the specified wavelengt...
QgsGeometry nearestPoint(const QgsGeometry &other) const
Returns the nearest (closest) point on this geometry to another geometry.
static QgsGeometry collectGeometry(const QVector< QgsGeometry > &geometries)
Creates a new multipart geometry from a list of QgsGeometry objects.
QgsGeometry mergeLines(const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const
Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line ...
static QgsGeometry fromMultiPolylineXY(const QgsMultiPolylineXY &multiline)
Creates a new geometry from a QgsMultiPolylineXY object.
QgsGeometry makeValid(Qgis::MakeValidMethod method=Qgis::MakeValidMethod::Linework, bool keepCollapsed=false) const
Attempts to make an invalid geometry valid without losing vertices.
QString lastError() const
Returns an error string referring to the last error encountered either when this geometry was created...
QgsGeometry combine(const QgsGeometry &geometry, const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const
Returns a geometry representing all the points in this geometry and other (a union geometry operation...
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer for a (multi)linestring geometry, where the width at each node is ...
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
QgsPoint vertexAt(int atVertex) const
Returns coordinates of a vertex.
bool disjoint(const QgsGeometry &geometry) const
Returns true if the geometry is disjoint of another geometry.
QVector< QgsGeometry > asGeometryCollection() const
Returns contents of the geometry as a list of geometries.
QgsGeometry roundWavesRandomized(double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed=0) const
Constructs randomized rounded (sine-like) waves along the boundary of the geometry,...
double distance(const QgsGeometry &geom) const
Returns the minimum distance between this geometry and another geometry.
QgsGeometry interpolate(double distance) const
Returns an interpolated point on the geometry at the specified distance.
QgsGeometry extrude(double x, double y)
Returns an extruded version of this geometry.
static QgsGeometry fromMultiPointXY(const QgsMultiPointXY &multipoint)
Creates a new geometry from a QgsMultiPointXY object.
QgsGeometry singleSidedBuffer(double distance, int segments, Qgis::BufferSide side, Qgis::JoinStyle joinStyle=Qgis::JoinStyle::Round, double miterLimit=2.0) const
Returns a single sided buffer for a (multi)line geometry.
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
static Q_INVOKABLE QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
bool contains(const QgsPointXY *p) const
Returns true if the geometry contains the point p.
QgsGeometry forceRHR() const
Forces geometries to respect the Right-Hand-Rule, in which the area that is bounded by a polygon is t...
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
bool equals(const QgsGeometry &geometry) const
Test if this geometry is exactly equal to another geometry.
bool isGeosValid(Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const
Checks validity of the geometry using GEOS.
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a variable width buffer ("tapered buffer") for a (multi)curve geometry.
bool within(const QgsGeometry &geometry) const
Returns true if the geometry is completely within another geometry.
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...
double area() const
Returns the planar, 2-dimensional area of the geometry.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
bool crosses(const QgsGeometry &geometry) const
Returns true if the geometry crosses another geometry.
double hausdorffDistance(const QgsGeometry &geom) const
Returns the Hausdorff distance between this geometry and geom.
QgsGeometry concaveHull(double targetPercent, bool allowHoles=false) const
Returns a possibly concave polygon that contains all the points in the geometry.
QgsGeometry convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry.
QgsGeometry sharedPaths(const QgsGeometry &other) const
Find paths shared between the two given lineal geometries (this and other).
void fromWkb(unsigned char *wkb, int length)
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length.
QgsGeometry intersection(const QgsGeometry &geometry, const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const
Returns a geometry representing the points shared by this geometry and other.
QgsGeometry symDifference(const QgsGeometry &geometry, const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const
Returns a geometry representing the points making up this geometry that do not make up other.
QgsGeometry minimalEnclosingCircle(QgsPointXY ¢er, double &radius, unsigned int segments=36) const
Returns the minimal enclosing circle for the geometry.
static QgsGeometry fromMultiPolygonXY(const QgsMultiPolygonXY &multipoly)
Creates a new geometry from a QgsMultiPolygonXY.
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...
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
double distanceToVertex(int vertex) const
Returns the distance along this geometry from its first vertex to the specified vertex.
QgsAbstractGeometry::const_part_iterator const_parts_end() const
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
QgsAbstractGeometry::vertex_iterator vertices_begin() const
Returns STL-style iterator pointing to the first vertex of the geometry.
QgsGeometry forcePolygonClockwise() const
Forces geometries to respect the exterior ring is clockwise, interior rings are counter-clockwise con...
static QgsGeometry createWedgeBuffer(const QgsPoint ¢er, double azimuth, double angularWidth, double outerRadius, double innerRadius=0)
Creates a wedge shaped buffer from a center point.
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...
QgsGeometry triangularWavesRandomized(double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed=0) const
Constructs randomized triangular waves along the boundary of the geometry, with the specified wavelen...
QgsGeometry squareWavesRandomized(double minimumWavelength, double maximumWavelength, double minimumAmplitude, double maximumAmplitude, unsigned long seed=0) const
Constructs randomized square waves along the boundary of the geometry, with the specified wavelength ...
QgsGeometry simplify(double tolerance) const
Returns a simplified version of this geometry using a specified tolerance value.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
Qgis::GeometryOperationResult rotate(double rotation, const QgsPointXY ¢er)
Rotate this geometry around the Z axis.
Qgis::GeometryOperationResult translate(double dx, double dy, double dz=0.0, double dm=0.0)
Translates this geometry by dx, dy, dz and dm.
double interpolateAngle(double distance) const
Returns the angle parallel to the linestring or polygon boundary at the specified distance along the ...
double angleAtVertex(int vertex) const
Returns the bisector angle for this geometry at the specified vertex.
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.
QgsGeometry forcePolygonCounterClockwise() const
Forces geometries to respect the exterior ring is counter-clockwise, interior rings are clockwise con...
Q_INVOKABLE QString asWkt(int precision=17) const
Exports the geometry to WKT.
Qgis::WkbType wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.).
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry, double precision=0.0, Qgis::GeosCreationFlags flags=Qgis::GeosCreationFlag::SkipEmptyInteriorRings)
Creates and returns a new geometry engine representing the specified geometry using precision on a gr...
bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
QgsAbstractGeometry::vertex_iterator vertices_end() const
Returns STL-style iterator pointing to the imaginary vertex after the last vertex of the geometry.
bool overlaps(const QgsGeometry &geometry) const
Returns true if the geometry overlaps another geometry.
QgsGeometry shortestLine(const QgsGeometry &other) const
Returns the shortest line joining this geometry to another geometry.
Does vector analysis using the GEOS library and handles import, export, and exception handling.
std::unique_ptr< QgsAbstractGeometry > maximumInscribedCircle(double tolerance, QString *errorMsg=nullptr) const
Returns the maximum inscribed circle.
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
Represents a color stop within a QgsGradientColorRamp color ramp.
static QString build(const QVariantMap &map)
Build a hstore-formatted string from a QVariantMap.
static QVariantMap parse(const QString &string)
Returns a QVariantMap object containing the key and values from a hstore-formatted string.
A representation of the interval between two datetime values.
bool isValid() const
Returns true if the interval is valid.
double days() const
Returns the interval duration in days.
double weeks() const
Returns the interval duration in weeks.
double months() const
Returns the interval duration in months (based on a 30 day month).
double seconds() const
Returns the interval duration in seconds.
double years() const
Returns the interval duration in years (based on an average year length).
double hours() const
Returns the interval duration in hours.
double minutes() const
Returns the interval duration in minutes.
Line string geometry type, with support for z-dimension and m-values.
bool lineLocatePointByM(double m, double &x, double &y, double &z, double &distanceFromStart, bool use3DDistance=true) const
Attempts to locate a point on the linestring by m value.
QgsLineString * clone() const override
Clones the geometry by performing a deep copy.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
Base class for all map layer types.
virtual QgsRectangle extent() const
Returns the extent of the layer.
QString source() const
Returns the source for the layer.
QString providerType() const
Returns the provider type (provider key) for this layer.
QgsCoordinateReferenceSystem crs
QgsMapLayerServerProperties * serverProperties()
Returns QGIS Server Properties for the map layer.
QgsLayerMetadata metadata
QString publicSource(bool hidePassword=false) const
Gets a version of the internal layer definition that has sensitive bits removed (for example,...
virtual bool isEditable() const
Returns true if the layer can be edited.
double minimumScale() const
Returns the minimum map scale (i.e.
virtual Q_INVOKABLE QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be nullptr.
double maximumScale() const
Returns the maximum map scale (i.e.
Implementation of a geometry simplifier using the "MapToPixel" algorithm.
@ SimplifyGeometry
The geometries can be simplified using the current map2pixel context state.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
Multi line string geometry collection.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
Multi point geometry collection.
bool addGeometry(QgsAbstractGeometry *g) override
Adds a geometry and takes ownership. Returns true in case of success.
Custom exception class which is raised when an operation is not supported.
static QgsGeometry geometryFromGML(const QString &xmlString, const QgsOgcUtils::Context &context=QgsOgcUtils::Context())
Static method that creates geometry from GML.
bool isEmpty() const
Returns true if the geometry is empty.
Point geometry type, with support for z-dimension and m-values.
double inclination(const QgsPoint &other) const
Calculates Cartesian inclination between this point and other one (starting from zenith = 0 to nadir ...
bool addZValue(double zValue=0) override
Adds a z-dimension to the geometry, initialized to a preset value.
bool isValid(QString &error, Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const override
Checks validity of the geometry, and returns true if the geometry is valid.
QgsPoint * clone() const override
Clones the geometry by performing a deep copy.
QgsPoint project(double distance, double azimuth, double inclination=90.0) const
Returns a new point which corresponds to this point projected by a specified distance with specified ...
QgsRelationManager * relationManager
static QgsProject * instance()
Returns the QgsProject singleton instance.
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Quadrilateral geometry type.
static QgsQuadrilateral squareFromDiagonal(const QgsPoint &p1, const QgsPoint &p2)
Construct a QgsQuadrilateral as a square from a diagonal.
QgsPolygon * toPolygon(bool force2D=false) const
Returns the quadrilateral as a new polygon.
static QgsQuadrilateral rectangleFrom3Points(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, ConstructionOption mode)
Construct a QgsQuadrilateral as a Rectangle from 3 points.
ConstructionOption
A quadrilateral can be constructed from 3 points where the second distance can be determined by the t...
@ Distance
Second distance is equal to the distance between 2nd and 3rd point.
@ Projected
Second distance is equal to the distance of the perpendicular projection of the 3rd point on the segm...
The Field class represents a Raster Attribute Table field, including its name, usage and type.
bool isRamp() const
Returns true if the field carries a color ramp component information (RedMin/RedMax,...
bool isColor() const
Returns true if the field carries a color component (Red, Green, Blue and optionally Alpha) informati...
The RasterBandStats struct is a container for statistics about a single raster band.
double mean
The mean cell value for the band. NO_DATA values are excluded.
double stdDev
The standard deviation of the cell values.
double minimumValue
The minimum cell value in the raster band.
double sum
The sum of all cells in the band. NO_DATA values are excluded.
double maximumValue
The maximum cell value in the raster band.
double range
The range is the distance between min & max.
A rectangle specified with double values.
void grow(double delta)
Grows the rectangle in place by the specified amount.
Regular Polygon geometry type.
ConstructionOption
A regular polygon can be constructed inscribed in a circle or circumscribed about a circle.
@ CircumscribedCircle
Circumscribed about a circle (the radius is the distance from the center to the midpoints of the side...
@ InscribedCircle
Inscribed in a circle (the radius is the distance between the center and vertices).
QgsPolygon * toPolygon() const
Returns as a polygon.
QList< QgsRelation > relationsByName(const QString &name) const
Returns a list of relations with matching names.
Q_INVOKABLE QgsRelation relation(const QString &id) const
Gets access to a relation by its id.
Represents a relationship between two vector layers.
QgsVectorLayer * referencedLayer
QgsVectorLayer * referencingLayer
Q_INVOKABLE QString getRelatedFeaturesFilter(const QgsFeature &feature) const
Returns a filter expression which returns all the features on the referencing (child) layer which hav...
A spatial index for QgsFeature objects.
@ FlagStoreFeatureGeometries
Indicates that the spatial index should also store feature geometries. This requires more memory,...
QList< QgsFeatureId > nearestNeighbor(const QgsPointXY &point, int neighbors=1, double maxDistance=0) const
Returns nearest neighbors to a point.
QList< QgsFeatureId > intersects(const QgsRectangle &rectangle) const
Returns a list of features with a bounding box which intersects the specified rectangle.
static QString quotedIdentifier(const QString &identifier)
Returns a properly quoted version of identifier.
static QString quotedValue(const QVariant &value)
Returns a properly quoted and escaped version of value for use in SQL strings.
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.
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.
QStringList aliases() const override
Returns a list of possible aliases for the function.
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.
void setUsesGeometryFunction(const std::function< bool(const QgsExpressionNodeFunction *node)> &usesGeometry)
Set a function that will be called when determining if the function requires feature geometry or not.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
void setIsStatic(bool isStatic)
Tag this function as either static or not static.
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...
QSet< QString > referencedColumns(const QgsExpressionNodeFunction *node) const override
Returns a set of field names which are required for this function.
bool usesGeometry(const QgsExpressionNodeFunction *node) const override
Does this function use a geometry object.
static int hammingDistance(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the Hamming distance between two strings.
static QString soundex(const QString &string)
Returns the Soundex representation of a string.
static int levenshteinDistance(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the Levenshtein edit distance between two strings.
static QString longestCommonSubstring(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the longest common substring between two strings.
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.
const QgsColorRamp * colorRampRef(const QString &name) const
Returns a const pointer to a symbol (doesn't create new instance).
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
Contains utility functions for working with symbols and symbol layers.
static QColor decodeColor(const QString &str)
static QString encodeColor(const QColor &color)
static bool runOnMainThread(const Func &func, QgsFeedback *feedback=nullptr)
Guarantees that func is executed on the main thread.
Allows creation of a multi-layer database-side transaction.
virtual bool executeSql(const QString &sql, QString &error, bool isDirty=false, const QString &name=QString())=0
Execute the sql string.
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
static QVariant createNullVariant(QMetaType::Type metaType)
Helper method to properly create a null QVariant from a metaType Returns the created QVariant.
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any.
static bool validateAttribute(const QgsVectorLayer *layer, const QgsFeature &feature, int attributeIndex, QStringList &errors, QgsFieldConstraints::ConstraintStrength strength=QgsFieldConstraints::ConstraintStrengthNotSet, QgsFieldConstraints::ConstraintOrigin origin=QgsFieldConstraints::ConstraintOriginNotSet)
Tests a feature attribute value to check whether it passes all constraints which are present on the c...
Represents a vector layer which manages a vector based dataset.
long long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
QVariant aggregate(Qgis::Aggregate aggregate, const QString &fieldOrExpression, const QgsAggregateCalculator::AggregateParameters ¶meters=QgsAggregateCalculator::AggregateParameters(), QgsExpressionContext *context=nullptr, bool *ok=nullptr, QgsFeatureIds *fids=nullptr, QgsFeedback *feedback=nullptr, QString *error=nullptr) const
Calculates an aggregated value from the layer's features.
int selectedFeatureCount() const
Returns the number of features that are selected in this layer.
Q_INVOKABLE const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
QString displayExpression
QgsEditorWidgetSetup editorWidgetSetup(int index) const
Returns the editor widget setup for the field at the specified index.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const final
Queries the layer for features specified in request.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
Q_INVOKABLE QgsFeature getFeature(QgsFeatureId fid) const
Queries the layer for the feature with the given id.
QgsVectorDataProvider * dataProvider() final
Returns the layer's data provider, it may be nullptr.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
QgsWithVariableExpressionFunction()
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...
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.
static Q_INVOKABLE bool hasZ(Qgis::WkbType type)
Tests whether a WKB type contains the z-dimension.
static Q_INVOKABLE QString geometryDisplayString(Qgis::GeometryType type)
Returns a display string for a geometry type.
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
sqlite3_statement_unique_ptr prepare(const QString &sql, int &resultCode) const
Prepares a sql statement, returning the result.
QString errorMessage() const
Returns the most recent error message encountered by the database.
int open_v2(const QString &path, int flags, const char *zVfs)
Opens the database at the specified file path.
int exec(const QString &sql, QString &errorMessage) const
Executes the sql command in the database.
Unique pointer for sqlite3 prepared statements, which automatically finalizes the statement when the ...
int step()
Steps to the next record in the statement, returning the sqlite3 result code.
qlonglong columnAsInt64(int column) const
Gets column value from the current statement row as a long long integer (64 bits).
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored).
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 allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
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
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
T qgsgeometry_cast(QgsAbstractGeometry *geom)
QVector< QgsRingSequence > QgsCoordinateSequence
QVector< QgsPointSequence > QgsRingSequence
QVector< QgsPoint > QgsPointSequence
QList< QgsGradientStop > QgsGradientStopsList
List of gradient stops.
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
QList< QgsExpressionFunction * > ExpressionFunctionList
QVariant fcnRampColor(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)
#define ENSURE_GEOM_TYPE(f, g, geomtype)
QVariant fcnRampColorObject(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction *)
bool(QgsGeometry::* RelationFunction)(const QgsGeometry &geometry) const
#define ENSURE_NO_EVAL_ERROR
#define FEAT_FROM_CONTEXT(c, f)
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QVector< QgsPolylineXY > QgsMultiPolylineXY
A collection of QgsPolylines that share a common collection of attributes.
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
QVector< QgsPolygonXY > QgsMultiPolygonXY
A collection of QgsPolygons that share a common collection of attributes.
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
QLineF segment(int index, QRectF rect, double radius)
A bundle of parameters controlling aggregate calculation.
QString filter
Optional filter for calculating aggregate over a subset of features, or an empty string to use all fe...
QString delimiter
Delimiter to use for joining values with the StringConcatenate aggregate.
QgsFeatureRequest::OrderBy orderBy
Optional order by clauses.
Single variable definition for use within a QgsExpressionContextScope.
The Context struct stores the current layer and coordinate transform context.
const QgsMapLayer * layer
QgsCoordinateTransformContext transformContext
Utility class for identifying a unique vertex within a geometry.