76 QVariantList argValues;
80 const QList< QgsExpressionNode * > argList = args->
list();
87 v = QVariant::fromValue( n );
91 v = n->eval( parent, context );
93 bool defaultParamIsNull = mParameterList.count() > arg && mParameterList.at( arg ).optional() && !mParameterList.at( arg ).defaultValue().isValid();
94 if ( QgsExpressionUtils::isNull( v ) && !defaultParamIsNull && !
handlesNull() )
97 argValues.append( v );
102 return func( argValues, context, parent, node );
113 return QStringList();
140 return mGroups.isEmpty() ? false : mGroups.contains( QStringLiteral(
"deprecated" ) );
145 return ( QString::compare( mName, other.mName, Qt::CaseInsensitive ) == 0 );
157 const QString &
group,
167 , mUsesGeometry(
false )
181 if ( mUsesGeometryFunc )
182 return mUsesGeometryFunc( node );
184 return mUsesGeometry;
189 if ( mReferencedColumnsFunc )
190 return mReferencedColumnsFunc( node );
192 return mReferencedColumns;
198 return mIsStaticFunc( node, parent, context );
206 return mPrepareFunc( node, parent, context );
218 mIsStaticFunc =
nullptr;
224 mPrepareFunc = prepareFunc;
229 if ( node && node->
args() )
231 const QList< QgsExpressionNode * > argList = node->
args()->
list();
234 if ( !argNode->isStatic( parent, context ) )
244 double start = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
245 double stop = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
246 double step = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
248 if ( step == 0.0 || ( step > 0.0 && start > stop ) || ( step < 0.0 && start < stop ) )
255 double current = start + step;
256 while ( ( ( step > 0.0 && current <= stop ) || ( step < 0.0 && current >= stop ) ) && length <= 1000000 )
271 QString
name = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
280 QString expString = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
282 return expression.evaluate( context );
287 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
288 return QVariant( std::sqrt( x ) );
293 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
294 return QVariant( std::fabs( val ) );
299 double deg = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
300 return ( deg * M_PI ) / 180;
304 double rad = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
305 return ( 180 * rad ) / M_PI;
309 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
310 return QVariant( std::sin( x ) );
314 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
315 return QVariant( std::cos( x ) );
319 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
320 return QVariant( std::tan( x ) );
324 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
325 return QVariant( std::asin( x ) );
329 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
330 return QVariant( std::acos( x ) );
334 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
335 return QVariant( std::atan( x ) );
339 double y = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
340 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
341 return QVariant( std::atan2( y, x ) );
345 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
346 return QVariant( std::exp( x ) );
350 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
353 return QVariant( std::log( x ) );
357 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
360 return QVariant( log10( x ) );
364 double b = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
365 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
366 if ( x <= 0 || b <= 0 )
368 return QVariant( std::log( x ) / std::log( b ) );
372 double min = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
373 double max = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
377 std::random_device rd;
378 std::mt19937_64 generator( rd() );
380 if ( !QgsExpressionUtils::isNull( values.at( 2 ) ) )
383 if ( QgsExpressionUtils::isIntSafe( values.at( 2 ) ) )
386 seed = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
391 QString seedStr = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
392 std::hash<std::string> hasher;
393 seed = hasher( seedStr.toStdString() );
395 generator.seed( seed );
399 double f =
static_cast< double >( generator() ) / generator.max();
400 return QVariant( min + f * ( max - min ) );
404 qlonglong min = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
405 qlonglong max = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
409 std::random_device rd;
410 std::mt19937_64 generator( rd() );
412 if ( !QgsExpressionUtils::isNull( values.at( 2 ) ) )
415 if ( QgsExpressionUtils::isIntSafe( values.at( 2 ) ) )
418 seed = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
423 QString seedStr = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
424 std::hash<std::string> hasher;
425 seed = hasher( seedStr.toStdString() );
427 generator.seed( seed );
431 return QVariant( min + ( generator() % ( max - min + 1 ) ) );
436 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
437 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
438 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
439 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
440 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
442 if ( domainMin >= domainMax )
444 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
449 if ( val >= domainMax )
453 else if ( val <= domainMin )
459 double m = ( rangeMax - rangeMin ) / ( domainMax - domainMin );
460 double c = rangeMin - ( domainMin * m );
463 return QVariant( m * val + c );
468 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
469 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
470 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
471 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
472 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
473 double exponent = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
475 if ( domainMin >= domainMax )
477 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
487 if ( val >= domainMax )
491 else if ( val <= domainMin )
497 return QVariant( ( ( rangeMax - rangeMin ) / std::pow( domainMax - domainMin, exponent ) ) * std::pow( val - domainMin, exponent ) + rangeMin );
502 QVariant result( QVariant::Double );
503 double maxVal = std::numeric_limits<double>::quiet_NaN();
504 for (
const QVariant &val : values )
506 double testVal = val.isNull() ? std::numeric_limits<double>::quiet_NaN() : QgsExpressionUtils::getDoubleValue( val, parent );
507 if ( std::isnan( maxVal ) )
511 else if ( !std::isnan( testVal ) )
513 maxVal = std::max( maxVal, testVal );
517 if ( !std::isnan( maxVal ) )
519 result = QVariant( maxVal );
526 QVariant result( QVariant::Double );
527 double minVal = std::numeric_limits<double>::quiet_NaN();
528 for (
const QVariant &val : values )
530 double testVal = val.isNull() ? std::numeric_limits<double>::quiet_NaN() : QgsExpressionUtils::getDoubleValue( val, parent );
531 if ( std::isnan( minVal ) )
535 else if ( !std::isnan( testVal ) )
537 minVal = std::min( minVal, testVal );
541 if ( !std::isnan( minVal ) )
543 result = QVariant( minVal );
555 QVariant value = node->
eval( parent, context );
557 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( value, parent );
560 parent->
setEvalErrorString( QObject::tr(
"Cannot find layer with name or ID '%1'" ).arg( value.toString() ) );
565 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
567 value = node->
eval( parent, context );
573 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
578 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
580 QString subExpression = node->
dump();
584 if ( values.count() > 3 )
586 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
589 if ( !nl || nl->value().isValid() )
594 if ( values.count() > 4 )
596 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
598 value = node->
eval( parent, context );
605 if ( values.count() > 5 )
607 node = QgsExpressionUtils::getNode( values.at( 5 ), parent );
610 if ( !nl || nl->value().isValid() )
612 orderBy = node->
dump();
628 cacheKey = QStringLiteral(
"aggfcn:%1:%2:%3:%4:%5%6:%7" ).arg( vl->id(), QString::number( aggregate ), subExpression, parameters.
filter,
633 cacheKey = QStringLiteral(
"aggfcn:%1:%2:%3:%4:%5" ).arg( vl->id(), QString::number( aggregate ), subExpression, parameters.
filter, orderBy );
643 result = vl->aggregate( aggregate, subExpression, parameters, &subContext, &ok );
649 result = vl->aggregate( aggregate, subExpression, parameters,
nullptr, &ok );
653 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
664 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
669 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
672 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
681 QVariant value = node->
eval( parent, context );
683 QString relationId = value.toString();
690 if ( relations.isEmpty() || relations.at( 0 ).referencedLayer() != vl )
692 parent->
setEvalErrorString( QObject::tr(
"Cannot find relation with id '%1'" ).arg( relationId ) );
697 relation = relations.at( 0 );
704 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
706 value = node->
eval( parent, context );
712 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
717 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
719 QString subExpression = node->
dump();
723 if ( values.count() > 3 )
725 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
727 value = node->
eval( parent, context );
734 if ( values.count() > 4 )
736 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
739 if ( !nl || nl->value().isValid() )
741 orderBy = node->
dump();
752 QString cacheKey = QStringLiteral(
"relagg:%1:%2:%3:%4:%5" ).arg( vl->
id(),
753 QString::number( static_cast< int >( aggregate ) ),
765 result = childLayer->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
769 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
783 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
788 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
791 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
800 QString subExpression = node->
dump();
804 if ( values.count() > 1 )
806 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
809 if ( !nl || nl->value().isValid() )
810 groupBy = node->
dump();
814 if ( values.count() > 2 )
816 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
819 if ( !nl || nl->value().isValid() )
825 if ( orderByPos >= 0 && values.count() > orderByPos )
827 node = QgsExpressionUtils::getNode( values.at( orderByPos ), parent );
830 if ( !nl || nl->value().isValid() )
832 orderBy = node->
dump();
840 if ( !groupBy.isEmpty() )
843 QVariant groupByValue = groupByExp.
evaluate( context );
844 QString groupByClause = QStringLiteral(
"%1 %2 %3" ).arg( groupBy,
845 groupByValue.isNull() ? QStringLiteral(
"is" ) : QStringLiteral(
"=" ),
847 if ( !parameters.
filter.isEmpty() )
848 parameters.
filter = QStringLiteral(
"(%1) AND (%2)" ).arg( parameters.
filter, groupByClause );
850 parameters.
filter = groupByClause;
853 QString cacheKey = QStringLiteral(
"agg:%1:%2:%3:%4:%5" ).arg( vl->
id(),
854 QString::number( static_cast< int >( aggregate ) ),
865 result = vl->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
869 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
974 if ( values.count() > 3 )
978 QVariant value = node->
eval( parent, context );
991 if ( values.count() > 3 )
995 QVariant value = node->
eval( parent, context );
1013 QVariant scale = context->
variable( QStringLiteral(
"map_scale" ) );
1015 if ( !scale.isValid() || scale.isNull() )
1018 const double v = scale.toDouble( &ok );
1026 double minValue = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1027 double testValue = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
1028 double maxValue = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
1031 if ( testValue <= minValue )
1033 return QVariant( minValue );
1035 else if ( testValue >= maxValue )
1037 return QVariant( maxValue );
1041 return QVariant( testValue );
1047 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1048 return QVariant( std::floor( x ) );
1053 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1054 return QVariant( std::ceil( x ) );
1059 return QVariant( QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) );
1063 return QVariant( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) );
1067 return QVariant( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ) );
1072 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1073 QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1074 if ( format.isEmpty() && !language.isEmpty() )
1076 parent->
setEvalErrorString( QObject::tr(
"A format is required to convert to DateTime when the language is specified" ) );
1077 return QVariant( QDateTime() );
1080 if ( format.isEmpty() && language.isEmpty() )
1081 return QVariant( QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent ) );
1083 QString datetimestring = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1084 QLocale locale = QLocale();
1085 if ( !language.isEmpty() )
1087 locale = QLocale( language );
1090 QDateTime datetime = locale.toDateTime( datetimestring, format );
1091 if ( !datetime.isValid() )
1093 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to DateTime" ).arg( datetimestring ) );
1094 datetime = QDateTime();
1096 return QVariant( datetime );
1101 for (
const QVariant &value : values )
1103 if ( value.isNull() )
1112 const QVariant val1 = values.at( 0 );
1113 const QVariant val2 = values.at( 1 );
1123 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1124 return QVariant( str.toLower() );
1128 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1129 return QVariant( str.toUpper() );
1133 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1134 QStringList elems = str.split(
' ' );
1135 for (
int i = 0; i < elems.size(); i++ )
1137 if ( elems[i].size() > 1 )
1138 elems[i] = elems[i].at( 0 ).toUpper() + elems[i].mid( 1 ).toLower();
1140 return QVariant( elems.join( QStringLiteral(
" " ) ) );
1145 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1146 return QVariant( str.trimmed() );
1151 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1152 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1158 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1159 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1165 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1166 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1173 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1179 QChar character = QChar( QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent ) );
1180 return QVariant( QString( character ) );
1185 if ( values.length() == 2 || values.length() == 3 )
1187 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1188 qlonglong wrap = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1190 QString customdelimiter = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1204 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1208 return QVariant( geom.
length() );
1212 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1213 return QVariant( str.length() );
1218 if ( values.count() == 2 && values.at( 1 ).type() == QVariant::Map )
1220 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1221 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 1 ), parent );
1223 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
1225 str = str.replace( it.key(), it.value().toString() );
1228 return QVariant( str );
1230 else if ( values.count() == 3 )
1232 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1233 QVariantList before;
1235 bool isSingleReplacement =
false;
1237 if ( values.at( 1 ).type() != QVariant::List && values.at( 2 ).type() != QVariant::StringList )
1239 before = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1243 before = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
1246 if ( values.at( 2 ).type() != QVariant::List && values.at( 2 ).type() != QVariant::StringList )
1248 after = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1249 isSingleReplacement =
true;
1253 after = QgsExpressionUtils::getListValue( values.at( 2 ), parent );
1256 if ( !isSingleReplacement && before.length() != after.length() )
1258 parent->
setEvalErrorString( QObject::tr(
"Invalid pair of array, length not identical" ) );
1262 for (
int i = 0; i < before.length(); i++ )
1264 str = str.replace( before.at( i ).toString(), after.at( isSingleReplacement ? 0 : i ).toString() );
1267 return QVariant( str );
1271 parent->
setEvalErrorString( QObject::tr(
"Function replace requires 2 or 3 arguments" ) );
1277 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1278 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1279 QString after = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1281 QRegularExpression re( regexp );
1282 if ( !re.isValid() )
1284 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1287 return QVariant( str.replace( re, after ) );
1292 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1293 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1295 QRegularExpression re( regexp );
1296 if ( !re.isValid() )
1298 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1301 return QVariant( ( str.indexOf( re ) + 1 ) );
1306 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1307 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1308 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1310 QRegularExpression re( regexp );
1311 if ( !re.isValid() )
1313 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1317 QRegularExpressionMatch matches = re.match( str );
1318 if ( matches.hasMatch() )
1321 QStringList list = matches.capturedTexts();
1324 for ( QStringList::const_iterator it = ++list.constBegin(); it != list.constEnd(); ++it )
1326 array += ( !( *it ).isEmpty() ) ? *it : empty;
1329 return QVariant( array );
1339 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1340 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1342 QRegularExpression re( regexp );
1343 if ( !re.isValid() )
1345 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1350 QRegularExpressionMatch match = re.match( str );
1351 if ( match.hasMatch() )
1354 if ( match.lastCapturedIndex() > 0 )
1357 return QVariant( match.captured( 1 ) );
1362 return QVariant( match.captured( 0 ) );
1367 return QVariant(
"" );
1373 return QUuid::createUuid().toString();
1378 if ( !values.at( 0 ).isValid() || !values.at( 1 ).isValid() )
1381 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1382 int from = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1385 if ( values.at( 2 ).isValid() )
1386 len = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
1392 from = str.size() + from;
1398 else if ( from > 0 )
1406 len = str.size() + len - from;
1413 return QVariant( str.mid( from, len ) );
1419 return QVariant( static_cast< int >( f.id() ) );
1424 QgsRasterLayer *layer = QgsExpressionUtils::getRasterLayer( values.at( 0 ), parent );
1427 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster layer." ) );
1431 int bandNb = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1432 if ( bandNb < 1 || bandNb > layer->
bandCount() )
1434 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster band number." ) );
1438 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
1441 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid point geometry." ) );
1449 if ( multiPoint.count() == 1 )
1451 point = multiPoint[0];
1461 return std::isnan( value ) ? QVariant() : value;
1476 if ( values.size() == 1 )
1478 attr = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1481 else if ( values.size() == 2 )
1483 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1484 attr = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1488 parent->
setEvalErrorString( QObject::tr(
"Function `attribute` requires one or two parameters. %1 given." ).arg( values.length() ) );
1498 if ( values.size() == 0 || values.at( 0 ).isNull() )
1504 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1509 for (
int i = 0; i < fields.count(); ++i )
1511 result.insert( fields.at( i ).name(), feature.
attribute( i ) );
1521 if ( values.isEmpty() )
1524 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1526 else if ( values.size() == 1 )
1528 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1529 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1531 else if ( values.size() == 2 )
1533 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1534 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
1538 parent->
setEvalErrorString( QObject::tr(
"Function `is_selected` requires no more than two parameters. %1 given." ).arg( values.length() ) );
1542 if ( !layer || !feature.
isValid() )
1544 return QVariant( QVariant::Bool );
1554 if ( values.isEmpty() )
1555 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1556 else if ( values.count() == 1 )
1557 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1560 parent->
setEvalErrorString( QObject::tr(
"Function `num_selected` requires no more than one parameter. %1 given." ).arg( values.length() ) );
1566 return QVariant( QVariant::LongLong );
1574 static QMap<QString, qlonglong> counterCache;
1575 QVariant functionResult;
1577 std::function<void()> fetchAndIncrementFunc = [ =, &functionResult ]()
1580 const QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1585 database = decodedUri.value( QStringLiteral(
"path" ) ).toString();
1586 if ( database.isEmpty() )
1588 parent->
setEvalErrorString( QObject::tr(
"Could not extract file path from layer `%1`." ).arg( layer->
name() ) );
1593 database = values.at( 0 ).toString();
1596 const QString table = values.at( 1 ).toString();
1597 const QString idColumn = values.at( 2 ).toString();
1598 const QString filterAttribute = values.at( 3 ).toString();
1599 const QVariant filterValue = values.at( 4 ).toString();
1600 const QVariantMap defaultValues = values.at( 5 ).toMap();
1606 if ( sqliteDb.
open_v2( database, SQLITE_OPEN_READWRITE,
nullptr ) != SQLITE_OK )
1609 functionResult = QVariant();
1613 QString errorMessage;
1614 QString currentValSql;
1616 qlonglong nextId = 0;
1617 bool cachedMode =
false;
1618 bool valueRetrieved =
false;
1620 QString cacheString = QStringLiteral(
"%1:%2:%3:%4:%5" ).arg( database, table, idColumn, filterAttribute, filterValue.toString() );
1627 auto cachedCounter = counterCache.find( cacheString );
1629 if ( cachedCounter != counterCache.end() )
1631 qlonglong &cachedValue = cachedCounter.value();
1632 nextId = cachedValue;
1634 cachedValue = nextId;
1635 valueRetrieved =
true;
1640 if ( !cachedMode || !valueRetrieved )
1642 int result = SQLITE_ERROR;
1645 if ( !filterAttribute.isNull() )
1650 sqliteStatement = sqliteDb.
prepare( currentValSql, result );
1652 if ( result == SQLITE_OK )
1655 if ( sqliteStatement.
step() == SQLITE_ROW )
1661 if ( cachedMode && result == SQLITE_OK )
1663 counterCache.insert( cacheString, nextId );
1667 counterCache.remove( cacheString );
1670 valueRetrieved =
true;
1674 if ( valueRetrieved )
1683 if ( !filterAttribute.isNull() )
1689 for ( QVariantMap::const_iterator iter = defaultValues.constBegin(); iter != defaultValues.constEnd(); ++iter )
1692 vals << iter.value().toString();
1695 upsertSql += QLatin1String(
" (" ) + cols.join(
',' ) +
')';
1696 upsertSql += QLatin1String(
" VALUES " );
1697 upsertSql +=
'(' + vals.join(
',' ) +
')';
1699 int result = SQLITE_ERROR;
1703 if ( transaction->
executeSql( upsertSql, errorMessage ) )
1710 result = sqliteDb.
exec( upsertSql, errorMessage );
1712 if ( result == SQLITE_OK )
1714 functionResult = QVariant( nextId );
1719 parent->
setEvalErrorString( QStringLiteral(
"Could not increment value: SQLite error: \"%1\" (%2)." ).arg( errorMessage, QString::number( result ) ) );
1720 functionResult = QVariant();
1725 functionResult = QVariant();
1730 return functionResult;
1736 for (
const QVariant &value : values )
1738 concat += QgsExpressionUtils::getStringValue( value, parent );
1745 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1746 return string.indexOf( QgsExpressionUtils::getStringValue( values.at( 1 ), parent ) ) + 1;
1751 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1752 int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1753 return string.right( pos );
1758 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1759 int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1760 return string.left( pos );
1765 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1766 int length = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1767 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1768 return string.leftJustified( length, fill.at( 0 ), true );
1773 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1774 int length = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1775 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1776 return string.rightJustified( length, fill.at( 0 ), true );
1781 if ( values.size() < 1 )
1783 parent->
setEvalErrorString( QObject::tr(
"Function format requires at least 1 argument" ) );
1787 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1788 for (
int n = 1; n < values.length(); n++ )
1790 string =
string.arg( QgsExpressionUtils::getStringValue( values.at( n ), parent ) );
1798 return QVariant( QDateTime::currentDateTime() );
1803 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1804 QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1805 if ( format.isEmpty() && !language.isEmpty() )
1807 parent->
setEvalErrorString( QObject::tr(
"A format is required to convert to Date when the language is specified" ) );
1808 return QVariant( QDate() );
1811 if ( format.isEmpty() && language.isEmpty() )
1812 return QVariant( QgsExpressionUtils::getDateValue( values.at( 0 ), parent ) );
1814 QString datestring = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1815 QLocale locale = QLocale();
1816 if ( !language.isEmpty() )
1818 locale = QLocale( language );
1821 QDate date = locale.toDate( datestring, format );
1822 if ( !date.isValid() )
1824 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to Date" ).arg( datestring ) );
1827 return QVariant( date );
1832 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1833 QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1834 if ( format.isEmpty() && !language.isEmpty() )
1836 parent->
setEvalErrorString( QObject::tr(
"A format is required to convert to Time when the language is specified" ) );
1837 return QVariant( QTime() );
1840 if ( format.isEmpty() && language.isEmpty() )
1841 return QVariant( QgsExpressionUtils::getTimeValue( values.at( 0 ), parent ) );
1843 QString timestring = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1844 QLocale locale = QLocale();
1845 if ( !language.isEmpty() )
1847 locale = QLocale( language );
1850 QTime time = locale.toTime( timestring, format );
1851 if ( !time.isValid() )
1853 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to Time" ).arg( timestring ) );
1856 return QVariant( time );
1861 return QVariant::fromValue( QgsExpressionUtils::getInterval( values.at( 0 ), parent ) );
1870 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1871 QString axis = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1872 int precision = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
1874 QString formatString;
1875 if ( values.count() > 3 )
1876 formatString = QgsExpressionUtils::getStringValue( values.at( 3 ), parent );
1878 QgsCoordinateFormatter::FormatFlags flags =
nullptr;
1879 if ( formatString.compare( QLatin1String(
"suffix" ), Qt::CaseInsensitive ) == 0 )
1883 else if ( formatString.compare( QLatin1String(
"aligned" ), Qt::CaseInsensitive ) == 0 )
1887 else if ( ! formatString.isEmpty() )
1889 parent->
setEvalErrorString( QObject::tr(
"Invalid formatting parameter: '%1'. It must be empty, or 'suffix' or 'aligned'." ).arg( formatString ) );
1893 if ( axis.compare( QLatin1String(
"x" ), Qt::CaseInsensitive ) == 0 )
1897 else if ( axis.compare( QLatin1String(
"y" ), Qt::CaseInsensitive ) == 0 )
1903 parent->
setEvalErrorString( QObject::tr(
"Invalid axis name: '%1'. It must be either 'x' or 'y'." ).arg( axis ) );
1911 return floatToDegreeFormat( format, values, context, parent, node );
1917 return floatToDegreeFormat( format, values, context, parent, node );
1922 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1923 QDateTime d2 = QgsExpressionUtils::getDateTimeValue( values.at( 1 ), parent );
1924 qint64 seconds = d2.secsTo( d1 );
1925 return QVariant::fromValue(
QgsInterval( seconds ) );
1930 if ( !values.at( 0 ).canConvert<QDate>() )
1933 QDate date = QgsExpressionUtils::getDateValue( values.at( 0 ), parent );
1934 if ( !date.isValid() )
1939 return date.dayOfWeek() % 7;
1944 QVariant value = values.at( 0 );
1945 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1948 return QVariant( inter.
days() );
1952 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1953 return QVariant( d1.date().day() );
1959 QVariant value = values.at( 0 );
1960 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1963 return QVariant( inter.
years() );
1967 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1968 return QVariant( d1.date().year() );
1974 QVariant value = values.at( 0 );
1975 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1978 return QVariant( inter.
months() );
1982 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1983 return QVariant( d1.date().month() );
1989 QVariant value = values.at( 0 );
1990 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1993 return QVariant( inter.
weeks() );
1997 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1998 return QVariant( d1.date().weekNumber() );
2004 QVariant value = values.at( 0 );
2005 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
2008 return QVariant( inter.
hours() );
2012 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
2013 return QVariant( t1.hour() );
2019 QVariant value = values.at( 0 );
2020 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
2023 return QVariant( inter.
minutes() );
2027 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
2028 return QVariant( t1.minute() );
2034 QVariant value = values.at( 0 );
2035 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
2038 return QVariant( inter.
seconds() );
2042 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
2043 return QVariant( t1.second() );
2049 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
2052 return QVariant( dt.toMSecsSinceEpoch() );
2062 long long millisecs_since_epoch = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
2064 return QVariant( QDateTime::fromMSecsSinceEpoch( millisecs_since_epoch ) );
2067 #define ENSURE_GEOM_TYPE(f, g, geomtype) \ 2068 if ( !(f).hasGeometry() ) \ 2069 return QVariant(); \ 2070 QgsGeometry g = (f).geometry(); \ 2071 if ( (g).type() != (geomtype) ) \ 2078 if ( g.isMultipart() )
2080 return g.asMultiPoint().at( 0 ).x();
2084 return g.asPoint().x();
2092 if ( g.isMultipart() )
2094 return g.asMultiPoint().at( 0 ).y();
2098 return g.asPoint().y();
2104 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2110 return QVariant( isValid );
2115 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2127 QVariant result( centroid.
asPoint().
x() );
2133 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2145 QVariant result( centroid.
asPoint().
y() );
2151 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2166 if ( collection->numGeometries() == 1 )
2168 if (
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( collection->geometryN( 0 ) ) )
2179 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2194 if ( collection->numGeometries() == 1 )
2196 if (
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( collection->geometryN( 0 ) ) )
2207 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2212 int idx = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
2239 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2256 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2273 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2278 bool ignoreClosing =
false;
2279 if ( values.length() > 1 )
2281 ignoreClosing = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
2291 bool skipLast =
false;
2292 if ( ignoreClosing && ring.count() > 2 && ring.first() == ring.last() )
2297 for (
int i = 0; i < ( skipLast ? ring.count() - 1 : ring.count() ); ++ i )
2299 mp->addGeometry( ring.at( i ).clone() );
2309 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2320 for (
int i = 0; i < line->numPoints() - 1; ++i )
2324 << line->pointN( i )
2325 << line->pointN( i + 1 ) );
2326 ml->addGeometry( segment );
2336 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2346 if ( collection->numGeometries() == 1 )
2353 if ( !curvePolygon )
2357 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
2363 QVariant result = curve ? QVariant::fromValue(
QgsGeometry( curve ) ) : QVariant();
2369 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2379 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
2385 QVariant result = part ? QVariant::fromValue(
QgsGeometry( part ) ) : QVariant();
2391 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2400 return QVariant::fromValue(
QgsGeometry( boundary ) );
2405 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2414 return QVariant::fromValue( merged );
2419 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2424 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2427 if ( simplified.isNull() )
2435 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2440 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2445 if ( simplified.
isNull() )
2453 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2458 int iterations = std::min( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), 10 );
2459 double offset = qBound( 0.0, QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ), 0.5 );
2460 double minLength = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2461 double maxAngle = qBound( 0.0, QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent ), 180.0 );
2463 QgsGeometry smoothed = geom.
smooth( static_cast<unsigned int>( iterations ), offset, minLength, maxAngle );
2473 if ( values.size() == 1 && ( values.at( 0 ).type() == QVariant::List || values.at( 0 ).type() == QVariant::StringList ) )
2475 list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
2482 QVector< QgsGeometry > parts;
2483 parts.reserve( list.size() );
2484 for (
const QVariant &value : qgis::as_const( list ) )
2502 if ( values.count() < 2 || values.count() > 4 )
2504 parent->
setEvalErrorString( QObject::tr(
"Function make_point requires 2-4 arguments" ) );
2508 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2509 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2510 double z = values.count() >= 3 ? QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) : 0.0;
2511 double m = values.count() >= 4 ? QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) : 0.0;
2512 switch ( values.count() )
2526 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2527 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2528 double m = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2534 if ( values.empty() )
2539 QVector<QgsPoint> points;
2540 points.reserve( values.count() );
2542 auto addPoint = [&points](
const QgsGeometry & geom )
2544 if ( geom.isNull() )
2557 for (
const QVariant &value : values )
2559 if ( value.type() == QVariant::List )
2561 const QVariantList list = value.toList();
2562 for (
const QVariant &v : list )
2564 addPoint( QgsExpressionUtils::getGeometry( v, parent ) );
2569 addPoint( QgsExpressionUtils::getGeometry( value, parent ) );
2573 if ( points.count() < 2 )
2581 if ( values.count() < 1 )
2583 parent->
setEvalErrorString( QObject::tr(
"Function make_polygon requires an argument" ) );
2587 QgsGeometry outerRing = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2591 std::unique_ptr< QgsPolygon > polygon = qgis::make_unique< QgsPolygon >();
2598 if ( collection->numGeometries() == 1 )
2605 if ( !exteriorRing )
2608 polygon->setExteriorRing( exteriorRing->segmentize() );
2611 for (
int i = 1; i < values.count(); ++i )
2613 QgsGeometry ringGeom = QgsExpressionUtils::getGeometry( values.at( i ), parent );
2625 if ( collection->numGeometries() == 1 )
2635 polygon->addInteriorRing( ring->
segmentize() );
2638 return QVariant::fromValue(
QgsGeometry( std::move( polygon ) ) );
2643 std::unique_ptr<QgsTriangle> tr(
new QgsTriangle() );
2644 std::unique_ptr<QgsLineString> lineString(
new QgsLineString() );
2645 lineString->clear();
2647 for (
const QVariant &value : values )
2649 QgsGeometry geom = QgsExpressionUtils::getGeometry( value, parent );
2661 if ( collection->numGeometries() == 1 )
2671 lineString->addVertex( *point );
2674 tr->setExteriorRing( lineString.release() );
2676 return QVariant::fromValue(
QgsGeometry( tr.release() ) );
2681 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2688 double radius = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2689 int segment = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
2701 if ( collection->numGeometries() == 1 )
2711 return QVariant::fromValue(
QgsGeometry( circ.
toPolygon( static_cast<unsigned int>( segment ) ) ) );
2716 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2723 double majorAxis = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2724 double minorAxis = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2725 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2726 int segment = QgsExpressionUtils::getNativeIntValue( values.at( 4 ), parent );
2737 if ( collection->numGeometries() == 1 )
2746 QgsEllipse elp( *point, majorAxis, minorAxis, azimuth );
2747 return QVariant::fromValue(
QgsGeometry( elp.
toPolygon( static_cast<unsigned int>( segment ) ) ) );
2753 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2760 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2767 unsigned int nbEdges =
static_cast<unsigned int>( QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) );
2770 parent->
setEvalErrorString( QObject::tr(
"Number of edges/sides must be greater than 2" ) );
2777 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (inscribed) or 1 (circumscribed)" ) );
2786 if ( collection->numGeometries() == 1 )
2800 if ( collection->numGeometries() == 1 )
2817 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2823 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2833 return QVariant::fromValue(
QgsGeometry( square.toPolygon() ) );
2838 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2844 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2850 QgsGeometry pt3 = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
2859 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (distance) or 1 (projected)" ) );
2866 return QVariant::fromValue(
QgsGeometry( rect.toPolygon() ) );
2872 int idx = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
2881 if ( idx < 0 || idx >= g.constGet()->nCoordinates() )
2888 return QVariant( QPointF( p.
x(), p.
y() ) );
2893 QVariant v = pointAt( values, f, parent );
2894 if ( v.type() == QVariant::PointF )
2895 return QVariant( v.toPointF().x() );
2901 QVariant v = pointAt( values, f, parent );
2902 if ( v.type() == QVariant::PointF )
2903 return QVariant( v.toPointF().y() );
2912 return QVariant::fromValue( geom );
2914 return QVariant( QVariant::UserType );
2919 QString wkt = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2921 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2927 const QByteArray wkb = QgsExpressionUtils::getBinaryValue( values.at( 0 ), parent );
2933 return !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2938 QString gml = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2940 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2953 return QVariant( area );
2957 return QVariant( f.geometry().area() );
2963 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2968 return QVariant( geom.
area() );
2980 return QVariant( len );
2984 return QVariant( f.geometry().length() );
2997 return QVariant( len );
3001 return f.geometry().isNull() ? QVariant( 0 ) : QVariant( f.geometry().constGet()->perimeter() );
3007 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3013 return QVariant( geom.
length() );
3018 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3024 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3033 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3046 for (
int i = 0; i < collection->numGeometries(); ++i )
3049 if ( !curvePolygon )
3061 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3068 return QVariant( curvePolygon->
ringCount() );
3070 bool foundPoly =
false;
3079 if ( !curvePolygon )
3090 return QVariant( ringCount );
3095 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3097 QVariant result = !geomBounds.
isNull() ? QVariant::fromValue( geomBounds ) : QVariant();
3103 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3109 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3115 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3121 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3127 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3133 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3139 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3143 std::unique_ptr< QgsAbstractGeometry > flipped( geom.
constGet()->
clone() );
3145 return QVariant::fromValue(
QgsGeometry( std::move( flipped ) ) );
3150 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3159 if ( collection->numGeometries() == 1 )
3169 return QVariant::fromValue( curve->
isClosed() );
3174 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3178 return QVariant::fromValue( fGeom.
isEmpty() );
3183 if ( values.at( 0 ).isNull() )
3184 return QVariant::fromValue(
true );
3186 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3187 return QVariant::fromValue( fGeom.
isNull() || fGeom.
isEmpty() );
3192 if ( values.length() < 2 || values.length() > 3 )
3195 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3196 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3198 if ( fGeom.
isNull() || sGeom.isNull() )
3203 if ( values.length() == 2 )
3206 QString result = engine->relate( sGeom.constGet() );
3207 return QVariant::fromValue( result );
3212 QString pattern = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
3213 bool result = engine->relatePattern( sGeom.constGet(), pattern );
3214 return QVariant::fromValue( result );
3220 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3221 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3222 return fGeom.
intersects( sGeom.boundingBox() ) ? TVL_True : TVL_False;
3226 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3227 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3228 return fGeom.
disjoint( sGeom ) ? TVL_True : TVL_False;
3232 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3233 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3234 return fGeom.
intersects( sGeom ) ? TVL_True : TVL_False;
3238 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3239 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3240 return fGeom.
touches( sGeom ) ? TVL_True : TVL_False;
3244 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3245 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3246 return fGeom.
crosses( sGeom ) ? TVL_True : TVL_False;
3250 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3251 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3252 return fGeom.
contains( sGeom ) ? TVL_True : TVL_False;
3256 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3257 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3258 return fGeom.
overlaps( sGeom ) ? TVL_True : TVL_False;
3262 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3263 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3264 return fGeom.
within( sGeom ) ? TVL_True : TVL_False;
3268 if ( values.length() < 2 || values.length() > 3 )
3271 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3272 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3274 if ( values.length() == 3 )
3275 seg = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
3278 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3284 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3286 return !reoriented.
isNull() ? QVariant::fromValue( reoriented ) : QVariant();
3291 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3297 if ( collection->numGeometries() == 1 )
3306 parent->
setEvalErrorString( QObject::tr(
"Function `wedge_buffer` requires a point value for the center." ) );
3310 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3311 double width = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3312 double outerRadius = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3313 double innerRadius = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
3316 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
3322 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3325 parent->
setEvalErrorString( QObject::tr(
"Function `tapered_buffer` requires a line geometry." ) );
3329 double startWidth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3330 double endWidth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3331 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) );
3334 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3340 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3343 parent->
setEvalErrorString( QObject::tr(
"Function `buffer_by_m` requires a line geometry." ) );
3347 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3350 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3356 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3357 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3358 int segments = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
3362 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3365 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3371 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3372 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3373 int segments = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
3377 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3380 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3386 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3387 double distStart = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3388 double distEnd = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3391 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3397 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3398 double dx = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3399 double dy = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3401 return QVariant::fromValue( fGeom );
3406 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3407 const double rotation = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3408 const QgsGeometry center = values.at( 2 ).isValid() ? QgsExpressionUtils::getGeometry( values.at( 2 ), parent )
3412 if ( center.isNull() )
3419 parent->
setEvalErrorString( QObject::tr(
"Function 'rotate' requires a point value for the center" ) );
3422 else if ( center.isMultipart() )
3425 if ( multiPoint.count() == 1 )
3431 parent->
setEvalErrorString( QObject::tr(
"Function 'rotate' requires a point value for the center" ) );
3437 pt = center.asPoint();
3440 fGeom.
rotate( rotation, pt );
3441 return QVariant::fromValue( fGeom );
3446 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3448 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3453 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3455 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3461 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3462 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3464 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3470 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3472 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3479 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3481 if ( values.length() == 2 )
3482 segments = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3490 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3496 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3498 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3504 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3505 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3507 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3513 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3525 result = reversed ? QVariant::fromValue(
QgsGeometry( reversed ) ) : QVariant();
3533 if (
const QgsCurve *curve = qgsgeometry_cast<const QgsCurve * >( collection->
geometryN( i ) ) )
3542 result = reversed ? QVariant::fromValue(
QgsGeometry( std::move( reversed ) ) ) : QVariant();
3549 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3558 if ( collection->numGeometries() == 1 )
3569 QVariant result = exterior ? QVariant::fromValue(
QgsGeometry( exterior ) ) : QVariant();
3575 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3576 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3577 return QVariant( fGeom.
distance( sGeom ) );
3582 QgsGeometry g1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3583 QgsGeometry g2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3586 if ( values.length() == 3 && values.at( 2 ).isValid() )
3588 double densify = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3589 densify = qBound( 0.0, densify, 1.0 );
3597 return res > -1 ? QVariant( res ) : QVariant();
3602 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3603 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3605 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3610 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3611 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3613 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3618 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3619 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3621 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3627 if ( values.length() < 1 || values.length() > 2 )
3630 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3632 if ( values.length() == 2 )
3633 prec = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3634 QString wkt = fGeom.
asWkt( prec );
3635 return QVariant( wkt );
3640 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3641 return fGeom.
isNull() ? QVariant() : QVariant( fGeom.
asWkb() );
3646 if ( values.length() != 2 )
3648 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires exactly two parameters. %1 given." ).arg( values.length() ) );
3652 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3653 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3660 if ( collection->numGeometries() == 1 )
3668 if ( !pt2 && fGeom2.isMultipart() )
3670 if (
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( fGeom2.constGet() ) )
3672 if ( collection->numGeometries() == 1 )
3681 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires two points as arguments." ) );
3688 if ( pt1->y() < pt2->y() )
3690 else if ( pt1->y() > pt2->y() )
3698 if ( pt1->x() < pt2->x() )
3700 else if ( pt1->x() > pt2->x() )
3701 return M_PI + ( M_PI_2 );
3706 if ( pt1->x() < pt2->x() )
3708 if ( pt1->y() < pt2->y() )
3710 return std::atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) );
3714 return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
3721 if ( pt1->y() > pt2->y() )
3723 return std::atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) )
3728 return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
3729 + ( M_PI + ( M_PI_2 ) );
3736 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3740 parent->
setEvalErrorString( QStringLiteral(
"'project' requires a point geometry" ) );
3744 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3745 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3746 double inclination = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3749 QgsPoint newPoint = p->
project( distance, 180.0 * azimuth / M_PI, 180.0 * inclination / M_PI );
3756 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3757 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3764 if ( collection->numGeometries() == 1 )
3771 if ( !pt2 && fGeom2.isMultipart() )
3773 if (
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( fGeom2.constGet() ) )
3775 if ( collection->numGeometries() == 1 )
3785 parent->
setEvalErrorString( QStringLiteral(
"Function 'inclination' requires two points as arguments." ) );
3789 return pt1->inclination( *pt2 );
3795 if ( values.length() != 3 )
3798 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3799 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3800 double y = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3804 QVariant result = geom.
constGet() ? QVariant::fromValue( geom ) : QVariant();
3810 if ( values.length() < 2 )
3813 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3816 return values.at( 0 );
3818 QString expString = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3819 QVariant cachedExpression;
3824 if ( cachedExpression.isValid() )
3831 bool asc = values.value( 2 ).toBool();
3849 Q_ASSERT( collection );
3853 QgsExpressionSorter sorter( orderBy );
3855 QList<QgsFeature> partFeatures;
3856 partFeatures.reserve( collection->
partCount() );
3857 for (
int i = 0; i < collection->
partCount(); ++i )
3863 sorter.sortFeatures( partFeatures, unconstedContext );
3867 Q_ASSERT( orderedGeom );
3872 for (
const QgsFeature &feature : qgis::as_const( partFeatures ) )
3874 orderedGeom->
addGeometry( feature.geometry().constGet()->clone() );
3877 QVariant result = QVariant::fromValue(
QgsGeometry( orderedGeom ) );
3880 delete unconstedContext;
3887 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3888 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3892 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3898 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3899 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3903 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3909 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3910 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3914 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3920 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3923 parent->
setEvalErrorString( QObject::tr(
"line_substring requires a curve geometry input" ) );
3929 curve = qgsgeometry_cast< const QgsCurve * >( lineGeom.
constGet() );
3934 if ( collection->numGeometries() > 0 )
3943 double startDistance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3944 double endDistance = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3946 std::unique_ptr< QgsCurve > substring( curve->
curveSubstring( startDistance, endDistance ) );
3948 return !result.isNull() ? QVariant::fromValue( result ) : QVariant();
3953 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3954 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3961 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3962 int vertex = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3967 vertex = count + vertex;
3975 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3976 int vertex = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3981 vertex = count + vertex;
3989 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3990 QgsGeometry pointGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3994 return distance >= 0 ? distance : QVariant();
3999 if ( values.length() == 2 && values.at( 1 ).toInt() != 0 )
4001 double number = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
4002 return qgsRound( number, QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
4005 if ( values.length() >= 1 )
4007 double number = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
4008 return QVariant( qlonglong( std::round( number ) ) );
4023 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
4024 int places = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4030 QLocale locale = QLocale();
4031 locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
4032 return locale.toString( value,
'f', places );
4037 QDateTime datetime = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
4038 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4039 QString language = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4041 QLocale locale = QLocale();
4042 if ( !language.isEmpty() )
4044 locale = QLocale( language );
4046 return locale.toString( datetime, format );
4052 int avg = ( color.red() + color.green() + color.blue() ) / 3;
4053 int alpha = color.alpha();
4055 color.setRgb( avg, avg, avg, alpha );
4064 double ratio = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
4069 else if ( ratio < 0 )
4074 int red =
static_cast<int>( color1.red() * ( 1 - ratio ) + color2.red() * ratio );
4075 int green =
static_cast<int>( color1.green() * ( 1 - ratio ) + color2.green() * ratio );
4076 int blue =
static_cast<int>( color1.blue() * ( 1 - ratio ) + color2.blue() * ratio );
4077 int alpha =
static_cast<int>( color1.alpha() * ( 1 - ratio ) + color2.alpha() * ratio );
4079 QColor newColor( red, green, blue, alpha );
4086 int red = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
4087 int green = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4088 int blue = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
4089 QColor color = QColor( red, green, blue );
4090 if ( ! color.isValid() )
4092 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( red ).arg( green ).arg( blue ) );
4093 color = QColor( 0, 0, 0 );
4096 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
4101 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
4102 QVariant value = node->
eval( parent, context );
4106 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
4108 value = node->
eval( parent, context );
4116 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
4118 QVariant value = node->
eval( parent, context );
4120 if ( value.toBool() )
4122 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
4124 value = node->
eval( parent, context );
4129 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
4131 value = node->
eval( parent, context );
4139 int red = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
4140 int green = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4141 int blue = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
4142 int alpha = QgsExpressionUtils::getNativeIntValue( values.at( 3 ), parent );
4143 QColor color = QColor( red, green, blue, alpha );
4144 if ( ! color.isValid() )
4146 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( red ).arg( green ).arg( blue ).arg( alpha ) );
4147 color = QColor( 0, 0, 0 );
4158 expRamp = QgsExpressionUtils::getRamp( values.at( 0 ), parent );
4163 QString rampName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4167 parent->
setEvalErrorString( QObject::tr(
"\"%1\" is not a valid color ramp" ).arg( rampName ) );
4172 double value = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
4173 QColor color = ramp->
color( value );
4180 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
4182 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
4184 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
4186 QColor color = QColor::fromHslF( hue, saturation, lightness );
4188 if ( ! color.isValid() )
4190 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( lightness ) );
4191 color = QColor( 0, 0, 0 );
4194 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
4200 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
4202 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
4204 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
4206 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
4208 QColor color = QColor::fromHslF( hue, saturation, lightness, alpha );
4209 if ( ! color.isValid() )
4211 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
4212 color = QColor( 0, 0, 0 );
4220 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
4222 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
4224 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
4226 QColor color = QColor::fromHsvF( hue, saturation, value );
4228 if ( ! color.isValid() )
4230 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( value ) );
4231 color = QColor( 0, 0, 0 );
4234 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
4240 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
4242 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
4244 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
4246 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
4248 QColor color = QColor::fromHsvF( hue, saturation, value, alpha );
4249 if ( ! color.isValid() )
4251 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
4252 color = QColor( 0, 0, 0 );
4260 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
4262 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
4264 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
4266 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
4268 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black );
4270 if ( ! color.isValid() )
4272 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ) );
4273 color = QColor( 0, 0, 0 );
4276 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
4282 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
4284 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
4286 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
4288 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
4290 double alpha = QgsExpressionUtils::getIntValue( values.at( 4 ), parent ) / 255.0;
4292 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
4293 if ( ! color.isValid() )
4295 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
4296 color = QColor( 0, 0, 0 );
4304 if ( ! color.isValid() )
4306 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4310 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4311 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
4313 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
4314 return color.green();
4315 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
4316 return color.blue();
4317 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
4318 return color.alpha();
4319 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
4320 return color.hsvHueF() * 360;
4321 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
4322 return color.hsvSaturationF() * 100;
4323 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
4324 return color.valueF() * 100;
4325 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
4326 return color.hslHueF() * 360;
4327 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
4328 return color.hslSaturationF() * 100;
4329 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
4330 return color.lightnessF() * 100;
4331 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
4332 return color.cyanF() * 100;
4333 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
4334 return color.magentaF() * 100;
4335 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
4336 return color.yellowF() * 100;
4337 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
4338 return color.blackF() * 100;
4340 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
4346 const QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4347 if ( map.count() < 1 )
4349 parent->
setEvalErrorString( QObject::tr(
"A minimum of two colors is required to create a ramp" ) );
4353 QList< QColor > colors;
4355 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
4358 if ( !colors.last().isValid() )
4360 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( it.value().toString() ) );
4364 double step = it.key().toDouble();
4365 if ( it == map.constBegin() )
4370 else if ( it == map.constEnd() )
4380 bool discrete = values.at( 1 ).toBool();
4382 return QVariant::fromValue(
QgsGradientColorRamp( colors.first(), colors.last(), discrete, stops ) );
4388 if ( ! color.isValid() )
4390 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4394 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4395 int value = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
4396 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
4397 color.setRed( value );
4398 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
4399 color.setGreen( value );
4400 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
4401 color.setBlue( value );
4402 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
4403 color.setAlpha( value );
4404 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
4405 color.setHsv( value, color.hsvSaturation(), color.value(), color.alpha() );
4406 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
4407 color.setHsvF( color.hsvHueF(), value / 100.0, color.valueF(), color.alphaF() );
4408 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
4409 color.setHsvF( color.hsvHueF(), color.hsvSaturationF(), value / 100.0, color.alphaF() );
4410 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
4411 color.setHsl( value, color.hslSaturation(), color.lightness(), color.alpha() );
4412 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
4413 color.setHslF( color.hslHueF(), value / 100.0, color.lightnessF(), color.alphaF() );
4414 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
4415 color.setHslF( color.hslHueF(), color.hslSaturationF(), value / 100.0, color.alphaF() );
4416 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
4417 color.setCmykF( value / 100.0, color.magentaF(), color.yellowF(), color.blackF(), color.alphaF() );
4418 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
4419 color.setCmykF( color.cyanF(), value / 100.0, color.yellowF(), color.blackF(), color.alphaF() );
4420 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
4421 color.setCmykF( color.cyanF(), color.magentaF(), value / 100.0, color.blackF(), color.alphaF() );
4422 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
4423 color.setCmykF( color.cyanF(), color.magentaF(), color.yellowF(), value / 100.0, color.alphaF() );
4426 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
4435 if ( ! color.isValid() )
4437 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4441 color = color.darker( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
4449 if ( ! color.isValid() )
4451 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4455 color = color.lighter( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
4462 QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
4464 if ( !geom.isNull() )
4465 return QVariant::fromValue( geom );
4471 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4472 QString sAuthId = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4473 QString dAuthId = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4476 if ( ! s.isValid() )
4477 return QVariant::fromValue( fGeom );
4480 return QVariant::fromValue( fGeom );
4489 return QVariant::fromValue( fGeom );
4503 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
4506 QgsFeatureId fid = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4516 result = QVariant::fromValue( fet );
4526 std::unique_ptr<QgsVectorLayerFeatureSource> featureSource = QgsExpressionUtils::getFeatureSource( values.at( 0 ), parent );
4529 if ( !featureSource )
4534 QString attribute = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4535 int attributeId = featureSource->fields().lookupField( attribute );
4536 if ( attributeId == -1 )
4541 const QVariant &attVal = values.at( 2 );
4543 const QString cacheValueKey = QStringLiteral(
"getfeature:%1:%2:%3" ).arg( featureSource->id(), QString::number( attributeId ), attVal.toString() );
4565 res = QVariant::fromValue( fet );
4580 if ( !values.isEmpty() )
4583 if ( col && ( values.size() == 1 || !values.at( 1 ).isValid() ) )
4584 fieldName = col->
name();
4585 else if ( values.size() == 2 )
4586 fieldName = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4589 QVariant value = values.at( 0 );
4594 if ( fieldIndex == -1 )
4596 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: Field not found %2" ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
4600 QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
4602 const QString cacheValueKey = QStringLiteral(
"repvalfcnval:%1:%2:%3" ).arg( layer ? layer->
id() : QStringLiteral(
"[None]" ), fieldName, value.toString() );
4611 const QString cacheKey = QStringLiteral(
"repvalfcn:%1:%2" ).arg( layer ? layer->
id() : QStringLiteral(
"[None]" ), fieldName );
4629 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: function cannot be evaluated without a context." ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
4637 QgsMapLayer *layer = QgsExpressionUtils::getMapLayer( values.at( 0 ), parent );
4643 QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4644 if ( QString::compare( layerProperty, QStringLiteral(
"name" ), Qt::CaseInsensitive ) == 0 )
4645 return layer->
name();
4646 else if ( QString::compare( layerProperty, QStringLiteral(
"id" ), Qt::CaseInsensitive ) == 0 )
4648 else if ( QString::compare( layerProperty, QStringLiteral(
"title" ), Qt::CaseInsensitive ) == 0 )
4650 else if ( QString::compare( layerProperty, QStringLiteral(
"abstract" ), Qt::CaseInsensitive ) == 0 )
4652 else if ( QString::compare( layerProperty, QStringLiteral(
"keywords" ), Qt::CaseInsensitive ) == 0 )
4654 QStringList keywords;
4656 for (
auto it = keywordMap.constBegin(); it != keywordMap.constEnd(); ++it )
4658 keywords.append( it.value() );
4660 if ( !keywords.isEmpty() )
4664 else if ( QString::compare( layerProperty, QStringLiteral(
"data_url" ), Qt::CaseInsensitive ) == 0 )
4666 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution" ), Qt::CaseInsensitive ) == 0 )
4670 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution_url" ), Qt::CaseInsensitive ) == 0 )
4672 else if ( QString::compare( layerProperty, QStringLiteral(
"source" ), Qt::CaseInsensitive ) == 0 )
4674 else if ( QString::compare( layerProperty, QStringLiteral(
"min_scale" ), Qt::CaseInsensitive ) == 0 )
4676 else if ( QString::compare( layerProperty, QStringLiteral(
"max_scale" ), Qt::CaseInsensitive ) == 0 )
4678 else if ( QString::compare( layerProperty, QStringLiteral(
"crs" ), Qt::CaseInsensitive ) == 0 )
4680 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_definition" ), Qt::CaseInsensitive ) == 0 )
4682 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_description" ), Qt::CaseInsensitive ) == 0 )
4684 else if ( QString::compare( layerProperty, QStringLiteral(
"extent" ), Qt::CaseInsensitive ) == 0 )
4687 QVariant result = QVariant::fromValue( extentGeom );
4690 else if ( QString::compare( layerProperty, QStringLiteral(
"type" ), Qt::CaseInsensitive ) == 0 )
4692 switch ( layer->
type() )
4695 return QCoreApplication::translate(
"expressions",
"Vector" );
4697 return QCoreApplication::translate(
"expressions",
"Raster" );
4699 return QCoreApplication::translate(
"expressions",
"Mesh" );
4701 return QCoreApplication::translate(
"expressions",
"Plugin" );
4710 if ( QString::compare( layerProperty, QStringLiteral(
"storage_type" ), Qt::CaseInsensitive ) == 0 )
4712 else if ( QString::compare( layerProperty, QStringLiteral(
"geometry_type" ), Qt::CaseInsensitive ) == 0 )
4714 else if ( QString::compare( layerProperty, QStringLiteral(
"feature_count" ), Qt::CaseInsensitive ) == 0 )
4716 else if ( QString::compare( layerProperty, QStringLiteral(
"path" ), Qt::CaseInsensitive ) == 0 )
4721 return decodedUri.value( QStringLiteral(
"path" ) );
4732 QgsMapLayer *layer = QgsExpressionUtils::getMapLayer( values.at( 0 ), parent );
4735 parent->
setEvalErrorString( QObject::tr(
"Cannot find layer %1" ).arg( values.at( 0 ).toString() ) );
4745 const QString uriPart = values.at( 1 ).toString();
4749 if ( !uriPart.isNull() )
4751 return decodedUri.value( values.at( 1 ).toString() );
4761 QString layerIdOrName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4768 if ( !layersByName.isEmpty() )
4770 layer = layersByName.at( 0 );
4781 int band = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4782 if ( band < 1 || band > rl->
bandCount() )
4784 parent->
setEvalErrorString( QObject::tr(
"Invalid band number %1 for layer %2" ).arg( band ).arg( layerIdOrName ) );
4788 QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4791 if ( QString::compare( layerProperty, QStringLiteral(
"avg" ), Qt::CaseInsensitive ) == 0 )
4793 else if ( QString::compare( layerProperty, QStringLiteral(
"stdev" ), Qt::CaseInsensitive ) == 0 )
4795 else if ( QString::compare( layerProperty, QStringLiteral(
"min" ), Qt::CaseInsensitive ) == 0 )
4797 else if ( QString::compare( layerProperty, QStringLiteral(
"max" ), Qt::CaseInsensitive ) == 0 )
4799 else if ( QString::compare( layerProperty, QStringLiteral(
"range" ), Qt::CaseInsensitive ) == 0 )
4801 else if ( QString::compare( layerProperty, QStringLiteral(
"sum" ), Qt::CaseInsensitive ) == 0 )
4805 parent->
setEvalErrorString( QObject::tr(
"Invalid raster statistic: '%1'" ).arg( layerProperty ) );
4835 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4836 bool ascending = values.value( 1 ).toBool();
4843 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).length();
4848 return QVariant( QgsExpressionUtils::getListValue( values.at( 0 ), parent ).contains( values.at( 1 ) ) );
4853 QVariantList listA = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4854 QVariantList listB = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
4856 for (
const auto &item : listB )
4858 if ( listA.contains( item ) )
4862 return QVariant( match == listB.count() );
4867 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).indexOf( values.at( 1 ) );
4872 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4873 const int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4874 if ( pos < 0 || pos >= list.length() )
return QVariant();
4875 return list.at( pos );
4880 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4881 return list.value( 0 );
4886 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4887 return list.value( list.size() - 1 );
4890 static QVariant convertToSameType(
const QVariant &value, QVariant::Type type )
4892 QVariant result = value;
4893 result.convert( static_cast<int>( type ) );
4899 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4900 list.append( values.at( 1 ) );
4901 return convertToSameType( list, values.at( 0 ).type() );
4906 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4907 list.prepend( values.at( 1 ) );
4908 return convertToSameType( list, values.at( 0 ).type() );
4913 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4914 list.insert( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), values.at( 2 ) );
4915 return convertToSameType( list, values.at( 0 ).type() );
4920 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4921 list.removeAt( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
4922 return convertToSameType( list, values.at( 0 ).type() );
4927 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4928 list.removeAll( values.at( 1 ) );
4929 return convertToSameType( list, values.at( 0 ).type() );
4935 for (
const QVariant &cur : values )
4937 list += QgsExpressionUtils::getListValue( cur, parent );
4939 return convertToSameType( list, values.at( 0 ).type() );
4944 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4945 int start_pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4946 const int end_pos = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
4947 int slice_length = 0;
4949 if ( start_pos < 0 )
4951 start_pos = list.length() + start_pos;
4955 slice_length = end_pos - start_pos + 1;
4959 slice_length = list.length() + end_pos - start_pos + 1;
4962 if ( slice_length < 0 )
4966 list = list.mid( start_pos, slice_length );
4972 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4973 std::reverse( list.begin(), list.end() );
4979 const QVariantList array1 = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4980 const QVariantList array2 = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
4981 for (
const QVariant &cur : array2 )
4983 if ( array1.contains( cur ) )
4984 return QVariant(
true );
4986 return QVariant(
false );
4991 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4993 QVariantList distinct;
4995 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
4997 if ( !distinct.contains( *it ) )
4999 distinct += ( *it );
5008 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
5009 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
5010 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
5014 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
5016 str += ( !( *it ).toString().isEmpty() ) ? ( *it ).toString() : empty;
5017 if ( it != ( array.constEnd() - 1 ) )
5023 return QVariant( str );
5028 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5029 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
5030 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
5032 QStringList list = str.split( delimiter );
5035 for ( QStringList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
5037 array += ( !( *it ).isEmpty() ) ? *it : empty;
5045 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5046 QJsonDocument document = QJsonDocument::fromJson( str.toUtf8() );
5047 if ( document.isNull() )
5050 return document.toVariant();
5056 QJsonDocument document = QJsonDocument::fromVariant( values.at( 0 ) );
5057 return document.toJson( QJsonDocument::Compact );
5062 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5063 if ( str.isEmpty() )
5064 return QVariantMap();
5065 str = str.trimmed();
5072 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
5079 for (
int i = 0; i + 1 < values.length(); i += 2 )
5081 result.insert( QgsExpressionUtils::getStringValue( values.at( i ), parent ), values.at( i + 1 ) );
5088 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).value( values.at( 1 ).toString() );
5093 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).contains( values.at( 1 ).toString() );
5098 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
5099 map.remove( values.at( 1 ).toString() );
5105 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
5106 map.insert( values.at( 1 ).toString(), values.at( 2 ) );
5113 for (
const QVariant &cur : values )
5115 const QVariantMap curMap = QgsExpressionUtils::getMapValue( cur, parent );
5116 for ( QVariantMap::const_iterator it = curMap.constBegin(); it != curMap.constEnd(); ++it )
5117 result.insert( it.key(), it.value() );
5124 return QStringList( QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).keys() );
5129 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).values();
5134 QString envVarName = values.at( 0 ).toString();
5135 return QProcessEnvironment::systemEnvironment().value( envVarName );
5140 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5141 return QFileInfo( file ).completeBaseName();
5146 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5147 return QFileInfo( file ).completeSuffix();
5152 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5153 return QFileInfo::exists( file );
5158 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5159 return QFileInfo( file ).fileName();
5164 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5165 return QFileInfo( file ).isFile();
5170 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5171 return QFileInfo( file ).isDir();
5176 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5177 return QDir::toNativeSeparators( QFileInfo( file ).path() );
5182 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5183 return QFileInfo( file ).size();
5186 static QVariant fcnHash(
const QString str,
const QCryptographicHash::Algorithm
algorithm )
5189 return QString( QCryptographicHash::hash( str.toUtf8(),
algorithm ).toHex() );
5195 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
5196 QString method = QgsExpressionUtils::getStringValue( values.at( 1 ), parent ).toLower();
5198 if ( method == QLatin1String(
"md4" ) )
5200 hash = fcnHash( str, QCryptographicHash::Md4 );
5202 else if ( method == QLatin1String(
"md5" ) )
5204 hash = fcnHash( str, QCryptographicHash::Md5 );
5206 else if ( method == QLatin1String(
"sha1" ) )
5208 hash = fcnHash( str, QCryptographicHash::Sha1 );
5210 else if ( method == QLatin1String(
"sha224" ) )
5212 hash = fcnHash( str, QCryptographicHash::Sha224 );
5214 else if ( method == QLatin1String(
"sha256" ) )
5216 hash = fcnHash( str, QCryptographicHash::Sha256 );
5218 else if ( method == QLatin1String(
"sha384" ) )
5220 hash = fcnHash( str, QCryptographicHash::Sha384 );
5222 else if ( method == QLatin1String(
"sha512" ) )
5224 hash = fcnHash( str, QCryptographicHash::Sha512 );
5226 else if ( method == QLatin1String(
"sha3_224" ) )
5228 hash = fcnHash( str, QCryptographicHash::Sha3_224 );
5230 else if ( method == QLatin1String(
"sha3_256" ) )
5232 hash = fcnHash( str, QCryptographicHash::Sha3_256 );
5234 else if ( method == QLatin1String(
"sha3_384" ) )
5236 hash = fcnHash( str, QCryptographicHash::Sha3_384 );
5238 else if ( method == QLatin1String(
"sha3_512" ) )
5240 hash = fcnHash( str, QCryptographicHash::Sha3_512 );
5242 #if QT_VERSION >= QT_VERSION_CHECK( 5, 9, 2 ) 5243 else if ( method == QLatin1String(
"keccak_224" ) )
5245 hash = fcnHash( str, QCryptographicHash::Keccak_224 );
5247 else if ( method == QLatin1String(
"keccak_256" ) )
5249 hash = fcnHash( str, QCryptographicHash::Keccak_256 );
5251 else if ( method == QLatin1String(
"keccak_384" ) )
5253 hash = fcnHash( str, QCryptographicHash::Keccak_384 );
5255 else if ( method == QLatin1String(
"keccak_512" ) )
5257 hash = fcnHash( str, QCryptographicHash::Keccak_512 );
5262 parent->
setEvalErrorString( QObject::tr(
"Hash method %1 is not available on this system." ).arg( str ) );
5269 return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Md5 );
5274 return fcnHash( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ), QCryptographicHash::Sha256 );
5283 static QMutex sFunctionsMutex( QMutex::Recursive );
5284 QMutexLocker locker( &sFunctionsMutex );
5286 QList<QgsExpressionFunction *> &functions = *sFunctions();
5288 if ( functions.isEmpty() )
5300 aggParamsArray << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true );
5306 <<
new QgsStaticExpressionFunction( QStringLiteral(
"azimuth" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point_b" ) ), fcnAzimuth, QStringList() << QStringLiteral(
"Math" ) << QStringLiteral(
"GeometryGroup" ) )
5307 <<
new QgsStaticExpressionFunction( QStringLiteral(
"inclination" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point_b" ) ), fcnInclination, QStringList() << QStringLiteral(
"Math" ) << QStringLiteral(
"GeometryGroup" ) )
5308 <<
new QgsStaticExpressionFunction( QStringLiteral(
"project" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"point" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"azimuth" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"elevation" ),
true, M_PI_2 ), fcnProject, QStringLiteral(
"GeometryGroup" ) )
5323 QgsStaticExpressionFunction *randFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"rand" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"max" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"seed" ),
true ), fcnRnd, QStringLiteral(
"Math" ) );
5325 functions << randFunc;
5327 QgsStaticExpressionFunction *randfFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"randf" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"min" ),
true, 0.0 ) << QgsExpressionFunction::Parameter( QStringLiteral(
"max" ),
true, 1.0 ) << QgsExpressionFunction::Parameter( QStringLiteral(
"seed" ),
true ), fcnRndF, QStringLiteral(
"Math" ) );
5329 functions << randfFunc;
5332 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max" ), -1, fcnMax, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5333 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min" ), -1, fcnMin, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5334 <<
new QgsStaticExpressionFunction( QStringLiteral(
"clamp" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"max" ) ), fcnClamp, QStringLiteral(
"Math" ) )
5335 <<
new QgsStaticExpressionFunction( QStringLiteral(
"scale_linear" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"val" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"domain_min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"domain_max" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"range_min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"range_max" ) ), fcnLinearScale, QStringLiteral(
"Math" ) )
5336 <<
new QgsStaticExpressionFunction( QStringLiteral(
"scale_exp" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"val" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"domain_min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"domain_max" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"range_min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"range_max" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"exponent" ) ), fcnExpScale, QStringLiteral(
"Math" ) )
5337 <<
new QgsStaticExpressionFunction( QStringLiteral(
"floor" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnFloor, QStringLiteral(
"Math" ) )
5338 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ceil" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnCeil, QStringLiteral(
"Math" ) )
5339 <<
new QgsStaticExpressionFunction( QStringLiteral(
"pi" ), 0, fcnPi, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$pi" ) )
5340 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_int" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToInt, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"toint" ) )
5341 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_real" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToReal, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"toreal" ) )
5342 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_string" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToString, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"String" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"tostring" ) )
5343 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_datetime" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ),
true, QVariant() ) << QgsExpressionFunction::Parameter( QStringLiteral(
"language" ),
true, QVariant() ), fcnToDateTime, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todatetime" ) )
5344 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_date" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ),
true, QVariant() ) << QgsExpressionFunction::Parameter( QStringLiteral(
"language" ),
true, QVariant() ), fcnToDate, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todate" ) )
5345 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_time" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ),
true, QVariant() ) << QgsExpressionFunction::Parameter( QStringLiteral(
"language" ),
true, QVariant() ), fcnToTime, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"totime" ) )
5346 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_interval" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToInterval, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"tointerval" ) )
5347 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_dm" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"axis" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"precision" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"formatting" ),
true ), fcnToDegreeMinute, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todm" ) )
5348 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_dms" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"axis" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"precision" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"formatting" ),
true ), fcnToDegreeMinuteSecond, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todms" ) )
5349 <<
new QgsStaticExpressionFunction( QStringLiteral(
"coalesce" ), -1, fcnCoalesce, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5350 <<
new QgsStaticExpressionFunction( QStringLiteral(
"nullif" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value2" ) ), fcnNullIf, QStringLiteral(
"Conditionals" ) )
5351 <<
new QgsStaticExpressionFunction( QStringLiteral(
"if" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"condition" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"result_when_true" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"result_when_false" ) ), fcnIf, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
true )
5352 <<
new QgsStaticExpressionFunction( QStringLiteral(
"try" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"alternative" ),
true, QVariant() ), fcnTry, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
true )
5354 <<
new QgsStaticExpressionFunction( QStringLiteral(
"aggregate" ),
5356 << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5357 << QgsExpressionFunction::Parameter( QStringLiteral(
"aggregate" ) )
5358 << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ),
false, QVariant(),
true )
5359 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter" ),
true, QVariant(),
true )
5360 << QgsExpressionFunction::Parameter( QStringLiteral(
"concatenator" ),
true )
5361 << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true ),
5363 QStringLiteral(
"Aggregates" ),
5372 if ( !node->
args() )
5375 QSet<QString> referencedVars;
5387 return referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() );
5396 if ( !node->
args() )
5397 return QSet<QString>();
5399 QSet<QString> referencedCols;
5400 QSet<QString> referencedVars;
5415 if ( referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() ) )
5418 return referencedCols;
5424 << QgsExpressionFunction::Parameter( QStringLiteral(
"relation" ) )
5425 << QgsExpressionFunction::Parameter( QStringLiteral(
"aggregate" ) )
5426 << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ),
false, QVariant(),
true )
5427 << QgsExpressionFunction::Parameter( QStringLiteral(
"concatenator" ),
true )
5428 << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true ),
5431 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count" ), aggParams, fcnAggregateCount, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5432 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_distinct" ), aggParams, fcnAggregateCountDistinct, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5433 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_missing" ), aggParams, fcnAggregateCountMissing, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5434 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minimum" ), aggParams, fcnAggregateMin, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5435 <<
new QgsStaticExpressionFunction( QStringLiteral(
"maximum" ), aggParams, fcnAggregateMax, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5436 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sum" ), aggParams, fcnAggregateSum, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5437 <<
new QgsStaticExpressionFunction( QStringLiteral(
"mean" ), aggParams, fcnAggregateMean, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5438 <<
new QgsStaticExpressionFunction( QStringLiteral(
"median" ), aggParams, fcnAggregateMedian, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5439 <<
new QgsStaticExpressionFunction( QStringLiteral(
"stdev" ), aggParams, fcnAggregateStdev, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5440 <<
new QgsStaticExpressionFunction( QStringLiteral(
"range" ), aggParams, fcnAggregateRange, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5441 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minority" ), aggParams, fcnAggregateMinority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5442 <<
new QgsStaticExpressionFunction( QStringLiteral(
"majority" ), aggParams, fcnAggregateMajority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5443 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q1" ), aggParams, fcnAggregateQ1, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5444 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q3" ), aggParams, fcnAggregateQ3, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5445 <<
new QgsStaticExpressionFunction( QStringLiteral(
"iqr" ), aggParams, fcnAggregateIQR, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5446 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min_length" ), aggParams, fcnAggregateMinLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5447 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max_length" ), aggParams, fcnAggregateMaxLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5448 <<
new QgsStaticExpressionFunction( QStringLiteral(
"collect" ), aggParams, fcnAggregateCollectGeometry, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5449 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concatenate" ), aggParamsConcat, fcnAggregateStringConcat, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5450 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concatenate_unique" ), aggParamsConcat, fcnAggregateStringConcatUnique, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5451 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_agg" ), aggParamsArray, fcnAggregateArray, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5453 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_match" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) ), fcnRegexpMatch, QStringList() << QStringLiteral(
"Conditionals" ) << QStringLiteral(
"String" ) )
5454 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_matches" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"emptyvalue" ),
true,
"" ), fcnRegexpMatches, QStringLiteral(
"Arrays" ) )
5456 <<
new QgsStaticExpressionFunction( QStringLiteral(
"now" ), 0, fcnNow, QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$now" ) )
5458 << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime2" ) ),
5459 fcnAge, QStringLiteral(
"Date and Time" ) )
5460 <<
new QgsStaticExpressionFunction( QStringLiteral(
"year" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnYear, QStringLiteral(
"Date and Time" ) )
5461 <<
new QgsStaticExpressionFunction( QStringLiteral(
"month" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnMonth, QStringLiteral(
"Date and Time" ) )
5462 <<
new QgsStaticExpressionFunction( QStringLiteral(
"week" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnWeek, QStringLiteral(
"Date and Time" ) )
5463 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnDay, QStringLiteral(
"Date and Time" ) )
5464 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hour" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), fcnHour, QStringLiteral(
"Date and Time" ) )
5465 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minute" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), fcnMinute, QStringLiteral(
"Date and Time" ) )
5466 <<
new QgsStaticExpressionFunction( QStringLiteral(
"second" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), fcnSeconds, QStringLiteral(
"Date and Time" ) )
5467 <<
new QgsStaticExpressionFunction( QStringLiteral(
"epoch" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnEpoch, QStringLiteral(
"Date and Time" ) )
5468 <<
new QgsStaticExpressionFunction( QStringLiteral(
"datetime_from_epoch" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"long" ) ), fcnDateTimeFromEpoch, QStringLiteral(
"Date and Time" ) )
5469 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day_of_week" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnDayOfWeek, QStringLiteral(
"Date and Time" ) )
5470 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lower" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnLower, QStringLiteral(
"String" ) )
5471 <<
new QgsStaticExpressionFunction( QStringLiteral(
"upper" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnUpper, QStringLiteral(
"String" ) )
5472 <<
new QgsStaticExpressionFunction( QStringLiteral(
"title" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnTitle, QStringLiteral(
"String" ) )
5473 <<
new QgsStaticExpressionFunction( QStringLiteral(
"trim" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnTrim, QStringLiteral(
"String" ) )
5474 <<
new QgsStaticExpressionFunction( QStringLiteral(
"levenshtein" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"string2" ) ), fcnLevenshtein, QStringLiteral(
"Fuzzy Matching" ) )
5475 <<
new QgsStaticExpressionFunction( QStringLiteral(
"longest_common_substring" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"string2" ) ), fcnLCS, QStringLiteral(
"Fuzzy Matching" ) )
5476 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hamming_distance" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"string2" ) ), fcnHamming, QStringLiteral(
"Fuzzy Matching" ) )
5477 <<
new QgsStaticExpressionFunction( QStringLiteral(
"soundex" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnSoundex, QStringLiteral(
"Fuzzy Matching" ) )
5478 <<
new QgsStaticExpressionFunction( QStringLiteral(
"char" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"code" ) ), fcnChar, QStringLiteral(
"String" ) )
5479 <<
new QgsStaticExpressionFunction( QStringLiteral(
"wordwrap" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"text" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"delimiter" ),
true,
"" ), fcnWordwrap, QStringLiteral(
"String" ) )
5480 <<
new QgsStaticExpressionFunction( QStringLiteral(
"length" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"text" ),
true,
"" ), fcnLength, QStringList() << QStringLiteral(
"String" ) << QStringLiteral(
"GeometryGroup" ) )
5481 <<
new QgsStaticExpressionFunction( QStringLiteral(
"replace" ), -1, fcnReplace, QStringLiteral(
"String" ) )
5482 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_replace" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"input_string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) )
5483 << QgsExpressionFunction::Parameter( QStringLiteral(
"replacement" ) ), fcnRegexpReplace, QStringLiteral(
"String" ) )
5484 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_substr" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"input_string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) ), fcnRegexpSubstr, QStringLiteral(
"String" ) )
5485 <<
new QgsStaticExpressionFunction( QStringLiteral(
"substr" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"start " ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ),
true ), fcnSubstr, QStringLiteral(
"String" ), QString(),
5486 false, QSet< QString >(),
false, QStringList(),
true )
5487 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concat" ), -1, fcnConcat, QStringLiteral(
"String" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5488 <<
new QgsStaticExpressionFunction( QStringLiteral(
"strpos" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"haystack" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"needle" ) ), fcnStrpos, QStringLiteral(
"String" ) )
5489 <<
new QgsStaticExpressionFunction( QStringLiteral(
"left" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ) ), fcnLeft, QStringLiteral(
"String" ) )
5490 <<
new QgsStaticExpressionFunction( QStringLiteral(
"right" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ) ), fcnRight, QStringLiteral(
"String" ) )
5491 <<
new QgsStaticExpressionFunction( QStringLiteral(
"rpad" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"width" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"fill" ) ), fcnRPad, QStringLiteral(
"String" ) )
5492 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lpad" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"width" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"fill" ) ), fcnLPad, QStringLiteral(
"String" ) )
5493 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format" ), -1, fcnFormatString, QStringLiteral(
"String" ) )
5494 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format_number" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"number" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"places" ) ), fcnFormatNumber, QStringLiteral(
"String" ) )
5495 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format_date" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"language" ),
true, QVariant() ), fcnFormatDate, QStringList() << QStringLiteral(
"String" ) << QStringLiteral(
"Date and Time" ) )
5496 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_grayscale_average" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"color" ) ), fcnColorGrayscaleAverage, QStringLiteral(
"Color" ) )
5497 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_mix_rgb" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"color1" ) )
5498 << QgsExpressionFunction::Parameter( QStringLiteral(
"color2" ) )
5499 << QgsExpressionFunction::Parameter( QStringLiteral(
"ratio" ) ),
5500 fcnColorMixRgb, QStringLiteral(
"Color" ) )
5502 << QgsExpressionFunction::Parameter( QStringLiteral(
"green" ) )
5503 << QgsExpressionFunction::Parameter( QStringLiteral(
"blue" ) ),
5504 fcnColorRgb, QStringLiteral(
"Color" ) )
5506 << QgsExpressionFunction::Parameter( QStringLiteral(
"green" ) )
5507 << QgsExpressionFunction::Parameter( QStringLiteral(
"blue" ) )
5508 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
5509 fncColorRgba, QStringLiteral(
"Color" ) )
5510 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ramp_color" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"ramp_name" ) )
5511 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ),
5514 << QgsExpressionFunction::Parameter( QStringLiteral(
"discrete" ),
true,
false ),
5515 fcnCreateRamp, QStringLiteral(
"Color" ) )
5517 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
5518 << QgsExpressionFunction::Parameter( QStringLiteral(
"lightness" ) ),
5519 fcnColorHsl, QStringLiteral(
"Color" ) )
5521 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
5522 << QgsExpressionFunction::Parameter( QStringLiteral(
"lightness" ) )
5523 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
5524 fncColorHsla, QStringLiteral(
"Color" ) )
5526 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
5527 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ),
5528 fcnColorHsv, QStringLiteral(
"Color" ) )
5530 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
5531 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) )
5532 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
5533 fncColorHsva, QStringLiteral(
"Color" ) )
5535 << QgsExpressionFunction::Parameter( QStringLiteral(
"magenta" ) )
5536 << QgsExpressionFunction::Parameter( QStringLiteral(
"yellow" ) )
5537 << QgsExpressionFunction::Parameter( QStringLiteral(
"black" ) ),
5538 fcnColorCmyk, QStringLiteral(
"Color" ) )
5540 << QgsExpressionFunction::Parameter( QStringLiteral(
"magenta" ) )
5541 << QgsExpressionFunction::Parameter( QStringLiteral(
"yellow" ) )
5542 << QgsExpressionFunction::Parameter( QStringLiteral(
"black" ) )
5543 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
5544 fncColorCmyka, QStringLiteral(
"Color" ) )
5546 << QgsExpressionFunction::Parameter( QStringLiteral(
"component" ) ),
5547 fncColorPart, QStringLiteral(
"Color" ) )
5549 << QgsExpressionFunction::Parameter( QStringLiteral(
"factor" ) ),
5550 fncDarker, QStringLiteral(
"Color" ) )
5552 << QgsExpressionFunction::Parameter( QStringLiteral(
"factor" ) ),
5553 fncLighter, QStringLiteral(
"Color" ) )
5554 <<
new QgsStaticExpressionFunction( QStringLiteral(
"set_color_part" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"color" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"component" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fncSetColorPart, QStringLiteral(
"Color" ) )
5557 <<
new QgsStaticExpressionFunction( QStringLiteral(
"base_file_name" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"path" ) ),
5558 fcnBaseFileName, QStringLiteral(
"Files and Paths" ) )
5560 fcnFileSuffix, QStringLiteral(
"Files and Paths" ) )
5562 fcnFileExists, QStringLiteral(
"Files and Paths" ) )
5564 fcnFileName, QStringLiteral(
"Files and Paths" ) )
5566 fcnPathIsFile, QStringLiteral(
"Files and Paths" ) )
5568 fcnPathIsDir, QStringLiteral(
"Files and Paths" ) )
5570 fcnFilePath, QStringLiteral(
"Files and Paths" ) )
5572 fcnFileSize, QStringLiteral(
"Files and Paths" ) )
5575 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hash" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"method" ) ),
5576 fcnGenericHash, QStringLiteral(
"Conversions" ) )
5578 fcnHashMd5, QStringLiteral(
"Conversions" ) )
5580 fcnHashSha256, QStringLiteral(
"Conversions" ) )
5585 QgsStaticExpressionFunction *geomFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$geometry" ), 0, fcnGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5587 functions << geomFunc;
5589 QgsStaticExpressionFunction *areaFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$area" ), 0, fcnGeomArea, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5591 functions << areaFunc;
5593 functions <<
new QgsStaticExpressionFunction( QStringLiteral(
"area" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnArea, QStringLiteral(
"GeometryGroup" ) );
5595 QgsStaticExpressionFunction *lengthFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$length" ), 0, fcnGeomLength, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5597 functions << lengthFunc;
5599 QgsStaticExpressionFunction *perimeterFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$perimeter" ), 0, fcnGeomPerimeter, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5601 functions << perimeterFunc;
5603 functions <<
new QgsStaticExpressionFunction( QStringLiteral(
"perimeter" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnPerimeter, QStringLiteral(
"GeometryGroup" ) );
5605 QgsStaticExpressionFunction *xFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$x" ), 0, fcnX, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5609 QgsStaticExpressionFunction *yFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$y" ), 0, fcnY, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5614 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_valid" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomIsValid, QStringLiteral(
"GeometryGroup" ) )
5615 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomX, QStringLiteral(
"GeometryGroup" ) )
5616 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomY, QStringLiteral(
"GeometryGroup" ) )
5617 <<
new QgsStaticExpressionFunction( QStringLiteral(
"z" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomZ, QStringLiteral(
"GeometryGroup" ) )
5618 <<
new QgsStaticExpressionFunction( QStringLiteral(
"m" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomM, QStringLiteral(
"GeometryGroup" ) )
5619 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_n" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"index" ) ), fcnPointN, QStringLiteral(
"GeometryGroup" ) )
5620 <<
new QgsStaticExpressionFunction( QStringLiteral(
"start_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnStartPoint, QStringLiteral(
"GeometryGroup" ) )
5621 <<
new QgsStaticExpressionFunction( QStringLiteral(
"end_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnEndPoint, QStringLiteral(
"GeometryGroup" ) )
5622 <<
new QgsStaticExpressionFunction( QStringLiteral(
"nodes_to_points" ), -1, fcnNodesToPoints, QStringLiteral(
"GeometryGroup" ) )
5623 <<
new QgsStaticExpressionFunction( QStringLiteral(
"segments_to_lines" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnSegmentsToLines, QStringLiteral(
"GeometryGroup" ) )
5624 <<
new QgsStaticExpressionFunction( QStringLiteral(
"collect_geometries" ), -1, fcnCollectGeometries, QStringLiteral(
"GeometryGroup" ) )
5625 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_point" ), -1, fcnMakePoint, QStringLiteral(
"GeometryGroup" ) )
5627 << QgsExpressionFunction::Parameter( QStringLiteral(
"y" ) )
5628 << QgsExpressionFunction::Parameter( QStringLiteral(
"m" ) ),
5629 fcnMakePointM, QStringLiteral(
"GeometryGroup" ) )
5630 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_line" ), -1, fcnMakeLine, QStringLiteral(
"GeometryGroup" ) )
5631 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_polygon" ), -1, fcnMakePolygon, QStringLiteral(
"GeometryGroup" ) )
5632 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_triangle" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5633 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5634 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
5635 fcnMakeTriangle, QStringLiteral(
"GeometryGroup" ) )
5637 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5638 << QgsExpressionFunction::Parameter( QStringLiteral(
"radius" ) )
5639 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 36 ),
5640 fcnMakeCircle, QStringLiteral(
"GeometryGroup" ) )
5642 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5643 << QgsExpressionFunction::Parameter( QStringLiteral(
"semi_major_axis" ) )
5644 << QgsExpressionFunction::Parameter( QStringLiteral(
"semi_minor_axis" ) )
5645 << QgsExpressionFunction::Parameter( QStringLiteral(
"azimuth" ) )
5646 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 36 ),
5647 fcnMakeEllipse, QStringLiteral(
"GeometryGroup" ) )
5649 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5650 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5651 << QgsExpressionFunction::Parameter( QStringLiteral(
"number_sides" ) )
5652 << QgsExpressionFunction::Parameter( QStringLiteral(
"circle" ),
true, 0 ),
5653 fcnMakeRegularPolygon, QStringLiteral(
"GeometryGroup" ) )
5655 << QgsExpressionFunction::Parameter( QStringLiteral(
"point1" ) )
5656 << QgsExpressionFunction::Parameter( QStringLiteral(
"point2" ) ),
5657 fcnMakeSquare, QStringLiteral(
"GeometryGroup" ) )
5659 << QgsExpressionFunction::Parameter( QStringLiteral(
"point1" ) )
5660 << QgsExpressionFunction::Parameter( QStringLiteral(
"point2" ) )
5661 << QgsExpressionFunction::Parameter( QStringLiteral(
"point3" ) )
5662 << QgsExpressionFunction::Parameter( QStringLiteral(
"option" ),
true, 0 ),
5663 fcnMakeRectangleFrom3Points, QStringLiteral(
"GeometryGroup" ) );
5664 QgsStaticExpressionFunction *xAtFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$x_at" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"i" ) ), fcnXat, QStringLiteral(
"GeometryGroup" ), QString(),
true, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xat" ) << QStringLiteral(
"x_at" ) );
5666 functions << xAtFunc;
5668 QgsStaticExpressionFunction *yAtFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$y_at" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"i" ) ), fcnYat, QStringLiteral(
"GeometryGroup" ), QString(),
true, QSet<QString>(),
false, QStringList() << QStringLiteral(
"yat" ) << QStringLiteral(
"y_at" ) );
5670 functions << yAtFunc;
5673 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_min" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnXMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmin" ) )
5674 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_max" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnXMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmax" ) )
5675 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_min" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnYMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymin" ) )
5676 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_max" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnYMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymax" ) )
5677 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_wkt" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"text" ) ), fcnGeomFromWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromWKT" ) )
5678 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_wkb" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"binary" ) ), fcnGeomFromWKB, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false )
5679 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_gml" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"gml" ) ), fcnGeomFromGML, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromGML" ) )
5680 <<
new QgsStaticExpressionFunction( QStringLiteral(
"flip_coordinates" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnFlipCoordinates, QStringLiteral(
"GeometryGroup" ) )
5681 <<
new QgsStaticExpressionFunction( QStringLiteral(
"relate" ), -1, fcnRelate, QStringLiteral(
"GeometryGroup" ) )
5682 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersects_bbox" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnBbox, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"bbox" ) )
5684 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5685 fcnDisjoint, QStringLiteral(
"GeometryGroup" ) )
5686 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersects" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry a" ) )
5687 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5688 fcnIntersects, QStringLiteral(
"GeometryGroup" ) )
5690 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5691 fcnTouches, QStringLiteral(
"GeometryGroup" ) )
5693 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5694 fcnCrosses, QStringLiteral(
"GeometryGroup" ) )
5696 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5697 fcnContains, QStringLiteral(
"GeometryGroup" ) )
5699 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5700 fcnOverlaps, QStringLiteral(
"GeometryGroup" ) )
5702 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5703 fcnWithin, QStringLiteral(
"GeometryGroup" ) )
5705 << QgsExpressionFunction::Parameter( QStringLiteral(
"dx" ) )
5706 << QgsExpressionFunction::Parameter( QStringLiteral(
"dy" ) ),
5707 fcnTranslate, QStringLiteral(
"GeometryGroup" ) )
5709 << QgsExpressionFunction::Parameter( QStringLiteral(
"rotation" ) )
5710 << QgsExpressionFunction::Parameter( QStringLiteral(
"center" ),
true ),
5711 fcnRotate, QStringLiteral(
"GeometryGroup" ) )
5712 <<
new QgsStaticExpressionFunction( QStringLiteral(
"buffer" ), -1, fcnBuffer, QStringLiteral(
"GeometryGroup" ) )
5714 fcnForceRHR, QStringLiteral(
"GeometryGroup" ) )
5716 << QgsExpressionFunction::Parameter( QStringLiteral(
"azimuth" ) )
5717 << QgsExpressionFunction::Parameter( QStringLiteral(
"width" ) )
5718 << QgsExpressionFunction::Parameter( QStringLiteral(
"outer_radius" ) )
5719 << QgsExpressionFunction::Parameter( QStringLiteral(
"inner_radius" ),
true, 0.0 ), fcnWedgeBuffer, QStringLiteral(
"GeometryGroup" ) )
5720 <<
new QgsStaticExpressionFunction( QStringLiteral(
"tapered_buffer" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5721 << QgsExpressionFunction::Parameter( QStringLiteral(
"start_width" ) )
5722 << QgsExpressionFunction::Parameter( QStringLiteral(
"end_width" ) )
5723 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
5724 , fcnTaperedBuffer, QStringLiteral(
"GeometryGroup" ) )
5725 <<
new QgsStaticExpressionFunction( QStringLiteral(
"buffer_by_m" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5726 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
5727 , fcnBufferByM, QStringLiteral(
"GeometryGroup" ) )
5728 <<
new QgsStaticExpressionFunction( QStringLiteral(
"offset_curve" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5729 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) )
5730 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
5732 << QgsExpressionFunction::Parameter( QStringLiteral(
"miter_limit" ),
true, 2.0 ),
5733 fcnOffsetCurve, QStringLiteral(
"GeometryGroup" ) )
5734 <<
new QgsStaticExpressionFunction( QStringLiteral(
"single_sided_buffer" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5735 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) )
5736 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
5738 << QgsExpressionFunction::Parameter( QStringLiteral(
"miter_limit" ),
true, 2.0 ),
5739 fcnSingleSidedBuffer, QStringLiteral(
"GeometryGroup" ) )
5741 << QgsExpressionFunction::Parameter( QStringLiteral(
"start_distance" ) )
5742 << QgsExpressionFunction::Parameter( QStringLiteral(
"end_distance" ) ),
5743 fcnExtend, QStringLiteral(
"GeometryGroup" ) )
5744 <<
new QgsStaticExpressionFunction( QStringLiteral(
"centroid" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnCentroid, QStringLiteral(
"GeometryGroup" ) )
5745 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_on_surface" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnPointOnSurface, QStringLiteral(
"GeometryGroup" ) )
5746 <<
new QgsStaticExpressionFunction( QStringLiteral(
"pole_of_inaccessibility" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5747 << QgsExpressionFunction::Parameter( QStringLiteral(
"tolerance" ) ), fcnPoleOfInaccessibility, QStringLiteral(
"GeometryGroup" ) )
5748 <<
new QgsStaticExpressionFunction( QStringLiteral(
"reverse" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnReverse, QStringLiteral(
"GeometryGroup" ) )
5749 <<
new QgsStaticExpressionFunction( QStringLiteral(
"exterior_ring" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnExteriorRing, QStringLiteral(
"GeometryGroup" ) )
5750 <<
new QgsStaticExpressionFunction( QStringLiteral(
"interior_ring_n" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5751 << QgsExpressionFunction::Parameter( QStringLiteral(
"index" ) ),
5752 fcnInteriorRingN, QStringLiteral(
"GeometryGroup" ) )
5754 << QgsExpressionFunction::Parameter( QStringLiteral(
"index" ) ),
5755 fcnGeometryN, QStringLiteral(
"GeometryGroup" ) )
5756 <<
new QgsStaticExpressionFunction( QStringLiteral(
"boundary" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnBoundary, QStringLiteral(
"GeometryGroup" ) )
5757 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_merge" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnLineMerge, QStringLiteral(
"GeometryGroup" ) )
5758 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnBounds, QStringLiteral(
"GeometryGroup" ) )
5759 <<
new QgsStaticExpressionFunction( QStringLiteral(
"simplify" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"tolerance" ) ), fcnSimplify, QStringLiteral(
"GeometryGroup" ) )
5760 <<
new QgsStaticExpressionFunction( QStringLiteral(
"simplify_vw" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"tolerance" ) ), fcnSimplifyVW, QStringLiteral(
"GeometryGroup" ) )
5761 <<
new QgsStaticExpressionFunction( QStringLiteral(
"smooth" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"iterations" ),
true, 1 )
5762 << QgsExpressionFunction::Parameter( QStringLiteral(
"offset" ),
true, 0.25 )
5763 << QgsExpressionFunction::Parameter( QStringLiteral(
"min_length" ),
true, -1 )
5764 << QgsExpressionFunction::Parameter( QStringLiteral(
"max_angle" ),
true, 180 ), fcnSmooth, QStringLiteral(
"GeometryGroup" ) )
5765 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_points" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomNumPoints, QStringLiteral(
"GeometryGroup" ) )
5766 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_interior_rings" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumInteriorRings, QStringLiteral(
"GeometryGroup" ) )
5767 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_rings" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumRings, QStringLiteral(
"GeometryGroup" ) )
5768 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_geometries" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumGeometries, QStringLiteral(
"GeometryGroup" ) )
5769 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_width" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnBoundsWidth, QStringLiteral(
"GeometryGroup" ) )
5770 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_height" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnBoundsHeight, QStringLiteral(
"GeometryGroup" ) )
5771 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_closed" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnIsClosed, QStringLiteral(
"GeometryGroup" ) )
5772 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_empty" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnIsEmpty, QStringLiteral(
"GeometryGroup" ) )
5773 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_empty_or_null" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnIsEmptyOrNull, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5774 <<
new QgsStaticExpressionFunction( QStringLiteral(
"convex_hull" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnConvexHull, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"convexHull" ) )
5776 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
5777 fcnOrientedBBox, QStringLiteral(
"GeometryGroup" ) )
5779 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5780 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 36 ),
5781 fcnMinimalCircle, QStringLiteral(
"GeometryGroup" ) )
5782 <<
new QgsStaticExpressionFunction( QStringLiteral(
"difference" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry_a" ) )
5783 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry_b" ) ),
5784 fcnDifference, QStringLiteral(
"GeometryGroup" ) )
5786 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5787 fcnDistance, QStringLiteral(
"GeometryGroup" ) )
5788 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hausdorff_distance" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) )
5789 << QgsExpressionFunction::Parameter( QStringLiteral(
"densify_fraction" ),
true ),
5790 fcnHausdorffDistance, QStringLiteral(
"GeometryGroup" ) )
5791 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersection" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry_a" ) )
5792 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry_b" ) ),
5793 fcnIntersection, QStringLiteral(
"GeometryGroup" ) )
5794 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sym_difference" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
5795 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5796 fcnSymDifference, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"symDifference" ) )
5798 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5799 fcnCombine, QStringLiteral(
"GeometryGroup" ) )
5801 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5802 fcnCombine, QStringLiteral(
"GeometryGroup" ) )
5803 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_to_wkt" ), -1, fcnGeomToWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomToWKT" ) )
5804 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_to_wkb" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomToWKB, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false )
5805 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geometry" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"feature" ) ), fcnGetGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true )
5807 << QgsExpressionFunction::Parameter( QStringLiteral(
"source_auth_id" ) )
5808 << QgsExpressionFunction::Parameter( QStringLiteral(
"dest_auth_id" ) ),
5809 fcnTransformGeometry, QStringLiteral(
"GeometryGroup" ) )
5811 << QgsExpressionFunction::Parameter( QStringLiteral(
"x" ) )
5812 << QgsExpressionFunction::Parameter( QStringLiteral(
"y" ) ),
5813 fcnExtrude, QStringLiteral(
"GeometryGroup" ), QString() );
5815 QgsStaticExpressionFunction *orderPartsFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"order_parts" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) )
5816 << QgsExpressionFunction::Parameter( QStringLiteral(
"orderby" ) )
5817 << QgsExpressionFunction::Parameter( QStringLiteral(
"ascending" ) ),
5818 fcnOrderParts, QStringLiteral(
"GeometryGroup" ), QString() );
5823 const QList< QgsExpressionNode *> argList = node->
args()->
list();
5826 if ( !argNode->isStatic( parent, context ) )
5834 QString expString = argNode->
eval( parent, context ).toString();
5850 QString expression = argNode->
eval( parent, context ).toString();
5858 functions << orderPartsFunc;
5861 <<
new QgsStaticExpressionFunction( QStringLiteral(
"closest_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
5862 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5863 fcnClosestPoint, QStringLiteral(
"GeometryGroup" ) )
5864 <<
new QgsStaticExpressionFunction( QStringLiteral(
"shortest_line" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
5865 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5866 fcnShortestLine, QStringLiteral(
"GeometryGroup" ) )
5867 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_interpolate_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5868 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) ), fcnLineInterpolatePoint, QStringLiteral(
"GeometryGroup" ) )
5869 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_interpolate_angle" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5870 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) ), fcnLineInterpolateAngle, QStringLiteral(
"GeometryGroup" ) )
5871 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_locate_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5872 << QgsExpressionFunction::Parameter( QStringLiteral(
"point" ) ), fcnLineLocatePoint, QStringLiteral(
"GeometryGroup" ) )
5873 <<
new QgsStaticExpressionFunction( QStringLiteral(
"angle_at_vertex" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5874 << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ) ), fcnAngleAtVertex, QStringLiteral(
"GeometryGroup" ) )
5875 <<
new QgsStaticExpressionFunction( QStringLiteral(
"distance_to_vertex" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5876 << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ) ), fcnDistanceToVertex, QStringLiteral(
"GeometryGroup" ) )
5877 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_substring" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5878 << QgsExpressionFunction::Parameter( QStringLiteral(
"start_distance" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"end_distance" ) ), fcnLineSubset, QStringLiteral(
"GeometryGroup" ) );
5883 QgsStaticExpressionFunction *idFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$id" ), 0, fcnFeatureId, QStringLiteral(
"Record and Attributes" ) );
5885 functions << idFunc;
5887 QgsStaticExpressionFunction *currentFeatureFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$currentfeature" ), 0, fcnFeature, QStringLiteral(
"Record and Attributes" ) );
5889 functions << currentFeatureFunc;
5891 QgsStaticExpressionFunction *uuidFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"uuid" ), 0, fcnUuid, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$uuid" ) );
5893 functions << uuidFunc;
5897 << QgsExpressionFunction::Parameter( QStringLiteral(
"attribute" ) )
5898 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ),
5899 fcnGetFeature, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"QgsExpressionUtils::getFeature" ) )
5900 <<
new QgsStaticExpressionFunction( QStringLiteral(
"get_feature_by_id" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5901 << QgsExpressionFunction::Parameter( QStringLiteral(
"feature_id" ) ),
5902 fcnGetFeatureById, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false )
5903 <<
new QgsStaticExpressionFunction( QStringLiteral(
"attributes" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"feature" ),
true ),
5906 QgsStaticExpressionFunction *isSelectedFunc =
new QgsStaticExpressionFunction(
5907 QStringLiteral(
"is_selected" ),
5910 QStringLiteral(
"Record and Attributes" ),
5916 functions << isSelectedFunc;
5919 <<
new QgsStaticExpressionFunction(
5920 QStringLiteral(
"num_selected" ),
5923 QStringLiteral(
"Record and Attributes" ),
5930 <<
new QgsStaticExpressionFunction(
5931 QStringLiteral(
"sqlite_fetch_and_increment" ),
5933 << QgsExpressionFunction::Parameter( QStringLiteral(
"database" ) )
5934 << QgsExpressionFunction::Parameter( QStringLiteral(
"table" ) )
5935 << QgsExpressionFunction::Parameter( QStringLiteral(
"id_field" ) )
5936 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter_attribute" ) )
5937 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter_value" ) )
5938 << QgsExpressionFunction::Parameter( QStringLiteral(
"default_values" ),
true ),
5939 fcnSqliteFetchAndIncrement,
5940 QStringLiteral(
"Record and Attributes" )
5944 QgsStaticExpressionFunction *representValueFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"represent_value" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"attribute" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"field_name" ),
true ), fcnRepresentValue, QStringLiteral(
"Record and Attributes" ) );
5958 parent->
setEvalErrorString( tr(
"If represent_value is called with 1 parameter, it must be an attribute." ) );
5968 parent->
setEvalErrorString( tr(
"represent_value must be called with exactly 1 or 2 parameters." ) );
5974 functions << representValueFunc;
5978 <<
new QgsStaticExpressionFunction( QStringLiteral(
"layer_property" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5979 << QgsExpressionFunction::Parameter( QStringLiteral(
"property" ) ),
5980 fcnGetLayerProperty, QStringLiteral(
"General" ) )
5981 <<
new QgsStaticExpressionFunction( QStringLiteral(
"decode_uri" ),
5983 << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5984 << QgsExpressionFunction::Parameter( QStringLiteral(
"part" ),
true ),
5985 fcnDecodeUri, QStringLiteral(
"Map Layers" ) )
5986 <<
new QgsStaticExpressionFunction( QStringLiteral(
"raster_statistic" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5987 << QgsExpressionFunction::Parameter( QStringLiteral(
"band" ) )
5988 << QgsExpressionFunction::Parameter( QStringLiteral(
"statistic" ) ), fcnGetRasterBandStat, QStringLiteral(
"Rasters" ) );
5991 QgsStaticExpressionFunction *varFunction =
new QgsStaticExpressionFunction( QStringLiteral(
"var" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"name" ) ), fcnGetVariable, QStringLiteral(
"General" ) );
6004 if ( !argNode->
isStatic( parent, context ) )
6007 QString varName = argNode->
eval( parent, context ).toString();
6010 return scope ? scope->
isStatic( varName ) :
false;
6026 if ( argNode->
isStatic( parent, context ) )
6028 QString expString = argNode->
eval( parent, context ).toString();
6040 functions << evalFunc;
6042 QgsStaticExpressionFunction *attributeFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"attribute" ), -1, fcnAttribute, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES );
6046 const QList< QgsExpressionNode *> argList = node->
args()->
list();
6049 if ( !argNode->isStatic( parent, context ) )
6061 functions << attributeFunc;
6064 <<
new QgsStaticExpressionFunction( QStringLiteral(
"env" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"name" ) ), fcnEnvVar, QStringLiteral(
"General" ), QString() )
6066 <<
new QgsStaticExpressionFunction( QStringLiteral(
"raster_value" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"band" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point" ) ), fcnRasterValue, QStringLiteral(
"Rasters" ) )
6071 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array" ), -1, fcnArray, QStringLiteral(
"Arrays" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
6072 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_sort" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"ascending" ),
true,
true ), fcnArraySort, QStringLiteral(
"Arrays" ) )
6073 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_length" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayLength, QStringLiteral(
"Arrays" ) )
6074 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_contains" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayContains, QStringLiteral(
"Arrays" ) )
6075 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_all" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"array_b" ) ), fcnArrayAll, QStringLiteral(
"Arrays" ) )
6076 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_find" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayFind, QStringLiteral(
"Arrays" ) )
6077 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_get" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"pos" ) ), fcnArrayGet, QStringLiteral(
"Arrays" ) )
6078 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_first" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayFirst, QStringLiteral(
"Arrays" ) )
6079 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_last" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayLast, QStringLiteral(
"Arrays" ) )
6080 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_append" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayAppend, QStringLiteral(
"Arrays" ) )
6081 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_prepend" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayPrepend, QStringLiteral(
"Arrays" ) )
6082 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_insert" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"pos" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayInsert, QStringLiteral(
"Arrays" ) )
6083 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_remove_at" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"pos" ) ), fcnArrayRemoveAt, QStringLiteral(
"Arrays" ) )
6084 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_remove_all" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayRemoveAll, QStringLiteral(
"Arrays" ) )
6085 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_cat" ), -1, fcnArrayCat, QStringLiteral(
"Arrays" ) )
6086 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_slice" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"start_pos" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"end_pos" ) ), fcnArraySlice, QStringLiteral(
"Arrays" ) )
6087 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_reverse" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayReverse, QStringLiteral(
"Arrays" ) )
6088 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_intersect" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"array2" ) ), fcnArrayIntersect, QStringLiteral(
"Arrays" ) )
6089 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_distinct" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayDistinct, QStringLiteral(
"Arrays" ) )
6090 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_to_string" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"delimiter" ),
true,
"," ) << QgsExpressionFunction::Parameter( QStringLiteral(
"emptyvalue" ),
true,
"" ), fcnArrayToString, QStringLiteral(
"Arrays" ) )
6091 <<
new QgsStaticExpressionFunction( QStringLiteral(
"string_to_array" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"delimiter" ),
true,
"," ) << QgsExpressionFunction::Parameter( QStringLiteral(
"emptyvalue" ),
true,
"" ), fcnStringToArray, QStringLiteral(
"Arrays" ) )
6092 <<
new QgsStaticExpressionFunction( QStringLiteral(
"generate_series" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"start" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"stop" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"step" ),
true, 1.0 ), fcnGenerateSeries, QStringLiteral(
"Arrays" ) )
6095 <<
new QgsStaticExpressionFunction( QStringLiteral(
"json_to_map" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnLoadJson, QStringLiteral(
"Maps" ) )
6096 <<
new QgsStaticExpressionFunction( QStringLiteral(
"from_json" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnLoadJson, QStringLiteral(
"Maps" ) )
6097 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_to_json" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnWriteJson, QStringLiteral(
"Maps" ) )
6098 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_json" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"json_string" ) ), fcnWriteJson, QStringLiteral(
"Maps" ) )
6099 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hstore_to_map" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnHstoreToMap, QStringLiteral(
"Maps" ) )
6100 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_to_hstore" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnMapToHstore, QStringLiteral(
"Maps" ) )
6101 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map" ), -1, fcnMap, QStringLiteral(
"Maps" ) )
6102 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_get" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ), fcnMapGet, QStringLiteral(
"Maps" ) )
6103 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_exist" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ), fcnMapExist, QStringLiteral(
"Maps" ) )
6104 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_delete" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ), fcnMapDelete, QStringLiteral(
"Maps" ) )
6105 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_insert" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnMapInsert, QStringLiteral(
"Maps" ) )
6106 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_concat" ), -1, fcnMapConcat, QStringLiteral(
"Maps" ) )
6107 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_akeys" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnMapAKeys, QStringLiteral(
"Maps" ) )
6108 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_avals" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnMapAVals, QStringLiteral(
"Maps" ) )
6116 *sOwnedFunctions() <<
func;
6117 *sBuiltinFunctions() <<
func->name();
6118 sBuiltinFunctions()->append(
func->aliases() );
6126 int fnIdx = functionIndex( function->name() );
6131 sFunctions()->append(
function );
6132 if ( transferOwnership )
6133 sOwnedFunctions()->append(
function );
6144 int fnIdx = functionIndex( name );
6147 sFunctions()->removeAt( fnIdx );
6155 qDeleteAll( *sOwnedFunctions() );
6156 sOwnedFunctions()->clear();
6161 if ( sBuiltinFunctions()->isEmpty() )
6165 return *sBuiltinFunctions();
6173 QStringLiteral(
"Arrays" ) )
6184 if ( args->
count() < 2 )
6187 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
6197 QVariantList result;
6199 if ( args->
count() < 2 )
6203 QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
6206 std::unique_ptr< QgsExpressionContext > tempContext;
6209 tempContext = qgis::make_unique< QgsExpressionContext >();
6210 subContext = tempContext.get();
6216 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
6219 result << args->
at( 1 )->
eval( parent, subContext );
6244 if ( args->
count() < 2 )
6248 args->
at( 0 )->
prepare( parent, context );
6252 subContext = *context;
6258 args->
at( 1 )->
prepare( parent, &subContext );
6267 QStringLiteral(
"Arrays" ) )
6278 if ( args->
count() < 2 )
6281 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
6291 QVariantList result;
6293 if ( args->
count() < 2 )
6297 const QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
6300 std::unique_ptr< QgsExpressionContext > tempContext;
6303 tempContext = qgis::make_unique< QgsExpressionContext >();
6304 subContext = tempContext.get();
6310 for (
const QVariant &value : array )
6313 if ( args->
at( 1 )->
eval( parent, subContext ).toBool() )
6339 if ( args->
count() < 2 )
6343 args->
at( 0 )->
prepare( parent, context );
6347 subContext = *context;
6353 args->
at( 1 )->
prepare( parent, &subContext );
6362 QStringLiteral(
"General" ) )
6373 if ( args->
count() < 3 )
6377 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
6379 QVariant
name = args->
at( 0 )->
eval( parent, context );
6380 QVariant value = args->
at( 1 )->
eval( parent, context );
6383 appendTemporaryVariable( context, name.toString(), value );
6384 if ( args->
at( 2 )->
isStatic( parent, context ) )
6386 popTemporaryVariable( context );
6397 if ( args->
count() < 3 )
6401 QVariant
name = args->
at( 0 )->
eval( parent, context );
6402 QVariant value = args->
at( 1 )->
eval( parent, context );
6405 std::unique_ptr< QgsExpressionContext > tempContext;
6406 if ( !updatedContext )
6408 tempContext = qgis::make_unique< QgsExpressionContext >();
6409 updatedContext = tempContext.get();
6412 appendTemporaryVariable( updatedContext, name.toString(), value );
6413 result = args->
at( 2 )->
eval( parent, updatedContext );
6416 popTemporaryVariable( updatedContext );
6437 if ( args->
count() < 3 )
6442 QVariant value = args->
at( 1 )->
prepare( parent, context );
6445 std::unique_ptr< QgsExpressionContext > tempContext;
6446 if ( !updatedContext )
6448 tempContext = qgis::make_unique< QgsExpressionContext >();
6449 updatedContext = tempContext.get();
6452 appendTemporaryVariable( updatedContext, name.toString(), value );
6453 args->
at( 2 )->
prepare( parent, updatedContext );
6456 popTemporaryVariable( updatedContext );
6461 void QgsWithVariableExpressionFunction::popTemporaryVariable(
const QgsExpressionContext *context )
const 6467 void QgsWithVariableExpressionFunction::appendTemporaryVariable(
const QgsExpressionContext *context,
const QString &
name,
const QVariant &value )
const int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QVariant run(QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Evaluates the function, first evaluating all required arguments before passing them to the function's...
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
static QString longestCommonSubstring(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the longest common substring between two strings.
bool isValid() const
Returns the validity of this feature.
Class for parsing and evaluation of expressions (formerly called "search strings").
static QgsQuadrilateral squareFromDiagonal(const QgsPoint &p1, const QgsPoint &p2)
Construct a QgsQuadrilateral as a square from a diagonal.
virtual double sample(const QgsPointXY &point, int band, bool *ok=nullptr, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Samples a raster value from the specified band found at the point position.
QVariant cachedValue(const QString &key) const
Returns the matching cached value, if set.
virtual QgsCurve * reversed() const =0
Returns a reversed copy of the curve, where the direction of the curve has been flipped.
Wrapper for iterator of features from vector data provider or vector layer.
virtual QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)=0
Returns result of evaluating the function.
Third quartile (numeric fields only)
virtual QVariant run(QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)
Evaluates the function, first evaluating all required arguments before passing them to the function's...
Single variable definition for use within a QgsExpressionContextScope.
virtual bool removeGeometry(int nr)
Removes a geometry from the collection.
const QgsColorRamp * colorRampRef(const QString &name) const
Returns a const pointer to a symbol (doesn't create new instance)
Base class for all map layer types.
Inter quartile range (IQR) (numeric fields only)
void setCachedValue(const QString &key, const QVariant &value) const
Sets a value to cache within the expression context.
bool prepare(QgsExpression *parent, const QgsExpressionContext *context)
Prepare this node for evaluation.
QgsGeometry combine(const QgsGeometry &geometry) const
Returns a geometry representing all the points in this geometry and other (a union geometry operation...
virtual QString dump() const =0
Dump this node into a serialized (part) of an expression.
QgsExpressionNode::NodeList * args() const
Returns a list of arguments specified for the function.
void setPoints(const QgsPointSequence &points)
Resets the line string to match the specified list of points.
double hausdorffDistanceDensify(const QgsGeometry &geom, double densifyFraction) const
Returns the Hausdorff distance between this geometry and geom.
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
Median of values (numeric fields only)
static QString quotedValue(const QVariant &value)
Returns a properly quoted and escaped version of value for use in SQL strings.
double sum
The sum of all cells in the band. NO_DATA values are excluded.
QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Returns result of evaluating the function.
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
QgsMapLayerType type() const
Returns the type of the layer.
QgsExpressionNode * at(int i)
Gets the node at position i in the list.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
bool isValid() const
Returns true if the interval is valid.
Represents a color stop within a QgsGradientColorRamp color ramp.
int bandCount() const
Returns the number of bands in this layer.
int params() const
The number of parameters this function takes.
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
double distance(const QgsGeometry &geom) const
Returns the minimum distance between this geometry and another geometry.
double months() const
Returns the interval duration in months (based on a 30 day month).
virtual QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be 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.
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.
Multi point geometry collection.
static QString wordWrap(const QString &string, int length, bool useMaxLineLength=true, const QString &customDelimiter=QString())
Automatically wraps a string by inserting new line characters at appropriate locations in the string...
QgsWithVariableExpressionFunction()
bool within(const QgsGeometry &geometry) const
Returns true if the geometry is completely within another geometry.
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
Unique pointer for sqlite3 prepared statements, which automatically finalizes the statement when the ...
void fromWkb(unsigned char *wkb, int length)
Set the geometry, feeding in the buffer containing OGC Well-Known Binary and the buffer's length...
QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Returns result of evaluating the function.
QgsArrayFilterExpressionFunction()
QString toProj() const
Returns a Proj string representation of this CRS.
double angleAtVertex(int vertex) const
Returns the bisector angle for this geometry at the specified vertex.
void setPrepareFunction(const std::function< bool(const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext *)> &prepareFunc)
Set a function that will be called in the prepare step to determine if the function is static or not...
QVector< QgsRingSequence > QgsCoordinateSequence
Represents a raster layer.
QgsExpressionContextScope * activeScopeForVariable(const QString &name)
Returns the currently active scope from the context for a specified variable name.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
First quartile (numeric fields only)
Number of missing (null) values.
A class to represent a 2D point.
QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request. ...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
bool hasCachedValue(const QString &key) const
Returns true if the expression context contains a cached value with a matching key.
OperationResult rotate(double rotation, const QgsPointXY ¢er)
Rotate this geometry around the Z axis.
int selectedFeatureCount() const
Returns the number of features that are selected in this layer.
QString providerType() const
Returns the provider type (provider key) for this layer.
int exec(const QString &sql, QString &errorMessage) const
Executes the sql command in the database.
static QString quotedIdentifier(const QString &identifier)
Returns a properly quoted version of identifier.
Abstract base class for color ramps.
QgsVectorLayer referencingLayer
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
QVariant evaluate()
Evaluate the feature and return the result.
double maximumValue
The maximum cell value in the raster band.
double seconds() const
Returns the interval duration in seconds.
Multi line string geometry collection.
QgsGeometry interpolate(double distance) const
Returns an interpolated point on the geometry at the specified distance.
Curve polygon geometry type.
bool overlaps(const QgsGeometry &geometry) const
Returns true if the geometry overlaps another geometry.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
virtual QSet< QString > referencedColumns(const QgsExpressionNodeFunction *node) const
Returns a set of field names which are required for this function.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
Handles the with_variable(name, value, node) expression function.
QgsGeometry buffer(double distance, int segments) const
Returns a buffer region around this geometry having the given width and with a specified number of se...
double convertLengthMeasurement(double length, QgsUnitTypes::DistanceUnit toUnits) const
Takes a length measurement calculated by this QgsDistanceArea object and converts it to a different d...
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
Handles the array_foreach(array, expression) expression function.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QgsLayerMetadata metadata
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
QgsFields fields() const
Convenience function for retrieving the fields for the context, if set.
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
This will be called during the prepare step() of an expression if it is not static.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
Quadrilateral geometry type.
QgsGeometry intersection(const QgsGeometry &geometry) const
Returns a geometry representing the points shared by this geometry and other.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
double distanceToVertex(int vertex) const
Returns the distance along this geometry from its first vertex to the specified vertex.
double convertAreaMeasurement(double area, QgsUnitTypes::AreaUnit toUnits) const
Takes an area measurement calculated by this QgsDistanceArea object and converts it to a different ar...
QgsStaticExpressionFunction(const QString &fnname, int params, FcnEval fcn, const QString &group, const QString &helpText=QString(), bool usesGeometry=false, const QSet< QString > &referencedColumns=QSet< QString >(), bool lazyEval=false, const QStringList &aliases=QStringList(), bool handlesNull=false)
Static function for evaluation against a QgsExpressionContext, using an unnamed list of parameter val...
QVariant run(QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Evaluates the function, first evaluating all required arguments before passing them to the function's...
QgsGeometry minimalEnclosingCircle(QgsPointXY ¢er, double &radius, unsigned int segments=36) const
Returns the minimal enclosing circle for the geometry.
QgsGeometry nearestPoint(const QgsGeometry &other) const
Returns the nearest point on this geometry to another geometry.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
QList< QgsExpressionFunction::Parameter > ParameterList
List of parameters, used for function definition.
QString delimiter
Delimiter to use for joining values with the StringConcatenate aggregate.
virtual bool executeSql(const QString &sql, QString &error, bool isDirty=false, const QString &name=QString())=0
Execute the sql string.
QString name() const
The name of the column.
static QString soundex(const QString &string)
Returns the Soundex representation of a string.
QVariant variable(const QString &name) const
Fetches a matching variable from the context.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
QList< QgsGradientStop > QgsGradientStopsList
List of gradient stops.
QSet< QString > referencedVariables() const
Returns a list of all variables which are used in this expression.
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
static QgsStyle * defaultStyle()
Returns default application-wide style.
virtual QgsRectangle extent() const
Returns the extent of the layer.
Concatenate unique values with a joining string (string fields only). Specify the delimiter using set...
void setEvalErrorString(const QString &str)
Sets evaluation error (used internally by evaluation functions)
bool hasFeature() const
Returns true if the context has a feature associated with it.
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
static QString encodeColor(const QColor &color)
void setVariable(const QString &name, const QVariant &value, bool isStatic=false)
Convenience method for setting a variable in the context scope by name name and value.
QgsGeometry poleOfInaccessibility(double precision, double *distanceToBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
static const QStringList & BuiltinFunctions()
static bool unregisterFunction(const QString &name)
Unregisters a function from the expression engine.
QString errorMessage() const
Returns the most recent error message encountered by the database.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QVariant(* FcnEval)(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)
Function definition for evaluation against an expression context, using a list of values as parameter...
QgsGeometry mergeLines() const
Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line ...
#define ENSURE_NO_EVAL_ERROR
QList< QgsExpressionFunction * > ExpressionFunctionList
QgsUnitTypes::AreaUnit areaUnits() const
Returns the desired areal units for calculations involving geomCalculator(), e.g., "$area".
double stdDev
The standard deviation of the cell values.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets feature ID that should be fetched.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
CORE_EXPORT QString build(const QVariantMap &map)
Build a hstore-formatted string from a QVariantMap.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
The RasterBandStats struct is a container for statistics about a single raster band.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QgsDistanceArea * geomCalculator()
Returns calculator used for distance and area calculations (used by $length, $area and $perimeter fun...
double mean
The mean cell value for the band. NO_DATA values are excluded.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
bool isGeosValid(QgsGeometry::ValidityFlags flags=nullptr) const
Checks validity of the geometry using GEOS.
Q_INVOKABLE const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
virtual QSet< QString > referencedColumns() const =0
Abstract virtual method which returns a list of columns required to evaluate this node...
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer for a (multi)linestring geometry, where the width at each node is ...
virtual QgsCurve * curveSubstring(double startDistance, double endDistance) const =0
Returns a new curve representing a substring of this curve.
Utility class for identifying a unique vertex within a geometry.
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a variable width buffer ("tapered buffer") for a (multi)curve geometry.
virtual QSet< QString > referencedVariables() const =0
Returns a set of all variables which are used in this expression.
virtual bool handlesNull() const
Returns true if the function handles NULL values in arguments by itself, and the default NULL value h...
static Aggregate stringToAggregate(const QString &string, bool *ok=nullptr)
Converts a string to a aggregate type.
int ringCount(int part=0) const override
Returns the number of rings of which this geometry is built.
bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
This will be called during the prepare step() of an expression if it is not static.
int step()
Steps to the next record in the statement, returning the sqlite3 result code.
QList< QgsRelation > relationsByName(const QString &name) const
Returns a list of relations with matching names.
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
Minimum length of string (string fields only)
virtual QgsPolygon * toPolygon(unsigned int segments=36) const
Returns a segmented polygon.
const QgsExpressionFunction::ParameterList & parameters() const
Returns the list of named parameters for the function, if set.
static void cleanRegisteredFunctions()
Deletes all registered functions whose ownership have been transferred to the expression engine...
QgsGeometry convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry. ...
static QString geometryDisplayString(GeometryType type)
Returns a display string for a geometry type.
double width() const
Returns the width of the rectangle.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
QgsFeatureRequest::OrderBy orderBy
Optional order by clauses.
QgsGeometryCollection * createEmptyWithSameType() const override
Creates a new geometry with the same class and same WKB type as the original and transfers ownership...
QVariant fcnRampColor(const QVariantList &values, const QgsExpressionContext *, QgsExpression *parent, const QgsExpressionNodeFunction *)
QgsGeometry extendLine(double startDistance, double endDistance) const
Extends a (multi)line geometry by extrapolating out the start or end of the line by a specified dista...
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Regular Polygon geometry type.
The simplification gives each point in a line an importance weighting, so that least important points...
T qgsgeometry_cast(const QgsAbstractGeometry *geom)
QgsGeometry offsetCurve(double distance, int segments, JoinStyle joinStyle, double miterLimit) const
Returns an offset line at a given distance and side from an input line.
QString description() const
Returns the descriptive name of the CRS, e.g., "WGS 84" or "GDA 94 / Vicgrid94".
static bool registerFunction(QgsExpressionFunction *function, bool transferOwnership=false)
Registers a function to the expression engine.
An expression node which takes it value from a feature's field.
QgsGeometry smooth(unsigned int iterations=1, double offset=0.25, double minimumDistance=-1.0, double maxAngle=180.0) const
Smooths a geometry by rounding off corners using the Chaikin algorithm.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
bool crosses(const QgsGeometry &geometry) const
Returns true if the geometry crosses another geometry.
static QgsQuadrilateral rectangleFrom3Points(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, ConstructionOption mode)
Construct a QgsQuadrilateral as a Rectangle from 3 points.
static const QString ALL_ATTRIBUTES
A special attribute that if set matches all attributes.
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example...
ConstructionOption
A regular polygon can be constructed inscribed in a circle or circumscribed about a circle...
virtual bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const
Will be called during prepare to determine if the function is static.
ConstructionOption
A quadrilateral can be constructed from 3 points where the second distance can be determined by the t...
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any.
QgsVectorLayer referencedLayer
Abstract base class for all nodes that can appear in an expression.
Abstract base class for curved geometry type.
Create an array of values.
double measureLength(const QgsGeometry &geometry) const
Measures the length of a geometry.
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry.
bool touches(const QgsGeometry &geometry) const
Returns true if the geometry touches another geometry.
sqlite3_statement_unique_ptr prepare(const QString &sql, int &resultCode) const
Prepares a sql statement, returning the result.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Abstract base class for all geometries.
An expression node for expression functions.
double minimumScale() const
Returns the minimum map scale (i.e.
Contains information about the context in which a coordinate transform is executed.
QgsRelationManager relationManager
static int levenshteinDistance(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the Levenshtein edit distance between two strings.
double maximumScale() const
Returns the maximum map scale (i.e.
static QVector< QgsLineString * > extractLineStrings(const QgsAbstractGeometry *geom)
Returns list of linestrings extracted from the passed geometry.
bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
This will be called during the prepare step() of an expression if it is not static.
static bool runOnMainThread(const Func &func, QgsFeedback *feedback=nullptr)
Guarantees that func is executed on the main thread.
Implementation of GeometrySimplifier using the "MapToPixel" algorithm.
static const QList< QgsExpressionFunction * > & Functions()
QgsPoint project(double distance, double azimuth, double inclination=90.0) const
Returns a new point which correspond to this point projected by a specified distance with specified a...
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
QList< QgsMapLayer * > mapLayersByName(const QString &layerName) const
Retrieve a list of matching registered layers by layer name.
QVariant eval(QgsExpression *parent, const QgsExpressionContext *context)
Evaluate this node with the given context and parent.
Point geometry type, with support for z-dimension and m-values.
virtual bool usesGeometry(const QgsExpressionNodeFunction *node) const
Does this function use a geometry object.
Majority of values (numeric fields only)
bool lazyEval() const
true if this function should use lazy evaluation.
QString group() const
Returns the first group which the function belongs to.
double length() const
Returns the planar, 2-dimensional length of geometry.
double measurePerimeter(const QgsGeometry &geometry) const
Measures the perimeter of a polygon geometry.
QByteArray asWkb() const
Export the geometry to WKB.
QgsGeometry extrude(double x, double y)
Returns an extruded version of this geometry.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
double weeks() const
Returns the interval duration in weeks.
int numGeometries() const
Returns the number of geometries within the collection.
QgsExpressionFunction(const QString &fnname, int params, const QString &group, const QString &helpText=QString(), bool lazyEval=false, bool handlesNull=false, bool isContextual=false)
Constructor for function which uses unnamed parameters.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
virtual bool isClosed() const
Returns true if the curve is closed.
uint qHash(const QVariant &variant)
Hash for QVariant.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsUnitTypes::DistanceUnit distanceUnits() const
Returns the desired distance units for calculations involving geomCalculator(), e.g., "$length" and "$perimeter".
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
Number of distinct values.
QgsArrayForeachExpressionFunction()
QString asWkt(int precision=17) const
Exports the geometry to WKT.
QString name() const
The name of the function.
double interpolateAngle(double distance) const
Returns the angle parallel to the linestring or polygon boundary at the specified distance along the ...
A representation of the interval between two datetime values.
Handles the array_filter(array, expression) expression function.
The OrderByClause class represents an order by clause for a QgsFeatureRequest.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
double xMaximum() const
Returns the x maximum value (right side of rectangle).
virtual QStringList aliases() const
Returns a list of possible aliases for the function.
QVector< QgsPoint > QgsPointSequence
double days() const
Returns the interval duration in days.
QgsCurve * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
virtual QgsRasterBandStats bandStatistics(int bandNo, int stats=QgsRasterBandStats::All, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
Returns the band statistics.
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
virtual QgsCoordinateSequence coordinateSequence() const =0
Retrieves the sequence of geometries, rings and nodes.
A general purpose distance and area calculator, capable of performing ellipsoid based calculations...
int partCount() const override
Returns count of parts contained in the geometry.
QVector< QgsPointSequence > QgsRingSequence
A abstract base class for defining QgsExpression functions.
A list of expression nodes.
static void registerContextFunctions()
Registers all known core functions provided by QgsExpressionContextScope objects. ...
Maximum length of string (string fields only)
int open_v2(const QString &path, int flags, const char *zVfs)
Opens the database at the specified file path.
QgsGeometry simplify(double tolerance) const
Returns a simplified version of this geometry using a specified tolerance value.
static QgsGeometry geometryFromGML(const QString &xmlString)
Static method that creates geometry from GML.
static bool allParamsStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context)
This will return true if all the params for the provided function node are static within the constrai...
QList< QgsExpressionNode * > list()
Gets a list of all the nodes.
QString getRelatedFeaturesFilter(const QgsFeature &feature) const
Returns a filter expression which returns all the features on the referencing (child) layer which hav...
static QgsCoordinateReferenceSystem fromOgcWmsCrs(const QString &ogcCrs)
Creates a CRS from a given OGC WMS-format Coordinate Reference System string.
QString filter
Optional filter for calculating aggregate over a subset of features, or an empty string to use all fe...
double years() const
Returns the interval duration in years (based on an average year length)
double hausdorffDistance(const QgsGeometry &geom) const
Returns the Hausdorff distance between this geometry and geom.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
An expression node for literal values.
Mean of values (numeric fields only)
const QString helpText() const
The help text for the function.
c++ helper class for defining QgsExpression functions.
const QgsExpressionNode * rootNode() const
Returns the root node of the expression.
double qgsRound(double number, int places)
Returns a double number, rounded (as close as possible) to the specified number of places...
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
This class allows including a set of layers in a database-side transaction, provided the layer data p...
void setIsStaticFunction(const std::function< bool(const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext *) > &isStatic)
Set a function that will be called in the prepare step to determine if the function is static or not...
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QgsFeatureRequest & setTimeout(int timeout)
Sets the timeout (in milliseconds) for the maximum time we should wait during feature requests before...
double minutes() const
Returns the interval duration in minutes.
Line string geometry type, with support for z-dimension and m-values.
static QgsGeometry createWedgeBuffer(const QgsPoint ¢er, double azimuth, double angularWidth, double outerRadius, double innerRadius=0)
Creates a wedge shaped buffer from a center point.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
#define ENSURE_GEOM_TYPE(f, g, geomtype)
static QgsProject * instance()
Returns the QgsProject singleton instance.
Create a multipart geometry from aggregated geometries.
bool usesGeometry(const QgsExpressionNodeFunction *node) const override
Does this function use a geometry object.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QgsGeometry shortestLine(const QgsGeometry &other) const
Returns the shortest line joining this geometry to another geometry.
This class represents a coordinate reference system (CRS).
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
QVariant run(QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Evaluates the function, first evaluating all required arguments before passing them to the function's...
double hours() const
Returns the interval duration in hours.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
double range
The range is the distance between min & max.
bool isStatic(const QString &name) const
Tests whether the variable with the specified name is static and can be cached.
QgsFeatureRequest & setLimit(long limit)
Set the maximum number of features to request.
bool operator==(const QgsExpressionFunction &other) const
void setIsStatic(bool isStatic)
Tag this function as either static or not static.
QgsGeometry singleSidedBuffer(double distance, int segments, BufferSide side, JoinStyle joinStyle=JoinStyleRound, double miterLimit=2.0) const
Returns a single sided buffer for a (multi)line geometry.
static QString quotedString(QString text)
Returns a quoted version of a string (in single quotes)
double xMinimum() const
Returns the x minimum value (left side of rectangle).
double minimumValue
The minimum cell value in the raster band.
static QString helpText(QString name)
Returns the help text for a specified function.
OperationResult translate(double dx, double dy, double dz=0.0, double dm=0.0)
Translates this geometry by dx, dy, dz and dm.
QgsFeature feature() const
Convenience function for retrieving the feature for the context, if set.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
QgsGeometry forceRHR() const
Forces geometries to respect the Right-Hand-Rule, in which the area that is bounded by a polygon is t...
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
QgsGeometry orientedMinimumBoundingBox(double &area, double &angle, double &width, double &height) const
Returns the oriented minimum bounding box for the geometry, which is the smallest (by area) rotated r...
virtual bool isStatic(QgsExpression *parent, const QgsExpressionContext *context) const =0
Returns true if this node can be evaluated for a static value.
QSet< QString > referencedColumns(const QgsExpressionNodeFunction *node) const override
Returns a set of field names which are required for this function.
Represents a single parameter passed to a function.
Concatenate values with a joining string (string fields only). Specify the delimiter using setDelimit...
QgsMultiPointXY asMultiPoint() const
Returns the contents of the geometry as a multi-point.
QgsWkbTypes::GeometryType type
QgsFeatureRequest & setRequestMayBeNested(bool requestMayBeNested)
In case this request may be run nested within another already running iteration on the same connectio...
Custom exception class for Coordinate Reference System related exceptions.
QgsPointXY center() const
Returns the center point of the rectangle.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
QgsPolygon * toPolygon() const
Returns as a polygon.
double area() const
Returns the planar, 2-dimensional area of the geometry.
int count() const
Returns the number of nodes in the list.
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
The geometries can be simplified using the current map2pixel context state.
bool nextFeature(QgsFeature &f)
QStringList aliases() const override
Returns a list of possible aliases for the function.
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required...
Minority of values (numeric fields only)
bool vertexIdFromVertexNr(int number, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
JoinStyle
Join styles for buffers.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
bool contains(const QgsPointXY *p) const
Returns true if the geometry contains the point p.
Q_INVOKABLE QgsRelation relation(const QString &id) const
Gets access to a relation by its id.
QgsGeometry symDifference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
CORE_EXPORT QVariantMap parse(const QString &string)
Returns a QVariantMap object containing the key and values from a hstore-formatted string...
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
Represents a vector layer which manages a vector based data sets.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
virtual bool isDeprecated() const
Returns true if the function is deprecated and should not be presented as a valid option to users in ...
Range of values (max - min) (numeric and datetime fields only)
bool isEmpty() const override
Returns true if the geometry is empty.
static QgsGeometry collectGeometry(const QVector< QgsGeometry > &geometries)
Creates a new multipart geometry from a list of QgsGeometry objects.
qlonglong columnAsInt64(int column) const
Gets column value from the current statement row as a long long integer (64 bits).
virtual bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const
This will be called during the prepare step() of an expression if it is not static.
double lineLocatePoint(const QgsGeometry &point) const
Returns a distance representing the location along this linestring of the closest point on this lines...
bool disjoint(const QgsGeometry &geometry) const
Returns true if the geometry is disjoint of another geometry.
double measureArea(const QgsGeometry &geometry) const
Measures the area of a geometry.
QString authid() const
Returns the authority identifier for the CRS.
QgsCoordinateReferenceSystem crs
Sample standard deviation of values (numeric fields only)
Aggregate
Available aggregates to calculate.
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
static int hammingDistance(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the Hamming distance between two strings.
static QColor decodeColor(const QString &str)
Represents a list of OrderByClauses, with the most important first and the least important last...
virtual int partCount() const =0
Returns count of parts contained in the geometry.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
double height() const
Returns the height of the rectangle.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
#define FEAT_FROM_CONTEXT(c, f)
A bundle of parameters controlling aggregate calculation.
QVariant aggregate(QgsAggregateCalculator::Aggregate aggregate, const QString &fieldOrExpression, const QgsAggregateCalculator::AggregateParameters ¶meters=QgsAggregateCalculator::AggregateParameters(), QgsExpressionContext *context=nullptr, bool *ok=nullptr, QgsFeatureIds *fids=nullptr) const
Calculates an aggregated value from the layer's features.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QgsGeometry difference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...