70#include <QCryptographicHash>
71#include <QMimeDatabase>
72#include <QProcessEnvironment>
73#include <QRegularExpression>
78using namespace Qt::StringLiterals;
99 QVariantList argValues;
103 const QList< QgsExpressionNode * > argList = args->
list();
104 argValues.reserve( argList.size() );
111 v = QVariant::fromValue( n );
115 v = n->eval( parent, context );
117 bool defaultParamIsNull = mParameterList.count() > arg && mParameterList.at( arg ).optional() && !mParameterList.at( arg ).defaultValue().isValid();
118 if ( QgsExpressionUtils::isNull( v ) && !defaultParamIsNull && !
handlesNull() )
121 argValues.append( v );
126 return func( argValues, context, parent, node );
137 return QStringList();
164 return mGroups.isEmpty() ? false : mGroups.contains( u
"deprecated"_s );
169 return ( QString::compare( mName, other.mName, Qt::CaseInsensitive ) == 0 );
180 const QString &fnname,
183 const QString &group,
184 const QString &helpText,
188 const QStringList &aliases,
193 , mAliases( aliases )
194 , mUsesGeometry( false )
195 , mUsesGeometryFunc( usesGeometry )
196 , mReferencedColumnsFunc( referencedColumns )
207 if ( mUsesGeometryFunc )
208 return mUsesGeometryFunc( node );
210 return mUsesGeometry;
220 if ( mReferencedColumnsFunc )
221 return mReferencedColumnsFunc( node );
223 return mReferencedColumns;
229 return mIsStaticFunc( node, parent, context );
237 return mPrepareFunc( node, parent, context );
249 mIsStaticFunc =
nullptr;
255 mPrepareFunc = prepareFunc;
260 if ( node && node->
args() )
262 const QList< QgsExpressionNode * > argList = node->
args()->
list();
265 if ( !argNode->isStatic( parent, context ) )
275 double start = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
276 double stop = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
277 double step = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
279 if ( step == 0.0 || ( step > 0.0 && start > stop ) || ( step < 0.0 && start < stop ) )
286 double current = start + step;
287 while ( ( ( step > 0.0 && current <= stop ) || ( step < 0.0 && current >= stop ) ) && length <= 1000000 )
302 const QString name = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
304 if ( name ==
"feature"_L1 )
306 return context->
hasFeature() ? QVariant::fromValue( context->
feature() ) : QVariant();
308 else if ( name ==
"id"_L1 )
310 return context->
hasFeature() ? QVariant::fromValue( context->
feature().
id() ) : QVariant();
312 else if ( name ==
"geometry"_L1 )
328 QString templateString = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
337 QString expString = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
339 return expression.evaluate( context );
344 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
345 return QVariant( std::sqrt( x ) );
350 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
351 return QVariant( std::fabs( val ) );
356 double deg = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
357 return ( deg * M_PI ) / 180;
361 double rad = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
362 return ( 180 * rad ) / M_PI;
366 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
367 return QVariant( std::sin( x ) );
371 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
372 return QVariant( std::cos( x ) );
376 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
377 return QVariant( std::tan( x ) );
381 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
382 return QVariant( std::asin( x ) );
386 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
387 return QVariant( std::acos( x ) );
391 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
392 return QVariant( std::atan( x ) );
396 double y = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
397 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
398 return QVariant( std::atan2( y, x ) );
402 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
403 return QVariant( std::exp( x ) );
407 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
410 return QVariant( std::log( x ) );
414 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
417 return QVariant( log10( x ) );
421 double b = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
422 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
423 if ( x <= 0 || b <= 0 )
425 return QVariant( std::log( x ) / std::log( b ) );
429 double min = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
430 double max = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
434 std::random_device rd;
435 std::mt19937_64 generator( rd() );
437 if ( !QgsExpressionUtils::isNull( values.at( 2 ) ) )
440 if ( QgsExpressionUtils::isIntSafe( values.at( 2 ) ) )
443 seed = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
448 QString seedStr = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
449 std::hash<std::string> hasher;
450 seed = hasher( seedStr.toStdString() );
452 generator.seed( seed );
456 double f =
static_cast< double >( generator() ) /
static_cast< double >( std::mt19937_64::max() );
457 return QVariant( min + f * ( max - min ) );
461 qlonglong min = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
462 qlonglong max = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
466 std::random_device rd;
467 std::mt19937_64 generator( rd() );
469 if ( !QgsExpressionUtils::isNull( values.at( 2 ) ) )
472 if ( QgsExpressionUtils::isIntSafe( values.at( 2 ) ) )
475 seed = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
480 QString seedStr = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
481 std::hash<std::string> hasher;
482 seed = hasher( seedStr.toStdString() );
484 generator.seed( seed );
487 qint64 randomInteger = min + ( generator() % ( max - min + 1 ) );
488 if ( randomInteger > std::numeric_limits<int>::max() || randomInteger < -std::numeric_limits<int>::max() )
489 return QVariant( randomInteger );
492 return QVariant(
int( randomInteger ) );
497 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
498 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
499 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
500 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
501 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
503 if ( domainMin >= domainMax )
505 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
510 if ( val >= domainMax )
514 else if ( val <= domainMin )
520 double m = ( rangeMax - rangeMin ) / ( domainMax - domainMin );
521 double c = rangeMin - ( domainMin * m );
524 return QVariant( m * val +
c );
529 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
530 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
531 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
532 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
533 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
534 double exponent = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
536 if ( domainMin >= domainMax )
538 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
548 if ( val >= domainMax )
552 else if ( val <= domainMin )
558 return QVariant( ( ( rangeMax - rangeMin ) / std::pow( domainMax - domainMin, exponent ) ) * std::pow( val - domainMin, exponent ) + rangeMin );
563 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
564 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
565 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
566 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
567 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
568 double exponent = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
570 if ( domainMin >= domainMax )
572 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
582 if ( val >= domainMax )
586 else if ( val <= domainMin )
592 double ratio = ( std::pow( exponent, val - domainMin ) - 1 ) / ( std::pow( exponent, domainMax - domainMin ) - 1 );
593 return QVariant( ( rangeMax - rangeMin ) * ratio + rangeMin );
599 double maxVal = std::numeric_limits<double>::quiet_NaN();
600 for (
const QVariant &val : values )
603 if ( std::isnan( maxVal ) )
607 else if ( !std::isnan( testVal ) )
609 maxVal = std::max( maxVal, testVal );
613 if ( !std::isnan( maxVal ) )
615 result = QVariant( maxVal );
623 double minVal = std::numeric_limits<double>::quiet_NaN();
624 for (
const QVariant &val : values )
627 if ( std::isnan( minVal ) )
631 else if ( !std::isnan( testVal ) )
633 minVal = std::min( minVal, testVal );
637 if ( !std::isnan( minVal ) )
639 result = QVariant( minVal );
651 QVariant value = node->
eval( parent, context );
656 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( value, context, parent );
660 parent->
setEvalErrorString( QObject::tr(
"Cannot find layer with name or ID '%1'" ).arg( value.toString() ) );
665 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
667 value = node->
eval( parent, context );
673 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
678 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
680 QString subExpression = node->
dump();
684 if ( values.count() > 3 )
686 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
689 if ( !nl || nl->value().isValid() )
694 if ( values.count() > 4 )
696 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
698 value = node->
eval( parent, context );
705 if ( values.count() > 5 )
707 node = QgsExpressionUtils::getNode( values.at( 5 ), parent );
710 if ( !nl || nl->value().isValid() )
712 orderBy = node->
dump();
717 QString aggregateError;
725 const QSet< QString > filterVars = filterExp.referencedVariables();
726 const QSet< QString > subExpVars = subExp.referencedVariables();
727 QSet<QString> allVars = filterVars + subExpVars;
729 bool isStatic =
true;
730 if ( filterVars.contains( u
"parent"_s ) || filterVars.contains( QString() ) || subExpVars.contains( u
"parent"_s ) || subExpVars.contains( QString() ) )
736 for (
const QString &varName : allVars )
739 if ( scope && !scope->
isStatic( varName ) )
747 if ( isStatic && !parameters.
orderBy.isEmpty() )
749 for (
const auto &orderByClause : std::as_const( parameters.
orderBy ) )
751 const QgsExpression &orderByExpression { orderByClause.expression() };
763 const QString contextHash = context->
uniqueHash( ok, allVars );
766 cacheKey = u
"aggfcn:%1:%2:%3:%4:%5:%6"_s.arg( vl->id(), QString::number(
static_cast< int >( aggregate ) ), subExpression, parameters.
filter, orderBy, contextHash );
771 cacheKey = u
"aggfcn:%1:%2:%3:%4:%5"_s.arg( vl->id(), QString::number(
static_cast< int >( aggregate ) ), subExpression, parameters.
filter, orderBy );
782 subContext.appendScope( subScope );
783 result = vl->aggregate( aggregate, subExpression, parameters, &subContext, &ok,
nullptr, context->
feedback(), &aggregateError );
795 result = vl->aggregate( aggregate, subExpression, parameters,
nullptr, &ok,
nullptr,
nullptr, &aggregateError );
799 if ( !aggregateError.isEmpty() )
800 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1 (%2)" ).arg( subExpression, aggregateError ) );
802 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
813 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
821 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( u
"layer"_s ), context, parent );
825 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
834 QVariant value = node->
eval( parent, context );
836 QString relationId = value.toString();
843 if ( relations.isEmpty() || relations.at( 0 ).referencedLayer() != vl )
845 parent->
setEvalErrorString( QObject::tr(
"Cannot find relation with id '%1'" ).arg( relationId ) );
850 relation = relations.at( 0 );
857 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
859 value = node->
eval( parent, context );
865 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
870 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
872 QString subExpression = node->
dump();
876 if ( values.count() > 3 )
878 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
880 value = node->
eval( parent, context );
887 if ( values.count() > 4 )
889 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
892 if ( !nl || nl->value().isValid() )
894 orderBy = node->
dump();
905 const QString
cacheKey = u
"relagg:%1%:%2:%3:%4:%5:%6"_s.arg( relationId, vl->id(), QString::number(
static_cast< int >( aggregate ) ), subExpression, parameters.
filter, orderBy );
915 result = childLayer->
aggregate( aggregate, subExpression, parameters, &subContext, &ok,
nullptr, context->
feedback(), &error );
919 if ( !error.isEmpty() )
920 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1 (%2)" ).arg( subExpression, error ) );
922 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
932static QVariant fcnAggregateGeneric(
938 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
946 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( u
"layer"_s ), 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 );
1004 if ( !parameters.
filter.isEmpty() )
1005 parameters.
filter = u
"(%1) AND (%2)"_s.arg( parameters.
filter, groupByClause );
1007 parameters.
filter = groupByClause;
1013 bool isStatic =
true;
1014 const QSet<QString> refVars = filterExp.referencedVariables() + subExp.referencedVariables();
1015 for (
const QString &varName : refVars )
1018 if ( scope && !scope->
isStatic( varName ) )
1029 const QString contextHash = context->
uniqueHash( ok, refVars );
1032 cacheKey = u
"agg:%1:%2:%3:%4:%5:%6"_s.arg( vl->id(), QString::number(
static_cast< int >( aggregate ) ), subExpression, parameters.
filter, orderBy, contextHash );
1037 cacheKey = u
"agg:%1:%2:%3:%4:%5"_s.arg( vl->id(), QString::number(
static_cast< int >( aggregate ) ), subExpression, parameters.
filter, orderBy );
1049 subContext.appendScope( subScope );
1051 result = vl->aggregate( aggregate, subExpression, parameters, &subContext, &ok,
nullptr, context->
feedback(), &error );
1055 if ( !error.isEmpty() )
1056 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1 (%2)" ).arg( subExpression, error ) );
1058 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
1163 if ( values.count() > 3 )
1165 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
1167 QVariant value = node->
eval( parent, context );
1169 parameters.
delimiter = value.toString();
1180 if ( values.count() > 3 )
1182 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
1184 QVariant value = node->
eval( parent, context );
1186 parameters.
delimiter = value.toString();
1202 QVariant scale = context->
variable( u
"map_scale"_s );
1207 const double v = scale.toDouble( &ok );
1215 double minValue = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1216 double testValue = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
1217 double maxValue = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
1220 if ( testValue <= minValue )
1222 return QVariant( minValue );
1224 else if ( testValue >= maxValue )
1226 return QVariant( maxValue );
1230 return QVariant( testValue );
1236 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1237 return QVariant( std::floor( x ) );
1242 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1243 return QVariant( std::ceil( x ) );
1248 const QVariant value = values.at( 0 );
1249 if ( QgsExpressionUtils::isNull( value.isValid() ) )
1251 return QVariant(
false );
1253 else if ( value.userType() == QMetaType::QString )
1256 return QVariant( !value.toString().isEmpty() );
1258 else if ( QgsExpressionUtils::isList( value ) )
1260 return !value.toList().isEmpty();
1262 return QVariant( value.toBool() );
1266 return QVariant( QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) );
1270 return QVariant( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) );
1274 return QVariant( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ) );
1279 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1280 QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1281 if ( format.isEmpty() && !language.isEmpty() )
1283 parent->
setEvalErrorString( QObject::tr(
"A format is required to convert to DateTime when the language is specified" ) );
1284 return QVariant( QDateTime() );
1287 if ( format.isEmpty() && language.isEmpty() )
1288 return QVariant( QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent ) );
1290 QString datetimestring = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1291 QLocale locale = QLocale();
1292 if ( !language.isEmpty() )
1294 locale = QLocale( language );
1297 QDateTime datetime = locale.toDateTime( datetimestring, format );
1298 if ( !datetime.isValid() )
1300 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to DateTime" ).arg( datetimestring ) );
1301 datetime = QDateTime();
1303 return QVariant( datetime );
1308 const int year = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
1309 const int month = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1310 const int day = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
1312 const QDate date( year, month, day );
1313 if ( !date.isValid() )
1315 parent->
setEvalErrorString( QObject::tr(
"'%1-%2-%3' is not a valid date" ).arg( year ).arg( month ).arg( day ) );
1318 return QVariant( date );
1323 const int hours = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
1324 const int minutes = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1325 const double seconds = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
1327 const QTime time( hours, minutes, std::floor( seconds ), ( seconds - std::floor( seconds ) ) * 1000 );
1328 if ( !time.isValid() )
1330 parent->
setEvalErrorString( QObject::tr(
"'%1-%2-%3' is not a valid time" ).arg( hours ).arg( minutes ).arg( seconds ) );
1333 return QVariant( time );
1338 const int year = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
1339 const int month = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1340 const int day = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
1341 const int hours = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
1342 const int minutes = QgsExpressionUtils::getIntValue( values.at( 4 ), parent );
1343 const double seconds = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
1345 const QDate date( year, month, day );
1346 if ( !date.isValid() )
1348 parent->
setEvalErrorString( QObject::tr(
"'%1-%2-%3' is not a valid date" ).arg( year ).arg( month ).arg( day ) );
1351 const QTime time( hours, minutes, std::floor( seconds ), ( seconds - std::floor( seconds ) ) * 1000 );
1352 if ( !time.isValid() )
1354 parent->
setEvalErrorString( QObject::tr(
"'%1-%2-%3' is not a valid time" ).arg( hours ).arg( minutes ).arg( seconds ) );
1357 return QVariant( QDateTime( date, time ) );
1362 const QString timeZoneId = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1366#if QT_FEATURE_timezone > 0
1367 if ( !timeZoneId.isEmpty() )
1369 tz = QTimeZone( timeZoneId.toUtf8() );
1372 if ( !tz.isValid() )
1374 parent->
setEvalErrorString( QObject::tr(
"'%1' is not a valid time zone ID" ).arg( timeZoneId ) );
1379 parent->
setEvalErrorString( QObject::tr(
"Qt is built without Qt timezone support, cannot use fcnTimeZoneFromId" ) );
1381 return QVariant::fromValue( tz );
1386#if QT_FEATURE_timezone > 0
1387 const QDateTime datetime = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1388 if ( datetime.isValid() )
1390 return QVariant::fromValue( datetime.timeZone() );
1394 parent->
setEvalErrorString( QObject::tr(
"Qt is built without Qt timezone support, cannot use fcnGetTimeZone" ) );
1401#if QT_FEATURE_timezone > 0
1402 QDateTime datetime = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1403 const QTimeZone tz = QgsExpressionUtils::getTimeZoneValue( values.at( 1 ), parent );
1404 if ( datetime.isValid() && tz.isValid() )
1406 datetime.setTimeZone( tz );
1407 return QVariant::fromValue( datetime );
1411 parent->
setEvalErrorString( QObject::tr(
"Qt is built without Qt timezone support, cannot use fcnSetTimeZone" ) );
1418#if QT_FEATURE_timezone > 0
1419 const QDateTime datetime = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1420 const QTimeZone tz = QgsExpressionUtils::getTimeZoneValue( values.at( 1 ), parent );
1421 if ( datetime.isValid() && tz.isValid() )
1423 return QVariant::fromValue( datetime.toTimeZone( tz ) );
1427 parent->
setEvalErrorString( QObject::tr(
"Qt is built without Qt timezone support, cannot use fcnConvertTimeZone" ) );
1434#if QT_FEATURE_timezone > 0
1435 const QTimeZone timeZone = QgsExpressionUtils::getTimeZoneValue( values.at( 0 ), parent );
1436 if ( timeZone.isValid() )
1438 return QString( timeZone.id() );
1442 parent->
setEvalErrorString( QObject::tr(
"Qt is built without Qt timezone support, cannot use fcnTimeZoneToId" ) );
1449 const double years = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1450 const double months = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
1451 const double weeks = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
1452 const double days = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
1453 const double hours = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
1454 const double minutes = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
1455 const double seconds = QgsExpressionUtils::getDoubleValue( values.at( 6 ), parent );
1457 return QVariant::fromValue(
QgsInterval( years, months, weeks, days, hours, minutes, seconds ) );
1462 for (
const QVariant &value : values )
1473 const QVariant val1 = values.at( 0 );
1474 const QVariant val2 = values.at( 1 );
1484 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1485 return QVariant( str.toLower() );
1489 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1490 return QVariant( str.toUpper() );
1494 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1495 QStringList elems = str.split(
' ' );
1496 for (
int i = 0; i < elems.size(); i++ )
1498 if ( elems[i].size() > 1 )
1499 elems[i] = elems[i].at( 0 ).toUpper() + elems[i].mid( 1 ).toLower();
1501 return QVariant( elems.join(
' '_L1 ) );
1506 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1507 return QVariant( str.trimmed() );
1512 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1514 const QString characters = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1516 const QRegularExpression re( u
"^([%1]*)"_s.arg( QRegularExpression::escape( characters ) ) );
1517 str.replace( re, QString() );
1518 return QVariant( str );
1523 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1525 const QString characters = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1527 const QRegularExpression re( u
"([%1]*)$"_s.arg( QRegularExpression::escape( characters ) ) );
1528 str.replace( re, QString() );
1529 return QVariant( str );
1534 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1535 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1541 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1542 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1548 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1549 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1556 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1562 QChar character = QChar( QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent ) );
1563 return QVariant( QString( character ) );
1568 QString value = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1570 if ( value.isEmpty() )
1575 int res = value.at( 0 ).unicode();
1576 return QVariant( res );
1581 if ( values.length() == 2 || values.length() == 3 )
1583 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1584 qlonglong wrap = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1586 QString customdelimiter = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1599 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent,
true );
1603 return QVariant( geom.
length() );
1609 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1610 return QVariant( str.length() );
1615 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1620 double totalLength = 0;
1625 totalLength += line->length3D();
1630 totalLength += segmentized->length3D();
1640 const QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1641 const qlonglong number = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1642 return string.repeated( std::max(
static_cast< int >( number ), 0 ) );
1647 if ( values.count() == 2 && values.at( 1 ).userType() == QMetaType::Type::QVariantMap )
1649 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1650 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 1 ), parent );
1651 QVector< QPair< QString, QString > > mapItems;
1653 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
1655 mapItems.append( qMakePair( it.key(), it.value().toString() ) );
1659 std::sort( mapItems.begin(), mapItems.end(), [](
const QPair< QString, QString > &pair1,
const QPair< QString, QString > &pair2 ) { return ( pair1.first.length() > pair2.first.length() ); } );
1661 for (
auto it = mapItems.constBegin(); it != mapItems.constEnd(); ++it )
1663 str = str.replace( it->first, it->second );
1666 return QVariant( str );
1668 else if ( values.count() == 3 )
1670 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1671 QVariantList before;
1673 bool isSingleReplacement =
false;
1675 if ( !QgsExpressionUtils::isList( values.at( 1 ) ) && values.at( 2 ).userType() != QMetaType::Type::QStringList )
1677 before = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1681 before = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
1684 if ( !QgsExpressionUtils::isList( values.at( 2 ) ) )
1686 after = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1687 isSingleReplacement =
true;
1691 after = QgsExpressionUtils::getListValue( values.at( 2 ), parent );
1694 if ( !isSingleReplacement && before.length() != after.length() )
1696 parent->
setEvalErrorString( QObject::tr(
"Invalid pair of array, length not identical" ) );
1700 for (
int i = 0; i < before.length(); i++ )
1702 str = str.replace( before.at( i ).toString(), after.at( isSingleReplacement ? 0 : i ).toString() );
1705 return QVariant( str );
1709 parent->
setEvalErrorString( QObject::tr(
"Function replace requires 2 or 3 arguments" ) );
1716 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1717 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1718 QString after = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1720 QRegularExpression re( regexp, QRegularExpression::UseUnicodePropertiesOption );
1721 if ( !re.isValid() )
1723 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1726 return QVariant( str.replace( re, after ) );
1731 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1732 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1734 QRegularExpression re( regexp, QRegularExpression::UseUnicodePropertiesOption );
1735 if ( !re.isValid() )
1737 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1740 return QVariant( ( str.indexOf( re ) + 1 ) );
1745 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1746 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1747 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1749 QRegularExpression re( regexp, QRegularExpression::UseUnicodePropertiesOption );
1750 if ( !re.isValid() )
1752 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1756 QRegularExpressionMatch matches = re.match( str );
1757 if ( matches.hasMatch() )
1760 QStringList list = matches.capturedTexts();
1763 for ( QStringList::const_iterator it = ++list.constBegin(); it != list.constEnd(); ++it )
1765 array += ( !( *it ).isEmpty() ) ? *it : empty;
1768 return QVariant( array );
1778 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1779 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1781 QRegularExpression re( regexp, QRegularExpression::UseUnicodePropertiesOption );
1782 if ( !re.isValid() )
1784 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1789 QRegularExpressionMatch match = re.match( str );
1790 if ( match.hasMatch() )
1793 if ( match.lastCapturedIndex() > 0 )
1796 return QVariant( match.captured( 1 ) );
1801 return QVariant( match.captured( 0 ) );
1806 return QVariant(
"" );
1812 QString uuid = QUuid::createUuid().toString();
1813 if ( values.at( 0 ).toString().compare( u
"WithoutBraces"_s, Qt::CaseInsensitive ) == 0 )
1814 uuid = QUuid::createUuid().toString( QUuid::StringFormat::WithoutBraces );
1815 else if ( values.at( 0 ).toString().compare( u
"Id128"_s, Qt::CaseInsensitive ) == 0 )
1816 uuid = QUuid::createUuid().toString( QUuid::StringFormat::Id128 );
1822 if ( !values.at( 0 ).isValid() || !values.at( 1 ).isValid() )
1825 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1826 int from = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1829 if ( values.at( 2 ).isValid() )
1830 len = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
1836 from = str.size() + from;
1842 else if ( from > 0 )
1850 len = str.size() + len - from;
1857 return QVariant( str.mid( from, len ) );
1862 return QVariant( f.
id() );
1867 const int bandNb = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1868 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
1869 bool foundLayer =
false;
1870 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe(
1875 QgsRasterLayer *layer = qobject_cast< QgsRasterLayer * >( mapLayer );
1876 if ( !layer || !layer->dataProvider() )
1878 parent->setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster layer." ) );
1882 if ( bandNb < 1 || bandNb > layer->bandCount() )
1884 parent->setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster band number." ) );
1890 parent->setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid point geometry." ) );
1897 QgsMultiPointXY multiPoint = geom.asMultiPoint();
1898 if ( multiPoint.count() == 1 )
1900 point = multiPoint[0];
1909 double value = layer->dataProvider()->sample( point, bandNb );
1910 return std::isnan( value ) ? QVariant() : value;
1917 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster layer." ) );
1928 const int bandNb = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1929 const double value = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
1931 bool foundLayer =
false;
1932 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe(
1936 [parent, bandNb, value](
QgsMapLayer *mapLayer ) -> QVariant {
1937 QgsRasterLayer *layer = qobject_cast< QgsRasterLayer *>( mapLayer );
1938 if ( !layer || !layer->dataProvider() )
1940 parent->setEvalErrorString( QObject::tr(
"Function `raster_attributes` requires a valid raster layer." ) );
1944 if ( bandNb < 1 || bandNb > layer->bandCount() )
1946 parent->setEvalErrorString( QObject::tr(
"Function `raster_attributes` requires a valid raster band number." ) );
1950 if ( std::isnan( value ) )
1952 parent->
setEvalErrorString( QObject::tr(
"Function `raster_attributes` requires a valid raster value." ) );
1956 if ( !layer->dataProvider()->attributeTable( bandNb ) )
1961 const QVariantList data = layer->dataProvider()->attributeTable( bandNb )->row( value );
1962 if ( data.isEmpty() )
1968 const QList<QgsRasterAttributeTable::Field> fields { layer->dataProvider()->attributeTable( bandNb )->fields() };
1969 for (
int idx = 0; idx < static_cast<int>( fields.count() ) && idx < static_cast<int>( data.count() ); ++idx )
1976 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(
"</th><th>"_L1 ), cells.join(
"</td><td>"_L1 ) );
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( u
"<dt>%1</dt><dd>%2</dd>"_s.arg( it.key().toHtmlEscaped(), it.value().toString().toHtmlEscaped() ) );
2094 return table.arg( rows );
2102 layer = context->
variable( u
"layer"_s );
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 ==
"hard"_L1 )
2129 else if ( strength ==
"soft"_L1 )
2134 bool foundLayer =
false;
2135 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe(
2139 [parent, feature, constraintStrength](
QgsMapLayer *mapLayer ) -> QVariant {
2140 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( mapLayer );
2143 parent->
setEvalErrorString( QObject::tr(
"No layer provided to conduct constraints checks" ) );
2149 for (
int i = 0; i < fields.
size(); i++ )
2166 parent->
setEvalErrorString( QObject::tr(
"No layer provided to conduct constraints checks" ) );
2178 layer = context->
variable( u
"layer"_s );
2183 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
2185 layer = node->
eval( parent, context );
2196 feature = QgsExpressionUtils::getFeature( values.at( 2 ), parent );
2200 const QString strength = QgsExpressionUtils::getStringValue( values.at( 3 ), parent ).toLower();
2201 if ( strength ==
"hard"_L1 )
2205 else if ( strength ==
"soft"_L1 )
2210 const QString attributeName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2212 bool foundLayer =
false;
2213 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe(
2217 [parent, feature, attributeName, constraintStrength](
QgsMapLayer *mapLayer ) -> QVariant {
2218 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( mapLayer );
2225 if ( fieldIndex == -1 )
2227 parent->
setEvalErrorString( QObject::tr(
"The attribute name did not match any field for the given feature" ) );
2240 parent->
setEvalErrorString( QObject::tr(
"No layer provided to conduct constraints checks" ) );
2256 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
2261 for (
int i = 0; i < fields.
count(); ++i )
2275 if ( values.isEmpty() )
2278 layer = QgsExpressionUtils::getVectorLayer( context->
variable( u
"layer"_s ), context, parent );
2280 else if ( values.size() == 1 )
2282 layer = QgsExpressionUtils::getVectorLayer( context->
variable( u
"layer"_s ), context, parent );
2283 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
2285 else if ( values.size() == 2 )
2287 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), context, parent );
2288 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
2292 parent->
setEvalErrorString( QObject::tr(
"Function `represent_attributes` requires no more than two parameters. %n given.",
nullptr, values.length() ) );
2299 parent->
setEvalErrorString( QObject::tr(
"Cannot use represent attributes function: layer could not be resolved." ) );
2305 parent->
setEvalErrorString( QObject::tr(
"Cannot use represent attributes function: feature could not be resolved." ) );
2311 for (
int fieldIndex = 0; fieldIndex < fields.
count(); ++fieldIndex )
2313 const QString fieldName { fields.
at( fieldIndex ).
name() };
2314 const QVariant attributeVal = feature.
attribute( fieldIndex );
2315 const QString cacheValueKey = u
"repvalfcnval:%1:%2:%3"_s.arg( layer->
id(), fieldName, attributeVal.toString() );
2318 result.insert( fieldName, context->
cachedValue( cacheValueKey ) );
2327 const QString
cacheKey = u
"repvalfcn:%1:%2"_s.arg( layer->
id(), fieldName );
2339 QString value( fieldFormatter->
representValue( layer, fieldIndex, setup.
config(), cache, attributeVal ) );
2341 result.insert( fields.
at( fieldIndex ).
name(), value );
2356 bool evaluate =
true;
2360 if ( values.isEmpty() )
2363 layer = QgsExpressionUtils::getVectorLayer( context->
variable( u
"layer"_s ), context, parent );
2365 else if ( values.size() == 1 )
2367 layer = QgsExpressionUtils::getVectorLayer( context->
variable( u
"layer"_s ), context, parent );
2368 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
2370 else if ( values.size() == 2 )
2372 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), context, parent );
2373 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
2375 else if ( values.size() == 3 )
2377 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), context, parent );
2378 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
2379 evaluate = values.value( 2 ).toBool();
2385 parent->
setEvalErrorString( QObject::tr(
"Function `maptip` requires no more than three parameters. %n given.",
nullptr, values.length() ) );
2389 parent->
setEvalErrorString( QObject::tr(
"Function `display` requires no more than three parameters. %n given.",
nullptr, values.length() ) );
2421 subContext.setFeature( feature );
2430 exp.prepare( &subContext );
2431 return exp.evaluate( &subContext ).toString();
2437 return fcnCoreFeatureMaptipDisplay( values, context, parent,
false );
2442 return fcnCoreFeatureMaptipDisplay( values, context, parent,
true );
2449 if ( values.isEmpty() )
2452 layer = context->
variable( u
"layer"_s );
2454 else if ( values.size() == 1 )
2456 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
2457 layer = context->
variable( u
"layer"_s );
2459 else if ( values.size() == 2 )
2461 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
2462 layer = values.at( 0 );
2466 parent->
setEvalErrorString( QObject::tr(
"Function `is_selected` requires no more than two parameters. %n given.",
nullptr, values.length() ) );
2470 bool foundLayer =
false;
2471 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe(
2476 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( mapLayer );
2477 if ( !layer || !feature.
isValid() )
2496 if ( values.isEmpty() )
2497 layer = context->
variable( u
"layer"_s );
2498 else if ( values.count() == 1 )
2499 layer = values.at( 0 );
2502 parent->
setEvalErrorString( QObject::tr(
"Function `num_selected` requires no more than one parameter. %n given.",
nullptr, values.length() ) );
2506 bool foundLayer =
false;
2507 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe(
2512 QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( mapLayer );
2530 static QMap<QString, qlonglong> counterCache;
2531 QVariant functionResult;
2533 auto fetchAndIncrementFunc = [values, parent, &functionResult](
QgsMapLayer *mapLayer,
const QString &databaseArgument ) {
2536 const QgsVectorLayer *layer = qobject_cast< QgsVectorLayer *>( mapLayer );
2541 database = decodedUri.value( u
"path"_s ).toString();
2542 if ( database.isEmpty() )
2544 parent->
setEvalErrorString( QObject::tr(
"Could not extract file path from layer `%1`." ).arg( layer->
name() ) );
2549 database = databaseArgument;
2552 const QString table = values.at( 1 ).toString();
2553 const QString idColumn = values.at( 2 ).toString();
2554 const QString filterAttribute = values.at( 3 ).toString();
2555 const QVariant filterValue = values.at( 4 ).toString();
2556 const QVariantMap defaultValues = values.at( 5 ).toMap();
2562 if ( sqliteDb.
open_v2( database, SQLITE_OPEN_READWRITE,
nullptr ) != SQLITE_OK )
2565 functionResult = QVariant();
2569 QString errorMessage;
2570 QString currentValSql;
2572 qlonglong nextId = 0;
2573 bool cachedMode =
false;
2574 bool valueRetrieved =
false;
2576 QString cacheString = u
"%1:%2:%3:%4:%5"_s.arg( database, table, idColumn, filterAttribute, filterValue.toString() );
2583 auto cachedCounter = counterCache.find( cacheString );
2585 if ( cachedCounter != counterCache.end() )
2587 qlonglong &cachedValue = cachedCounter.value();
2588 nextId = cachedValue;
2590 cachedValue = nextId;
2591 valueRetrieved =
true;
2596 if ( !cachedMode || !valueRetrieved )
2598 int result = SQLITE_ERROR;
2601 if ( !filterAttribute.isNull() )
2606 sqliteStatement = sqliteDb.
prepare( currentValSql, result );
2608 if ( result == SQLITE_OK )
2611 if ( sqliteStatement.
step() == SQLITE_ROW )
2617 if ( cachedMode && result == SQLITE_OK )
2619 counterCache.insert( cacheString, nextId );
2621 QObject::connect( layer->
dataProvider()->
transaction(), &QgsTransaction::destroyed, [cacheString]() { counterCache.remove( cacheString ); } );
2623 valueRetrieved =
true;
2627 if ( valueRetrieved )
2636 if ( !filterAttribute.isNull() )
2642 for ( QVariantMap::const_iterator iter = defaultValues.constBegin(); iter != defaultValues.constEnd(); ++iter )
2645 vals << iter.value().toString();
2648 upsertSql +=
" ("_L1 + cols.join(
',' ) +
')';
2649 upsertSql +=
" VALUES "_L1;
2650 upsertSql +=
'(' + vals.join(
',' ) +
')';
2652 int result = SQLITE_ERROR;
2656 if ( transaction->
executeSql( upsertSql, errorMessage ) )
2663 result = sqliteDb.
exec( upsertSql, errorMessage );
2665 if ( result == SQLITE_OK )
2667 functionResult = QVariant( nextId );
2672 parent->
setEvalErrorString( u
"Could not increment value: SQLite error: \"%1\" (%2)."_s.arg( errorMessage, QString::number( result ) ) );
2673 functionResult = QVariant();
2678 functionResult = QVariant();
2681 bool foundLayer =
false;
2682 QgsExpressionUtils::executeLambdaForMapLayer( values.at( 0 ), context, parent, [&fetchAndIncrementFunc](
QgsMapLayer *layer ) { fetchAndIncrementFunc( layer, QString() ); }, foundLayer );
2685 const QString databasePath = values.at( 0 ).toString();
2689 return functionResult;
2702 QString definition = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2707 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to coordinate reference system" ).arg( definition ) );
2710 return QVariant::fromValue( crs );
2716 for (
const QVariant &value : values )
2719 concat += QgsExpressionUtils::getStringValue( value, parent );
2726 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2727 return string.indexOf( QgsExpressionUtils::getStringValue( values.at( 1 ), parent ) ) + 1;
2735 if ( values.isEmpty() || values[0].isNull() )
2744 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2745 int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
2746 return string.right( pos );
2751 if ( values.length() < 2 || values.length() > 3 )
2754 const QString input = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2755 const QString substring = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
2757 bool overlapping =
false;
2758 if ( values.length() == 3 )
2760 overlapping = values.at( 2 ).toBool();
2763 if ( substring.isEmpty() )
2764 return QVariant( 0 );
2769 count = input.count( substring );
2774 while ( ( pos = input.indexOf( substring, pos ) ) != -1 )
2777 pos += substring.length();
2781 return QVariant( count );
2786 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2787 int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
2788 return string.left( pos );
2793 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2794 int length = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
2795 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
2796 return string.leftJustified( length, fill.at( 0 ),
true );
2801 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2802 int length = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
2803 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
2804 return string.rightJustified( length, fill.at( 0 ),
true );
2809 if ( values.size() < 1 )
2811 parent->
setEvalErrorString( QObject::tr(
"Function format requires at least 1 argument" ) );
2815 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2816 for (
int n = 1; n < values.length(); n++ )
2818 string =
string.arg( QgsExpressionUtils::getStringValue( values.at( n ), parent ) );
2826 return QVariant( QDateTime::currentDateTime() );
2831 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
2832 QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
2833 if ( format.isEmpty() && !language.isEmpty() )
2835 parent->
setEvalErrorString( QObject::tr(
"A format is required to convert to Date when the language is specified" ) );
2836 return QVariant( QDate() );
2839 if ( format.isEmpty() && language.isEmpty() )
2840 return QVariant( QgsExpressionUtils::getDateValue( values.at( 0 ), parent ) );
2842 QString datestring = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2843 QLocale locale = QLocale();
2844 if ( !language.isEmpty() )
2846 locale = QLocale( language );
2849 QDate date = locale.toDate( datestring, format );
2850 if ( !date.isValid() )
2852 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to Date" ).arg( datestring ) );
2855 return QVariant( date );
2860 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
2861 QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
2862 if ( format.isEmpty() && !language.isEmpty() )
2864 parent->
setEvalErrorString( QObject::tr(
"A format is required to convert to Time when the language is specified" ) );
2865 return QVariant( QTime() );
2868 if ( format.isEmpty() && language.isEmpty() )
2869 return QVariant( QgsExpressionUtils::getTimeValue( values.at( 0 ), parent ) );
2871 QString timestring = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2872 QLocale locale = QLocale();
2873 if ( !language.isEmpty() )
2875 locale = QLocale( language );
2878 QTime time = locale.toTime( timestring, format );
2879 if ( !time.isValid() )
2881 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to Time" ).arg( timestring ) );
2884 return QVariant( time );
2889 return QVariant::fromValue( QgsExpressionUtils::getInterval( values.at( 0 ), parent ) );
2898 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2899 QString axis = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
2900 int precision = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
2902 QString formatString;
2903 if ( values.count() > 3 )
2904 formatString = QgsExpressionUtils::getStringValue( values.at( 3 ), parent );
2907 if ( formatString.compare(
"suffix"_L1, Qt::CaseInsensitive ) == 0 )
2911 else if ( formatString.compare(
"aligned"_L1, Qt::CaseInsensitive ) == 0 )
2915 else if ( !formatString.isEmpty() )
2917 parent->
setEvalErrorString( QObject::tr(
"Invalid formatting parameter: '%1'. It must be empty, or 'suffix' or 'aligned'." ).arg( formatString ) );
2921 if ( axis.compare(
'x'_L1, Qt::CaseInsensitive ) == 0 )
2925 else if ( axis.compare(
'y'_L1, Qt::CaseInsensitive ) == 0 )
2931 parent->
setEvalErrorString( QObject::tr(
"Invalid axis name: '%1'. It must be either 'x' or 'y'." ).arg( axis ) );
2939 return floatToDegreeFormat( format, values, context, parent, node );
2946 value = QgsCoordinateUtils::dmsToDecimal( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), &ok );
2948 return ok ? QVariant( value ) : QVariant();
2954 return floatToDegreeFormat( format, values, context, parent, node );
2959 const double decimalDegrees = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2960 return static_cast< int >( decimalDegrees );
2965 const double absoluteDecimalDegrees = std::abs( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) );
2966 const double remainder = absoluteDecimalDegrees -
static_cast<int>( absoluteDecimalDegrees );
2967 return static_cast< int >( remainder * 60 );
2972 const double absoluteDecimalDegrees = std::abs( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) );
2973 const double remainder = absoluteDecimalDegrees -
static_cast<int>( absoluteDecimalDegrees );
2974 const double remainderInMinutes = remainder * 60;
2975 const double remainderSecondsFraction = remainderInMinutes -
static_cast< int >( remainderInMinutes );
2977 return remainderSecondsFraction * 60;
2982 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
2983 QDateTime d2 = QgsExpressionUtils::getDateTimeValue( values.at( 1 ), parent );
2984 qint64 seconds = d2.secsTo( d1 );
2985 return QVariant::fromValue(
QgsInterval( seconds ) );
2990 if ( !values.at( 0 ).canConvert<QDate>() )
2993 QDate date = QgsExpressionUtils::getDateValue( values.at( 0 ), parent );
2994 if ( !date.isValid() )
2999 return date.dayOfWeek() % 7;
3004 QVariant value = values.at( 0 );
3005 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3008 return QVariant( inter.
days() );
3012 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
3013 return QVariant( d1.date().day() );
3019 QVariant value = values.at( 0 );
3020 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3023 return QVariant( inter.
years() );
3027 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
3028 return QVariant( d1.date().year() );
3034 QVariant value = values.at( 0 );
3035 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3038 return QVariant( inter.
months() );
3042 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
3043 return QVariant( d1.date().month() );
3049 QVariant value = values.at( 0 );
3050 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3053 return QVariant( inter.
weeks() );
3057 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
3058 return QVariant( d1.date().weekNumber() );
3064 QVariant value = values.at( 0 );
3065 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3068 return QVariant( inter.
hours() );
3072 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
3073 return QVariant( t1.hour() );
3079 QVariant value = values.at( 0 );
3080 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3083 return QVariant( inter.
minutes() );
3087 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
3088 return QVariant( t1.minute() );
3094 QVariant value = values.at( 0 );
3095 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
3098 return QVariant( inter.
seconds() );
3102 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
3103 return QVariant( t1.second() );
3109 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
3112 return QVariant( dt.toMSecsSinceEpoch() );
3122 long long millisecs_since_epoch = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3124 return QVariant( QDateTime::fromMSecsSinceEpoch( millisecs_since_epoch ) );
3129 const QString filepath = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
3132 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg(
"exif"_L1 ) );
3135 QString tag = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3141 const QString filepath = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
3144 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg(
"exif_geotag"_L1 ) );
3153 if ( !dateTime.isValid() )
3158 const int year = dateTime.date().year();
3159 const QDateTime startOfYear( QDate( year, 1, 1 ), QTime( 0, 0, 0 ) );
3160 const QDateTime startOfNextYear( QDate( year + 1, 1, 1 ), QTime( 0, 0, 0 ) );
3161 const qint64 secondsFromStartOfYear = startOfYear.secsTo( dateTime );
3162 const qint64 totalSecondsInYear = startOfYear.secsTo( startOfNextYear );
3163 return static_cast<double>( year ) + (
static_cast<double>( secondsFromStartOfYear ) /
static_cast< double >( totalSecondsInYear ) );
3168 const QString name = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
3169 const QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 1 ), parent );
3172 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a valid date" ).arg(
"magnetic_declination"_L1 ) );
3175 const double latitude = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3180 const double longitude = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3185 const double height = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
3190 const QString filePath = QgsExpressionUtils::getFilePathValue( values.at( 5 ), context, parent );
3195 double declination = 0;
3202 parent->
setEvalErrorString( QObject::tr(
"Cannot evaluate magnetic declination: %1" ).arg( model.error() ) );
3214 const QString name = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
3215 const QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 1 ), parent );
3218 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a valid date" ).arg(
"magnetic_inclination"_L1 ) );
3221 const double latitude = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3226 const double longitude = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3231 const double height = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
3236 const QString filePath = QgsExpressionUtils::getFilePathValue( values.at( 5 ), context, parent );
3241 double inclination = 0;
3248 parent->
setEvalErrorString( QObject::tr(
"Cannot evaluate magnetic inclination: %1" ).arg( model.error() ) );
3260 const QString name = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
3261 const QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 1 ), parent );
3264 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a valid date" ).arg(
"magnetic_declination_rate_of_change"_L1 ) );
3267 const double latitude = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3272 const double longitude = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3277 const double height = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
3282 const QString filePath = QgsExpressionUtils::getFilePathValue( values.at( 5 ), context, parent );
3287 double declination = 0;
3295 if ( model.getComponentsWithTimeDerivatives(
qDateTimeToDecimalYear( dt ), latitude, longitude, height, Bx, By, Bz, Bxt, Byt, Bzt ) )
3305 if (
QgsMagneticModel::fieldComponentsWithTimeDerivatives( Bx, By, Bz, Bxt, Byt, Bzt, H, F, D, I, Ht, Ft, Dt, It ) )
3311 parent->
setEvalErrorString( QObject::tr(
"Cannot evaluate magnetic declination rate of change" ) );
3317 parent->
setEvalErrorString( QObject::tr(
"Cannot evaluate magnetic declination rate of change: %1" ).arg( model.error() ) );
3322 parent->
setEvalErrorString( QObject::tr(
"Cannot evaluate magnetic declination rate of change: %1" ).arg( e.
what() ) );
3329 const QString name = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
3330 const QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 1 ), parent );
3333 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a valid date" ).arg(
"magnetic_inclination_rate_of_change"_L1 ) );
3336 const double latitude = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3341 const double longitude = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3346 const double height = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
3351 const QString filePath = QgsExpressionUtils::getFilePathValue( values.at( 5 ), context, parent );
3356 double declination = 0;
3364 if ( model.getComponentsWithTimeDerivatives(
qDateTimeToDecimalYear( dt ), latitude, longitude, height, Bx, By, Bz, Bxt, Byt, Bzt ) )
3374 if (
QgsMagneticModel::fieldComponentsWithTimeDerivatives( Bx, By, Bz, Bxt, Byt, Bzt, H, F, D, I, Ht, Ft, Dt, It ) )
3380 parent->
setEvalErrorString( QObject::tr(
"Cannot evaluate magnetic inclination rate of change" ) );
3386 parent->
setEvalErrorString( QObject::tr(
"Cannot evaluate magnetic inclination rate of change: %1" ).arg( model.error() ) );
3391 parent->
setEvalErrorString( QObject::tr(
"Cannot evaluate magnetic inclination rate of change: %1" ).arg( e.
what() ) );
3396#define ENSURE_GEOM_TYPE( f, g, geomtype ) \
3397 if ( !( f ).hasGeometry() ) \
3398 return QVariant(); \
3399 QgsGeometry g = ( f ).geometry(); \
3400 if ( ( g ).type() != ( geomtype ) ) \
3407 if ( g.isMultipart() )
3409 return g.asMultiPoint().at( 0 ).x();
3413 return g.asPoint().x();
3421 if ( g.isMultipart() )
3423 return g.asMultiPoint().at( 0 ).y();
3427 return g.asPoint().y();
3441 if ( g.isEmpty() || !abGeom->
is3D() )
3454 if ( collection->numGeometries() > 0 )
3467 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3473 return QVariant( isValid );
3478 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3482 const QString methodString = QgsExpressionUtils::getStringValue( values.at( 1 ), parent ).trimmed();
3483#if GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR < 10
3488 if ( methodString.compare(
"linework"_L1, Qt::CaseInsensitive ) == 0 )
3490 else if ( methodString.compare(
"structure"_L1, Qt::CaseInsensitive ) == 0 )
3493 const bool keepCollapsed = values.value( 2 ).toBool();
3498 valid = geom.
makeValid( method, keepCollapsed );
3502 parent->
setEvalErrorString( QObject::tr(
"The make_valid parameters require a newer GEOS library version" ) );
3506 return QVariant::fromValue( valid );
3511 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3517 for (
int i = 0; i < multiGeom.size(); ++i )
3519 array += QVariant::fromValue( multiGeom.at( i ) );
3527 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3539 QVariant result( centroid.
asPoint().
x() );
3545 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3557 QVariant result( centroid.
asPoint().
y() );
3563 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3581 if ( collection->numGeometries() == 1 )
3594 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3612 if ( collection->numGeometries() == 1 )
3625 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3630 int idx = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3657 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3674 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3691 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3696 bool ignoreClosing =
false;
3697 if ( values.length() > 1 )
3699 ignoreClosing = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3709 bool skipLast =
false;
3710 if ( ignoreClosing && ring.count() > 2 && ring.first() == ring.last() )
3715 for (
int i = 0; i < ( skipLast ? ring.count() - 1 : ring.count() ); ++i )
3727 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3738 for (
int i = 0; i < line->numPoints() - 1; ++i )
3752 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3762 if ( collection->numGeometries() == 1 )
3769 if ( !curvePolygon )
3773 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
3779 QVariant result = curve ? QVariant::fromValue(
QgsGeometry( curve ) ) : QVariant();
3785 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3795 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
3801 QVariant result = part ? QVariant::fromValue(
QgsGeometry( part ) ) : QVariant();
3807 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3816 return QVariant::fromValue(
QgsGeometry( boundary ) );
3821 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3830 return QVariant::fromValue( merged );
3835 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3839 const QgsGeometry geom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3844 if ( sharedPaths.
isNull() )
3847 return QVariant::fromValue( sharedPaths );
3853 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3858 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3861 if ( simplified.
isNull() )
3869 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3874 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3879 if ( simplified.
isNull() )
3887 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3892 int iterations = std::min( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), 10 );
3893 double offset = std::clamp( QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ), 0.0, 0.5 );
3894 double minLength = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3895 double maxAngle = std::clamp( QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent ), 0.0, 180.0 );
3897 QgsGeometry smoothed = geom.
smooth(
static_cast<unsigned int>( iterations ), offset, minLength, maxAngle );
3906 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3911 const double wavelength = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3912 const double amplitude = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3913 const bool strict = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
3924 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3929 const double minWavelength = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3930 const double maxWavelength = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3931 const double minAmplitude = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3932 const double maxAmplitude = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
3933 const long long seed = QgsExpressionUtils::getIntValue( values.at( 5 ), parent );
3944 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3949 const double wavelength = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3950 const double amplitude = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3951 const bool strict = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
3962 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3967 const double minWavelength = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3968 const double maxWavelength = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3969 const double minAmplitude = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3970 const double maxAmplitude = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
3971 const long long seed = QgsExpressionUtils::getIntValue( values.at( 5 ), parent );
3982 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3987 const double wavelength = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3988 const double amplitude = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3989 const bool strict = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
4000 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4005 const double minWavelength = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
4006 const double maxWavelength = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
4007 const double minAmplitude = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
4008 const double maxAmplitude = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
4009 const long long seed = QgsExpressionUtils::getIntValue( values.at( 5 ), parent );
4020 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4025 const QVariantList pattern = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
4026 QVector< double > dashPattern;
4027 dashPattern.reserve( pattern.size() );
4028 for (
const QVariant &value : std::as_const( pattern ) )
4031 double v = value.toDouble( &ok );
4043 if ( dashPattern.size() % 2 != 0 )
4045 parent->
setEvalErrorString( u
"Dash pattern must contain an even number of elements"_s );
4049 const QString startRuleString = QgsExpressionUtils::getStringValue( values.at( 2 ), parent ).trimmed();
4051 if ( startRuleString.compare(
"no_rule"_L1, Qt::CaseInsensitive ) == 0 )
4053 else if ( startRuleString.compare(
"full_dash"_L1, Qt::CaseInsensitive ) == 0 )
4055 else if ( startRuleString.compare(
"half_dash"_L1, Qt::CaseInsensitive ) == 0 )
4057 else if ( startRuleString.compare(
"full_gap"_L1, Qt::CaseInsensitive ) == 0 )
4059 else if ( startRuleString.compare(
"half_gap"_L1, Qt::CaseInsensitive ) == 0 )
4063 parent->
setEvalErrorString( u
"'%1' is not a valid dash pattern rule"_s.arg( startRuleString ) );
4067 const QString endRuleString = QgsExpressionUtils::getStringValue( values.at( 3 ), parent ).trimmed();
4069 if ( endRuleString.compare(
"no_rule"_L1, Qt::CaseInsensitive ) == 0 )
4071 else if ( endRuleString.compare(
"full_dash"_L1, Qt::CaseInsensitive ) == 0 )
4073 else if ( endRuleString.compare(
"half_dash"_L1, Qt::CaseInsensitive ) == 0 )
4075 else if ( endRuleString.compare(
"full_gap"_L1, Qt::CaseInsensitive ) == 0 )
4077 else if ( endRuleString.compare(
"half_gap"_L1, Qt::CaseInsensitive ) == 0 )
4081 parent->
setEvalErrorString( u
"'%1' is not a valid dash pattern rule"_s.arg( endRuleString ) );
4085 const QString adjustString = QgsExpressionUtils::getStringValue( values.at( 4 ), parent ).trimmed();
4087 if ( adjustString.compare(
"both"_L1, Qt::CaseInsensitive ) == 0 )
4089 else if ( adjustString.compare(
"dash"_L1, Qt::CaseInsensitive ) == 0 )
4091 else if ( adjustString.compare(
"gap"_L1, Qt::CaseInsensitive ) == 0 )
4095 parent->
setEvalErrorString( u
"'%1' is not a valid dash pattern size adjustment"_s.arg( adjustString ) );
4099 const double patternOffset = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
4110 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4115 const long long count = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4117 if ( densified.
isNull() )
4125 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4130 const double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
4132 if ( densified.
isNull() )
4141 if ( values.size() == 1 && QgsExpressionUtils::isList( values.at( 0 ) ) )
4143 list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4150 QVector< QgsGeometry > parts;
4151 parts.reserve( list.size() );
4152 for (
const QVariant &value : std::as_const( list ) )
4154 QgsGeometry part = QgsExpressionUtils::getGeometry( value, parent );
4165 if ( values.count() < 2 || values.count() > 4 )
4167 parent->
setEvalErrorString( QObject::tr(
"Function make_point requires 2-4 arguments" ) );
4171 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
4172 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
4173 double z = values.count() >= 3 ? QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) : 0.0;
4174 double m = values.count() >= 4 ? QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) : 0.0;
4175 switch ( values.count() )
4189 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
4190 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
4191 double m = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
4197 if ( values.empty() )
4202 QVector<QgsPoint> points;
4203 points.reserve( values.count() );
4205 auto addPoint = [&points](
const QgsGeometry &geom ) {
4219 for (
const QVariant &value : values )
4221 if ( value.userType() == QMetaType::Type::QVariantList )
4223 const QVariantList list = value.toList();
4224 for (
const QVariant &v : list )
4226 addPoint( QgsExpressionUtils::getGeometry( v, parent ) );
4231 addPoint( QgsExpressionUtils::getGeometry( value, parent ) );
4235 if ( points.count() < 2 )
4243 if ( values.count() < 1 )
4245 parent->
setEvalErrorString( QObject::tr(
"Function make_polygon requires an argument" ) );
4249 QgsGeometry outerRing = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4257 auto polygon = std::make_unique< QgsPolygon >();
4271 if ( !exteriorRing )
4274 polygon->setExteriorRing( exteriorRing->
segmentize() );
4277 for (
int i = 1; i < values.count(); ++i )
4279 QgsGeometry ringGeom = QgsExpressionUtils::getGeometry( values.at( i ), parent );
4301 polygon->addInteriorRing( ring->
segmentize() );
4304 return QVariant::fromValue(
QgsGeometry( std::move( polygon ) ) );
4309 auto tr = std::make_unique<QgsTriangle>();
4310 auto lineString = std::make_unique<QgsLineString>();
4311 lineString->clear();
4313 for (
const QVariant &value : values )
4315 QgsGeometry geom = QgsExpressionUtils::getGeometry( value, parent );
4337 lineString->addVertex( *point );
4340 tr->setExteriorRing( lineString.release() );
4342 return QVariant::fromValue(
QgsGeometry( tr.release() ) );
4347 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4354 double radius = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
4355 int segment = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
4377 return QVariant::fromValue(
QgsGeometry( circ.toPolygon(
static_cast<unsigned int>(
segment ) ) ) );
4382 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4389 double majorAxis = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
4390 double minorAxis = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
4391 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
4392 int segment = QgsExpressionUtils::getNativeIntValue( values.at( 4 ), parent );
4412 QgsEllipse elp( *point, majorAxis, minorAxis, azimuth );
4413 return QVariant::fromValue(
QgsGeometry( elp.toPolygon(
static_cast<unsigned int>(
segment ) ) ) );
4418 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4425 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
4432 unsigned int nbEdges =
static_cast<unsigned int>( QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) );
4435 parent->
setEvalErrorString( QObject::tr(
"Number of edges/sides must be greater than 2" ) );
4442 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (inscribed) or 1 (circumscribed)" ) );
4481 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4487 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
4502 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4508 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
4514 QgsGeometry pt3 = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
4523 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (distance) or 1 (projected)" ) );
4547 return QVariant::fromValue( geom.
vertexAt( idx ) );
4555 const int idx = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
4557 const QVariant v = pointAt( geom, idx, parent );
4560 return QVariant( v.value<
QgsPoint>().
x() );
4566 if ( values.at( 1 ).isNull() && !values.at( 0 ).isNull() )
4568 return fcnOldXat( values, f, parent, node );
4570 else if ( values.at( 0 ).isNull() && !values.at( 1 ).isNull() )
4572 return fcnOldXat( QVariantList() << values[1], f, parent, node );
4575 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4581 const int vertexNumber = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4583 const QVariant v = pointAt( geom, vertexNumber, parent );
4585 return QVariant( v.value<
QgsPoint>().
x() );
4595 const int idx = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
4597 const QVariant v = pointAt( geom, idx, parent );
4600 return QVariant( v.value<
QgsPoint>().
y() );
4606 if ( values.at( 1 ).isNull() && !values.at( 0 ).isNull() )
4608 return fcnOldYat( values, f, parent, node );
4610 else if ( values.at( 0 ).isNull() && !values.at( 1 ).isNull() )
4612 return fcnOldYat( QVariantList() << values[1], f, parent, node );
4615 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4621 const int vertexNumber = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4623 const QVariant v = pointAt( geom, vertexNumber, parent );
4625 return QVariant( v.value<
QgsPoint>().
y() );
4632 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4638 const int vertexNumber = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4640 const QVariant v = pointAt( geom, vertexNumber, parent );
4642 return QVariant( v.value<
QgsPoint>().
z() );
4649 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4655 const int vertexNumber = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4657 const QVariant v = pointAt( geom, vertexNumber, parent );
4659 return QVariant( v.value<
QgsPoint>().
m() );
4678 return QVariant::fromValue( geom );
4686 QString wkt = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4688 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
4694 const QByteArray wkb = QgsExpressionUtils::getBinaryValue( values.at( 0 ), parent );
4700 return !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
4705 QString gml = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4712 ogcContext.
layer = mapLayerPtr.data();
4717 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
4732 return QVariant( area );
4736 parent->
setEvalErrorString( QObject::tr(
"An error occurred while calculating area" ) );
4748 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4753 return QVariant( geom.
area() );
4767 return QVariant( len );
4771 parent->
setEvalErrorString( QObject::tr(
"An error occurred while calculating length" ) );
4792 return QVariant( len );
4796 parent->
setEvalErrorString( QObject::tr(
"An error occurred while calculating perimeter" ) );
4802 return f.
geometry().
isNull() ? QVariant( 0 ) : QVariant( f.geometry().constGet()->perimeter() );
4808 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4814 return QVariant( geom.
length() );
4819 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4825 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4834 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4843 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4859 if ( !curvePolygon )
4871 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4878 return QVariant( curvePolygon->
ringCount() );
4880 bool foundPoly =
false;
4889 if ( !curvePolygon )
4900 return QVariant( ringCount );
4905 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4907 QVariant result = !geomBounds.
isNull() ? QVariant::fromValue( geomBounds ) : QVariant();
4913 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4919 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4925 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4934 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4940 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4946 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4952 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4958 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4966 double max = std::numeric_limits< double >::lowest();
4970 double z = ( *it ).z();
4976 if ( max == std::numeric_limits< double >::lowest() )
4979 return QVariant( max );
4984 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4992 double min = std::numeric_limits< double >::max();
4996 double z = ( *it ).z();
5002 if ( min == std::numeric_limits< double >::max() )
5005 return QVariant( min );
5010 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5018 double min = std::numeric_limits< double >::max();
5022 double m = ( *it ).m();
5028 if ( min == std::numeric_limits< double >::max() )
5031 return QVariant( min );
5036 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5044 double max = std::numeric_limits< double >::lowest();
5048 double m = ( *it ).m();
5054 if ( max == std::numeric_limits< double >::lowest() )
5057 return QVariant( max );
5062 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5066 parent->
setEvalErrorString( QObject::tr(
"Function `sinuosity` requires a line geometry." ) );
5075 const QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5079 parent->
setEvalErrorString( QObject::tr(
"Function `straight_distance_2d` requires a line geometry or a multi line geometry with a single part." ) );
5088 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5093 parent->
setEvalErrorString( QObject::tr(
"Function `roundness` requires a polygon geometry or a multi polygon geometry with a single part." ) );
5103 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5107 std::unique_ptr< QgsAbstractGeometry > flipped( geom.
constGet()->
clone() );
5109 return QVariant::fromValue(
QgsGeometry( std::move( flipped ) ) );
5114 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5133 return QVariant::fromValue( curve->
isClosed() );
5138 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5151 std::unique_ptr< QgsLineString > closedLine( line->
clone() );
5152 closedLine->close();
5154 result = QVariant::fromValue(
QgsGeometry( std::move( closedLine ) ) );
5168 std::unique_ptr< QgsLineString > closedLine( line->
clone() );
5169 closedLine->close();
5171 closed->addGeometry( closedLine.release() );
5174 result = QVariant::fromValue(
QgsGeometry( std::move( closed ) ) );
5182 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5186 return QVariant::fromValue( fGeom.
isEmpty() );
5192 return QVariant::fromValue(
true );
5194 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5195 return QVariant::fromValue( fGeom.
isNull() || fGeom.
isEmpty() );
5200 if ( values.length() < 2 || values.length() > 3 )
5203 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5204 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5211 if ( values.length() == 2 )
5214 QString result = engine->relate( sGeom.
constGet() );
5215 return QVariant::fromValue( result );
5220 QString pattern = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
5221 bool result = engine->relatePattern( sGeom.
constGet(), pattern );
5222 return QVariant::fromValue( result );
5228 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5229 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5234 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5235 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5236 return fGeom.
disjoint( sGeom ) ? TVL_True : TVL_False;
5240 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5241 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5242 return fGeom.
intersects( sGeom ) ? TVL_True : TVL_False;
5246 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5247 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5248 return fGeom.
touches( sGeom ) ? TVL_True : TVL_False;
5252 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5253 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5254 return fGeom.
crosses( sGeom ) ? TVL_True : TVL_False;
5258 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5259 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5260 return fGeom.
contains( sGeom ) ? TVL_True : TVL_False;
5264 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5265 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5266 return fGeom.
overlaps( sGeom ) ? TVL_True : TVL_False;
5270 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5271 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5272 return fGeom.
within( sGeom ) ? TVL_True : TVL_False;
5277 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5278 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5279 return fGeom.
equals( sGeom ) ? TVL_True : TVL_False;
5284 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5285 const double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5286 const int seg = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
5287 const QString endCapString = QgsExpressionUtils::getStringValue( values.at( 3 ), parent ).trimmed();
5288 const QString joinString = QgsExpressionUtils::getStringValue( values.at( 4 ), parent ).trimmed();
5289 const double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
5292 if ( endCapString.compare(
"flat"_L1, Qt::CaseInsensitive ) == 0 )
5294 else if ( endCapString.compare(
"square"_L1, Qt::CaseInsensitive ) == 0 )
5298 if ( joinString.compare(
"miter"_L1, Qt::CaseInsensitive ) == 0 )
5300 else if ( joinString.compare(
"bevel"_L1, Qt::CaseInsensitive ) == 0 )
5304 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5310 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5312 return !reoriented.
isNull() ? QVariant::fromValue( reoriented ) : QVariant();
5317 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5319 return !reoriented.
isNull() ? QVariant::fromValue( reoriented ) : QVariant();
5324 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5326 return !reoriented.
isNull() ? QVariant::fromValue( reoriented ) : QVariant();
5331 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5346 parent->
setEvalErrorString( QObject::tr(
"Function `wedge_buffer` requires a point value for the center." ) );
5350 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5351 double width = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5352 double outerRadius = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
5353 double innerRadius = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
5356 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5362 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5365 parent->
setEvalErrorString( QObject::tr(
"Function `tapered_buffer` requires a line geometry." ) );
5369 double startWidth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5370 double endWidth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5371 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) );
5374 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5380 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5383 parent->
setEvalErrorString( QObject::tr(
"Function `buffer_by_m` requires a line geometry." ) );
5387 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
5390 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5396 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5397 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5398 int segments = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
5399 const int joinInt = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
5400 if ( joinInt < 1 || joinInt > 3 )
5404 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
5407 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5413 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5414 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5415 int segments = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
5417 const int joinInt = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
5418 if ( joinInt < 1 || joinInt > 3 )
5422 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
5425 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5431 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5432 double distStart = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5433 double distEnd = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5436 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5442 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5443 double dx = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5444 double dy = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5446 return QVariant::fromValue( fGeom );
5451 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5452 const double rotation = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5454 const bool perPart = values.value( 3 ).toBool();
5461 std::unique_ptr< QgsGeometryCollection > collection( qgsgeometry_cast< QgsGeometryCollection * >( fGeom.constGet()->clone() ) );
5462 for ( auto it = collection->parts_begin(); it != collection->parts_end(); ++it )
5464 const QgsPointXY partCenter = ( *it )->boundingBox().center();
5465 QTransform t = QTransform::fromTranslate( partCenter.x(), partCenter.y() );
5466 t.rotate( -rotation );
5467 t.translate( -partCenter.x(), -partCenter.y() );
5468 ( *it )->transform( t );
5470 return QVariant::fromValue(
QgsGeometry( std::move( collection ) ) );
5482 parent->
setEvalErrorString( QObject::tr(
"Function 'rotate' requires a point value for the center" ) );
5490 fGeom.
rotate( rotation, pt );
5491 return QVariant::fromValue( fGeom );
5497 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5498 const double xScale = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5499 const double yScale = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5500 const QgsGeometry center = values.at( 3 ).isValid() ? QgsExpressionUtils::getGeometry( values.at( 3 ), parent ) :
QgsGeometry();
5506 pt = fGeom.boundingBox().center();
5510 parent->setEvalErrorString( QObject::tr(
"Function 'scale' requires a point value for the center" ) );
5515 pt = center.asPoint();
5518 QTransform t = QTransform::fromTranslate( pt.
x(), pt.
y() );
5519 t.scale( xScale, yScale );
5520 t.translate( -pt.
x(), -pt.
y() );
5522 return QVariant::fromValue( fGeom );
5527 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5533 const double deltaX = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5534 const double deltaY = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5536 const double rotationZ = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
5538 const double scaleX = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
5539 const double scaleY = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
5541 const double deltaZ = QgsExpressionUtils::getDoubleValue( values.at( 6 ), parent );
5542 const double deltaM = QgsExpressionUtils::getDoubleValue( values.at( 7 ), parent );
5543 const double scaleZ = QgsExpressionUtils::getDoubleValue( values.at( 8 ), parent );
5544 const double scaleM = QgsExpressionUtils::getDoubleValue( values.at( 9 ), parent );
5555 QTransform transform;
5556 transform.translate( deltaX, deltaY );
5557 transform.rotate( rotationZ );
5558 transform.scale( scaleX, scaleY );
5559 fGeom.
transform( transform, deltaZ, scaleZ, deltaM, scaleM );
5561 return QVariant::fromValue( fGeom );
5567 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5569 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5574 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5576 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5582 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5583 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5585 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5591 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5593 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5597#if GEOS_VERSION_MAJOR > 3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR >= 11 )
5602 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5603 const double targetPercent = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5604 const bool allowHoles = values.value( 2 ).toBool();
5606 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5619 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5621 if ( values.length() == 2 )
5622 segments = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
5630 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5636 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5638 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5644 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5650 double area,
angle, width, height;
5663 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5664 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5666 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5677 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent,
true );
5688 result = reversed ? QVariant::fromValue(
QgsGeometry( reversed ) ) : QVariant();
5698 reversed->addGeometry( curve->
reversed() );
5705 result = reversed ? QVariant::fromValue(
QgsGeometry( std::move( reversed ) ) ) : QVariant();
5711 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5712 std::reverse(
string.begin(),
string.end() );
5718 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5738 QVariant result = exterior ? QVariant::fromValue(
QgsGeometry( exterior ) ) : QVariant();
5744 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5745 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5746 return QVariant( fGeom.
distance( sGeom ) );
5751 QgsGeometry g1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5752 QgsGeometry g2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5755 if ( values.length() == 3 && values.at( 2 ).isValid() )
5757 double densify = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5758 densify = std::clamp( densify, 0.0, 1.0 );
5766 return res > -1 ? QVariant( res ) : QVariant();
5771 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5772 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5774 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5779 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5780 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5782 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5787 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5788 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5790 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
5796 if ( values.length() < 1 || values.length() > 2 )
5799 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5801 if ( values.length() == 2 )
5802 prec = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
5803 QString wkt = fGeom.
asWkt( prec );
5804 return QVariant( wkt );
5809 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5810 return fGeom.
isNull() ? QVariant() : QVariant( fGeom.asWkb() );
5815 if ( values.length() != 2 )
5817 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires exactly two parameters. %n given.",
nullptr, values.length() ) );
5821 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5822 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5850 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires two points as arguments." ) );
5857 if ( pt1->
y() < pt2->
y() )
5859 else if ( pt1->
y() > pt2->
y() )
5867 if ( pt1->
x() < pt2->
x() )
5869 else if ( pt1->
x() > pt2->
x() )
5870 return M_PI + ( M_PI_2 );
5875 if ( pt1->
x() < pt2->
x() )
5877 if ( pt1->
y() < pt2->
y() )
5879 return std::atan( std::fabs( pt1->
x() - pt2->
x() ) / std::fabs( pt1->
y() - pt2->
y() ) );
5883 return std::atan( std::fabs( pt1->
y() - pt2->
y() ) / std::fabs( pt1->
x() - pt2->
x() ) ) + ( M_PI_2 );
5889 if ( pt1->
y() > pt2->
y() )
5891 return std::atan( std::fabs( pt1->
x() - pt2->
x() ) / std::fabs( pt1->
y() - pt2->
y() ) ) + M_PI;
5895 return std::atan( std::fabs( pt1->
y() - pt2->
y() ) / std::fabs( pt1->
x() - pt2->
x() ) ) + ( M_PI + ( M_PI_2 ) );
5902 const QgsGeometry geom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5903 const QgsGeometry geom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
5905 QString ellipsoid = QgsExpressionUtils::getStringValue( values.at( 3 ), parent );
5909 parent->
setEvalErrorString( QObject::tr(
"Function `bearing` requires two valid point geometries." ) );
5917 parent->
setEvalErrorString( QObject::tr(
"Function `bearing` requires point geometries or multi point geometries with a single part." ) );
5931 if ( ellipsoid.isEmpty() )
5933 ellipsoid = context->
variable( u
"project_ellipsoid"_s ).toString();
5939 parent->
setEvalErrorString( QObject::tr(
"Function `bearing` requires a valid source CRS." ) );
5947 parent->
setEvalErrorString( QObject::tr(
"Function `bearing` requires a valid ellipsoid acronym or ellipsoid authority ID." ) );
5953 const double bearing = da.
bearing( point1, point2 );
5954 if ( std::isfinite( bearing ) )
5956 return std::fmod( bearing + 2 * M_PI, 2 * M_PI );
5969 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5977 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
5978 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
5979 double inclination = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
5982 QgsPoint newPoint = p->
project( distance, 180.0 * azimuth / M_PI, 180.0 * inclination / M_PI );
5989 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
5990 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
6017 parent->
setEvalErrorString( u
"Function 'inclination' requires two points as arguments."_s );
6026 if ( values.length() != 3 )
6029 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6030 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
6031 double y = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
6035 QVariant result = geom.
constGet() ? QVariant::fromValue( geom ) : QVariant();
6041 if ( values.length() < 2 )
6044 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6047 return values.at( 0 );
6049 QString expString = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
6050 QVariant cachedExpression;
6055 if ( cachedExpression.isValid() )
6062 bool asc = values.value( 2 ).toBool();
6080 Q_ASSERT( collection );
6084 QgsExpressionSorter sorter( orderBy );
6086 QList<QgsFeature> partFeatures;
6087 partFeatures.reserve( collection->
partCount() );
6088 for (
int i = 0; i < collection->
partCount(); ++i )
6094 sorter.sortFeatures( partFeatures, unconstedContext );
6098 Q_ASSERT( orderedGeom );
6103 for (
const QgsFeature &feature : std::as_const( partFeatures ) )
6108 QVariant result = QVariant::fromValue(
QgsGeometry( orderedGeom ) );
6111 delete unconstedContext;
6118 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6119 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
6123 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
6129 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6130 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
6134 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
6140 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6141 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
6145 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
6151 const QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6152 const double m = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
6153 const bool use3DDistance = values.at( 2 ).toBool();
6155 double x, y, z, distance;
6178 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6181 parent->
setEvalErrorString( QObject::tr(
"line_substring requires a curve geometry input" ) );
6201 double startDistance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
6202 double endDistance = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
6204 std::unique_ptr< QgsCurve > substring( curve->
curveSubstring( startDistance, endDistance ) );
6206 return !result.isNull() ? QVariant::fromValue( result ) : QVariant();
6211 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6212 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
6219 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6220 int vertex = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
6225 vertex = count + vertex;
6233 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6234 int vertex = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
6239 vertex = count + vertex;
6247 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6248 QgsGeometry pointGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
6252 return distance >= 0 ? distance : QVariant();
6257 const QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6258 const double m = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
6259 const bool use3DDistance = values.at( 2 ).toBool();
6261 double x, y, z, distance;
6270 return found ? distance : QVariant();
6275 if ( values.length() == 2 && values.at( 1 ).toInt() != 0 )
6277 double number = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
6278 return qgsRound( number, QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
6281 if ( values.length() >= 1 )
6283 double number = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
6284 return QVariant( qlonglong( std::round( number ) ) );
6299 const double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
6300 const int places = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
6301 const QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
6308 const bool omitGroupSeparator = values.value( 3 ).toBool();
6309 const bool trimTrailingZeros = values.value( 4 ).toBool();
6311 QLocale locale = !language.isEmpty() ? QLocale( language ) : QLocale();
6312 if ( !omitGroupSeparator )
6313 locale.setNumberOptions( locale.numberOptions() & ~QLocale::NumberOption::OmitGroupSeparator );
6315 locale.setNumberOptions( locale.numberOptions() | QLocale::NumberOption::OmitGroupSeparator );
6317 QString res = locale.toString( value,
'f', places );
6319 if ( trimTrailingZeros )
6321 const QChar decimal = locale.decimalPoint().at( 0 );
6322 const QChar zeroDigit = locale.zeroDigit().at( 0 );
6324 if ( res.contains( decimal ) )
6326 int trimPoint = res.length() - 1;
6328 while ( res.at( trimPoint ) == zeroDigit )
6331 if ( res.at( trimPoint ) == decimal )
6334 res.truncate( trimPoint + 1 );
6343 QDateTime datetime = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
6344 const QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
6345 const QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
6348 if ( format.indexOf(
"Z" ) > 0 )
6349 datetime = datetime.toUTC();
6351 QLocale locale = !language.isEmpty() ? QLocale( language ) : QLocale();
6352 return locale.toString( datetime, format );
6357 const QVariant variant = values.at( 0 );
6359 QColor color = QgsExpressionUtils::getColorValue( variant, parent, isQColor );
6360 if ( !color.isValid() )
6363 const float alpha = color.alphaF();
6364 if ( color.spec() == QColor::Spec::Cmyk )
6366 const float avg = ( color.cyanF() + color.magentaF() + color.yellowF() )
6368 color = QColor::fromCmykF( avg, avg, avg, color.blackF(), alpha );
6372 const float avg = ( color.redF() + color.greenF() + color.blueF() )
6374 color.setRgbF( avg, avg, avg, alpha );
6377 return isQColor ? QVariant( color ) : QVariant(
QgsSymbolLayerUtils::encodeColor( color ) );
6384 double ratio = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
6389 else if ( ratio < 0 )
6394 int red =
static_cast<int>( color1.red() * ( 1 - ratio ) + color2.red() * ratio );
6395 int green =
static_cast<int>( color1.green() * ( 1 - ratio ) + color2.green() * ratio );
6396 int blue =
static_cast<int>( color1.blue() * ( 1 - ratio ) + color2.blue() * ratio );
6397 int alpha =
static_cast<int>( color1.alpha() * ( 1 - ratio ) + color2.alpha() * ratio );
6399 QColor newColor( red, green, blue, alpha );
6406 const QVariant variant1 = values.at( 0 );
6407 const QVariant variant2 = values.at( 1 );
6409 if ( variant1.userType() != variant2.userType() )
6411 parent->
setEvalErrorString( QObject::tr(
"Both color arguments must have the same type (string or color object)" ) );
6416 const QColor color1 = QgsExpressionUtils::getColorValue( variant1, parent, isQColor );
6417 if ( !color1.isValid() )
6420 const QColor color2 = QgsExpressionUtils::getColorValue( variant2, parent, isQColor );
6421 if ( !color2.isValid() )
6424 if ( ( color1.spec() == QColor::Cmyk ) != ( color2.spec() == QColor::Cmyk ) )
6426 parent->
setEvalErrorString( QObject::tr(
"Both color arguments must have compatible color type (CMYK or RGB/HSV/HSL)" ) );
6430 const float ratio =
static_cast<float>( std::clamp( QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ), 0., 1. ) );
6436 const float alpha = color1.alphaF() * ( 1 - ratio ) + color2.alphaF() * ratio;
6437 if ( color1.spec() == QColor::Spec::Cmyk )
6439 float cyan = color1.cyanF() * ( 1 - ratio ) + color2.cyanF() * ratio;
6440 float magenta = color1.magentaF() * ( 1 - ratio ) + color2.magentaF() * ratio;
6441 float yellow = color1.yellowF() * ( 1 - ratio ) + color2.yellowF() * ratio;
6442 float black = color1.blackF() * ( 1 - ratio ) + color2.blackF() * ratio;
6443 newColor = QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
6447 float red = color1.redF() * ( 1 - ratio ) + color2.redF() * ratio;
6448 float green = color1.greenF() * ( 1 - ratio ) + color2.greenF() * ratio;
6449 float blue = color1.blueF() * ( 1 - ratio ) + color2.blueF() * ratio;
6450 newColor = QColor::fromRgbF( red, green, blue, alpha );
6455 return isQColor ? QVariant( newColor ) : QVariant(
QgsSymbolLayerUtils::encodeColor( newColor ) );
6460 int red = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
6461 int green = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
6462 int blue = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
6463 QColor color = QColor( red, green, blue );
6464 if ( !color.isValid() )
6466 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( red ).arg( green ).arg( blue ) );
6467 color = QColor( 0, 0, 0 );
6470 return u
"%1,%2,%3"_s.arg( color.red() ).arg( color.green() ).arg( color.blue() );
6475 const float red = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) ), 0.f, 1.f );
6476 const float green = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent ) ), 0.f, 1.f );
6477 const float blue = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) ), 0.f, 1.f );
6478 const float alpha = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) ), 0.f, 1.f );
6479 QColor color = QColor::fromRgbF( red, green, blue, alpha );
6480 if ( !color.isValid() )
6482 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( red ).arg( green ).arg( blue ).arg( alpha ) );
6491 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
6492 QVariant value = node->
eval( parent, context );
6496 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
6498 value = node->
eval( parent, context );
6506 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
6508 QVariant value = node->
eval( parent, context );
6510 if ( value.toBool() )
6512 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
6514 value = node->
eval( parent, context );
6519 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
6521 value = node->
eval( parent, context );
6529 int red = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
6530 int green = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
6531 int blue = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
6532 int alpha = QgsExpressionUtils::getNativeIntValue( values.at( 3 ), parent );
6533 QColor color = QColor( red, green, blue, alpha );
6534 if ( !color.isValid() )
6536 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( red ).arg( green ).arg( blue ).arg( alpha ) );
6537 color = QColor( 0, 0, 0 );
6546 if ( values.at( 0 ).userType() == qMetaTypeId< QgsGradientColorRamp>() )
6548 expRamp = QgsExpressionUtils::getRamp( values.at( 0 ), parent );
6553 QString rampName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
6557 parent->
setEvalErrorString( QObject::tr(
"\"%1\" is not a valid color ramp" ).arg( rampName ) );
6562 double value = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
6563 QColor color = ramp->
color( value );
6576 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
6578 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
6580 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
6582 QColor color = QColor::fromHslF( hue, saturation, lightness );
6584 if ( !color.isValid() )
6586 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( lightness ) );
6587 color = QColor( 0, 0, 0 );
6590 return u
"%1,%2,%3"_s.arg( color.red() ).arg( color.green() ).arg( color.blue() );
6596 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
6598 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
6600 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
6602 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
6604 QColor color = QColor::fromHslF( hue, saturation, lightness, alpha );
6605 if ( !color.isValid() )
6607 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
6608 color = QColor( 0, 0, 0 );
6615 float hue = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) ), 0.f, 1.f );
6616 float saturation = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent ) ), 0.f, 1.f );
6617 float lightness = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) ), 0.f, 1.f );
6618 float alpha = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) ), 0.f, 1.f );
6620 QColor color = QColor::fromHslF( hue, saturation, lightness, alpha );
6621 if ( !color.isValid() )
6623 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
6633 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
6635 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
6637 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
6639 QColor color = QColor::fromHsvF( hue, saturation, value );
6641 if ( !color.isValid() )
6643 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( value ) );
6644 color = QColor( 0, 0, 0 );
6647 return u
"%1,%2,%3"_s.arg( color.red() ).arg( color.green() ).arg( color.blue() );
6653 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
6655 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
6657 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
6659 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
6661 QColor color = QColor::fromHsvF( hue, saturation, value, alpha );
6662 if ( !color.isValid() )
6664 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
6665 color = QColor( 0, 0, 0 );
6672 float hue = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) ), 0.f, 1.f );
6673 float saturation = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent ) ), 0.f, 1.f );
6674 float value = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) ), 0.f, 1.f );
6675 float alpha = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) ), 0.f, 1.f );
6676 QColor color = QColor::fromHsvF( hue, saturation, value, alpha );
6678 if ( !color.isValid() )
6680 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
6689 const float cyan = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) ), 0.f, 1.f );
6690 const float magenta = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent ) ), 0.f, 1.f );
6691 const float yellow = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) ), 0.f, 1.f );
6692 const float black = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) ), 0.f, 1.f );
6693 const float alpha = std::clamp(
static_cast<float>( QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent ) ), 0.f, 1.f );
6695 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
6696 if ( !color.isValid() )
6698 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
6708 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
6710 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
6712 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
6714 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
6716 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black );
6718 if ( !color.isValid() )
6720 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ) );
6721 color = QColor( 0, 0, 0 );
6724 return u
"%1,%2,%3"_s.arg( color.red() ).arg( color.green() ).arg( color.blue() );
6730 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
6732 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
6734 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
6736 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
6738 double alpha = QgsExpressionUtils::getIntValue( values.at( 4 ), parent ) / 255.0;
6740 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
6741 if ( !color.isValid() )
6743 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
6744 color = QColor( 0, 0, 0 );
6751 const QVariant variant = values.at( 0 );
6753 const QColor color = QgsExpressionUtils::getColorValue( variant, parent, isQColor );
6754 if ( !color.isValid() )
6757 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
6758 if ( part.compare(
"red"_L1, Qt::CaseInsensitive ) == 0 )
6760 else if ( part.compare(
"green"_L1, Qt::CaseInsensitive ) == 0 )
6761 return color.green();
6762 else if ( part.compare(
"blue"_L1, Qt::CaseInsensitive ) == 0 )
6763 return color.blue();
6764 else if ( part.compare(
"alpha"_L1, Qt::CaseInsensitive ) == 0 )
6765 return color.alpha();
6766 else if ( part.compare(
"hue"_L1, Qt::CaseInsensitive ) == 0 )
6767 return static_cast< double >( color.hsvHueF() * 360 );
6768 else if ( part.compare(
"saturation"_L1, Qt::CaseInsensitive ) == 0 )
6769 return static_cast< double >( color.hsvSaturationF() * 100 );
6770 else if ( part.compare(
"value"_L1, Qt::CaseInsensitive ) == 0 )
6771 return static_cast< double >( color.valueF() * 100 );
6772 else if ( part.compare(
"hsl_hue"_L1, Qt::CaseInsensitive ) == 0 )
6773 return static_cast< double >( color.hslHueF() * 360 );
6774 else if ( part.compare(
"hsl_saturation"_L1, Qt::CaseInsensitive ) == 0 )
6775 return static_cast< double >( color.hslSaturationF() * 100 );
6776 else if ( part.compare(
"lightness"_L1, Qt::CaseInsensitive ) == 0 )
6777 return static_cast< double >( color.lightnessF() * 100 );
6778 else if ( part.compare(
"cyan"_L1, Qt::CaseInsensitive ) == 0 )
6779 return static_cast< double >( color.cyanF() * 100 );
6780 else if ( part.compare(
"magenta"_L1, Qt::CaseInsensitive ) == 0 )
6781 return static_cast< double >( color.magentaF() * 100 );
6782 else if ( part.compare(
"yellow"_L1, Qt::CaseInsensitive ) == 0 )
6783 return static_cast< double >( color.yellowF() * 100 );
6784 else if ( part.compare(
"black"_L1, Qt::CaseInsensitive ) == 0 )
6785 return static_cast< double >( color.blackF() * 100 );
6787 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
6793 const QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
6796 parent->
setEvalErrorString( QObject::tr(
"A minimum of two colors is required to create a ramp" ) );
6800 QList< QColor > colors;
6802 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
6805 if ( !colors.last().isValid() )
6807 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( it.value().toString() ) );
6811 double step = it.key().toDouble();
6812 if ( it == map.constBegin() )
6817 else if ( it == map.constEnd() )
6827 bool discrete = values.at( 1 ).toBool();
6829 if ( colors.empty() )
6832 return QVariant::fromValue(
QgsGradientColorRamp( colors.first(), colors.last(), discrete, stops ) );
6837 const QVariant variant = values.at( 0 );
6839 QColor color = QgsExpressionUtils::getColorValue( variant, parent, isQColor );
6840 if ( !color.isValid() )
6843 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
6844 int value = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
6845 if ( part.compare(
"red"_L1, Qt::CaseInsensitive ) == 0 )
6846 color.setRed( std::clamp( value, 0, 255 ) );
6847 else if ( part.compare(
"green"_L1, Qt::CaseInsensitive ) == 0 )
6848 color.setGreen( std::clamp( value, 0, 255 ) );
6849 else if ( part.compare(
"blue"_L1, Qt::CaseInsensitive ) == 0 )
6850 color.setBlue( std::clamp( value, 0, 255 ) );
6851 else if ( part.compare(
"alpha"_L1, Qt::CaseInsensitive ) == 0 )
6852 color.setAlpha( std::clamp( value, 0, 255 ) );
6853 else if ( part.compare(
"hue"_L1, Qt::CaseInsensitive ) == 0 )
6854 color.setHsv( std::clamp( value, 0, 359 ), color.hsvSaturation(), color.value(), color.alpha() );
6855 else if ( part.compare(
"saturation"_L1, Qt::CaseInsensitive ) == 0 )
6856 color.setHsvF( color.hsvHueF(), std::clamp( value, 0, 100 ) / 100.0, color.valueF(), color.alphaF() );
6857 else if ( part.compare(
"value"_L1, Qt::CaseInsensitive ) == 0 )
6858 color.setHsvF( color.hsvHueF(), color.hsvSaturationF(), std::clamp( value, 0, 100 ) / 100.0, color.alphaF() );
6859 else if ( part.compare(
"hsl_hue"_L1, Qt::CaseInsensitive ) == 0 )
6860 color.setHsl( std::clamp( value, 0, 359 ), color.hslSaturation(), color.lightness(), color.alpha() );
6861 else if ( part.compare(
"hsl_saturation"_L1, Qt::CaseInsensitive ) == 0 )
6862 color.setHslF( color.hslHueF(), std::clamp( value, 0, 100 ) / 100.0, color.lightnessF(), color.alphaF() );
6863 else if ( part.compare(
"lightness"_L1, Qt::CaseInsensitive ) == 0 )
6864 color.setHslF( color.hslHueF(), color.hslSaturationF(), std::clamp( value, 0, 100 ) / 100.0, color.alphaF() );
6865 else if ( part.compare(
"cyan"_L1, Qt::CaseInsensitive ) == 0 )
6866 color.setCmykF( std::clamp( value, 0, 100 ) / 100.0, color.magentaF(), color.yellowF(), color.blackF(), color.alphaF() );
6867 else if ( part.compare(
"magenta"_L1, Qt::CaseInsensitive ) == 0 )
6868 color.setCmykF( color.cyanF(), std::clamp( value, 0, 100 ) / 100.0, color.yellowF(), color.blackF(), color.alphaF() );
6869 else if ( part.compare(
"yellow"_L1, Qt::CaseInsensitive ) == 0 )
6870 color.setCmykF( color.cyanF(), color.magentaF(), std::clamp( value, 0, 100 ) / 100.0, color.blackF(), color.alphaF() );
6871 else if ( part.compare(
"black"_L1, Qt::CaseInsensitive ) == 0 )
6872 color.setCmykF( color.cyanF(), color.magentaF(), color.yellowF(), std::clamp( value, 0, 100 ) / 100.0, color.alphaF() );
6875 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
6878 return isQColor ? QVariant( color ) : QVariant(
QgsSymbolLayerUtils::encodeColor( color ) );
6883 const QVariant variant = values.at( 0 );
6885 QColor color = QgsExpressionUtils::getColorValue( variant, parent, isQColor );
6886 if ( !color.isValid() )
6889 color = color.darker( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
6891 return isQColor ? QVariant( color ) : QVariant(
QgsSymbolLayerUtils::encodeColor( color ) );
6896 const QVariant variant = values.at( 0 );
6898 QColor color = QgsExpressionUtils::getColorValue( variant, parent, isQColor );
6899 if ( !color.isValid() )
6902 color = color.lighter( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
6904 return isQColor ? QVariant( color ) : QVariant(
QgsSymbolLayerUtils::encodeColor( color ) );
6909 QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
6912 return QVariant::fromValue( geom );
6918 const QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
6926 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
6931 return QVariant::fromValue( fGeom );
6934 return QVariant::fromValue( fGeom );
6943 return QVariant::fromValue( fGeom );
6956 bool foundLayer =
false;
6957 std::unique_ptr<QgsVectorLayerFeatureSource> featureSource = QgsExpressionUtils::getFeatureSource( values.at( 0 ), context, parent, foundLayer );
6960 if ( !featureSource || !foundLayer )
6965 const QgsFeatureId fid = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
6978 result = QVariant::fromValue( fet );
6986 bool foundLayer =
false;
6987 std::unique_ptr<QgsVectorLayerFeatureSource> featureSource = QgsExpressionUtils::getFeatureSource( values.at( 0 ), context, parent, foundLayer );
6990 if ( !featureSource || !foundLayer )
6995 QString cacheValueKey;
6996 if ( values.at( 1 ).userType() == QMetaType::Type::QVariantMap )
6998 QVariantMap attributeMap = QgsExpressionUtils::getMapValue( values.at( 1 ), parent );
7000 QMap<QString, QVariant>::const_iterator i = attributeMap.constBegin();
7001 QString filterString;
7002 for ( ; i != attributeMap.constEnd(); ++i )
7004 if ( !filterString.isEmpty() )
7006 filterString.append(
" AND " );
7010 cacheValueKey = u
"getfeature:%1:%2"_s.arg( featureSource->id(), filterString );
7019 QString attribute = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
7020 int attributeId = featureSource->fields().lookupField( attribute );
7021 if ( attributeId == -1 )
7026 const QVariant &attVal = values.at( 2 );
7028 cacheValueKey = u
"getfeature:%1:%2:%3"_s.arg( featureSource->id(), QString::number( attributeId ), attVal.toString() );
7051 res = QVariant::fromValue( fet );
7066 if ( !values.isEmpty() )
7069 if ( col && ( values.size() == 1 || !values.at( 1 ).isValid() ) )
7070 fieldName = col->
name();
7071 else if ( values.size() == 2 )
7072 fieldName = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
7075 QVariant value = values.at( 0 );
7080 if ( fieldIndex == -1 )
7082 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: Field not found %2" ).arg( u
"represent_value"_s, fieldName ) );
7088 QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( context->
variable( u
"layer"_s ), context, parent );
7091 const QString cacheValueKey = u
"repvalfcnval:%1:%2:%3"_s.arg( layer ? layer->id() : u
"[None]"_s, fieldName, value.toString() );
7100 const QString
cacheKey = u
"repvalfcn:%1:%2"_s.arg( layer ? layer->id() : u
"[None]"_s, fieldName );
7118 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: function cannot be evaluated without a context." ).arg( u
"represent_value"_s, fieldName ) );
7126 const QVariant data = values.at( 0 );
7127 const QMimeDatabase db;
7128 return db.mimeTypeForData( data.toByteArray() ).name();
7133 const QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
7135 bool foundLayer =
false;
7136 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe(
7140 [layerProperty](
QgsMapLayer *layer ) -> QVariant {
7145 if ( QString::compare( layerProperty, u
"name"_s, Qt::CaseInsensitive ) == 0 )
7146 return layer->name();
7147 else if ( QString::compare( layerProperty, u
"id"_s, Qt::CaseInsensitive ) == 0 )
7149 else if ( QString::compare( layerProperty, u
"title"_s, Qt::CaseInsensitive ) == 0 )
7150 return !layer->metadata().title().isEmpty() ? layer->metadata().title() : layer->serverProperties()->title();
7151 else if ( QString::compare( layerProperty, u
"abstract"_s, Qt::CaseInsensitive ) == 0 )
7152 return !layer->metadata().abstract().isEmpty() ? layer->metadata().abstract() : layer->serverProperties()->abstract();
7153 else if ( QString::compare( layerProperty, u
"keywords"_s, Qt::CaseInsensitive ) == 0 )
7155 QStringList keywords;
7156 const QgsAbstractMetadataBase::KeywordMap keywordMap = layer->metadata().keywords();
7157 for ( auto it = keywordMap.constBegin(); it != keywordMap.constEnd(); ++it )
7159 keywords.append( it.value() );
7161 if ( !keywords.isEmpty() )
7163 return layer->serverProperties()->keywordList();
7165 else if ( QString::compare( layerProperty, u
"data_url"_s, Qt::CaseInsensitive ) == 0 )
7167 else if ( QString::compare( layerProperty, u
"attribution"_s, Qt::CaseInsensitive ) == 0 )
7169 return !layer->
metadata().
rights().isEmpty() ? QVariant( layer->
metadata().
rights() ) : QVariant( layer->serverProperties()->attribution() );
7171 else if ( QString::compare( layerProperty, u
"attribution_url"_s, Qt::CaseInsensitive ) == 0 )
7173 else if ( QString::compare( layerProperty, u
"source"_s, Qt::CaseInsensitive ) == 0 )
7175 else if ( QString::compare( layerProperty, u
"min_scale"_s, Qt::CaseInsensitive ) == 0 )
7177 else if ( QString::compare( layerProperty, u
"max_scale"_s, Qt::CaseInsensitive ) == 0 )
7179 else if ( QString::compare( layerProperty, u
"is_editable"_s, Qt::CaseInsensitive ) == 0 )
7181 else if ( QString::compare( layerProperty, u
"crs"_s, Qt::CaseInsensitive ) == 0 )
7183 else if ( QString::compare( layerProperty, u
"crs_definition"_s, Qt::CaseInsensitive ) == 0 )
7185 else if ( QString::compare( layerProperty, u
"crs_description"_s, Qt::CaseInsensitive ) == 0 )
7187 else if ( QString::compare( layerProperty, u
"crs_ellipsoid"_s, Qt::CaseInsensitive ) == 0 )
7189 else if ( QString::compare( layerProperty, u
"extent"_s, Qt::CaseInsensitive ) == 0 )
7192 QVariant result = QVariant::fromValue( extentGeom );
7195 else if ( QString::compare( layerProperty, u
"distance_units"_s, Qt::CaseInsensitive ) == 0 )
7197 else if ( QString::compare( layerProperty, u
"path"_s, Qt::CaseInsensitive ) == 0 )
7200 return decodedUri.value( u
"path"_s );
7202 else if ( QString::compare( layerProperty, u
"type"_s, Qt::CaseInsensitive ) == 0 )
7204 switch ( layer->
type() )
7207 return QCoreApplication::translate(
"expressions",
"Vector" );
7209 return QCoreApplication::translate(
"expressions",
"Raster" );
7211 return QCoreApplication::translate(
"expressions",
"Mesh" );
7213 return QCoreApplication::translate(
"expressions",
"Vector Tile" );
7215 return QCoreApplication::translate(
"expressions",
"Plugin" );
7217 return QCoreApplication::translate(
"expressions",
"Annotation" );
7219 return QCoreApplication::translate(
"expressions",
"Point Cloud" );
7221 return QCoreApplication::translate(
"expressions",
"Group" );
7223 return QCoreApplication::translate(
"expressions",
"Tiled Scene" );
7229 QgsVectorLayer *vLayer = qobject_cast< QgsVectorLayer * >( layer );
7232 if ( QString::compare( layerProperty, u
"storage_type"_s, Qt::CaseInsensitive ) == 0 )
7234 else if ( QString::compare( layerProperty, u
"geometry_type"_s, Qt::CaseInsensitive ) == 0 )
7236 else if ( QString::compare( layerProperty, u
"feature_count"_s, Qt::CaseInsensitive ) == 0 )
7254 const QString uriPart = values.at( 1 ).toString();
7256 bool foundLayer =
false;
7258 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe(
7262 [parent, uriPart](
QgsMapLayer *layer ) -> QVariant {
7263 if ( !layer->dataProvider() )
7265 parent->setEvalErrorString( QObject::tr(
"Layer %1 has invalid data provider" ).arg( layer->name() ) );
7271 if ( !uriPart.isNull() )
7273 return decodedUri.value( uriPart );
7285 parent->
setEvalErrorString( QObject::tr(
"Function `decode_uri` requires a valid layer." ) );
7296 const int band = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
7297 const QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
7299 bool foundLayer =
false;
7300 const QVariant res = QgsExpressionUtils::runMapLayerFunctionThreadSafe(
7304 [parent, band, layerProperty](
QgsMapLayer *layer ) -> QVariant {
7305 QgsRasterLayer *rl = qobject_cast< QgsRasterLayer * >( layer );
7309 if ( band < 1 || band > rl->bandCount() )
7311 parent->setEvalErrorString( QObject::tr(
"Invalid band number %1 for layer" ).arg( band ) );
7317 if ( QString::compare( layerProperty, u
"avg"_s, Qt::CaseInsensitive ) == 0 )
7319 else if ( QString::compare( layerProperty, u
"stdev"_s, Qt::CaseInsensitive ) == 0 )
7321 else if ( QString::compare( layerProperty, u
"min"_s, Qt::CaseInsensitive ) == 0 )
7323 else if ( QString::compare( layerProperty, u
"max"_s, Qt::CaseInsensitive ) == 0 )
7325 else if ( QString::compare( layerProperty, u
"range"_s, Qt::CaseInsensitive ) == 0 )
7327 else if ( QString::compare( layerProperty, u
"sum"_s, Qt::CaseInsensitive ) == 0 )
7331 parent->
setEvalErrorString( QObject::tr(
"Invalid raster statistic: '%1'" ).arg( layerProperty ) );
7361 parent->
setEvalErrorString( QObject::tr(
"Function `raster_statistic` requires a valid raster layer." ) );
7378 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7379 bool ascending = values.value( 1 ).toBool();
7380 std::sort( list.begin(), list.end(), [ascending]( QVariant a, QVariant b ) ->
bool { return ( !ascending ? qgsVariantLessThan( b, a ) : qgsVariantLessThan( a, b ) ); } );
7386 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).length();
7391 return QVariant( QgsExpressionUtils::getListValue( values.at( 0 ), parent ).contains( values.at( 1 ) ) );
7396 return QVariant( QgsExpressionUtils::getListValue( values.at( 0 ), parent ).count( values.at( 1 ) ) );
7401 QVariantList listA = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7402 QVariantList listB = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
7404 for (
const auto &item : listB )
7406 if ( listA.contains( item ) )
7410 return QVariant( match == listB.count() );
7415 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).indexOf( values.at( 1 ) );
7420 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7421 const int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
7422 if ( pos < list.length() && pos >= 0 )
7423 return list.at( pos );
7424 else if ( pos < 0 && ( list.length() + pos ) >= 0 )
7425 return list.at( list.length() + pos );
7431 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7432 return list.value( 0 );
7437 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7438 return list.value( list.size() - 1 );
7443 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7444 return list.isEmpty() ? QVariant() : *std::min_element( list.constBegin(), list.constEnd(), []( QVariant a, QVariant b ) -> bool { return (
qgsVariantLessThan( a, b ) ); } );
7449 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7450 return list.isEmpty() ? QVariant() : *std::max_element( list.constBegin(), list.constEnd(), []( QVariant a, QVariant b ) -> bool { return (
qgsVariantLessThan( a, b ) ); } );
7455 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7458 for (
const QVariant &item : list )
7460 switch ( item.userType() )
7462 case QMetaType::Int:
7463 case QMetaType::UInt:
7464 case QMetaType::LongLong:
7465 case QMetaType::ULongLong:
7466 case QMetaType::Float:
7467 case QMetaType::Double:
7468 total += item.toDouble();
7473 return i == 0 ? QVariant() : total / i;
7478 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7479 QVariantList numbers;
7480 for (
const auto &item : list )
7482 switch ( item.userType() )
7484 case QMetaType::Int:
7485 case QMetaType::UInt:
7486 case QMetaType::LongLong:
7487 case QMetaType::ULongLong:
7488 case QMetaType::Float:
7489 case QMetaType::Double:
7490 numbers.append( item );
7494 std::sort( numbers.begin(), numbers.end(), []( QVariant a, QVariant b ) ->
bool { return ( qgsVariantLessThan( a, b ) ); } );
7495 const int count = numbers.count();
7500 else if ( count % 2 )
7502 return numbers.at( count / 2 );
7506 return ( numbers.at( count / 2 - 1 ).toDouble() + numbers.at( count / 2 ).toDouble() ) / 2;
7512 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7515 for (
const QVariant &item : list )
7517 switch ( item.userType() )
7519 case QMetaType::Int:
7520 case QMetaType::UInt:
7521 case QMetaType::LongLong:
7522 case QMetaType::ULongLong:
7523 case QMetaType::Float:
7524 case QMetaType::Double:
7525 total += item.toDouble();
7530 return i == 0 ? QVariant() : total;
7533static QVariant convertToSameType(
const QVariant &value, QMetaType::Type type )
7535 QVariant result = value;
7536 ( void ) result.convert(
static_cast<int>( type ) );
7542 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7543 QHash< QVariant, int > hash;
7544 for (
const auto &item : list )
7548 const QList< int > occurrences = hash.values();
7549 if ( occurrences.empty() )
7550 return QVariantList();
7552 const int maxValue = *std::max_element( occurrences.constBegin(), occurrences.constEnd() );
7554 const QString option = values.at( 1 ).toString();
7555 if ( option.compare(
"all"_L1, Qt::CaseInsensitive ) == 0 )
7557 return convertToSameType( hash.keys( maxValue ),
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7559 else if ( option.compare(
"any"_L1, Qt::CaseInsensitive ) == 0 )
7561 if ( hash.isEmpty() )
7564 return QVariant( hash.key( maxValue ) );
7566 else if ( option.compare(
"median"_L1, Qt::CaseInsensitive ) == 0 )
7568 return fcnArrayMedian( QVariantList() << convertToSameType( hash.keys( maxValue ),
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) ), context, parent, node );
7570 else if ( option.compare(
"real_majority"_L1, Qt::CaseInsensitive ) == 0 )
7572 if ( maxValue * 2 <= list.size() )
7575 return QVariant( hash.key( maxValue ) );
7586 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7587 QHash< QVariant, int > hash;
7588 for (
const auto &item : list )
7592 const QList< int > occurrences = hash.values();
7593 if ( occurrences.empty() )
7594 return QVariantList();
7596 const int minValue = *std::min_element( occurrences.constBegin(), occurrences.constEnd() );
7598 const QString option = values.at( 1 ).toString();
7599 if ( option.compare(
"all"_L1, Qt::CaseInsensitive ) == 0 )
7601 return convertToSameType( hash.keys( minValue ),
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7603 else if ( option.compare(
"any"_L1, Qt::CaseInsensitive ) == 0 )
7605 if ( hash.isEmpty() )
7608 return QVariant( hash.key( minValue ) );
7610 else if ( option.compare(
"median"_L1, Qt::CaseInsensitive ) == 0 )
7612 return fcnArrayMedian( QVariantList() << convertToSameType( hash.keys( minValue ),
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) ), context, parent, node );
7614 else if ( option.compare(
"real_minority"_L1, Qt::CaseInsensitive ) == 0 )
7616 if ( hash.isEmpty() )
7620 const int maxValue = *std::max_element( occurrences.constBegin(), occurrences.constEnd() );
7621 if ( maxValue * 2 > list.size() )
7622 hash.remove( hash.key( maxValue ) );
7624 return convertToSameType( hash.keys(),
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7635 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7636 list.append( values.at( 1 ) );
7637 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7642 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7643 list.prepend( values.at( 1 ) );
7644 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7649 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7650 list.insert( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), values.at( 2 ) );
7651 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7656 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7657 int position = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
7659 position = position + list.length();
7660 if ( position >= 0 && position < list.length() )
7661 list.removeAt( position );
7662 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7670 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7672 const QVariant toRemove = values.at( 1 );
7675 list.erase( std::remove_if( list.begin(), list.end(), [](
const QVariant &element ) { return QgsVariantUtils::isNull( element ); } ), list.end() );
7679 list.removeAll( toRemove );
7681 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7686 if ( values.count() == 2 && values.at( 1 ).userType() == QMetaType::Type::QVariantMap )
7688 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 1 ), parent );
7690 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7691 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
7693 int index = list.indexOf( it.key() );
7694 while ( index >= 0 )
7696 list.replace( index, it.value() );
7697 index = list.indexOf( it.key() );
7701 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7703 else if ( values.count() == 3 )
7705 QVariantList before;
7707 bool isSingleReplacement =
false;
7709 if ( !QgsExpressionUtils::isList( values.at( 1 ) ) && values.at( 2 ).userType() != QMetaType::Type::QStringList )
7711 before = QVariantList() << values.at( 1 );
7715 before = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
7718 if ( !QgsExpressionUtils::isList( values.at( 2 ) ) )
7720 after = QVariantList() << values.at( 2 );
7721 isSingleReplacement =
true;
7725 after = QgsExpressionUtils::getListValue( values.at( 2 ), parent );
7728 if ( !isSingleReplacement && before.length() != after.length() )
7730 parent->
setEvalErrorString( QObject::tr(
"Invalid pair of array, length not identical" ) );
7734 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7735 for (
int i = 0; i < before.length(); i++ )
7737 int index = list.indexOf( before.at( i ) );
7738 while ( index >= 0 )
7740 list.replace( index, after.at( isSingleReplacement ? 0 : i ) );
7741 index = list.indexOf( before.at( i ) );
7745 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7749 parent->
setEvalErrorString( QObject::tr(
"Function array_replace requires 2 or 3 arguments" ) );
7756 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7757 QVariantList list_new;
7759 for (
const QVariant &cur : QgsExpressionUtils::getListValue( values.at( 1 ), parent ) )
7761 while ( list.removeOne( cur ) )
7763 list_new.append( cur );
7767 list_new.append( list );
7769 return convertToSameType( list_new,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7775 for (
const QVariant &cur : values )
7777 list += QgsExpressionUtils::getListValue( cur, parent );
7779 return convertToSameType( list,
static_cast<QMetaType::Type
>( values.at( 0 ).userType() ) );
7784 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7785 int start_pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
7786 const int end_pos = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
7787 int slice_length = 0;
7789 if ( start_pos < 0 )
7791 start_pos = list.length() + start_pos;
7795 slice_length = end_pos - start_pos + 1;
7799 slice_length = list.length() + end_pos - start_pos + 1;
7802 if ( slice_length < 0 )
7806 list = list.mid( start_pos, slice_length );
7812 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7813 std::reverse( list.begin(), list.end() );
7819 const QVariantList array1 = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7820 const QVariantList array2 = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
7821 for (
const QVariant &cur : array2 )
7823 if ( array1.contains( cur ) )
7824 return QVariant(
true );
7826 return QVariant(
false );
7831 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7833 QVariantList distinct;
7835 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
7837 if ( !distinct.contains( *it ) )
7839 distinct += ( *it );
7848 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
7849 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
7850 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
7854 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
7856 str += ( !( *it ).toString().isEmpty() ) ? ( *it ).toString() : empty;
7857 if ( it != ( array.constEnd() - 1 ) )
7863 return QVariant( str );
7868 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
7869 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
7870 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
7872 QStringList list = str.split( delimiter );
7875 for ( QStringList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
7877 array += ( !( *it ).isEmpty() ) ? *it : empty;
7885 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
7886 QJsonDocument document = QJsonDocument::fromJson( str.toUtf8() );
7887 if ( document.isNull() )
7890 return document.toVariant();
7896 QJsonDocument document = QJsonDocument::fromVariant( values.at( 0 ) );
7897 return QString( document.toJson( QJsonDocument::Compact ) );
7902 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
7903 if ( str.isEmpty() )
7904 return QVariantMap();
7905 str = str.trimmed();
7912 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
7919 for (
int i = 0; i + 1 < values.length(); i += 2 )
7921 result.insert( QgsExpressionUtils::getStringValue( values.at( i ), parent ), values.at( i + 1 ) );
7928 const QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
7929 const QString prefix = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
7930 QVariantMap resultMap;
7932 for (
auto it = map.cbegin(); it != map.cend(); it++ )
7934 resultMap.insert( QString( it.key() ).prepend( prefix ), it.value() );
7942 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).value( values.at( 1 ).toString() );
7947 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).contains( values.at( 1 ).toString() );
7952 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
7953 map.remove( values.at( 1 ).toString() );
7959 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
7960 map.insert( values.at( 1 ).toString(), values.at( 2 ) );
7967 for (
const QVariant &cur : values )
7969 const QVariantMap curMap = QgsExpressionUtils::getMapValue( cur, parent );
7970 for ( QVariantMap::const_iterator it = curMap.constBegin(); it != curMap.constEnd(); ++it )
7971 result.insert( it.key(), it.value() );
7978 return QStringList( QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).keys() );
7983 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).values();
7988 const QString envVarName = values.at( 0 ).toString();
7989 if ( !QProcessEnvironment::systemEnvironment().contains( envVarName ) )
7992 return QProcessEnvironment::systemEnvironment().value( envVarName );
7997 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
8000 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg(
"base_file_name"_L1 ) );
8003 return QFileInfo( file ).completeBaseName();
8008 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
8011 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg(
"file_suffix"_L1 ) );
8014 return QFileInfo( file ).completeSuffix();
8019 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
8022 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg(
"file_exists"_L1 ) );
8025 return QFileInfo::exists( file );
8030 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
8033 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg(
"file_name"_L1 ) );
8036 return QFileInfo( file ).fileName();
8041 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
8044 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg(
"is_file"_L1 ) );
8047 return QFileInfo( file ).isFile();
8052 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
8055 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg(
"is_directory"_L1 ) );
8058 return QFileInfo( file ).isDir();
8063 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
8066 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg(
"file_path"_L1 ) );
8069 return QDir::toNativeSeparators( QFileInfo( file ).path() );
8074 const QString file = QgsExpressionUtils::getFilePathValue( values.at( 0 ), context, parent );
8077 parent->
setEvalErrorString( QObject::tr(
"Function `%1` requires a value which represents a possible file path" ).arg(
"file_size"_L1 ) );
8080 return QFileInfo( file ).size();
8083static QVariant fcnHash(
const QString &str,
const QCryptographicHash::Algorithm
algorithm )
8085 return QString( QCryptographicHash::hash( str.toUtf8(),
algorithm ).toHex() );
8091 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
8092 QString method = QgsExpressionUtils::getStringValue( values.at( 1 ), parent ).toLower();
8094 if ( method ==
"md4"_L1 )
8096 hash = fcnHash( str, QCryptographicHash::Md4 );
8098 else if ( method ==
"md5"_L1 )
8100 hash = fcnHash( str, QCryptographicHash::Md5 );
8102 else if ( method ==
"sha1"_L1 )
8104 hash = fcnHash( str, QCryptographicHash::Sha1 );
8106 else if ( method ==
"sha224"_L1 )
8108 hash = fcnHash( str, QCryptographicHash::Sha224 );
8110 else if ( method ==
"sha256"_L1 )
8112 hash = fcnHash( str, QCryptographicHash::Sha256 );
8114 else if ( method ==
"sha384"_L1 )
8116 hash = fcnHash( str, QCryptographicHash::Sha384 );
8118 else if ( method ==
"sha512"_L1 )
8120 hash = fcnHash( str, QCryptographicHash::Sha512 );
8122 else if ( method ==
"sha3_224"_L1 )
8124 hash = fcnHash( str, QCryptographicHash::Sha3_224 );
8126 else if ( method ==
"sha3_256"_L1 )
8128 hash = fcnHash( str, QCryptographicHash::Sha3_256 );
8130 else if ( method ==
"sha3_384"_L1 )
8132 hash = fcnHash( str, QCryptographicHash::Sha3_384 );
8134 else if ( method ==
"sha3_512"_L1 )
8136 hash = fcnHash( str, QCryptographicHash::Sha3_512 );
8138 else if ( method ==
"keccak_224"_L1 )
8140 hash = fcnHash( str, QCryptographicHash::Keccak_224 );
8142 else if ( method ==
"keccak_256"_L1 )
8144 hash = fcnHash( str, QCryptographicHash::Keccak_256 );
8146 else if ( method ==
"keccak_384"_L1 )
8148 hash = fcnHash( str, QCryptographicHash::Keccak_384 );
8150 else if ( method ==
"keccak_512"_L1 )
8152 hash = fcnHash( str, QCryptographicHash::Keccak_512 );
8156 parent->
setEvalErrorString( QObject::tr(
"Hash method %1 is not available on this system." ).arg( str ) );
8163 return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Md5 );
8168 return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Sha256 );
8173 const QByteArray input = values.at( 0 ).toByteArray();
8174 return QVariant( QString( input.toBase64() ) );
8179 const QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
8181 for (
auto it = map.cbegin(); it != map.cend(); it++ )
8183 query.addQueryItem( it.key(), it.value().toString() );
8185 return query.toString( QUrl::ComponentFormattingOption::FullyEncoded );
8190 const QString value = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
8191 const QByteArray base64 = value.toLocal8Bit();
8192 const QByteArray decoded = QByteArray::fromBase64( base64 );
8193 return QVariant( decoded );
8198static QVariant executeGeomOverlay(
8199 const QVariantList &values,
8203 bool invert =
false,
8204 double bboxGrow = 0,
8205 bool isNearestFunc =
false,
8206 bool isIntersectsFunc =
false
8211 parent->
setEvalErrorString( u
"This function was called without an expression context."_s );
8215 const QVariant sourceLayerRef = context->
variable( u
"layer"_s );
8218 QgsVectorLayer *sourceLayer = QgsExpressionUtils::getVectorLayer( sourceLayerRef, context, parent );
8227 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
8230 const bool layerCanBeCached = node->
isStatic( parent, context );
8231 QVariant targetLayerValue = node->
eval( parent, context );
8235 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
8237 QString subExpString = node->dump();
8239 bool testOnly = ( subExpString ==
"NULL" );
8242 QgsVectorLayer *targetLayer = QgsExpressionUtils::getVectorLayer( targetLayerValue, context, parent );
8246 parent->
setEvalErrorString( QObject::tr(
"Layer '%1' could not be loaded." ).arg( targetLayerValue.toString() ) );
8251 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
8253 QString filterString = node->dump();
8254 if ( filterString !=
"NULL" )
8256 request.setFilterExpression( filterString );
8260 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
8262 QVariant limitValue = node->eval( parent, context );
8264 qlonglong limit = QgsExpressionUtils::getIntValue( limitValue, parent );
8267 double max_distance = 0;
8268 if ( isNearestFunc )
8270 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
8272 QVariant distanceValue = node->eval( parent, context );
8274 max_distance = QgsExpressionUtils::getDoubleValue( distanceValue, parent );
8278 node = QgsExpressionUtils::getNode( values.at( isNearestFunc ? 5 : 4 ), parent );
8280 QVariant cacheValue = node->eval( parent, context );
8282 bool cacheEnabled = cacheValue.toBool();
8288 double minOverlap { -1 };
8289 double minInscribedCircleRadius { -1 };
8290 bool returnDetails =
false;
8291 bool sortByMeasure =
false;
8292 bool sortAscending =
false;
8293 bool requireMeasures =
false;
8294 bool overlapOrRadiusFilter =
false;
8295 if ( isIntersectsFunc )
8297 node = QgsExpressionUtils::getNode( values.at( 5 ), parent );
8299 const QVariant minOverlapValue = node->eval( parent, context );
8301 minOverlap = QgsExpressionUtils::getDoubleValue( minOverlapValue, parent );
8302 node = QgsExpressionUtils::getNode( values.at( 6 ), parent );
8304 const QVariant minInscribedCircleRadiusValue = node->eval( parent, context );
8306 minInscribedCircleRadius = QgsExpressionUtils::getDoubleValue( minInscribedCircleRadiusValue, parent );
8307 node = QgsExpressionUtils::getNode( values.at( 7 ), parent );
8309 returnDetails = !testOnly && node->eval( parent, context ).toBool();
8310 node = QgsExpressionUtils::getNode( values.at( 8 ), parent );
8312 const QString sorting { node->eval( parent, context ).toString().toLower() };
8313 sortByMeasure = !testOnly && ( sorting.startsWith(
"asc" ) || sorting.startsWith(
"des" ) );
8314 sortAscending = sorting.startsWith(
"asc" );
8315 requireMeasures = sortByMeasure || returnDetails;
8316 overlapOrRadiusFilter = minInscribedCircleRadius != -1 || minOverlap != -1;
8323 if ( sourceLayer && targetLayer->crs() != sourceLayer->crs() )
8326 request.setDestinationCrs( sourceLayer->crs(), TransformContext );
8329 bool sameLayers = ( sourceLayer && sourceLayer->id() == targetLayer->id() );
8332 if ( bboxGrow != 0 )
8334 intDomain.
grow( bboxGrow );
8337 const QString cacheBase { u
"%1:%2:%3"_s.arg( targetLayer->id(), subExpString, filterString ) };
8343 QList<QgsFeature> features;
8344 if ( isNearestFunc || ( layerCanBeCached && cacheEnabled ) )
8348 const QString cacheLayer { u
"ovrlaylyr:%1"_s.arg( cacheBase ) };
8349 const QString cacheIndex { u
"ovrlayidx:%1"_s.arg( cacheBase ) };
8353 cachedTarget = targetLayer->
materialize( request );
8354 if ( layerCanBeCached )
8355 context->
setCachedValue( cacheLayer, QVariant::fromValue( cachedTarget ) );
8365 if ( layerCanBeCached )
8366 context->
setCachedValue( cacheIndex, QVariant::fromValue( spatialIndex ) );
8373 QList<QgsFeatureId> fidsList;
8374 if ( isNearestFunc )
8376 fidsList = spatialIndex.
nearestNeighbor( geometry, sameLayers ? limit + 1 : limit, max_distance );
8380 fidsList = spatialIndex.
intersects( intDomain );
8383 QListIterator<QgsFeatureId> i( fidsList );
8384 while ( i.hasNext() )
8387 if ( sameLayers && feat.
id() == fId2 )
8389 features.append( cachedTarget->
getFeature( fId2 ) );
8396 request.setFilterRect( intDomain );
8401 if ( sameLayers && feat.
id() == feat2.
id() )
8403 features.append( feat2 );
8411 const QString expCacheKey { u
"exp:%1"_s.arg( cacheBase ) };
8412 const QString ctxCacheKey { u
"ctx:%1"_s.arg( cacheBase ) };
8418 subExpression.
prepare( &subContext );
8431 auto testLinestring = [minOverlap, requireMeasures](
const QgsGeometry intersection,
double &overlapValue ) ->
bool {
8432 bool testResult {
false };
8434 QVector<double> overlapValues;
8435 const QgsGeometry merged { intersection.mergeLines() };
8440 if ( minOverlap != -1 || requireMeasures )
8442 overlapValue = geom->
length();
8443 overlapValues.append( overlapValue );
8444 if ( minOverlap != -1 )
8446 if ( overlapValue >= minOverlap )
8458 if ( !overlapValues.isEmpty() )
8460 overlapValue = *std::max_element( overlapValues.cbegin(), overlapValues.cend() );
8467 auto testPolygon = [minOverlap, requireMeasures, minInscribedCircleRadius](
const QgsGeometry intersection,
double &radiusValue,
double &overlapValue ) ->
bool {
8469 bool testResult {
false };
8471 QVector<double> overlapValues;
8472 QVector<double> radiusValues;
8473 for (
auto it = intersection.const_parts_begin(); ( !testResult || requireMeasures ) && it != intersection.const_parts_end(); ++it )
8477 if ( minOverlap != -1 || requireMeasures )
8479 overlapValue = geom->
area();
8480 overlapValues.append( geom->
area() );
8481 if ( minOverlap != -1 )
8483 if ( overlapValue >= minOverlap )
8495 if ( minInscribedCircleRadius != -1 || requireMeasures )
8498 const double width = bbox.
width();
8499 const double height = bbox.
height();
8500 const double size = width > height ? width : height;
8501 const double tolerance = size / 100.0;
8503 testResult = radiusValue >= minInscribedCircleRadius;
8504 radiusValues.append( radiusValues );
8509 if ( !radiusValues.isEmpty() )
8511 radiusValue = *std::max_element( radiusValues.cbegin(), radiusValues.cend() );
8514 if ( !overlapValues.isEmpty() )
8516 overlapValue = *std::max_element( overlapValues.cbegin(), overlapValues.cend() );
8525 QVariantList results;
8527 QListIterator<QgsFeature> i( features );
8528 while ( i.hasNext() && ( sortByMeasure || limit == -1 || foundCount < limit ) )
8533 if ( !relationFunction || ( geometry.*relationFunction )( feat2.
geometry() ) )
8535 double overlapValue = -1;
8536 double radiusValue = -1;
8538 if ( isIntersectsFunc && ( requireMeasures || overlapOrRadiusFilter ) )
8550 for (
const auto &geom : std::as_const( geometries ) )
8552 switch ( geom.type() )
8556 poly.append( geom.asPolygon() );
8561 line.append( geom.asPolyline() );
8566 point.append( geom.asPoint() );
8577 switch ( geometry.
type() )
8605 switch ( intersection.
type() )
8610 bool testResult { testPolygon( intersection, radiusValue, overlapValue ) };
8612 if ( !testResult && overlapOrRadiusFilter )
8624 if ( minInscribedCircleRadius != -1 )
8630 const bool testResult { testLinestring( intersection, overlapValue ) };
8632 if ( !testResult && overlapOrRadiusFilter )
8644 if ( minInscribedCircleRadius != -1 )
8649 bool testResult {
false };
8650 if ( minOverlap != -1 || requireMeasures )
8670 testResult = testLinestring( feat2.
geometry(), overlapValue );
8675 testResult = testPolygon( feat2.
geometry(), radiusValue, overlapValue );
8681 if ( !testResult && overlapOrRadiusFilter )
8708 const QVariant expResult = subExpression.
evaluate( &subContext );
8710 if ( requireMeasures )
8712 QVariantMap resultRecord;
8713 resultRecord.insert( u
"id"_s, feat2.
id() );
8714 resultRecord.insert( u
"result"_s, expResult );
8716 resultRecord.insert( u
"overlap"_s, overlapValue );
8718 if ( radiusValue != -1 )
8720 resultRecord.insert( u
"radius"_s, radiusValue );
8722 results.append( resultRecord );
8726 results.append( expResult );
8732 results.append( feat2.
id() );
8746 if ( requireMeasures )
8748 if ( sortByMeasure )
8750 std::sort( results.begin(), results.end(), [sortAscending](
const QVariant &recordA,
const QVariant &recordB ) ->
bool {
8751 return sortAscending ? recordB.toMap().value( u
"overlap"_s ).toDouble() > recordA.toMap().value( u
"overlap"_s ).toDouble()
8752 : recordA.toMap().value( u
"overlap"_s ).toDouble() > recordB.toMap().value( u
"overlap"_s ).toDouble();
8756 if ( limit > 0 && results.size() > limit )
8758 results.erase( results.begin() + limit );
8761 if ( !returnDetails )
8763 QVariantList expResults;
8764 for (
auto it = results.constBegin(); it != results.constEnd(); ++it )
8766 expResults.append( it->toMap().value( u
"result"_s ) );
8776 QVariantList disjoint_results;
8785 if ( !results.contains( feat2.
id() ) )
8788 disjoint_results.append( subExpression.
evaluate( &subContext ) );
8791 return disjoint_results;
8833 return executeGeomOverlay( values, context, parent,
nullptr,
false, 0,
true );
8842 QMutexLocker locker( &sFunctionsMutex );
8844 QList<QgsExpressionFunction *> &functions = *sFunctions();
8846 if ( functions.isEmpty() )
8849 << QgsExpressionFunction::Parameter( u
"expression"_s )
8850 << QgsExpressionFunction::Parameter( u
"group_by"_s,
true )
8851 << QgsExpressionFunction::Parameter( u
"filter"_s,
true );
8854 aggParamsConcat << QgsExpressionFunction::Parameter( u
"concatenator"_s,
true ) << QgsExpressionFunction::Parameter( u
"order_by"_s,
true, QVariant(),
true );
8857 aggParamsArray << QgsExpressionFunction::Parameter( u
"order_by"_s,
true, QVariant(),
true );
8863 <<
new QgsStaticExpressionFunction( u
"azimuth"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"point_a"_s ) << QgsExpressionFunction::Parameter( u
"point_b"_s ), fcnAzimuth, u
"GeometryGroup"_s )
8864 <<
new QgsStaticExpressionFunction(
8867 << QgsExpressionFunction::Parameter( u
"point_a"_s )
8868 << QgsExpressionFunction::Parameter( u
"point_b"_s )
8869 << QgsExpressionFunction::Parameter( u
"source_crs"_s,
true, QVariant() )
8870 << QgsExpressionFunction::Parameter( u
"ellipsoid"_s,
true, QVariant() ),
8874 <<
new QgsStaticExpressionFunction( u
"inclination"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"point_a"_s ) << QgsExpressionFunction::Parameter( u
"point_b"_s ), fcnInclination, u
"GeometryGroup"_s )
8875 <<
new QgsStaticExpressionFunction(
8878 << QgsExpressionFunction::Parameter( u
"point"_s )
8879 << QgsExpressionFunction::Parameter( u
"distance"_s )
8880 << QgsExpressionFunction::Parameter( u
"azimuth"_s )
8881 << QgsExpressionFunction::Parameter( u
"elevation"_s,
true, M_PI_2 ),
8892 <<
new QgsStaticExpressionFunction( u
"atan2"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"dx"_s ) << QgsExpressionFunction::Parameter( u
"dy"_s ), fcnAtan2, u
"Math"_s )
8896 <<
new QgsStaticExpressionFunction( u
"log"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"base"_s ) << QgsExpressionFunction::Parameter( u
"value"_s ), fcnLog, u
"Math"_s )
8897 <<
new QgsStaticExpressionFunction( u
"round"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"value"_s ) << QgsExpressionFunction::Parameter( u
"places"_s,
true, 0 ), fcnRound, u
"Math"_s );
8899 QgsStaticExpressionFunction *randFunc =
new QgsStaticExpressionFunction(
8901 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"min"_s ) << QgsExpressionFunction::Parameter( u
"max"_s ) << QgsExpressionFunction::Parameter( u
"seed"_s,
true ),
8906 functions << randFunc;
8908 QgsStaticExpressionFunction *randfFunc =
new QgsStaticExpressionFunction(
8911 << QgsExpressionFunction::Parameter( u
"min"_s,
true, 0.0 )
8912 << QgsExpressionFunction::Parameter( u
"max"_s,
true, 1.0 )
8913 << QgsExpressionFunction::Parameter( u
"seed"_s,
true ),
8918 functions << randfFunc;
8921 <<
new QgsStaticExpressionFunction( u
"max"_s, -1, fcnMax, u
"Math"_s, QString(),
false, QSet<QString>(),
false, QStringList(),
true )
8922 <<
new QgsStaticExpressionFunction( u
"min"_s, -1, fcnMin, u
"Math"_s, QString(),
false, QSet<QString>(),
false, QStringList(),
true )
8923 <<
new QgsStaticExpressionFunction( u
"clamp"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"min"_s ) << QgsExpressionFunction::Parameter( u
"value"_s ) << QgsExpressionFunction::Parameter( u
"max"_s ), fcnClamp, u
"Math"_s )
8924 <<
new QgsStaticExpressionFunction(
8927 << QgsExpressionFunction::Parameter( u
"value"_s )
8928 << QgsExpressionFunction::Parameter( u
"domain_min"_s )
8929 << QgsExpressionFunction::Parameter( u
"domain_max"_s )
8930 << QgsExpressionFunction::Parameter( u
"range_min"_s )
8931 << QgsExpressionFunction::Parameter( u
"range_max"_s ),
8935 <<
new QgsStaticExpressionFunction(
8936 u
"scale_polynomial"_s,
8938 << QgsExpressionFunction::Parameter( u
"value"_s )
8939 << QgsExpressionFunction::Parameter( u
"domain_min"_s )
8940 << QgsExpressionFunction::Parameter( u
"domain_max"_s )
8941 << QgsExpressionFunction::Parameter( u
"range_min"_s )
8942 << QgsExpressionFunction::Parameter( u
"range_max"_s )
8943 << QgsExpressionFunction::Parameter( u
"exponent"_s ),
8950 QStringList() << u
"scale_exp"_s
8952 <<
new QgsStaticExpressionFunction(
8953 u
"scale_exponential"_s,
8955 << QgsExpressionFunction::Parameter( u
"value"_s )
8956 << QgsExpressionFunction::Parameter( u
"domain_min"_s )
8957 << QgsExpressionFunction::Parameter( u
"domain_max"_s )
8958 << QgsExpressionFunction::Parameter( u
"range_min"_s )
8959 << QgsExpressionFunction::Parameter( u
"range_max"_s )
8960 << QgsExpressionFunction::Parameter( u
"exponent"_s ),
8961 fcnExponentialScale,
8966 <<
new QgsStaticExpressionFunction( u
"pi"_s, 0, fcnPi, u
"Math"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"$pi"_s )
8967 <<
new QgsStaticExpressionFunction( u
"to_bool"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"value"_s ), fcnToBool, u
"Conversions"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"tobool"_s,
true )
8968 <<
new QgsStaticExpressionFunction( u
"to_int"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"value"_s ), fcnToInt, u
"Conversions"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"toint"_s )
8969 <<
new QgsStaticExpressionFunction( u
"to_real"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"value"_s ), fcnToReal, u
"Conversions"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"toreal"_s )
8970 <<
new QgsStaticExpressionFunction(
8974 QStringList() << u
"Conversions"_s << u
"String"_s,
8979 QStringList() << u
"tostring"_s
8981 <<
new QgsStaticExpressionFunction(
8984 << QgsExpressionFunction::Parameter( u
"value"_s )
8985 << QgsExpressionFunction::Parameter( u
"format"_s,
true, QVariant() )
8986 << QgsExpressionFunction::Parameter( u
"language"_s,
true, QVariant() ),
8988 QStringList() << u
"Conversions"_s << u
"Date and Time"_s,
8993 QStringList() << u
"todatetime"_s
8995 <<
new QgsStaticExpressionFunction(
8998 << QgsExpressionFunction::Parameter( u
"value"_s )
8999 << QgsExpressionFunction::Parameter( u
"format"_s,
true, QVariant() )
9000 << QgsExpressionFunction::Parameter( u
"language"_s,
true, QVariant() ),
9002 QStringList() << u
"Conversions"_s << u
"Date and Time"_s,
9007 QStringList() << u
"todate"_s
9009 <<
new QgsStaticExpressionFunction(
9012 << QgsExpressionFunction::Parameter( u
"value"_s )
9013 << QgsExpressionFunction::Parameter( u
"format"_s,
true, QVariant() )
9014 << QgsExpressionFunction::Parameter( u
"language"_s,
true, QVariant() ),
9016 QStringList() << u
"Conversions"_s << u
"Date and Time"_s,
9021 QStringList() << u
"totime"_s
9023 <<
new QgsStaticExpressionFunction(
9027 QStringList() << u
"Conversions"_s << u
"Date and Time"_s,
9032 QStringList() << u
"tointerval"_s
9034 <<
new QgsStaticExpressionFunction(
9037 << QgsExpressionFunction::Parameter( u
"value"_s )
9038 << QgsExpressionFunction::Parameter( u
"axis"_s )
9039 << QgsExpressionFunction::Parameter( u
"precision"_s )
9040 << QgsExpressionFunction::Parameter( u
"formatting"_s,
true ),
9047 QStringList() << u
"todm"_s
9049 <<
new QgsStaticExpressionFunction(
9052 << QgsExpressionFunction::Parameter( u
"value"_s )
9053 << QgsExpressionFunction::Parameter( u
"axis"_s )
9054 << QgsExpressionFunction::Parameter( u
"precision"_s )
9055 << QgsExpressionFunction::Parameter( u
"formatting"_s,
true ),
9056 fcnToDegreeMinuteSecond,
9062 QStringList() << u
"todms"_s
9064 <<
new QgsStaticExpressionFunction( u
"to_decimal"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"value"_s ), fcnToDecimal, u
"Conversions"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"todecimal"_s )
9065 <<
new QgsStaticExpressionFunction( u
"extract_degrees"_s, { QgsExpressionFunction::Parameter { u
"value"_s } }, fcnExtractDegrees, u
"Conversions"_s )
9066 <<
new QgsStaticExpressionFunction( u
"extract_minutes"_s, { QgsExpressionFunction::Parameter { u
"value"_s } }, fcnExtractMinutes, u
"Conversions"_s )
9067 <<
new QgsStaticExpressionFunction( u
"extract_seconds"_s, { QgsExpressionFunction::Parameter { u
"value"_s } }, fcnExtractSeconds, u
"Conversions"_s )
9068 <<
new QgsStaticExpressionFunction( u
"coalesce"_s, -1, fcnCoalesce, u
"Conditionals"_s, QString(),
false, QSet<QString>(),
false, QStringList(),
true )
9069 <<
new QgsStaticExpressionFunction( u
"nullif"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"value1"_s ) << QgsExpressionFunction::Parameter( u
"value2"_s ), fcnNullIf, u
"Conditionals"_s )
9070 <<
new QgsStaticExpressionFunction(
9073 << QgsExpressionFunction::Parameter( u
"condition"_s )
9074 << QgsExpressionFunction::Parameter( u
"result_when_true"_s )
9075 << QgsExpressionFunction::Parameter( u
"result_when_false"_s ),
9083 <<
new QgsStaticExpressionFunction(
9094 <<
new QgsStaticExpressionFunction(
9097 << QgsExpressionFunction::Parameter( u
"layer"_s )
9098 << QgsExpressionFunction::Parameter( u
"aggregate"_s )
9099 << QgsExpressionFunction::Parameter( u
"expression"_s,
false, QVariant(),
true )
9100 << QgsExpressionFunction::Parameter( u
"filter"_s,
true, QVariant(),
true )
9101 << QgsExpressionFunction::Parameter( u
"concatenator"_s,
true )
9102 << QgsExpressionFunction::Parameter( u
"order_by"_s,
true, QVariant(),
true ),
9112 if ( !node->
args() )
9115 QSet<QString> referencedVars;
9118 QgsExpressionNode *subExpressionNode = node->
args()->
at( 2 );
9124 QgsExpressionNode *filterNode = node->
args()->
at( 3 );
9127 return referencedVars.contains( u
"parent"_s ) || referencedVars.contains( QString() );
9135 if ( !node->
args() )
9136 return QSet<QString>();
9138 QSet<QString> referencedCols;
9139 QSet<QString> referencedVars;
9143 QgsExpressionNode *subExpressionNode = node->
args()->
at( 2 );
9149 QgsExpressionNode *filterNode = node->
args()->
at( 3 );
9154 if ( referencedVars.contains( u
"parent"_s ) || referencedVars.contains( QString() ) )
9157 return referencedCols;
9162 <<
new QgsStaticExpressionFunction(
9163 u
"relation_aggregate"_s,
9165 << QgsExpressionFunction::Parameter( u
"relation"_s )
9166 << QgsExpressionFunction::Parameter( u
"aggregate"_s )
9167 << QgsExpressionFunction::Parameter( u
"expression"_s,
false, QVariant(),
true )
9168 << QgsExpressionFunction::Parameter( u
"concatenator"_s,
true )
9169 << QgsExpressionFunction::Parameter( u
"order_by"_s,
true, QVariant(),
true ),
9170 fcnAggregateRelation,
9178 <<
new QgsStaticExpressionFunction( u
"count"_s, aggParams, fcnAggregateCount, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9179 <<
new QgsStaticExpressionFunction( u
"count_distinct"_s, aggParams, fcnAggregateCountDistinct, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9180 <<
new QgsStaticExpressionFunction( u
"count_missing"_s, aggParams, fcnAggregateCountMissing, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9181 <<
new QgsStaticExpressionFunction( u
"minimum"_s, aggParams, fcnAggregateMin, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9182 <<
new QgsStaticExpressionFunction( u
"maximum"_s, aggParams, fcnAggregateMax, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9183 <<
new QgsStaticExpressionFunction( u
"sum"_s, aggParams, fcnAggregateSum, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9184 <<
new QgsStaticExpressionFunction( u
"mean"_s, aggParams, fcnAggregateMean, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9185 <<
new QgsStaticExpressionFunction( u
"median"_s, aggParams, fcnAggregateMedian, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9186 <<
new QgsStaticExpressionFunction( u
"stdev"_s, aggParams, fcnAggregateStdev, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9187 <<
new QgsStaticExpressionFunction( u
"range"_s, aggParams, fcnAggregateRange, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9188 <<
new QgsStaticExpressionFunction( u
"minority"_s, aggParams, fcnAggregateMinority, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9189 <<
new QgsStaticExpressionFunction( u
"majority"_s, aggParams, fcnAggregateMajority, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9190 <<
new QgsStaticExpressionFunction( u
"q1"_s, aggParams, fcnAggregateQ1, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9191 <<
new QgsStaticExpressionFunction( u
"q3"_s, aggParams, fcnAggregateQ3, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9192 <<
new QgsStaticExpressionFunction( u
"iqr"_s, aggParams, fcnAggregateIQR, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9193 <<
new QgsStaticExpressionFunction( u
"min_length"_s, aggParams, fcnAggregateMinLength, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9194 <<
new QgsStaticExpressionFunction( u
"max_length"_s, aggParams, fcnAggregateMaxLength, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9195 <<
new QgsStaticExpressionFunction( u
"collect"_s, aggParams, fcnAggregateCollectGeometry, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9196 <<
new QgsStaticExpressionFunction( u
"concatenate"_s, aggParamsConcat, fcnAggregateStringConcat, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9197 <<
new QgsStaticExpressionFunction( u
"concatenate_unique"_s, aggParamsConcat, fcnAggregateStringConcatUnique, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9198 <<
new QgsStaticExpressionFunction( u
"array_agg"_s, aggParamsArray, fcnAggregateArray, u
"Aggregates"_s, QString(),
false, QSet<QString>(),
true )
9200 <<
new QgsStaticExpressionFunction( u
"regexp_match"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string"_s ) << QgsExpressionFunction::Parameter( u
"regex"_s ), fcnRegexpMatch, QStringList() << u
"Conditionals"_s << u
"String"_s )
9201 <<
new QgsStaticExpressionFunction(
9202 u
"regexp_matches"_s,
9204 << QgsExpressionFunction::Parameter( u
"string"_s )
9205 << QgsExpressionFunction::Parameter( u
"regex"_s )
9206 << QgsExpressionFunction::Parameter( u
"emptyvalue"_s,
true,
"" ),
9211 <<
new QgsStaticExpressionFunction( u
"now"_s, 0, fcnNow, u
"Date and Time"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"$now"_s )
9212 <<
new QgsStaticExpressionFunction( u
"age"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"datetime1"_s ) << QgsExpressionFunction::Parameter( u
"datetime2"_s ), fcnAge, u
"Date and Time"_s )
9221 <<
new QgsStaticExpressionFunction( u
"datetime_from_epoch"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"long"_s ), fcnDateTimeFromEpoch, u
"Date and Time"_s )
9222 <<
new QgsStaticExpressionFunction( u
"day_of_week"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"date"_s ), fcnDayOfWeek, u
"Date and Time"_s )
9223 <<
new QgsStaticExpressionFunction( u
"make_date"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"year"_s ) << QgsExpressionFunction::Parameter( u
"month"_s ) << QgsExpressionFunction::Parameter( u
"day"_s ), fcnMakeDate, u
"Date and Time"_s )
9224 <<
new QgsStaticExpressionFunction(
9226 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"hour"_s ) << QgsExpressionFunction::Parameter( u
"minute"_s ) << QgsExpressionFunction::Parameter( u
"second"_s ),
9230 <<
new QgsStaticExpressionFunction(
9233 << QgsExpressionFunction::Parameter( u
"year"_s )
9234 << QgsExpressionFunction::Parameter( u
"month"_s )
9235 << QgsExpressionFunction::Parameter( u
"day"_s )
9236 << QgsExpressionFunction::Parameter( u
"hour"_s )
9237 << QgsExpressionFunction::Parameter( u
"minute"_s )
9238 << QgsExpressionFunction::Parameter( u
"second"_s ),
9242 <<
new QgsStaticExpressionFunction(
9245 << QgsExpressionFunction::Parameter( u
"years"_s,
true, 0 )
9246 << QgsExpressionFunction::Parameter( u
"months"_s,
true, 0 )
9247 << QgsExpressionFunction::Parameter( u
"weeks"_s,
true, 0 )
9248 << QgsExpressionFunction::Parameter( u
"days"_s,
true, 0 )
9249 << QgsExpressionFunction::Parameter( u
"hours"_s,
true, 0 )
9250 << QgsExpressionFunction::Parameter( u
"minutes"_s,
true, 0 )
9251 << QgsExpressionFunction::Parameter( u
"seconds"_s,
true, 0 ),
9255 <<
new QgsStaticExpressionFunction( u
"timezone_from_id"_s, { QgsExpressionFunction::Parameter( u
"id"_s ) }, fcnTimeZoneFromId, u
"Date and Time"_s )
9256 <<
new QgsStaticExpressionFunction( u
"timezone_id"_s, { QgsExpressionFunction::Parameter( u
"timezone"_s ) }, fcnTimeZoneToId, u
"Date and Time"_s )
9257 <<
new QgsStaticExpressionFunction( u
"get_timezone"_s, { QgsExpressionFunction::Parameter( u
"datetime"_s ) }, fcnGetTimeZone, u
"Date and Time"_s )
9258 <<
new QgsStaticExpressionFunction( u
"set_timezone"_s, { QgsExpressionFunction::Parameter( u
"datetime"_s ), QgsExpressionFunction::Parameter( u
"timezone"_s ) }, fcnSetTimeZone, u
"Date and Time"_s )
9259 <<
new QgsStaticExpressionFunction( u
"convert_timezone"_s, { QgsExpressionFunction::Parameter( u
"datetime"_s ), QgsExpressionFunction::Parameter( u
"timezone"_s ) }, fcnConvertTimeZone, u
"Date and Time"_s )
9261 <<
new QgsStaticExpressionFunction(
9264 << QgsExpressionFunction::Parameter( u
"string"_s )
9265 << QgsExpressionFunction::Parameter( u
"substring"_s )
9266 << QgsExpressionFunction::Parameter( u
"overlapping"_s,
true,
false ),
9273 <<
new QgsStaticExpressionFunction( u
"unaccent"_s, { QgsExpressionFunction::Parameter( u
"string"_s ) }, fcnUnaccent, u
"String"_s )
9274 <<
new QgsStaticExpressionFunction( u
"ltrim"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string"_s ) << QgsExpressionFunction::Parameter( u
"characters"_s,
true, u
" "_s ), fcnLTrim, u
"String"_s )
9275 <<
new QgsStaticExpressionFunction( u
"rtrim"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string"_s ) << QgsExpressionFunction::Parameter( u
"characters"_s,
true, u
" "_s ), fcnRTrim, u
"String"_s )
9276 <<
new QgsStaticExpressionFunction( u
"levenshtein"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string1"_s ) << QgsExpressionFunction::Parameter( u
"string2"_s ), fcnLevenshtein, u
"Fuzzy Matching"_s )
9277 <<
new QgsStaticExpressionFunction( u
"longest_common_substring"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string1"_s ) << QgsExpressionFunction::Parameter( u
"string2"_s ), fcnLCS, u
"Fuzzy Matching"_s )
9278 <<
new QgsStaticExpressionFunction( u
"hamming_distance"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string1"_s ) << QgsExpressionFunction::Parameter( u
"string2"_s ), fcnHamming, u
"Fuzzy Matching"_s )
9282 <<
new QgsStaticExpressionFunction(
9285 << QgsExpressionFunction::Parameter( u
"text"_s )
9286 << QgsExpressionFunction::Parameter( u
"length"_s )
9287 << QgsExpressionFunction::Parameter( u
"delimiter"_s,
true,
"" ),
9291 <<
new QgsStaticExpressionFunction( u
"length"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"text"_s,
true,
"" ), fcnLength, QStringList() << u
"String"_s << u
"GeometryGroup"_s )
9292 <<
new QgsStaticExpressionFunction( u
"length3D"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnLength3D, u
"GeometryGroup"_s )
9293 <<
new QgsStaticExpressionFunction( u
"repeat"_s, { QgsExpressionFunction::Parameter( u
"text"_s ), QgsExpressionFunction::Parameter( u
"number"_s ) }, fcnRepeat, u
"String"_s )
9294 <<
new QgsStaticExpressionFunction( u
"replace"_s, -1, fcnReplace, u
"String"_s )
9295 <<
new QgsStaticExpressionFunction(
9296 u
"regexp_replace"_s,
9297 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"input_string"_s ) << QgsExpressionFunction::Parameter( u
"regex"_s ) << QgsExpressionFunction::Parameter( u
"replacement"_s ),
9301 <<
new QgsStaticExpressionFunction( u
"regexp_substr"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"input_string"_s ) << QgsExpressionFunction::Parameter( u
"regex"_s ), fcnRegexpSubstr, u
"String"_s )
9302 <<
new QgsStaticExpressionFunction(
9304 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string"_s ) << QgsExpressionFunction::Parameter( u
"start"_s ) << QgsExpressionFunction::Parameter( u
"length"_s,
true ),
9314 <<
new QgsStaticExpressionFunction( u
"concat"_s, -1, fcnConcat, u
"String"_s, QString(),
false, QSet<QString>(),
false, QStringList(),
true )
9315 <<
new QgsStaticExpressionFunction( u
"strpos"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"haystack"_s ) << QgsExpressionFunction::Parameter( u
"needle"_s ), fcnStrpos, u
"String"_s )
9316 <<
new QgsStaticExpressionFunction( u
"left"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string"_s ) << QgsExpressionFunction::Parameter( u
"length"_s ), fcnLeft, u
"String"_s )
9317 <<
new QgsStaticExpressionFunction( u
"right"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string"_s ) << QgsExpressionFunction::Parameter( u
"length"_s ), fcnRight, u
"String"_s )
9318 <<
new QgsStaticExpressionFunction( u
"rpad"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string"_s ) << QgsExpressionFunction::Parameter( u
"width"_s ) << QgsExpressionFunction::Parameter( u
"fill"_s ), fcnRPad, u
"String"_s )
9319 <<
new QgsStaticExpressionFunction( u
"lpad"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string"_s ) << QgsExpressionFunction::Parameter( u
"width"_s ) << QgsExpressionFunction::Parameter( u
"fill"_s ), fcnLPad, u
"String"_s )
9320 <<
new QgsStaticExpressionFunction( u
"format"_s, -1, fcnFormatString, u
"String"_s )
9321 <<
new QgsStaticExpressionFunction(
9324 << QgsExpressionFunction::Parameter( u
"number"_s )
9325 << QgsExpressionFunction::Parameter( u
"places"_s,
true, 0 )
9326 << QgsExpressionFunction::Parameter( u
"language"_s,
true, QVariant() )
9327 << QgsExpressionFunction::Parameter( u
"omit_group_separators"_s,
true,
false )
9328 << QgsExpressionFunction::Parameter( u
"trim_trailing_zeroes"_s,
true,
false ),
9332 <<
new QgsStaticExpressionFunction(
9335 << QgsExpressionFunction::Parameter( u
"datetime"_s )
9336 << QgsExpressionFunction::Parameter( u
"format"_s )
9337 << QgsExpressionFunction::Parameter( u
"language"_s,
true, QVariant() ),
9339 QStringList() << u
"String"_s << u
"Date and Time"_s
9341 <<
new QgsStaticExpressionFunction( u
"color_grayscale_average"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"color"_s ), fcnColorGrayscaleAverage, u
"Color"_s )
9342 <<
new QgsStaticExpressionFunction(
9344 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"color1"_s ) << QgsExpressionFunction::Parameter( u
"color2"_s ) << QgsExpressionFunction::Parameter( u
"ratio"_s ),
9348 <<
new QgsStaticExpressionFunction(
9350 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"color1"_s ) << QgsExpressionFunction::Parameter( u
"color2"_s ) << QgsExpressionFunction::Parameter( u
"ratio"_s ),
9354 <<
new QgsStaticExpressionFunction( u
"color_rgb"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"red"_s ) << QgsExpressionFunction::Parameter( u
"green"_s ) << QgsExpressionFunction::Parameter( u
"blue"_s ), fcnColorRgb, u
"Color"_s )
9355 <<
new QgsStaticExpressionFunction(
9358 << QgsExpressionFunction::Parameter( u
"red"_s )
9359 << QgsExpressionFunction::Parameter( u
"green"_s )
9360 << QgsExpressionFunction::Parameter( u
"blue"_s )
9361 << QgsExpressionFunction::Parameter( u
"alpha"_s,
true, 1. ),
9365 <<
new QgsStaticExpressionFunction(
9368 << QgsExpressionFunction::Parameter( u
"red"_s )
9369 << QgsExpressionFunction::Parameter( u
"green"_s )
9370 << QgsExpressionFunction::Parameter( u
"blue"_s )
9371 << QgsExpressionFunction::Parameter( u
"alpha"_s ),
9377 <<
new QgsStaticExpressionFunction( u
"create_ramp"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"map"_s ) << QgsExpressionFunction::Parameter( u
"discrete"_s,
true,
false ), fcnCreateRamp, u
"Color"_s )
9378 <<
new QgsStaticExpressionFunction(
9380 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"hue"_s ) << QgsExpressionFunction::Parameter( u
"saturation"_s ) << QgsExpressionFunction::Parameter( u
"lightness"_s ),
9384 <<
new QgsStaticExpressionFunction(
9387 << QgsExpressionFunction::Parameter( u
"hue"_s )
9388 << QgsExpressionFunction::Parameter( u
"saturation"_s )
9389 << QgsExpressionFunction::Parameter( u
"lightness"_s )
9390 << QgsExpressionFunction::Parameter( u
"alpha"_s ),
9394 <<
new QgsStaticExpressionFunction(
9397 << QgsExpressionFunction::Parameter( u
"hue"_s )
9398 << QgsExpressionFunction::Parameter( u
"saturation"_s )
9399 << QgsExpressionFunction::Parameter( u
"lightness"_s )
9400 << QgsExpressionFunction::Parameter( u
"alpha"_s,
true, 1. ),
9404 <<
new QgsStaticExpressionFunction(
9406 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"hue"_s ) << QgsExpressionFunction::Parameter( u
"saturation"_s ) << QgsExpressionFunction::Parameter( u
"value"_s ),
9410 <<
new QgsStaticExpressionFunction(
9413 << QgsExpressionFunction::Parameter( u
"hue"_s )
9414 << QgsExpressionFunction::Parameter( u
"saturation"_s )
9415 << QgsExpressionFunction::Parameter( u
"value"_s )
9416 << QgsExpressionFunction::Parameter( u
"alpha"_s ),
9420 <<
new QgsStaticExpressionFunction(
9423 << QgsExpressionFunction::Parameter( u
"hue"_s )
9424 << QgsExpressionFunction::Parameter( u
"saturation"_s )
9425 << QgsExpressionFunction::Parameter( u
"value"_s )
9426 << QgsExpressionFunction::Parameter( u
"alpha"_s,
true, 1. ),
9430 <<
new QgsStaticExpressionFunction(
9433 << QgsExpressionFunction::Parameter( u
"cyan"_s )
9434 << QgsExpressionFunction::Parameter( u
"magenta"_s )
9435 << QgsExpressionFunction::Parameter( u
"yellow"_s )
9436 << QgsExpressionFunction::Parameter( u
"black"_s ),
9440 <<
new QgsStaticExpressionFunction(
9443 << QgsExpressionFunction::Parameter( u
"cyan"_s )
9444 << QgsExpressionFunction::Parameter( u
"magenta"_s )
9445 << QgsExpressionFunction::Parameter( u
"yellow"_s )
9446 << QgsExpressionFunction::Parameter( u
"black"_s )
9447 << QgsExpressionFunction::Parameter( u
"alpha"_s ),
9451 <<
new QgsStaticExpressionFunction(
9454 << QgsExpressionFunction::Parameter( u
"cyan"_s )
9455 << QgsExpressionFunction::Parameter( u
"magenta"_s )
9456 << QgsExpressionFunction::Parameter( u
"yellow"_s )
9457 << QgsExpressionFunction::Parameter( u
"black"_s )
9458 << QgsExpressionFunction::Parameter( u
"alpha"_s,
true, 1. ),
9462 <<
new QgsStaticExpressionFunction( u
"color_part"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"color"_s ) << QgsExpressionFunction::Parameter( u
"component"_s ), fncColorPart, u
"Color"_s )
9463 <<
new QgsStaticExpressionFunction( u
"darker"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"color"_s ) << QgsExpressionFunction::Parameter( u
"factor"_s ), fncDarker, u
"Color"_s )
9464 <<
new QgsStaticExpressionFunction( u
"lighter"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"color"_s ) << QgsExpressionFunction::Parameter( u
"factor"_s ), fncLighter, u
"Color"_s )
9465 <<
new QgsStaticExpressionFunction(
9466 u
"set_color_part"_s,
9467 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"color"_s ) << QgsExpressionFunction::Parameter( u
"component"_s ) << QgsExpressionFunction::Parameter( u
"value"_s ),
9473 <<
new QgsStaticExpressionFunction( u
"base_file_name"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"path"_s ), fcnBaseFileName, u
"Files and Paths"_s )
9474 <<
new QgsStaticExpressionFunction( u
"file_suffix"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"path"_s ), fcnFileSuffix, u
"Files and Paths"_s )
9475 <<
new QgsStaticExpressionFunction( u
"file_exists"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"path"_s ), fcnFileExists, u
"Files and Paths"_s )
9476 <<
new QgsStaticExpressionFunction( u
"file_name"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"path"_s ), fcnFileName, u
"Files and Paths"_s )
9477 <<
new QgsStaticExpressionFunction( u
"is_file"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"path"_s ), fcnPathIsFile, u
"Files and Paths"_s )
9478 <<
new QgsStaticExpressionFunction( u
"is_directory"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"path"_s ), fcnPathIsDir, u
"Files and Paths"_s )
9479 <<
new QgsStaticExpressionFunction( u
"file_path"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"path"_s ), fcnFilePath, u
"Files and Paths"_s )
9480 <<
new QgsStaticExpressionFunction( u
"file_size"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"path"_s ), fcnFileSize, u
"Files and Paths"_s )
9482 <<
new QgsStaticExpressionFunction( u
"exif"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"path"_s ) << QgsExpressionFunction::Parameter( u
"tag"_s,
true ), fcnExif, u
"Files and Paths"_s )
9483 <<
new QgsStaticExpressionFunction( u
"exif_geotag"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"path"_s ), fcnExifGeoTag, u
"GeometryGroup"_s )
9486 <<
new QgsStaticExpressionFunction( u
"hash"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string"_s ) << QgsExpressionFunction::Parameter( u
"method"_s ), fcnGenericHash, u
"Conversions"_s )
9492 <<
new QgsStaticExpressionFunction( u
"from_base64"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string"_s ), fcnFromBase64, u
"Conversions"_s )
9495 <<
new QgsStaticExpressionFunction(
9496 u
"magnetic_declination"_s,
9498 << QgsExpressionFunction::Parameter( u
"model_name"_s )
9499 << QgsExpressionFunction::Parameter( u
"date"_s )
9500 << QgsExpressionFunction::Parameter( u
"latitude"_s )
9501 << QgsExpressionFunction::Parameter( u
"longitude"_s )
9502 << QgsExpressionFunction::Parameter( u
"height"_s )
9503 << QgsExpressionFunction::Parameter( u
"model_path"_s,
true ),
9504 fcnMagneticDeclination,
9507 <<
new QgsStaticExpressionFunction(
9508 u
"magnetic_inclination"_s,
9510 << QgsExpressionFunction::Parameter( u
"model_name"_s )
9511 << QgsExpressionFunction::Parameter( u
"date"_s )
9512 << QgsExpressionFunction::Parameter( u
"latitude"_s )
9513 << QgsExpressionFunction::Parameter( u
"longitude"_s )
9514 << QgsExpressionFunction::Parameter( u
"height"_s )
9515 << QgsExpressionFunction::Parameter( u
"model_path"_s,
true ),
9516 fcnMagneticInclination,
9519 <<
new QgsStaticExpressionFunction(
9520 u
"magnetic_declination_rate_of_change"_s,
9522 << QgsExpressionFunction::Parameter( u
"model_name"_s )
9523 << QgsExpressionFunction::Parameter( u
"date"_s )
9524 << QgsExpressionFunction::Parameter( u
"latitude"_s )
9525 << QgsExpressionFunction::Parameter( u
"longitude"_s )
9526 << QgsExpressionFunction::Parameter( u
"height"_s )
9527 << QgsExpressionFunction::Parameter( u
"model_path"_s,
true ),
9528 fcnMagneticDeclinationRateOfChange,
9531 <<
new QgsStaticExpressionFunction(
9532 u
"magnetic_inclination_rate_of_change"_s,
9534 << QgsExpressionFunction::Parameter( u
"model_name"_s )
9535 << QgsExpressionFunction::Parameter( u
"date"_s )
9536 << QgsExpressionFunction::Parameter( u
"latitude"_s )
9537 << QgsExpressionFunction::Parameter( u
"longitude"_s )
9538 << QgsExpressionFunction::Parameter( u
"height"_s )
9539 << QgsExpressionFunction::Parameter( u
"model_path"_s,
true ),
9540 fcnMagneticInclinationRateOfChange,
9547 QgsStaticExpressionFunction *geomFunc =
new QgsStaticExpressionFunction( u
"$geometry"_s, 0, fcnGeometry, u
"GeometryGroup"_s, QString(),
true );
9549 functions << geomFunc;
9551 QgsStaticExpressionFunction *areaFunc =
new QgsStaticExpressionFunction( u
"$area"_s, 0, fcnGeomArea, u
"GeometryGroup"_s, QString(),
true );
9553 functions << areaFunc;
9555 functions <<
new QgsStaticExpressionFunction( u
"area"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnArea, u
"GeometryGroup"_s );
9557 QgsStaticExpressionFunction *lengthFunc =
new QgsStaticExpressionFunction( u
"$length"_s, 0, fcnGeomLength, u
"GeometryGroup"_s, QString(),
true );
9559 functions << lengthFunc;
9561 QgsStaticExpressionFunction *perimeterFunc =
new QgsStaticExpressionFunction( u
"$perimeter"_s, 0, fcnGeomPerimeter, u
"GeometryGroup"_s, QString(),
true );
9563 functions << perimeterFunc;
9565 functions <<
new QgsStaticExpressionFunction( u
"perimeter"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnPerimeter, u
"GeometryGroup"_s );
9567 functions <<
new QgsStaticExpressionFunction( u
"roundness"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnRoundness, u
"GeometryGroup"_s );
9569 QgsStaticExpressionFunction *xFunc =
new QgsStaticExpressionFunction( u
"$x"_s, 0, fcnX, u
"GeometryGroup"_s, QString(),
true );
9573 QgsStaticExpressionFunction *yFunc =
new QgsStaticExpressionFunction( u
"$y"_s, 0, fcnY, u
"GeometryGroup"_s, QString(),
true );
9577 QgsStaticExpressionFunction *zFunc =
new QgsStaticExpressionFunction( u
"$z"_s, 0, fcnZ, u
"GeometryGroup"_s, QString(),
true );
9581 QMap< QString, QgsExpressionFunction::FcnEval > geometry_overlay_definitions {
9582 { u
"overlay_intersects"_s, fcnGeomOverlayIntersects },
9583 { u
"overlay_contains"_s, fcnGeomOverlayContains },
9584 { u
"overlay_crosses"_s, fcnGeomOverlayCrosses },
9585 { u
"overlay_equals"_s, fcnGeomOverlayEquals },
9586 { u
"overlay_touches"_s, fcnGeomOverlayTouches },
9587 { u
"overlay_disjoint"_s, fcnGeomOverlayDisjoint },
9588 { u
"overlay_within"_s, fcnGeomOverlayWithin },
9590 QMapIterator< QString, QgsExpressionFunction::FcnEval > i( geometry_overlay_definitions );
9591 while ( i.hasNext() )
9594 QgsStaticExpressionFunction *fcnGeomOverlayFunc =
new QgsStaticExpressionFunction(
9597 << QgsExpressionFunction::Parameter( u
"layer"_s )
9598 << QgsExpressionFunction::Parameter( u
"expression"_s,
true, QVariant(),
true )
9599 << QgsExpressionFunction::Parameter( u
"filter"_s,
true, QVariant(),
true )
9600 << QgsExpressionFunction::Parameter( u
"limit"_s,
true, QVariant( -1 ),
true )
9601 << QgsExpressionFunction::Parameter( u
"cache"_s,
true, QVariant(
false ),
false )
9602 << QgsExpressionFunction::Parameter( u
"min_overlap"_s,
true, QVariant( -1 ),
false )
9603 << QgsExpressionFunction::Parameter( u
"min_inscribed_circle_radius"_s,
true, QVariant( -1 ),
false )
9604 << QgsExpressionFunction::Parameter( u
"return_details"_s,
true,
false,
false )
9605 << QgsExpressionFunction::Parameter( u
"sort_by_intersection_size"_s,
true, QString(),
false ),
9616 functions << fcnGeomOverlayFunc;
9619 QgsStaticExpressionFunction *fcnGeomOverlayNearestFunc =
new QgsStaticExpressionFunction(
9620 u
"overlay_nearest"_s,
9622 << QgsExpressionFunction::Parameter( u
"layer"_s )
9623 << QgsExpressionFunction::Parameter( u
"expression"_s,
true, QVariant(),
true )
9624 << QgsExpressionFunction::Parameter( u
"filter"_s,
true, QVariant(),
true )
9625 << QgsExpressionFunction::Parameter( u
"limit"_s,
true, QVariant( 1 ),
true )
9626 << QgsExpressionFunction::Parameter( u
"max_distance"_s,
true, 0 )
9627 << QgsExpressionFunction::Parameter( u
"cache"_s,
true, QVariant(
false ),
false ),
9628 fcnGeomOverlayNearest,
9637 functions << fcnGeomOverlayNearestFunc;
9640 <<
new QgsStaticExpressionFunction( u
"is_valid"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnGeomIsValid, u
"GeometryGroup"_s )
9645 <<
new QgsStaticExpressionFunction( u
"point_n"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"index"_s ), fcnPointN, u
"GeometryGroup"_s )
9646 <<
new QgsStaticExpressionFunction( u
"start_point"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnStartPoint, u
"GeometryGroup"_s )
9647 <<
new QgsStaticExpressionFunction( u
"end_point"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnEndPoint, u
"GeometryGroup"_s )
9648 <<
new QgsStaticExpressionFunction( u
"nodes_to_points"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"ignore_closing_nodes"_s,
true,
false ), fcnNodesToPoints, u
"GeometryGroup"_s )
9649 <<
new QgsStaticExpressionFunction( u
"segments_to_lines"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnSegmentsToLines, u
"GeometryGroup"_s )
9650 <<
new QgsStaticExpressionFunction( u
"collect_geometries"_s, -1, fcnCollectGeometries, u
"GeometryGroup"_s )
9651 <<
new QgsStaticExpressionFunction( u
"make_point"_s, -1, fcnMakePoint, u
"GeometryGroup"_s )
9652 <<
new QgsStaticExpressionFunction( u
"make_point_m"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"x"_s ) << QgsExpressionFunction::Parameter( u
"y"_s ) << QgsExpressionFunction::Parameter( u
"m"_s ), fcnMakePointM, u
"GeometryGroup"_s )
9653 <<
new QgsStaticExpressionFunction( u
"make_line"_s, -1, fcnMakeLine, u
"GeometryGroup"_s )
9654 <<
new QgsStaticExpressionFunction( u
"make_polygon"_s, -1, fcnMakePolygon, u
"GeometryGroup"_s )
9655 <<
new QgsStaticExpressionFunction(
9657 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"point1"_s ) << QgsExpressionFunction::Parameter( u
"point2"_s ) << QgsExpressionFunction::Parameter( u
"point3"_s ),
9661 <<
new QgsStaticExpressionFunction(
9664 << QgsExpressionFunction::Parameter( u
"center"_s )
9665 << QgsExpressionFunction::Parameter( u
"radius"_s )
9666 << QgsExpressionFunction::Parameter( u
"segments"_s,
true, 36 ),
9670 <<
new QgsStaticExpressionFunction(
9673 << QgsExpressionFunction::Parameter( u
"center"_s )
9674 << QgsExpressionFunction::Parameter( u
"semi_major_axis"_s )
9675 << QgsExpressionFunction::Parameter( u
"semi_minor_axis"_s )
9676 << QgsExpressionFunction::Parameter( u
"azimuth"_s )
9677 << QgsExpressionFunction::Parameter( u
"segments"_s,
true, 36 ),
9681 <<
new QgsStaticExpressionFunction(
9682 u
"make_regular_polygon"_s,
9684 << QgsExpressionFunction::Parameter( u
"center"_s )
9685 << QgsExpressionFunction::Parameter( u
"radius"_s )
9686 << QgsExpressionFunction::Parameter( u
"number_sides"_s )
9687 << QgsExpressionFunction::Parameter( u
"circle"_s,
true, 0 ),
9688 fcnMakeRegularPolygon,
9691 <<
new QgsStaticExpressionFunction( u
"make_square"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"point1"_s ) << QgsExpressionFunction::Parameter( u
"point2"_s ), fcnMakeSquare, u
"GeometryGroup"_s )
9692 <<
new QgsStaticExpressionFunction(
9693 u
"make_rectangle_3points"_s,
9695 << QgsExpressionFunction::Parameter( u
"point1"_s )
9696 << QgsExpressionFunction::Parameter( u
"point2"_s )
9697 << QgsExpressionFunction::Parameter( u
"point3"_s )
9698 << QgsExpressionFunction::Parameter( u
"option"_s,
true, 0 ),
9699 fcnMakeRectangleFrom3Points,
9702 <<
new QgsStaticExpressionFunction(
9705 QgsExpressionFunction::Parameter( u
"geometry"_s ),
9706#if GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR < 10
9707 QgsExpressionFunction::Parameter( u
"method"_s,
true, u
"linework"_s ),
9709 QgsExpressionFunction::Parameter( u
"method"_s,
true, u
"structure"_s ),
9711 QgsExpressionFunction::Parameter( u
"keep_collapsed"_s,
true,
false )
9718 <<
new QgsStaticExpressionFunction( u
"x_at"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s,
true ) << QgsExpressionFunction::Parameter( u
"vertex"_s,
true ), fcnXat, u
"GeometryGroup"_s );
9720 <<
new QgsStaticExpressionFunction( u
"y_at"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s,
true ) << QgsExpressionFunction::Parameter( u
"vertex"_s,
true ), fcnYat, u
"GeometryGroup"_s );
9722 <<
new QgsStaticExpressionFunction( u
"z_at"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"vertex"_s,
true ), fcnZat, u
"GeometryGroup"_s );
9724 <<
new QgsStaticExpressionFunction( u
"m_at"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"vertex"_s,
true ), fcnMat, u
"GeometryGroup"_s );
9726 QgsStaticExpressionFunction *xAtFunc
9727 =
new QgsStaticExpressionFunction( u
"$x_at"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"vertex"_s ), fcnOldXat, u
"GeometryGroup"_s, QString(),
true, QSet<QString>(),
false, QStringList() << u
"xat"_s );
9729 functions << xAtFunc;
9732 QgsStaticExpressionFunction *yAtFunc
9733 =
new QgsStaticExpressionFunction( u
"$y_at"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"vertex"_s ), fcnOldYat, u
"GeometryGroup"_s, QString(),
true, QSet<QString>(),
false, QStringList() << u
"yat"_s );
9735 functions << yAtFunc;
9738 <<
new QgsStaticExpressionFunction( u
"geometry_type"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnGeometryType, u
"GeometryGroup"_s )
9739 <<
new QgsStaticExpressionFunction( u
"x_min"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnXMin, u
"GeometryGroup"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"xmin"_s )
9740 <<
new QgsStaticExpressionFunction( u
"x_max"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnXMax, u
"GeometryGroup"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"xmax"_s )
9741 <<
new QgsStaticExpressionFunction( u
"y_min"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnYMin, u
"GeometryGroup"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"ymin"_s )
9742 <<
new QgsStaticExpressionFunction( u
"y_max"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnYMax, u
"GeometryGroup"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"ymax"_s )
9743 <<
new QgsStaticExpressionFunction( u
"geom_from_wkt"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"text"_s ), fcnGeomFromWKT, u
"GeometryGroup"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"geomFromWKT"_s )
9744 <<
new QgsStaticExpressionFunction( u
"geom_from_wkb"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"binary"_s ), fcnGeomFromWKB, u
"GeometryGroup"_s, QString(),
false, QSet<QString>(),
false )
9745 <<
new QgsStaticExpressionFunction( u
"geom_from_gml"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"gml"_s ), fcnGeomFromGML, u
"GeometryGroup"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"geomFromGML"_s )
9746 <<
new QgsStaticExpressionFunction( u
"flip_coordinates"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnFlipCoordinates, u
"GeometryGroup"_s )
9747 <<
new QgsStaticExpressionFunction( u
"relate"_s, -1, fcnRelate, u
"GeometryGroup"_s )
9748 <<
new QgsStaticExpressionFunction(
9749 u
"intersects_bbox"_s,
9757 QStringList() << u
"bbox"_s
9759 <<
new QgsStaticExpressionFunction( u
"disjoint"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnDisjoint, u
"GeometryGroup"_s )
9760 <<
new QgsStaticExpressionFunction( u
"intersects"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnIntersects, u
"GeometryGroup"_s )
9761 <<
new QgsStaticExpressionFunction( u
"touches"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnTouches, u
"GeometryGroup"_s )
9762 <<
new QgsStaticExpressionFunction( u
"crosses"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnCrosses, u
"GeometryGroup"_s )
9763 <<
new QgsStaticExpressionFunction( u
"contains"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnContains, u
"GeometryGroup"_s )
9764 <<
new QgsStaticExpressionFunction( u
"overlaps"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnOverlaps, u
"GeometryGroup"_s )
9765 <<
new QgsStaticExpressionFunction( u
"within"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnWithin, u
"GeometryGroup"_s )
9766 <<
new QgsStaticExpressionFunction( u
"equals"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnEquals, u
"GeometryGroup"_s )
9767 <<
new QgsStaticExpressionFunction( u
"translate"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"dx"_s ) << QgsExpressionFunction::Parameter( u
"dy"_s ), fcnTranslate, u
"GeometryGroup"_s )
9768 <<
new QgsStaticExpressionFunction(
9771 << QgsExpressionFunction::Parameter( u
"geometry"_s )
9772 << QgsExpressionFunction::Parameter( u
"rotation"_s )
9773 << QgsExpressionFunction::Parameter( u
"center"_s,
true )
9774 << QgsExpressionFunction::Parameter( u
"per_part"_s,
true,
false ),
9778 <<
new QgsStaticExpressionFunction(
9781 << QgsExpressionFunction::Parameter( u
"geometry"_s )
9782 << QgsExpressionFunction::Parameter( u
"x_scale"_s )
9783 << QgsExpressionFunction::Parameter( u
"y_scale"_s )
9784 << QgsExpressionFunction::Parameter( u
"center"_s,
true ),
9788 <<
new QgsStaticExpressionFunction(
9789 u
"affine_transform"_s,
9791 << QgsExpressionFunction::Parameter( u
"geometry"_s )
9792 << QgsExpressionFunction::Parameter( u
"delta_x"_s )
9793 << QgsExpressionFunction::Parameter( u
"delta_y"_s )
9794 << QgsExpressionFunction::Parameter( u
"rotation_z"_s )
9795 << QgsExpressionFunction::Parameter( u
"scale_x"_s )
9796 << QgsExpressionFunction::Parameter( u
"scale_y"_s )
9797 << QgsExpressionFunction::Parameter( u
"delta_z"_s,
true, 0 )
9798 << QgsExpressionFunction::Parameter( u
"delta_m"_s,
true, 0 )
9799 << QgsExpressionFunction::Parameter( u
"scale_z"_s,
true, 1 )
9800 << QgsExpressionFunction::Parameter( u
"scale_m"_s,
true, 1 ),
9804 <<
new QgsStaticExpressionFunction(
9807 << QgsExpressionFunction::Parameter( u
"geometry"_s )
9808 << QgsExpressionFunction::Parameter( u
"distance"_s )
9809 << QgsExpressionFunction::Parameter( u
"segments"_s,
true, 8 )
9810 << QgsExpressionFunction::Parameter( u
"cap"_s,
true, u
"round"_s )
9811 << QgsExpressionFunction::Parameter( u
"join"_s,
true, u
"round"_s )
9812 << QgsExpressionFunction::Parameter( u
"miter_limit"_s,
true, 2 ),
9816 <<
new QgsStaticExpressionFunction( u
"force_rhr"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnForceRHR, u
"GeometryGroup"_s )
9817 <<
new QgsStaticExpressionFunction( u
"force_polygon_cw"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnForcePolygonCW, u
"GeometryGroup"_s )
9818 <<
new QgsStaticExpressionFunction( u
"force_polygon_ccw"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnForcePolygonCCW, u
"GeometryGroup"_s )
9819 <<
new QgsStaticExpressionFunction(
9822 << QgsExpressionFunction::Parameter( u
"center"_s )
9823 << QgsExpressionFunction::Parameter( u
"azimuth"_s )
9824 << QgsExpressionFunction::Parameter( u
"width"_s )
9825 << QgsExpressionFunction::Parameter( u
"outer_radius"_s )
9826 << QgsExpressionFunction::Parameter( u
"inner_radius"_s,
true, 0.0 ),
9830 <<
new QgsStaticExpressionFunction(
9831 u
"tapered_buffer"_s,
9833 << QgsExpressionFunction::Parameter( u
"geometry"_s )
9834 << QgsExpressionFunction::Parameter( u
"start_width"_s )
9835 << QgsExpressionFunction::Parameter( u
"end_width"_s )
9836 << QgsExpressionFunction::Parameter( u
"segments"_s,
true, 8.0 ),
9840 <<
new QgsStaticExpressionFunction( u
"buffer_by_m"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"segments"_s,
true, 8.0 ), fcnBufferByM, u
"GeometryGroup"_s )
9841 <<
new QgsStaticExpressionFunction(
9844 << QgsExpressionFunction::Parameter( u
"geometry"_s )
9845 << QgsExpressionFunction::Parameter( u
"distance"_s )
9846 << QgsExpressionFunction::Parameter( u
"segments"_s,
true, 8.0 )
9848 << QgsExpressionFunction::Parameter( u
"miter_limit"_s,
true, 2.0 ),
9852 <<
new QgsStaticExpressionFunction(
9853 u
"single_sided_buffer"_s,
9855 << QgsExpressionFunction::Parameter( u
"geometry"_s )
9856 << QgsExpressionFunction::Parameter( u
"distance"_s )
9857 << QgsExpressionFunction::Parameter( u
"segments"_s,
true, 8.0 )
9859 << QgsExpressionFunction::Parameter( u
"miter_limit"_s,
true, 2.0 ),
9860 fcnSingleSidedBuffer,
9863 <<
new QgsStaticExpressionFunction(
9865 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"start_distance"_s ) << QgsExpressionFunction::Parameter( u
"end_distance"_s ),
9869 <<
new QgsStaticExpressionFunction( u
"centroid"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnCentroid, u
"GeometryGroup"_s )
9870 <<
new QgsStaticExpressionFunction( u
"point_on_surface"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnPointOnSurface, u
"GeometryGroup"_s )
9871 <<
new QgsStaticExpressionFunction( u
"pole_of_inaccessibility"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"tolerance"_s ), fcnPoleOfInaccessibility, u
"GeometryGroup"_s )
9872 <<
new QgsStaticExpressionFunction( u
"reverse"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnReverse, { u
"String"_s, u
"GeometryGroup"_s } )
9873 <<
new QgsStaticExpressionFunction( u
"exterior_ring"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnExteriorRing, u
"GeometryGroup"_s )
9874 <<
new QgsStaticExpressionFunction( u
"interior_ring_n"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"index"_s ), fcnInteriorRingN, u
"GeometryGroup"_s )
9875 <<
new QgsStaticExpressionFunction( u
"geometry_n"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"index"_s ), fcnGeometryN, u
"GeometryGroup"_s )
9876 <<
new QgsStaticExpressionFunction( u
"boundary"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnBoundary, u
"GeometryGroup"_s )
9877 <<
new QgsStaticExpressionFunction( u
"line_merge"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnLineMerge, u
"GeometryGroup"_s )
9878 <<
new QgsStaticExpressionFunction( u
"shared_paths"_s,
QgsExpressionFunction::ParameterList { QgsExpressionFunction::Parameter( u
"geometry1"_s ), QgsExpressionFunction::Parameter( u
"geometry2"_s ) }, fcnSharedPaths, u
"GeometryGroup"_s )
9880 <<
new QgsStaticExpressionFunction( u
"simplify"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"tolerance"_s ), fcnSimplify, u
"GeometryGroup"_s )
9881 <<
new QgsStaticExpressionFunction( u
"simplify_vw"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"tolerance"_s ), fcnSimplifyVW, u
"GeometryGroup"_s )
9882 <<
new QgsStaticExpressionFunction(
9885 << QgsExpressionFunction::Parameter( u
"geometry"_s )
9886 << QgsExpressionFunction::Parameter( u
"iterations"_s,
true, 1 )
9887 << QgsExpressionFunction::Parameter( u
"offset"_s,
true, 0.25 )
9888 << QgsExpressionFunction::Parameter( u
"min_length"_s,
true, -1 )
9889 << QgsExpressionFunction::Parameter( u
"max_angle"_s,
true, 180 ),
9893 <<
new QgsStaticExpressionFunction(
9894 u
"triangular_wave"_s,
9895 { QgsExpressionFunction::Parameter( u
"geometry"_s ),
9896 QgsExpressionFunction::Parameter( u
"wavelength"_s ),
9897 QgsExpressionFunction::Parameter( u
"amplitude"_s ),
9898 QgsExpressionFunction::Parameter( u
"strict"_s,
true,
false ) },
9902 <<
new QgsStaticExpressionFunction(
9903 u
"triangular_wave_randomized"_s,
9904 { QgsExpressionFunction::Parameter( u
"geometry"_s ),
9905 QgsExpressionFunction::Parameter( u
"min_wavelength"_s ),
9906 QgsExpressionFunction::Parameter( u
"max_wavelength"_s ),
9907 QgsExpressionFunction::Parameter( u
"min_amplitude"_s ),
9908 QgsExpressionFunction::Parameter( u
"max_amplitude"_s ),
9909 QgsExpressionFunction::Parameter( u
"seed"_s,
true, 0 ) },
9910 fcnTriangularWaveRandomized,
9913 <<
new QgsStaticExpressionFunction(
9915 { QgsExpressionFunction::Parameter( u
"geometry"_s ),
9916 QgsExpressionFunction::Parameter( u
"wavelength"_s ),
9917 QgsExpressionFunction::Parameter( u
"amplitude"_s ),
9918 QgsExpressionFunction::Parameter( u
"strict"_s,
true,
false ) },
9922 <<
new QgsStaticExpressionFunction(
9923 u
"square_wave_randomized"_s,
9924 { QgsExpressionFunction::Parameter( u
"geometry"_s ),
9925 QgsExpressionFunction::Parameter( u
"min_wavelength"_s ),
9926 QgsExpressionFunction::Parameter( u
"max_wavelength"_s ),
9927 QgsExpressionFunction::Parameter( u
"min_amplitude"_s ),
9928 QgsExpressionFunction::Parameter( u
"max_amplitude"_s ),
9929 QgsExpressionFunction::Parameter( u
"seed"_s,
true, 0 ) },
9930 fcnSquareWaveRandomized,
9933 <<
new QgsStaticExpressionFunction(
9935 { QgsExpressionFunction::Parameter( u
"geometry"_s ),
9936 QgsExpressionFunction::Parameter( u
"wavelength"_s ),
9937 QgsExpressionFunction::Parameter( u
"amplitude"_s ),
9938 QgsExpressionFunction::Parameter( u
"strict"_s,
true,
false ) },
9942 <<
new QgsStaticExpressionFunction(
9943 u
"wave_randomized"_s,
9944 { QgsExpressionFunction::Parameter( u
"geometry"_s ),
9945 QgsExpressionFunction::Parameter( u
"min_wavelength"_s ),
9946 QgsExpressionFunction::Parameter( u
"max_wavelength"_s ),
9947 QgsExpressionFunction::Parameter( u
"min_amplitude"_s ),
9948 QgsExpressionFunction::Parameter( u
"max_amplitude"_s ),
9949 QgsExpressionFunction::Parameter( u
"seed"_s,
true, 0 ) },
9950 fcnRoundWaveRandomized,
9953 <<
new QgsStaticExpressionFunction(
9954 u
"apply_dash_pattern"_s,
9956 QgsExpressionFunction::Parameter( u
"geometry"_s ),
9957 QgsExpressionFunction::Parameter( u
"pattern"_s ),
9958 QgsExpressionFunction::Parameter( u
"start_rule"_s,
true, u
"no_rule"_s ),
9959 QgsExpressionFunction::Parameter( u
"end_rule"_s,
true, u
"no_rule"_s ),
9960 QgsExpressionFunction::Parameter( u
"adjustment"_s,
true, u
"both"_s ),
9961 QgsExpressionFunction::Parameter( u
"pattern_offset"_s,
true, 0 ),
9963 fcnApplyDashPattern,
9966 <<
new QgsStaticExpressionFunction( u
"densify_by_count"_s, { QgsExpressionFunction::Parameter( u
"geometry"_s ), QgsExpressionFunction::Parameter( u
"vertices"_s ) }, fcnDensifyByCount, u
"GeometryGroup"_s )
9967 <<
new QgsStaticExpressionFunction( u
"densify_by_distance"_s, { QgsExpressionFunction::Parameter( u
"geometry"_s ), QgsExpressionFunction::Parameter( u
"distance"_s ) }, fcnDensifyByDistance, u
"GeometryGroup"_s )
9968 <<
new QgsStaticExpressionFunction( u
"num_points"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnGeomNumPoints, u
"GeometryGroup"_s )
9969 <<
new QgsStaticExpressionFunction( u
"num_interior_rings"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnGeomNumInteriorRings, u
"GeometryGroup"_s )
9970 <<
new QgsStaticExpressionFunction( u
"num_rings"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnGeomNumRings, u
"GeometryGroup"_s )
9971 <<
new QgsStaticExpressionFunction( u
"num_geometries"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnGeomNumGeometries, u
"GeometryGroup"_s )
9972 <<
new QgsStaticExpressionFunction( u
"bounds_width"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnBoundsWidth, u
"GeometryGroup"_s )
9973 <<
new QgsStaticExpressionFunction( u
"bounds_height"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnBoundsHeight, u
"GeometryGroup"_s )
9974 <<
new QgsStaticExpressionFunction( u
"is_closed"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnIsClosed, u
"GeometryGroup"_s )
9975 <<
new QgsStaticExpressionFunction( u
"close_line"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnCloseLine, u
"GeometryGroup"_s )
9976 <<
new QgsStaticExpressionFunction( u
"is_empty"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnIsEmpty, u
"GeometryGroup"_s )
9977 <<
new QgsStaticExpressionFunction(
9978 u
"is_empty_or_null"_s,
9989 <<
new QgsStaticExpressionFunction( u
"convex_hull"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnConvexHull, u
"GeometryGroup"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"convexHull"_s )
9990#if GEOS_VERSION_MAJOR > 3 || ( GEOS_VERSION_MAJOR == 3 && GEOS_VERSION_MINOR >= 11 )
9991 <<
new QgsStaticExpressionFunction(
9994 << QgsExpressionFunction::Parameter( u
"geometry"_s )
9995 << QgsExpressionFunction::Parameter( u
"target_percent"_s )
9996 << QgsExpressionFunction::Parameter( u
"allow_holes"_s,
true,
false ),
10001 <<
new QgsStaticExpressionFunction( u
"oriented_bbox"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnOrientedBBox, u
"GeometryGroup"_s )
10002 <<
new QgsStaticExpressionFunction( u
"main_angle"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnMainAngle, u
"GeometryGroup"_s )
10003 <<
new QgsStaticExpressionFunction( u
"minimal_circle"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"segments"_s,
true, 36 ), fcnMinimalCircle, u
"GeometryGroup"_s )
10004 <<
new QgsStaticExpressionFunction( u
"difference"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnDifference, u
"GeometryGroup"_s )
10005 <<
new QgsStaticExpressionFunction( u
"distance"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnDistance, u
"GeometryGroup"_s )
10006 <<
new QgsStaticExpressionFunction(
10007 u
"hausdorff_distance"_s,
10009 << QgsExpressionFunction::Parameter( u
"geometry1"_s )
10010 << QgsExpressionFunction::Parameter( u
"geometry2"_s )
10011 << QgsExpressionFunction::Parameter( u
"densify_fraction"_s,
true ),
10012 fcnHausdorffDistance,
10015 <<
new QgsStaticExpressionFunction( u
"intersection"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnIntersection, u
"GeometryGroup"_s )
10016 <<
new QgsStaticExpressionFunction(
10017 u
"sym_difference"_s,
10020 u
"GeometryGroup"_s,
10025 QStringList() << u
"symDifference"_s
10027 <<
new QgsStaticExpressionFunction( u
"combine"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnCombine, u
"GeometryGroup"_s )
10028 <<
new QgsStaticExpressionFunction( u
"union"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnCombine, u
"GeometryGroup"_s )
10029 <<
new QgsStaticExpressionFunction(
10033 u
"GeometryGroup"_s,
10038 QStringList() << u
"geomToWKT"_s
10040 <<
new QgsStaticExpressionFunction( u
"geom_to_wkb"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnGeomToWKB, u
"GeometryGroup"_s, QString(),
false, QSet<QString>(),
false )
10041 <<
new QgsStaticExpressionFunction( u
"geometry"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"feature"_s ), fcnGetGeometry, u
"GeometryGroup"_s, QString(),
true )
10042 <<
new QgsStaticExpressionFunction(
10044 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"source_auth_id"_s ) << QgsExpressionFunction::Parameter( u
"dest_auth_id"_s ),
10045 fcnTransformGeometry,
10048 <<
new QgsStaticExpressionFunction(
10050 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"x"_s ) << QgsExpressionFunction::Parameter( u
"y"_s ),
10052 u
"GeometryGroup"_s,
10055 <<
new QgsStaticExpressionFunction( u
"is_multipart"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnGeomIsMultipart, u
"GeometryGroup"_s )
10060 <<
new QgsStaticExpressionFunction( u
"sinuosity"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnSinuosity, u
"GeometryGroup"_s )
10061 <<
new QgsStaticExpressionFunction( u
"straight_distance_2d"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ), fcnStraightDistance2d, u
"GeometryGroup"_s );
10064 QgsStaticExpressionFunction *orderPartsFunc =
new QgsStaticExpressionFunction(
10067 << QgsExpressionFunction::Parameter( u
"geometry"_s )
10068 << QgsExpressionFunction::Parameter( u
"orderby"_s )
10069 << QgsExpressionFunction::Parameter( u
"ascending"_s,
true,
true ),
10071 u
"GeometryGroup"_s,
10076 const QList< QgsExpressionNode *> argList = node->
args()->
list();
10077 for ( QgsExpressionNode *argNode : argList )
10079 if ( !argNode->isStatic( parent, context ) )
10085 QgsExpressionNode *argNode = node->
args()->
at( 1 );
10087 QString expString = argNode->
eval( parent, context ).toString();
10091 if ( e.rootNode() && e.rootNode()->isStatic( parent, context ) )
10101 QgsExpressionNode *argNode = node->
args()->
at( 1 );
10102 QString
expression = argNode->
eval( parent, context ).toString();
10104 e.prepare( context );
10109 functions << orderPartsFunc;
10112 <<
new QgsStaticExpressionFunction( u
"closest_point"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnClosestPoint, u
"GeometryGroup"_s )
10113 <<
new QgsStaticExpressionFunction( u
"shortest_line"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry1"_s ) << QgsExpressionFunction::Parameter( u
"geometry2"_s ), fcnShortestLine, u
"GeometryGroup"_s )
10114 <<
new QgsStaticExpressionFunction( u
"line_interpolate_point"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"distance"_s ), fcnLineInterpolatePoint, u
"GeometryGroup"_s )
10115 <<
new QgsStaticExpressionFunction(
10116 u
"line_interpolate_point_by_m"_s,
10118 << QgsExpressionFunction::Parameter( u
"geometry"_s )
10119 << QgsExpressionFunction::Parameter( u
"m"_s )
10120 << QgsExpressionFunction::Parameter( u
"use_3d_distance"_s,
true,
false ),
10121 fcnLineInterpolatePointByM,
10124 <<
new QgsStaticExpressionFunction( u
"line_interpolate_angle"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"distance"_s ), fcnLineInterpolateAngle, u
"GeometryGroup"_s )
10125 <<
new QgsStaticExpressionFunction( u
"line_locate_point"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"point"_s ), fcnLineLocatePoint, u
"GeometryGroup"_s )
10126 <<
new QgsStaticExpressionFunction(
10127 u
"line_locate_m"_s,
10129 << QgsExpressionFunction::Parameter( u
"geometry"_s )
10130 << QgsExpressionFunction::Parameter( u
"m"_s )
10131 << QgsExpressionFunction::Parameter( u
"use_3d_distance"_s,
true,
false ),
10135 <<
new QgsStaticExpressionFunction( u
"angle_at_vertex"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"vertex"_s ), fcnAngleAtVertex, u
"GeometryGroup"_s )
10136 <<
new QgsStaticExpressionFunction( u
"distance_to_vertex"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"vertex"_s ), fcnDistanceToVertex, u
"GeometryGroup"_s )
10137 <<
new QgsStaticExpressionFunction(
10138 u
"line_substring"_s,
10139 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometry"_s ) << QgsExpressionFunction::Parameter( u
"start_distance"_s ) << QgsExpressionFunction::Parameter( u
"end_distance"_s ),
10147 QgsStaticExpressionFunction *idFunc =
new QgsStaticExpressionFunction( u
"$id"_s, 0, fcnFeatureId, u
"Record and Attributes"_s );
10149 functions << idFunc;
10151 QgsStaticExpressionFunction *currentFeatureFunc =
new QgsStaticExpressionFunction( u
"$currentfeature"_s, 0, fcnFeature, u
"Record and Attributes"_s );
10153 functions << currentFeatureFunc;
10155 QgsStaticExpressionFunction *uuidFunc =
new QgsStaticExpressionFunction(
10159 u
"Record and Attributes"_s,
10164 QStringList() << u
"$uuid"_s
10167 functions << uuidFunc;
10170 <<
new QgsStaticExpressionFunction( u
"feature_id"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"feature"_s ), fcnGetFeatureId, u
"Record and Attributes"_s, QString(),
true )
10171 <<
new QgsStaticExpressionFunction(
10173 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"layer"_s ) << QgsExpressionFunction::Parameter( u
"attribute"_s ) << QgsExpressionFunction::Parameter( u
"value"_s,
true ),
10175 u
"Record and Attributes"_s,
10180 QStringList() << u
"QgsExpressionUtils::getFeature"_s
10182 <<
new QgsStaticExpressionFunction(
10183 u
"get_feature_by_id"_s,
10186 u
"Record and Attributes"_s,
10193 QgsStaticExpressionFunction *attributesFunc =
new QgsStaticExpressionFunction(
10197 u
"Record and Attributes"_s,
10203 functions << attributesFunc;
10204 QgsStaticExpressionFunction *representAttributesFunc
10205 =
new QgsStaticExpressionFunction( u
"represent_attributes"_s, -1, fcnRepresentAttributes, u
"Record and Attributes"_s, QString(),
false, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES );
10207 functions << representAttributesFunc;
10209 QgsStaticExpressionFunction *validateFeature =
new QgsStaticExpressionFunction(
10210 u
"is_feature_valid"_s,
10212 << QgsExpressionFunction::Parameter( u
"layer"_s,
true )
10213 << QgsExpressionFunction::Parameter( u
"feature"_s,
true )
10214 << QgsExpressionFunction::Parameter( u
"strength"_s,
true ),
10215 fcnValidateFeature,
10216 u
"Record and Attributes"_s,
10222 functions << validateFeature;
10224 QgsStaticExpressionFunction *validateAttribute =
new QgsStaticExpressionFunction(
10225 u
"is_attribute_valid"_s,
10227 << QgsExpressionFunction::Parameter( u
"attribute"_s,
false )
10229 << QgsExpressionFunction::Parameter( u
"layer"_s,
true )
10230 << QgsExpressionFunction::Parameter( u
"feature"_s,
true )
10231 << QgsExpressionFunction::Parameter( u
"strength"_s,
true ),
10232 fcnValidateAttribute,
10233 u
"Record and Attributes"_s,
10239 functions << validateAttribute;
10241 QgsStaticExpressionFunction *maptipFunc =
new QgsStaticExpressionFunction( u
"maptip"_s, -1, fcnFeatureMaptip, u
"Record and Attributes"_s, QString(),
false, QSet<QString>() );
10243 functions << maptipFunc;
10245 QgsStaticExpressionFunction *displayFunc =
new QgsStaticExpressionFunction( u
"display_expression"_s, -1, fcnFeatureDisplayExpression, u
"Record and Attributes"_s, QString(),
false, QSet<QString>() );
10247 functions << displayFunc;
10249 QgsStaticExpressionFunction *isSelectedFunc =
new QgsStaticExpressionFunction( u
"is_selected"_s, -1, fcnIsSelected, u
"Record and Attributes"_s, QString(),
false, QSet<QString>() );
10251 functions << isSelectedFunc;
10253 functions <<
new QgsStaticExpressionFunction( u
"num_selected"_s, -1, fcnNumSelected, u
"Record and Attributes"_s, QString(),
false, QSet<QString>() );
10255 functions <<
new QgsStaticExpressionFunction(
10256 u
"sqlite_fetch_and_increment"_s,
10258 << QgsExpressionFunction::Parameter( u
"database"_s )
10259 << QgsExpressionFunction::Parameter( u
"table"_s )
10260 << QgsExpressionFunction::Parameter( u
"id_field"_s )
10261 << QgsExpressionFunction::Parameter( u
"filter_attribute"_s )
10262 << QgsExpressionFunction::Parameter( u
"filter_value"_s )
10263 << QgsExpressionFunction::Parameter( u
"default_values"_s,
true ),
10264 fcnSqliteFetchAndIncrement,
10265 u
"Record and Attributes"_s
10270 <<
new QgsStaticExpressionFunction( u
"crs_to_authid"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"crs"_s ), fcnCrsToAuthid, u
"CRS"_s, QString(),
true )
10271 <<
new QgsStaticExpressionFunction( u
"crs_from_text"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"definition"_s ), fcnCrsFromText, u
"CRS"_s );
10275 QgsStaticExpressionFunction *representValueFunc
10276 =
new QgsStaticExpressionFunction( u
"represent_value"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"attribute"_s ) << QgsExpressionFunction::Parameter( u
"field_name"_s,
true ), fcnRepresentValue, u
"Record and Attributes"_s );
10279 Q_UNUSED( context )
10282 QgsExpressionNodeColumnRef *colRef =
dynamic_cast<QgsExpressionNodeColumnRef *
>( node->
args()->at( 0 ) );
10289 parent->
setEvalErrorString( tr(
"If represent_value is called with 1 parameter, it must be an attribute." ) );
10299 parent->
setEvalErrorString( tr(
"represent_value must be called with exactly 1 or 2 parameters." ) );
10304 functions << representValueFunc;
10308 <<
new QgsStaticExpressionFunction( u
"layer_property"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"layer"_s ) << QgsExpressionFunction::Parameter( u
"property"_s ), fcnGetLayerProperty, u
"Map Layers"_s )
10309 <<
new QgsStaticExpressionFunction( u
"decode_uri"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"layer"_s ) << QgsExpressionFunction::Parameter( u
"part"_s,
true ), fcnDecodeUri, u
"Map Layers"_s )
10310 <<
new QgsStaticExpressionFunction( u
"mime_type"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"binary_data"_s ), fcnMimeType, u
"General"_s )
10311 <<
new QgsStaticExpressionFunction(
10312 u
"raster_statistic"_s,
10313 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"layer"_s ) << QgsExpressionFunction::Parameter( u
"band"_s ) << QgsExpressionFunction::Parameter( u
"statistic"_s ),
10314 fcnGetRasterBandStat,
10319 QgsStaticExpressionFunction *varFunction
10329 QgsExpressionNode *argNode = node->
args()->
at( 0 );
10331 if ( !argNode->
isStatic( parent, context ) )
10334 const QString varName = argNode->
eval( parent, context ).toString();
10335 if ( varName ==
"feature"_L1 || varName ==
"id"_L1 || varName ==
"geometry"_L1 )
10339 return scope ? scope->
isStatic( varName ) :
false;
10344 if ( node && node->
args()->
count() > 0 )
10346 QgsExpressionNode *argNode = node->
args()->
at( 0 );
10347 if ( QgsExpressionNodeLiteral *literal =
dynamic_cast<QgsExpressionNodeLiteral *
>( argNode ) )
10349 if ( literal->value() ==
"geometry"_L1 || literal->value() ==
"feature"_L1 )
10356 functions << varFunction;
10358 QgsStaticExpressionFunction *evalTemplateFunction
10363 QgsExpressionNode *argNode = node->
args()->
at( 0 );
10365 if ( argNode->
isStatic( parent, context ) )
10367 QString expString = argNode->
eval( parent, context ).toString();
10371 if ( e.rootNode() && e.rootNode()->isStatic( parent, context ) )
10378 functions << evalTemplateFunction;
10380 QgsStaticExpressionFunction *evalFunc
10385 QgsExpressionNode *argNode = node->
args()->
at( 0 );
10387 if ( argNode->
isStatic( parent, context ) )
10389 QString expString = argNode->
eval( parent, context ).toString();
10393 if ( e.rootNode() && e.rootNode()->isStatic( parent, context ) )
10401 functions << evalFunc;
10403 QgsStaticExpressionFunction *attributeFunc
10404 =
new QgsStaticExpressionFunction( u
"attribute"_s, -1, fcnAttribute, u
"Record and Attributes"_s, QString(),
false, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES );
10406 const QList< QgsExpressionNode *> argList = node->
args()->
list();
10407 for ( QgsExpressionNode *argNode : argList )
10409 if ( !argNode->
isStatic( parent, context ) )
10421 functions << attributeFunc;
10425 <<
new QgsWithVariableExpressionFunction()
10426 <<
new QgsStaticExpressionFunction(
10428 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"layer"_s ) << QgsExpressionFunction::Parameter( u
"band"_s ) << QgsExpressionFunction::Parameter( u
"point"_s ),
10432 <<
new QgsStaticExpressionFunction(
10433 u
"raster_attributes"_s,
10434 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"layer"_s ) << QgsExpressionFunction::Parameter( u
"band"_s ) << QgsExpressionFunction::Parameter( u
"point"_s ),
10435 fcnRasterAttributes,
10440 <<
new QgsArrayForeachExpressionFunction()
10441 <<
new QgsArrayFilterExpressionFunction()
10442 <<
new QgsStaticExpressionFunction( u
"array"_s, -1, fcnArray, u
"Arrays"_s, QString(),
false, QSet<QString>(),
false, QStringList(),
true )
10443 <<
new QgsStaticExpressionFunction( u
"array_sort"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"ascending"_s,
true,
true ), fcnArraySort, u
"Arrays"_s )
10444 <<
new QgsStaticExpressionFunction( u
"array_length"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ), fcnArrayLength, u
"Arrays"_s )
10445 <<
new QgsStaticExpressionFunction( u
"array_contains"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"value"_s ), fcnArrayContains, u
"Arrays"_s )
10446 <<
new QgsStaticExpressionFunction( u
"array_count"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"value"_s ), fcnArrayCount, u
"Arrays"_s )
10447 <<
new QgsStaticExpressionFunction( u
"array_all"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array_a"_s ) << QgsExpressionFunction::Parameter( u
"array_b"_s ), fcnArrayAll, u
"Arrays"_s )
10448 <<
new QgsStaticExpressionFunction( u
"array_find"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"value"_s ), fcnArrayFind, u
"Arrays"_s )
10449 <<
new QgsStaticExpressionFunction( u
"array_get"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"pos"_s ), fcnArrayGet, u
"Arrays"_s )
10455 <<
new QgsStaticExpressionFunction( u
"array_median"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ), fcnArrayMedian, u
"Arrays"_s )
10456 <<
new QgsStaticExpressionFunction( u
"array_majority"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"option"_s,
true, QVariant(
"all" ) ), fcnArrayMajority, u
"Arrays"_s )
10457 <<
new QgsStaticExpressionFunction( u
"array_minority"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"option"_s,
true, QVariant(
"all" ) ), fcnArrayMinority, u
"Arrays"_s )
10459 <<
new QgsStaticExpressionFunction( u
"array_append"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"value"_s ), fcnArrayAppend, u
"Arrays"_s )
10460 <<
new QgsStaticExpressionFunction( u
"array_prepend"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"value"_s ), fcnArrayPrepend, u
"Arrays"_s )
10461 <<
new QgsStaticExpressionFunction(
10463 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"pos"_s ) << QgsExpressionFunction::Parameter( u
"value"_s ),
10467 <<
new QgsStaticExpressionFunction( u
"array_remove_at"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"pos"_s ), fcnArrayRemoveAt, u
"Arrays"_s )
10468 <<
new QgsStaticExpressionFunction(
10469 u
"array_remove_all"_s,
10480 <<
new QgsStaticExpressionFunction( u
"array_replace"_s, -1, fcnArrayReplace, u
"Arrays"_s )
10481 <<
new QgsStaticExpressionFunction( u
"array_prioritize"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"array_prioritize"_s ), fcnArrayPrioritize, u
"Arrays"_s )
10482 <<
new QgsStaticExpressionFunction( u
"array_cat"_s, -1, fcnArrayCat, u
"Arrays"_s )
10483 <<
new QgsStaticExpressionFunction(
10485 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ) << QgsExpressionFunction::Parameter( u
"start_pos"_s ) << QgsExpressionFunction::Parameter( u
"end_pos"_s ),
10489 <<
new QgsStaticExpressionFunction( u
"array_reverse"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ), fcnArrayReverse, u
"Arrays"_s )
10490 <<
new QgsStaticExpressionFunction( u
"array_intersect"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array1"_s ) << QgsExpressionFunction::Parameter( u
"array2"_s ), fcnArrayIntersect, u
"Arrays"_s )
10491 <<
new QgsStaticExpressionFunction( u
"array_distinct"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"array"_s ), fcnArrayDistinct, u
"Arrays"_s )
10492 <<
new QgsStaticExpressionFunction(
10493 u
"array_to_string"_s,
10495 << QgsExpressionFunction::Parameter( u
"array"_s )
10496 << QgsExpressionFunction::Parameter( u
"delimiter"_s,
true,
"," )
10497 << QgsExpressionFunction::Parameter( u
"emptyvalue"_s,
true,
"" ),
10501 <<
new QgsStaticExpressionFunction(
10502 u
"string_to_array"_s,
10504 << QgsExpressionFunction::Parameter( u
"string"_s )
10505 << QgsExpressionFunction::Parameter( u
"delimiter"_s,
true,
"," )
10506 << QgsExpressionFunction::Parameter( u
"emptyvalue"_s,
true,
"" ),
10510 <<
new QgsStaticExpressionFunction(
10511 u
"generate_series"_s,
10512 QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"start"_s ) << QgsExpressionFunction::Parameter( u
"stop"_s ) << QgsExpressionFunction::Parameter( u
"step"_s,
true, 1.0 ),
10516 <<
new QgsStaticExpressionFunction( u
"geometries_to_array"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"geometries"_s ), fcnGeometryCollectionAsArray, u
"Arrays"_s )
10519 <<
new QgsStaticExpressionFunction( u
"from_json"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"value"_s ), fcnLoadJson, u
"Maps"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"json_to_map"_s )
10520 <<
new QgsStaticExpressionFunction( u
"to_json"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"json_string"_s ), fcnWriteJson, u
"Maps"_s, QString(),
false, QSet<QString>(),
false, QStringList() << u
"map_to_json"_s )
10521 <<
new QgsStaticExpressionFunction( u
"hstore_to_map"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"string"_s ), fcnHstoreToMap, u
"Maps"_s )
10523 <<
new QgsStaticExpressionFunction( u
"map"_s, -1, fcnMap, u
"Maps"_s )
10524 <<
new QgsStaticExpressionFunction( u
"map_get"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"map"_s ) << QgsExpressionFunction::Parameter( u
"key"_s ), fcnMapGet, u
"Maps"_s )
10525 <<
new QgsStaticExpressionFunction( u
"map_exist"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"map"_s ) << QgsExpressionFunction::Parameter( u
"key"_s ), fcnMapExist, u
"Maps"_s )
10526 <<
new QgsStaticExpressionFunction( u
"map_delete"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"map"_s ) << QgsExpressionFunction::Parameter( u
"key"_s ), fcnMapDelete, u
"Maps"_s )
10527 <<
new QgsStaticExpressionFunction( u
"map_insert"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"map"_s ) << QgsExpressionFunction::Parameter( u
"key"_s ) << QgsExpressionFunction::Parameter( u
"value"_s ), fcnMapInsert, u
"Maps"_s )
10528 <<
new QgsStaticExpressionFunction( u
"map_concat"_s, -1, fcnMapConcat, u
"Maps"_s )
10531 <<
new QgsStaticExpressionFunction( u
"map_prefix_keys"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"map"_s ) << QgsExpressionFunction::Parameter( u
"prefix"_s ), fcnMapPrefixKeys, u
"Maps"_s )
10532 <<
new QgsStaticExpressionFunction( u
"map_to_html_table"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"map"_s ), fcnMapToHtmlTable, u
"Maps"_s )
10533 <<
new QgsStaticExpressionFunction( u
"map_to_html_dl"_s,
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( u
"map"_s ), fcnMapToHtmlDefinitionList, u
"Maps"_s )
10543 *sOwnedFunctions() << func;
10544 *sBuiltinFunctions() << func->name();
10545 sBuiltinFunctions()->append( func->aliases() );
10559 QMutexLocker locker( &sFunctionsMutex );
10560 sFunctions()->append( function );
10561 if ( transferOwnership )
10562 sOwnedFunctions()->append( function );
10577 QMutexLocker locker( &sFunctionsMutex );
10578 sFunctions()->removeAt( fnIdx );
10579 sFunctionIndexMap.clear();
10587 const QList<QgsExpressionFunction *> &ownedFunctions = *sOwnedFunctions();
10588 for ( QgsExpressionFunction *func : std::as_const( ownedFunctions ) )
10590 sBuiltinFunctions()->removeAll( func->name() );
10591 for (
const QString &alias : func->aliases() )
10593 sBuiltinFunctions()->removeAll( alias );
10596 sFunctions()->removeAll( func );
10599 qDeleteAll( *sOwnedFunctions() );
10600 sOwnedFunctions()->clear();
10605 if ( sBuiltinFunctions()->isEmpty() )
10609 return *sBuiltinFunctions();
10614 u
"array_foreach"_s,
10624 QgsExpressionNode::NodeList *args = node->
args();
10626 if ( args->
count() < 2 )
10629 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
10639 QVariantList result;
10641 if ( args->
count() < 2 )
10645 QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
10647 QgsExpressionContext *subContext =
const_cast<QgsExpressionContext *
>( context );
10648 std::unique_ptr< QgsExpressionContext > tempContext;
10651 tempContext = std::make_unique< QgsExpressionContext >();
10652 subContext = tempContext.get();
10655 QgsExpressionContextScope *subScope =
new QgsExpressionContextScope();
10659 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it, ++i )
10663 result << args->
at( 1 )->
eval( parent, subContext );
10676 Q_UNUSED( context )
10688 if ( args->
count() < 2 )
10692 args->
at( 0 )->
prepare( parent, context );
10696 subContext = *context;
10703 args->
at( 1 )->
prepare( parent, &subContext );
10716 QgsExpressionNode::NodeList *args = node->
args();
10718 if ( args->
count() < 2 )
10721 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
10731 QVariantList result;
10733 if ( args->
count() < 2 )
10737 const QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
10739 QgsExpressionContext *subContext =
const_cast<QgsExpressionContext *
>( context );
10740 std::unique_ptr< QgsExpressionContext > tempContext;
10743 tempContext = std::make_unique< QgsExpressionContext >();
10744 subContext = tempContext.get();
10747 QgsExpressionContextScope *subScope =
new QgsExpressionContextScope();
10751 if ( args->
count() >= 3 )
10753 const QVariant limitVar = args->
at( 2 )->
eval( parent, context );
10755 if ( QgsExpressionUtils::isIntSafe( limitVar ) )
10757 limit = limitVar.toInt();
10765 for (
const QVariant &value : array )
10767 subScope->
addVariable( QgsExpressionContextScope::StaticVariable( u
"element"_s, value,
true ) );
10768 if ( args->
at( 1 )->
eval( parent, subContext ).toBool() )
10772 if ( limit > 0 && limit == result.size() )
10787 Q_UNUSED( context )
10799 if ( args->
count() < 2 )
10803 args->
at( 0 )->
prepare( parent, context );
10807 subContext = *context;
10813 args->
at( 1 )->
prepare( parent, &subContext );
10825 QgsExpressionNode::NodeList *args = node->
args();
10827 if ( args->
count() < 3 )
10831 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
10833 QVariant
name = args->
at( 0 )->
eval( parent, context );
10834 QVariant value = args->
at( 1 )->
eval( parent, context );
10837 appendTemporaryVariable( context,
name.toString(), value );
10838 if ( args->
at( 2 )->
isStatic( parent, context ) )
10840 popTemporaryVariable( context );
10851 if ( args->
count() < 3 )
10855 QVariant
name = args->
at( 0 )->
eval( parent, context );
10856 QVariant value = args->
at( 1 )->
eval( parent, context );
10858 const QgsExpressionContext *updatedContext = context;
10859 std::unique_ptr< QgsExpressionContext > tempContext;
10860 if ( !updatedContext )
10862 tempContext = std::make_unique< QgsExpressionContext >();
10863 updatedContext = tempContext.get();
10866 appendTemporaryVariable( updatedContext,
name.toString(), value );
10867 result = args->
at( 2 )->
eval( parent, updatedContext );
10870 popTemporaryVariable( updatedContext );
10879 Q_UNUSED( context )
10891 if ( args->
count() < 3 )
10896 QVariant value = args->
at( 1 )->
prepare( parent, context );
10899 std::unique_ptr< QgsExpressionContext > tempContext;
10900 if ( !updatedContext )
10902 tempContext = std::make_unique< QgsExpressionContext >();
10903 updatedContext = tempContext.get();
10906 appendTemporaryVariable( updatedContext,
name.toString(), value );
10907 args->
at( 2 )->
prepare( parent, updatedContext );
10910 popTemporaryVariable( updatedContext );
10915void QgsWithVariableExpressionFunction::popTemporaryVariable(
const QgsExpressionContext *context )
const
10917 QgsExpressionContext *updatedContext =
const_cast<QgsExpressionContext *
>( context );
10918 delete updatedContext->
popScope();
10921void QgsWithVariableExpressionFunction::appendTemporaryVariable(
const QgsExpressionContext *context,
const QString &name,
const QVariant &value )
const
10923 QgsExpressionContextScope *scope =
new QgsExpressionContextScope();
10924 scope->
addVariable( QgsExpressionContextScope::StaticVariable(
name, value,
true ) );
10926 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.
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.
Represents a model of the Earth's magnetic field.
static bool fieldComponentsWithTimeDerivatives(double Bx, double By, double Bz, double Bxt, double Byt, double Bzt, double &H, double &F, double &D, double &I, double &Ht, double &Ft, double &Dt, double &It)
Compute various quantities dependent on a magnetic field and their rates of change.
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(), Qgis::StringFormat format=Qgis::StringFormat::PlainText)
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 unaccent(const QString &input)
Removes accents and other diacritical marks from a string, replacing accented characters with their u...
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
const QString cacheKey(const QString &pathIn)
QList< QgsGradientStop > QgsGradientStopsList
List of gradient stops.
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
double qDateTimeToDecimalYear(const QDateTime &dateTime)
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.