68 QVariantList argValues;
72 const QList< QgsExpressionNode * > argList = args->
list();
79 v = QVariant::fromValue( n );
83 v = n->eval( parent, context );
85 bool defaultParamIsNull = mParameterList.count() > arg && mParameterList.at( arg ).optional() && !mParameterList.at( arg ).defaultValue().isValid();
86 if ( QgsExpressionUtils::isNull( v ) && !defaultParamIsNull && !
handlesNull() )
89 argValues.append( v );
94 return func( argValues, context, parent, node );
105 return QStringList();
132 return mGroups.isEmpty() ? false : mGroups.contains( QStringLiteral(
"deprecated" ) );
137 return ( QString::compare( mName, other.mName, Qt::CaseInsensitive ) == 0 );
149 const QString &
group,
159 , mUsesGeometry(
false )
173 if ( mUsesGeometryFunc )
174 return mUsesGeometryFunc( node );
176 return mUsesGeometry;
181 if ( mReferencedColumnsFunc )
182 return mReferencedColumnsFunc( node );
184 return mReferencedColumns;
190 return mIsStaticFunc( node, parent, context );
198 return mPrepareFunc( node, parent, context );
210 mIsStaticFunc =
nullptr;
216 mPrepareFunc = prepareFunc;
221 if ( node && node->
args() )
223 const QList< QgsExpressionNode * > argList = node->
args()->
list();
226 if ( !argNode->isStatic( parent, context ) )
236 double start = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
237 double stop = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
238 double step = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
240 if ( step == 0.0 || ( step > 0.0 && start > stop ) || ( step < 0.0 && start < stop ) )
247 double current = start + step;
248 while ( ( ( step > 0.0 && current <= stop ) || ( step < 0.0 && current >= stop ) ) && length <= 1000000 )
263 QString
name = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
272 QString expString = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
274 return expression.evaluate( context );
279 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
280 return QVariant( std::sqrt( x ) );
285 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
286 return QVariant( std::fabs( val ) );
291 double deg = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
292 return ( deg * M_PI ) / 180;
296 double rad = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
297 return ( 180 * rad ) / M_PI;
301 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
302 return QVariant( std::sin( x ) );
306 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
307 return QVariant( std::cos( x ) );
311 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
312 return QVariant( std::tan( x ) );
316 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
317 return QVariant( std::asin( x ) );
321 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
322 return QVariant( std::acos( x ) );
326 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
327 return QVariant( std::atan( x ) );
331 double y = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
332 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
333 return QVariant( std::atan2( y, x ) );
337 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
338 return QVariant( std::exp( x ) );
342 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
345 return QVariant( std::log( x ) );
349 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
352 return QVariant( log10( x ) );
356 double b = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
357 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
358 if ( x <= 0 || b <= 0 )
360 return QVariant( std::log( x ) / std::log( b ) );
364 double min = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
365 double max = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
370 double f =
static_cast< double >( qrand() ) / RAND_MAX;
371 return QVariant( min + f * ( max - min ) );
375 qlonglong min = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
376 qlonglong max = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
381 return QVariant( min + ( qrand() % static_cast< qlonglong >( max - min + 1 ) ) );
386 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
387 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
388 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
389 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
390 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
392 if ( domainMin >= domainMax )
394 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
399 if ( val >= domainMax )
403 else if ( val <= domainMin )
409 double m = ( rangeMax - rangeMin ) / ( domainMax - domainMin );
410 double c = rangeMin - ( domainMin * m );
413 return QVariant( m * val + c );
418 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
419 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
420 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
421 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
422 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
423 double exponent = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
425 if ( domainMin >= domainMax )
427 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
437 if ( val >= domainMax )
441 else if ( val <= domainMin )
447 return QVariant( ( ( rangeMax - rangeMin ) / std::pow( domainMax - domainMin, exponent ) ) * std::pow( val - domainMin, exponent ) + rangeMin );
452 QVariant result( QVariant::Double );
453 double maxVal = std::numeric_limits<double>::quiet_NaN();
454 for (
const QVariant &val : values )
456 double testVal = val.isNull() ? std::numeric_limits<double>::quiet_NaN() : QgsExpressionUtils::getDoubleValue( val, parent );
457 if ( std::isnan( maxVal ) )
461 else if ( !std::isnan( testVal ) )
463 maxVal = std::max( maxVal, testVal );
467 if ( !std::isnan( maxVal ) )
469 result = QVariant( maxVal );
476 QVariant result( QVariant::Double );
477 double minVal = std::numeric_limits<double>::quiet_NaN();
478 for (
const QVariant &val : values )
480 double testVal = val.isNull() ? std::numeric_limits<double>::quiet_NaN() : QgsExpressionUtils::getDoubleValue( val, parent );
481 if ( std::isnan( minVal ) )
485 else if ( !std::isnan( testVal ) )
487 minVal = std::min( minVal, testVal );
491 if ( !std::isnan( minVal ) )
493 result = QVariant( minVal );
505 QVariant value = node->
eval( parent, context );
507 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( value, parent );
510 parent->
setEvalErrorString( QObject::tr(
"Cannot find layer with name or ID '%1'" ).arg( value.toString() ) );
515 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
517 value = node->
eval( parent, context );
523 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
528 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
530 QString subExpression = node->
dump();
534 if ( values.count() > 3 )
536 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
539 if ( !nl || nl->value().isValid() )
544 if ( values.count() > 4 )
546 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
548 value = node->
eval( parent, context );
555 if ( values.count() > 5 )
557 node = QgsExpressionUtils::getNode( values.at( 5 ), parent );
560 if ( !nl || nl->value().isValid() )
562 orderBy = node->
dump();
578 cacheKey = QStringLiteral(
"aggfcn:%1:%2:%3:%4:%5%6:%7" ).arg( vl->id(), QString::number( aggregate ), subExpression, parameters.
filter,
583 cacheKey = QStringLiteral(
"aggfcn:%1:%2:%3:%4:%5" ).arg( vl->id(), QString::number( aggregate ), subExpression, parameters.
filter, orderBy );
593 result = vl->aggregate( aggregate, subExpression, parameters, &subContext, &ok );
599 result = vl->aggregate( aggregate, subExpression, parameters,
nullptr, &ok );
603 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
614 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
619 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
622 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
631 QVariant value = node->
eval( parent, context );
633 QString relationId = value.toString();
640 if ( relations.isEmpty() || relations.at( 0 ).referencedLayer() != vl )
642 parent->
setEvalErrorString( QObject::tr(
"Cannot find relation with id '%1'" ).arg( relationId ) );
647 relation = relations.at( 0 );
654 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
656 value = node->
eval( parent, context );
662 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
667 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
669 QString subExpression = node->
dump();
673 if ( values.count() > 3 )
675 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
677 value = node->
eval( parent, context );
684 if ( values.count() > 4 )
686 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
689 if ( !nl || nl->value().isValid() )
691 orderBy = node->
dump();
700 QString cacheKey = QStringLiteral(
"relagg:%1:%2:%3:%4:%5" ).arg( vl->
id(),
701 QString::number( static_cast< int >( aggregate ) ),
713 result = childLayer->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
717 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
732 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
737 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
740 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
749 QString subExpression = node->
dump();
753 if ( values.count() > 1 )
755 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
758 if ( !nl || nl->value().isValid() )
759 groupBy = node->
dump();
763 if ( values.count() > 2 )
765 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
768 if ( !nl || nl->value().isValid() )
774 if ( orderByPos >= 0 && values.count() > orderByPos )
776 node = QgsExpressionUtils::getNode( values.at( orderByPos ), parent );
779 if ( !nl || nl->value().isValid() )
781 orderBy = node->
dump();
789 if ( !groupBy.isEmpty() )
792 QVariant groupByValue = groupByExp.
evaluate( context );
793 QString groupByClause = QStringLiteral(
"%1 %2 %3" ).arg( groupBy,
794 groupByValue.isNull() ? QStringLiteral(
"is" ) : QStringLiteral(
"=" ),
796 if ( !parameters.
filter.isEmpty() )
797 parameters.
filter = QStringLiteral(
"(%1) AND (%2)" ).arg( parameters.
filter, groupByClause );
799 parameters.
filter = groupByClause;
802 QString cacheKey = QStringLiteral(
"agg:%1:%2:%3:%4:%5" ).arg( vl->
id(),
803 QString::number( static_cast< int >( aggregate ) ),
814 result = vl->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
818 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
924 if ( values.count() > 3 )
928 QVariant value = node->
eval( parent, context );
941 if ( values.count() > 3 )
945 QVariant value = node->
eval( parent, context );
963 QVariant scale = context->
variable( QStringLiteral(
"map_scale" ) );
965 if ( !scale.isValid() || scale.isNull() )
968 const double v = scale.toDouble( &ok );
976 double minValue = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
977 double testValue = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
978 double maxValue = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
981 if ( testValue <= minValue )
983 return QVariant( minValue );
985 else if ( testValue >= maxValue )
987 return QVariant( maxValue );
991 return QVariant( testValue );
997 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
998 return QVariant( std::floor( x ) );
1003 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1004 return QVariant( std::ceil( x ) );
1009 return QVariant( QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) );
1013 return QVariant( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) );
1017 return QVariant( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ) );
1022 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1023 if ( format.isEmpty() )
1024 return QVariant( QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent ) );
1026 QString datetimestring = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1027 QDateTime datetime = QDateTime::fromString( datetimestring, format );
1028 if ( !datetime.isValid() )
1030 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to DateTime" ).arg( datetimestring ) );
1031 datetime = QDateTime();
1033 return QVariant( datetime );
1038 for (
const QVariant &value : values )
1040 if ( value.isNull() )
1049 const QVariant val1 = values.at( 0 );
1050 const QVariant val2 = values.at( 1 );
1060 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1061 return QVariant( str.toLower() );
1065 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1066 return QVariant( str.toUpper() );
1070 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1071 QStringList elems = str.split(
' ' );
1072 for (
int i = 0; i < elems.size(); i++ )
1074 if ( elems[i].size() > 1 )
1075 elems[i] = elems[i].at( 0 ).toUpper() + elems[i].mid( 1 ).toLower();
1077 return QVariant( elems.join( QStringLiteral(
" " ) ) );
1082 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1083 return QVariant( str.trimmed() );
1088 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1089 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1095 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1096 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1102 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1103 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1110 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1116 QChar character = QChar( QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent ) );
1117 return QVariant( QString( character ) );
1122 if ( values.length() == 2 || values.length() == 3 )
1124 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1125 qlonglong wrap = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1127 QString customdelimiter = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1141 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1145 return QVariant( geom.
length() );
1149 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1150 return QVariant( str.length() );
1155 if ( values.count() == 2 && values.at( 1 ).type() == QVariant::Map )
1157 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1158 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 1 ), parent );
1160 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
1162 str = str.replace( it.key(), it.value().toString() );
1165 return QVariant( str );
1167 else if ( values.count() == 3 )
1169 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1170 QVariantList before;
1172 bool isSingleReplacement =
false;
1174 if ( values.at( 1 ).type() != QVariant::List && values.at( 2 ).type() != QVariant::StringList )
1176 before = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1180 before = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
1183 if ( values.at( 2 ).type() != QVariant::List && values.at( 2 ).type() != QVariant::StringList )
1185 after = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1186 isSingleReplacement =
true;
1190 after = QgsExpressionUtils::getListValue( values.at( 2 ), parent );
1193 if ( !isSingleReplacement && before.length() != after.length() )
1195 parent->
setEvalErrorString( QObject::tr(
"Invalid pair of array, length not identical" ) );
1199 for (
int i = 0; i < before.length(); i++ )
1201 str = str.replace( before.at( i ).toString(), after.at( isSingleReplacement ? 0 : i ).toString() );
1204 return QVariant( str );
1208 parent->
setEvalErrorString( QObject::tr(
"Function replace requires 2 or 3 arguments" ) );
1214 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1215 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1216 QString after = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1218 QRegularExpression re( regexp );
1219 if ( !re.isValid() )
1221 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1224 return QVariant( str.replace( re, after ) );
1229 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1230 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1232 QRegularExpression re( regexp );
1233 if ( !re.isValid() )
1235 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1238 return QVariant( ( str.indexOf( re ) + 1 ) );
1243 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1244 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1245 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1247 QRegularExpression re( regexp );
1248 if ( !re.isValid() )
1250 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1254 QRegularExpressionMatch matches = re.match( str );
1255 if ( matches.hasMatch() )
1258 QStringList list = matches.capturedTexts();
1261 for ( QStringList::const_iterator it = ++list.constBegin(); it != list.constEnd(); ++it )
1263 array += ( !( *it ).isEmpty() ) ? *it : empty;
1266 return QVariant( array );
1276 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1277 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1279 QRegularExpression re( regexp );
1280 if ( !re.isValid() )
1282 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1287 QRegularExpressionMatch match = re.match( str );
1288 if ( match.hasMatch() )
1291 if ( match.lastCapturedIndex() > 0 )
1294 return QVariant( match.captured( 1 ) );
1299 return QVariant( match.captured( 0 ) );
1304 return QVariant(
"" );
1310 return QUuid::createUuid().toString();
1315 if ( !values.at( 0 ).isValid() || !values.at( 1 ).isValid() )
1318 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1319 int from = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1322 if ( values.at( 2 ).isValid() )
1323 len = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
1329 from = str.size() + from;
1335 else if ( from > 0 )
1343 len = str.size() + len - from;
1350 return QVariant( str.mid( from, len ) );
1356 return QVariant( static_cast< int >( f.id() ) );
1361 QgsRasterLayer *layer = QgsExpressionUtils::getRasterLayer( values.at( 0 ), parent );
1364 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster layer." ) );
1368 int bandNb = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1369 if ( bandNb < 1 || bandNb > layer->
bandCount() )
1371 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster band number." ) );
1375 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
1378 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid point geometry." ) );
1386 if ( multiPoint.count() == 1 )
1388 point = multiPoint[0];
1398 return std::isnan( value ) ? QVariant() : value;
1413 if ( values.size() == 1 )
1415 attr = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1418 else if ( values.size() == 2 )
1420 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1421 attr = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1425 parent->
setEvalErrorString( QObject::tr(
"Function `attribute` requires one or two parameters. %1 given." ).arg( values.length() ) );
1436 if ( values.size() == 0 || values.at( 0 ).isNull() )
1442 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1447 for (
int i = 0; i < fields.count(); ++i )
1449 result.insert( fields.at( i ).name(), feature.
attribute( i ) );
1459 if ( values.isEmpty() )
1462 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1464 else if ( values.size() == 1 )
1466 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1467 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1469 else if ( values.size() == 2 )
1471 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1472 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
1476 parent->
setEvalErrorString( QObject::tr(
"Function `is_selected` requires no more than two parameters. %1 given." ).arg( values.length() ) );
1480 if ( !layer || !feature.
isValid() )
1482 return QVariant( QVariant::Bool );
1492 if ( values.isEmpty() )
1493 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1494 else if ( values.count() == 1 )
1495 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1498 parent->
setEvalErrorString( QObject::tr(
"Function `num_selected` requires no more than one parameter. %1 given." ).arg( values.length() ) );
1504 return QVariant( QVariant::LongLong );
1512 static QMap<QString, qlonglong> counterCache;
1513 QVariant functionResult;
1515 std::function<void()> fetchAndIncrementFunc = [ =, &functionResult ]()
1518 const QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1523 database = decodedUri.value( QStringLiteral(
"path" ) ).toString();
1524 if ( database.isEmpty() )
1526 parent->
setEvalErrorString( QObject::tr(
"Could not extract file path from layer `%1`." ).arg( layer->
name() ) );
1531 database = values.at( 0 ).toString();
1534 const QString table = values.at( 1 ).toString();
1535 const QString idColumn = values.at( 2 ).toString();
1536 const QString filterAttribute = values.at( 3 ).toString();
1537 const QVariant filterValue = values.at( 4 ).toString();
1538 const QVariantMap defaultValues = values.at( 5 ).toMap();
1544 if ( sqliteDb.
open_v2( database, SQLITE_OPEN_READWRITE,
nullptr ) != SQLITE_OK )
1547 functionResult = QVariant();
1551 QString errorMessage;
1552 QString currentValSql;
1554 qlonglong nextId = 0;
1555 bool cachedMode =
false;
1556 bool valueRetrieved =
false;
1558 QString cacheString = QStringLiteral(
"%1:%2:%3:%4:%5" ).arg( database, table, idColumn, filterAttribute, filterValue.toString() );
1565 auto cachedCounter = counterCache.find( cacheString );
1567 if ( cachedCounter != counterCache.end() )
1569 qlonglong &cachedValue = cachedCounter.value();
1570 nextId = cachedValue;
1572 cachedValue = nextId;
1573 valueRetrieved =
true;
1578 if ( !cachedMode || !valueRetrieved )
1580 int result = SQLITE_ERROR;
1583 if ( !filterAttribute.isNull() )
1588 sqliteStatement = sqliteDb.
prepare( currentValSql, result );
1590 if ( result == SQLITE_OK )
1593 if ( sqliteStatement.
step() == SQLITE_ROW )
1599 if ( cachedMode && result == SQLITE_OK )
1601 counterCache.insert( cacheString, nextId );
1605 counterCache.remove( cacheString );
1608 valueRetrieved =
true;
1612 if ( valueRetrieved )
1621 if ( !filterAttribute.isNull() )
1627 for ( QVariantMap::const_iterator iter = defaultValues.constBegin(); iter != defaultValues.constEnd(); ++iter )
1630 vals << iter.value().toString();
1633 upsertSql += QLatin1String(
" (" ) + cols.join(
',' ) +
')';
1634 upsertSql += QLatin1String(
" VALUES " );
1635 upsertSql +=
'(' + vals.join(
',' ) +
')';
1637 int result = SQLITE_ERROR;
1641 if ( transaction->
executeSql( upsertSql, errorMessage ) )
1648 result = sqliteDb.
exec( upsertSql, errorMessage );
1650 if ( result == SQLITE_OK )
1652 functionResult = QVariant( nextId );
1657 parent->
setEvalErrorString( QStringLiteral(
"Could not increment value: SQLite error: \"%1\" (%2)." ).arg( errorMessage, QString::number( result ) ) );
1658 functionResult = QVariant();
1663 functionResult = QVariant();
1668 return functionResult;
1674 for (
const QVariant &value : values )
1676 concat += QgsExpressionUtils::getStringValue( value, parent );
1683 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1684 return string.indexOf( QgsExpressionUtils::getStringValue( values.at( 1 ), parent ) ) + 1;
1689 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1690 int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1691 return string.right( pos );
1696 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1697 int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1698 return string.left( pos );
1703 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1704 int length = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1705 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1706 return string.leftJustified( length, fill.at( 0 ), true );
1711 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1712 int length = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
1713 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1714 return string.rightJustified( length, fill.at( 0 ), true );
1719 if ( values.size() < 1 )
1721 parent->
setEvalErrorString( QObject::tr(
"Function format requires at least 1 argument" ) );
1725 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1726 for (
int n = 1; n < values.length(); n++ )
1728 string =
string.arg( QgsExpressionUtils::getStringValue( values.at( n ), parent ) );
1736 return QVariant( QDateTime::currentDateTime() );
1741 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1742 if ( format.isEmpty() )
1743 return QVariant( QgsExpressionUtils::getDateValue( values.at( 0 ), parent ) );
1745 QString datestring = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1746 QDate date = QDate::fromString( datestring, format );
1747 if ( !date.isValid() )
1749 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to Date" ).arg( datestring ) );
1752 return QVariant( date );
1757 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1758 if ( format.isEmpty() )
1759 return QVariant( QgsExpressionUtils::getTimeValue( values.at( 0 ), parent ) );
1761 QString timestring = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1762 QTime time = QTime::fromString( timestring, format );
1763 if ( !time.isValid() )
1765 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to Time" ).arg( timestring ) );
1768 return QVariant( time );
1773 return QVariant::fromValue( QgsExpressionUtils::getInterval( values.at( 0 ), parent ) );
1782 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1783 QString axis = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1784 int precision = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
1786 QString formatString;
1787 if ( values.count() > 3 )
1788 formatString = QgsExpressionUtils::getStringValue( values.at( 3 ), parent );
1790 QgsCoordinateFormatter::FormatFlags flags =
nullptr;
1791 if ( formatString.compare( QLatin1String(
"suffix" ), Qt::CaseInsensitive ) == 0 )
1795 else if ( formatString.compare( QLatin1String(
"aligned" ), Qt::CaseInsensitive ) == 0 )
1799 else if ( ! formatString.isEmpty() )
1801 parent->
setEvalErrorString( QObject::tr(
"Invalid formatting parameter: '%1'. It must be empty, or 'suffix' or 'aligned'." ).arg( formatString ) );
1805 if ( axis.compare( QLatin1String(
"x" ), Qt::CaseInsensitive ) == 0 )
1809 else if ( axis.compare( QLatin1String(
"y" ), Qt::CaseInsensitive ) == 0 )
1815 parent->
setEvalErrorString( QObject::tr(
"Invalid axis name: '%1'. It must be either 'x' or 'y'." ).arg( axis ) );
1823 return floatToDegreeFormat( format, values, context, parent, node );
1829 return floatToDegreeFormat( format, values, context, parent, node );
1834 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1835 QDateTime d2 = QgsExpressionUtils::getDateTimeValue( values.at( 1 ), parent );
1836 qint64 seconds = d2.secsTo( d1 );
1837 return QVariant::fromValue(
QgsInterval( seconds ) );
1842 if ( !values.at( 0 ).canConvert<QDate>() )
1845 QDate date = QgsExpressionUtils::getDateValue( values.at( 0 ), parent );
1846 if ( !date.isValid() )
1851 return date.dayOfWeek() % 7;
1856 QVariant value = values.at( 0 );
1857 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1860 return QVariant( inter.
days() );
1864 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1865 return QVariant( d1.date().day() );
1871 QVariant value = values.at( 0 );
1872 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1875 return QVariant( inter.
years() );
1879 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1880 return QVariant( d1.date().year() );
1886 QVariant value = values.at( 0 );
1887 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1890 return QVariant( inter.
months() );
1894 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1895 return QVariant( d1.date().month() );
1901 QVariant value = values.at( 0 );
1902 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1905 return QVariant( inter.
weeks() );
1909 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1910 return QVariant( d1.date().weekNumber() );
1916 QVariant value = values.at( 0 );
1917 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1920 return QVariant( inter.
hours() );
1924 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1925 return QVariant( t1.hour() );
1931 QVariant value = values.at( 0 );
1932 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1935 return QVariant( inter.
minutes() );
1939 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1940 return QVariant( t1.minute() );
1946 QVariant value = values.at( 0 );
1947 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1950 return QVariant( inter.
seconds() );
1954 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1955 return QVariant( t1.second() );
1961 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1964 return QVariant( dt.toMSecsSinceEpoch() );
1972 #define ENSURE_GEOM_TYPE(f, g, geomtype) \ 1973 if ( !(f).hasGeometry() ) \ 1974 return QVariant(); \ 1975 QgsGeometry g = (f).geometry(); \ 1976 if ( (g).type() != (geomtype) ) \ 1983 if ( g.isMultipart() )
1985 return g.asMultiPoint().at( 0 ).x();
1989 return g.asPoint().x();
1997 if ( g.isMultipart() )
1999 return g.asMultiPoint().at( 0 ).y();
2003 return g.asPoint().y();
2009 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2021 QVariant result( centroid.
asPoint().
x() );
2027 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2039 QVariant result( centroid.
asPoint().
y() );
2045 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2060 if ( collection->numGeometries() == 1 )
2062 if (
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( collection->geometryN( 0 ) ) )
2073 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2088 if ( collection->numGeometries() == 1 )
2090 if (
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( collection->geometryN( 0 ) ) )
2101 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2106 int idx = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
2133 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2150 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2167 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2172 bool ignoreClosing =
false;
2173 if ( values.length() > 1 )
2175 ignoreClosing = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
2185 bool skipLast =
false;
2186 if ( ignoreClosing && ring.count() > 2 && ring.first() == ring.last() )
2191 for (
int i = 0; i < ( skipLast ? ring.count() - 1 : ring.count() ); ++ i )
2193 mp->addGeometry( ring.at( i ).clone() );
2203 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2214 for (
int i = 0; i < line->numPoints() - 1; ++i )
2218 << line->pointN( i )
2219 << line->pointN( i + 1 ) );
2220 ml->addGeometry( segment );
2230 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2240 if ( collection->numGeometries() == 1 )
2247 if ( !curvePolygon )
2251 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
2257 QVariant result = curve ? QVariant::fromValue(
QgsGeometry( curve ) ) : QVariant();
2263 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2273 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
2279 QVariant result = part ? QVariant::fromValue(
QgsGeometry( part ) ) : QVariant();
2285 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2294 return QVariant::fromValue(
QgsGeometry( boundary ) );
2299 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2308 return QVariant::fromValue( merged );
2313 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2318 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2321 if ( simplified.isNull() )
2329 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2334 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2339 if ( simplified.
isNull() )
2347 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2352 int iterations = std::min( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), 10 );
2353 double offset = qBound( 0.0, QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ), 0.5 );
2354 double minLength = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2355 double maxAngle = qBound( 0.0, QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent ), 180.0 );
2357 QgsGeometry smoothed = geom.
smooth( static_cast<unsigned int>( iterations ), offset, minLength, maxAngle );
2367 if ( values.size() == 1 && ( values.at( 0 ).type() == QVariant::List || values.at( 0 ).type() == QVariant::StringList ) )
2369 list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
2376 QVector< QgsGeometry > parts;
2377 parts.reserve( list.size() );
2378 for (
const QVariant &value : qgis::as_const( list ) )
2396 if ( values.count() < 2 || values.count() > 4 )
2398 parent->
setEvalErrorString( QObject::tr(
"Function make_point requires 2-4 arguments" ) );
2402 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2403 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2404 double z = values.count() >= 3 ? QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) : 0.0;
2405 double m = values.count() >= 4 ? QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) : 0.0;
2406 switch ( values.count() )
2420 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2421 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2422 double m = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2428 if ( values.empty() )
2433 QVector<QgsPoint> points;
2434 points.reserve( values.count() );
2436 auto addPoint = [&points](
const QgsGeometry & geom )
2438 if ( geom.isNull() )
2451 for (
const QVariant &value : values )
2453 if ( value.type() == QVariant::List )
2455 const QVariantList list = value.toList();
2456 for (
const QVariant &v : list )
2458 addPoint( QgsExpressionUtils::getGeometry( v, parent ) );
2463 addPoint( QgsExpressionUtils::getGeometry( value, parent ) );
2467 if ( points.count() < 2 )
2475 if ( values.count() < 1 )
2477 parent->
setEvalErrorString( QObject::tr(
"Function make_polygon requires an argument" ) );
2481 QgsGeometry outerRing = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2485 std::unique_ptr< QgsPolygon > polygon = qgis::make_unique< QgsPolygon >();
2492 if ( collection->numGeometries() == 1 )
2499 if ( !exteriorRing )
2502 polygon->setExteriorRing( exteriorRing->segmentize() );
2505 for (
int i = 1; i < values.count(); ++i )
2507 QgsGeometry ringGeom = QgsExpressionUtils::getGeometry( values.at( i ), parent );
2519 if ( collection->numGeometries() == 1 )
2529 polygon->addInteriorRing( ring->
segmentize() );
2532 return QVariant::fromValue(
QgsGeometry( std::move( polygon ) ) );
2537 std::unique_ptr<QgsTriangle> tr(
new QgsTriangle() );
2538 std::unique_ptr<QgsLineString> lineString(
new QgsLineString() );
2539 lineString->clear();
2541 for (
const QVariant &value : values )
2543 QgsGeometry geom = QgsExpressionUtils::getGeometry( value, parent );
2555 if ( collection->numGeometries() == 1 )
2565 lineString->addVertex( *point );
2568 tr->setExteriorRing( lineString.release() );
2570 return QVariant::fromValue(
QgsGeometry( tr.release() ) );
2575 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2582 double radius = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2583 int segment = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
2595 if ( collection->numGeometries() == 1 )
2605 return QVariant::fromValue(
QgsGeometry( circ.
toPolygon( static_cast<unsigned int>( segment ) ) ) );
2610 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2617 double majorAxis = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2618 double minorAxis = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2619 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2620 int segment = QgsExpressionUtils::getNativeIntValue( values.at( 4 ), parent );
2631 if ( collection->numGeometries() == 1 )
2640 QgsEllipse elp( *point, majorAxis, minorAxis, azimuth );
2641 return QVariant::fromValue(
QgsGeometry( elp.
toPolygon( static_cast<unsigned int>( segment ) ) ) );
2647 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2654 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2661 unsigned int nbEdges =
static_cast<unsigned int>( QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) );
2664 parent->
setEvalErrorString( QObject::tr(
"Number of edges/sides must be greater than 2" ) );
2671 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (inscribed) or 1 (circumscribed)" ) );
2680 if ( collection->numGeometries() == 1 )
2694 if ( collection->numGeometries() == 1 )
2711 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2717 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2727 return QVariant::fromValue(
QgsGeometry( square.toPolygon() ) );
2732 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2738 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2744 QgsGeometry pt3 = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
2753 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (distance) or 1 (projected)" ) );
2760 return QVariant::fromValue(
QgsGeometry( rect.toPolygon() ) );
2766 int idx = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
2775 if ( idx < 0 || idx >= g.constGet()->nCoordinates() )
2782 return QVariant( QPointF( p.
x(), p.
y() ) );
2787 QVariant v = pointAt( values, f, parent );
2788 if ( v.type() == QVariant::PointF )
2789 return QVariant( v.toPointF().x() );
2795 QVariant v = pointAt( values, f, parent );
2796 if ( v.type() == QVariant::PointF )
2797 return QVariant( v.toPointF().y() );
2806 return QVariant::fromValue( geom );
2808 return QVariant( QVariant::UserType );
2812 QString wkt = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2814 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2819 QString gml = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2821 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2834 return QVariant( area );
2838 return QVariant( f.geometry().area() );
2844 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2849 return QVariant( geom.
area() );
2861 return QVariant( len );
2865 return QVariant( f.geometry().length() );
2878 return QVariant( len );
2882 return f.geometry().isNull() ? QVariant( 0 ) : QVariant( f.geometry().constGet()->perimeter() );
2888 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2894 return QVariant( geom.
length() );
2899 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2905 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2914 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2927 for (
int i = 0; i < collection->numGeometries(); ++i )
2930 if ( !curvePolygon )
2942 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2949 return QVariant( curvePolygon->
ringCount() );
2951 bool foundPoly =
false;
2960 if ( !curvePolygon )
2971 return QVariant( ringCount );
2976 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2978 QVariant result = !geomBounds.
isNull() ? QVariant::fromValue( geomBounds ) : QVariant();
2984 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2990 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2996 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3002 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3008 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3014 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3020 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3024 std::unique_ptr< QgsAbstractGeometry > flipped( geom.
constGet()->
clone() );
3026 return QVariant::fromValue(
QgsGeometry( std::move( flipped ) ) );
3031 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3040 if ( collection->numGeometries() == 1 )
3050 return QVariant::fromValue( curve->
isClosed() );
3055 if ( values.length() < 2 || values.length() > 3 )
3058 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3059 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3061 if ( fGeom.
isNull() || sGeom.isNull() )
3066 if ( values.length() == 2 )
3069 QString result = engine->relate( sGeom.constGet() );
3070 return QVariant::fromValue( result );
3075 QString pattern = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
3076 bool result = engine->relatePattern( sGeom.constGet(), pattern );
3077 return QVariant::fromValue( result );
3083 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3084 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3085 return fGeom.
intersects( sGeom.boundingBox() ) ? TVL_True : TVL_False;
3089 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3090 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3091 return fGeom.
disjoint( sGeom ) ? TVL_True : TVL_False;
3095 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3096 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3097 return fGeom.
intersects( sGeom ) ? TVL_True : TVL_False;
3101 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3102 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3103 return fGeom.
touches( sGeom ) ? TVL_True : TVL_False;
3107 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3108 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3109 return fGeom.
crosses( sGeom ) ? TVL_True : TVL_False;
3113 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3114 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3115 return fGeom.
contains( sGeom ) ? TVL_True : TVL_False;
3119 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3120 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3121 return fGeom.
overlaps( sGeom ) ? TVL_True : TVL_False;
3125 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3126 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3127 return fGeom.
within( sGeom ) ? TVL_True : TVL_False;
3131 if ( values.length() < 2 || values.length() > 3 )
3134 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3135 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3137 if ( values.length() == 3 )
3138 seg = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
3141 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3147 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3149 return !reoriented.
isNull() ? QVariant::fromValue( reoriented ) : QVariant();
3154 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3160 if ( collection->numGeometries() == 1 )
3169 parent->
setEvalErrorString( QObject::tr(
"Function `wedge_buffer` requires a point value for the center." ) );
3173 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3174 double width = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3175 double outerRadius = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3176 double innerRadius = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
3179 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
3185 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3188 parent->
setEvalErrorString( QObject::tr(
"Function `tapered_buffer` requires a line geometry." ) );
3192 double startWidth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3193 double endWidth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3194 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) );
3197 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3203 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3206 parent->
setEvalErrorString( QObject::tr(
"Function `buffer_by_m` requires a line geometry." ) );
3210 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3213 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3219 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3220 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3221 int segments = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
3225 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3228 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3234 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3235 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3236 int segments = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
3240 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3243 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3249 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3250 double distStart = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3251 double distEnd = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3254 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3260 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3261 double dx = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3262 double dy = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3264 return QVariant::fromValue( fGeom );
3268 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3270 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3275 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3277 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3283 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3284 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3286 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3292 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3294 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3301 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3303 if ( values.length() == 2 )
3304 segments = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3312 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3318 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3320 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3326 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3327 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3329 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3335 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3347 result = reversed ? QVariant::fromValue(
QgsGeometry( reversed ) ) : QVariant();
3355 if (
const QgsCurve *curve = qgsgeometry_cast<const QgsCurve * >( collection->
geometryN( i ) ) )
3364 result = reversed ? QVariant::fromValue(
QgsGeometry( std::move( reversed ) ) ) : QVariant();
3371 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3380 if ( collection->numGeometries() == 1 )
3391 QVariant result = exterior ? QVariant::fromValue(
QgsGeometry( exterior ) ) : QVariant();
3397 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3398 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3399 return QVariant( fGeom.
distance( sGeom ) );
3404 QgsGeometry g1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3405 QgsGeometry g2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3408 if ( values.length() == 3 && values.at( 2 ).isValid() )
3410 double densify = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3411 densify = qBound( 0.0, densify, 1.0 );
3419 return res > -1 ? QVariant( res ) : QVariant();
3424 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3425 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3427 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3432 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3433 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3435 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3440 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3441 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3443 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3448 if ( values.length() < 1 || values.length() > 2 )
3451 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3453 if ( values.length() == 2 )
3454 prec = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3455 QString wkt = fGeom.
asWkt( prec );
3456 return QVariant( wkt );
3461 if ( values.length() != 2 )
3463 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires exactly two parameters. %1 given." ).arg( values.length() ) );
3467 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3468 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3475 if ( collection->numGeometries() == 1 )
3483 if ( !pt2 && fGeom2.isMultipart() )
3485 if (
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( fGeom2.constGet() ) )
3487 if ( collection->numGeometries() == 1 )
3496 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires two points as arguments." ) );
3503 if ( pt1->y() < pt2->y() )
3505 else if ( pt1->y() > pt2->y() )
3513 if ( pt1->x() < pt2->x() )
3515 else if ( pt1->x() > pt2->x() )
3516 return M_PI + ( M_PI_2 );
3521 if ( pt1->x() < pt2->x() )
3523 if ( pt1->y() < pt2->y() )
3525 return std::atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) );
3529 return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
3536 if ( pt1->y() > pt2->y() )
3538 return std::atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) )
3543 return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
3544 + ( M_PI + ( M_PI_2 ) );
3551 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3555 parent->
setEvalErrorString( QStringLiteral(
"'project' requires a point geometry" ) );
3559 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3560 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3561 double inclination = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3564 QgsPoint newPoint = p->
project( distance, 180.0 * azimuth / M_PI, 180.0 * inclination / M_PI );
3571 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3572 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3579 if ( collection->numGeometries() == 1 )
3586 if ( !pt2 && fGeom2.isMultipart() )
3588 if (
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( fGeom2.constGet() ) )
3590 if ( collection->numGeometries() == 1 )
3600 parent->
setEvalErrorString( QStringLiteral(
"Function 'inclination' requires two points as arguments." ) );
3604 return pt1->inclination( *pt2 );
3610 if ( values.length() != 3 )
3613 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3614 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3615 double y = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3619 QVariant result = geom.
constGet() ? QVariant::fromValue( geom ) : QVariant();
3625 if ( values.length() < 2 )
3628 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3631 return values.at( 0 );
3633 QString expString = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3634 QVariant cachedExpression;
3639 if ( cachedExpression.isValid() )
3646 bool asc = values.value( 2 ).toBool();
3664 Q_ASSERT( collection );
3668 QgsExpressionSorter sorter( orderBy );
3670 QList<QgsFeature> partFeatures;
3671 partFeatures.reserve( collection->
partCount() );
3672 for (
int i = 0; i < collection->
partCount(); ++i )
3678 sorter.sortFeatures( partFeatures, unconstedContext );
3682 Q_ASSERT( orderedGeom );
3687 for (
const QgsFeature &feature : qgis::as_const( partFeatures ) )
3689 orderedGeom->
addGeometry( feature.geometry().constGet()->clone() );
3692 QVariant result = QVariant::fromValue(
QgsGeometry( orderedGeom ) );
3695 delete unconstedContext;
3702 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3703 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3707 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3713 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3714 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3718 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3724 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3725 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3729 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3735 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3738 parent->
setEvalErrorString( QObject::tr(
"line_substring requires a curve geometry input" ) );
3744 curve = qgsgeometry_cast< const QgsCurve * >( lineGeom.
constGet() );
3749 if ( collection->numGeometries() > 0 )
3758 double startDistance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3759 double endDistance = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3761 std::unique_ptr< QgsCurve > substring( curve->
curveSubstring( startDistance, endDistance ) );
3763 return !result.isNull() ? QVariant::fromValue( result ) : QVariant();
3768 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3769 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3776 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3777 int vertex = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3782 vertex = count + vertex;
3790 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3791 int vertex = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3796 vertex = count + vertex;
3804 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3805 QgsGeometry pointGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3809 return distance >= 0 ? distance : QVariant();
3814 if ( values.length() == 2 && values.at( 1 ).toInt() != 0 )
3816 double number = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
3817 return qgsRound( number, QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
3820 if ( values.length() >= 1 )
3822 double number = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3823 return QVariant( qlonglong( std::round( number ) ) );
3838 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
3839 int places = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3845 QLocale locale = QLocale();
3846 locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
3847 return locale.toString( value,
'f', places );
3852 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
3853 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3854 return dt.toString( format );
3860 int avg = ( color.red() + color.green() + color.blue() ) / 3;
3861 int alpha = color.alpha();
3863 color.setRgb( avg, avg, avg, alpha );
3872 double ratio = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3877 else if ( ratio < 0 )
3882 int red =
static_cast<int>( color1.red() * ( 1 - ratio ) + color2.red() * ratio );
3883 int green =
static_cast<int>( color1.green() * ( 1 - ratio ) + color2.green() * ratio );
3884 int blue =
static_cast<int>( color1.blue() * ( 1 - ratio ) + color2.blue() * ratio );
3885 int alpha =
static_cast<int>( color1.alpha() * ( 1 - ratio ) + color2.alpha() * ratio );
3887 QColor newColor( red, green, blue, alpha );
3894 int red = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
3895 int green = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3896 int blue = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
3897 QColor color = QColor( red, green, blue );
3898 if ( ! color.isValid() )
3900 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( red ).arg( green ).arg( blue ) );
3901 color = QColor( 0, 0, 0 );
3904 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3909 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
3910 QVariant value = node->
eval( parent, context );
3914 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
3916 value = node->
eval( parent, context );
3924 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
3926 QVariant value = node->
eval( parent, context );
3928 if ( value.toBool() )
3930 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
3932 value = node->
eval( parent, context );
3937 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
3939 value = node->
eval( parent, context );
3947 int red = QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent );
3948 int green = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
3949 int blue = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
3950 int alpha = QgsExpressionUtils::getNativeIntValue( values.at( 3 ), parent );
3951 QColor color = QColor( red, green, blue, alpha );
3952 if ( ! color.isValid() )
3954 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( red ).arg( green ).arg( blue ).arg( alpha ) );
3955 color = QColor( 0, 0, 0 );
3966 expRamp = QgsExpressionUtils::getRamp( values.at( 0 ), parent );
3971 QString rampName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
3975 parent->
setEvalErrorString( QObject::tr(
"\"%1\" is not a valid color ramp" ).arg( rampName ) );
3980 double value = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3981 QColor color = ramp->
color( value );
3988 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3990 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3992 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3994 QColor color = QColor::fromHslF( hue, saturation, lightness );
3996 if ( ! color.isValid() )
3998 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( lightness ) );
3999 color = QColor( 0, 0, 0 );
4002 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
4008 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
4010 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
4012 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
4014 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
4016 QColor color = QColor::fromHslF( hue, saturation, lightness, alpha );
4017 if ( ! color.isValid() )
4019 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
4020 color = QColor( 0, 0, 0 );
4028 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
4030 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
4032 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
4034 QColor color = QColor::fromHsvF( hue, saturation, value );
4036 if ( ! color.isValid() )
4038 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( value ) );
4039 color = QColor( 0, 0, 0 );
4042 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
4048 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
4050 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
4052 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
4054 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
4056 QColor color = QColor::fromHsvF( hue, saturation, value, alpha );
4057 if ( ! color.isValid() )
4059 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
4060 color = QColor( 0, 0, 0 );
4068 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
4070 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
4072 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
4074 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
4076 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black );
4078 if ( ! color.isValid() )
4080 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ) );
4081 color = QColor( 0, 0, 0 );
4084 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
4090 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
4092 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
4094 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
4096 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
4098 double alpha = QgsExpressionUtils::getIntValue( values.at( 4 ), parent ) / 255.0;
4100 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
4101 if ( ! color.isValid() )
4103 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
4104 color = QColor( 0, 0, 0 );
4112 if ( ! color.isValid() )
4114 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4118 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4119 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
4121 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
4122 return color.green();
4123 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
4124 return color.blue();
4125 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
4126 return color.alpha();
4127 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
4128 return color.hsvHueF() * 360;
4129 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
4130 return color.hsvSaturationF() * 100;
4131 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
4132 return color.valueF() * 100;
4133 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
4134 return color.hslHueF() * 360;
4135 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
4136 return color.hslSaturationF() * 100;
4137 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
4138 return color.lightnessF() * 100;
4139 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
4140 return color.cyanF() * 100;
4141 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
4142 return color.magentaF() * 100;
4143 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
4144 return color.yellowF() * 100;
4145 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
4146 return color.blackF() * 100;
4148 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
4154 const QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4155 if ( map.count() < 1 )
4157 parent->
setEvalErrorString( QObject::tr(
"A minimum of two colors is required to create a ramp" ) );
4161 QList< QColor > colors;
4163 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
4166 if ( !colors.last().isValid() )
4168 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( it.value().toString() ) );
4172 double step = it.key().toDouble();
4173 if ( it == map.constBegin() )
4178 else if ( it == map.constEnd() )
4188 bool discrete = values.at( 1 ).toBool();
4190 return QVariant::fromValue(
QgsGradientColorRamp( colors.first(), colors.last(), discrete, stops ) );
4196 if ( ! color.isValid() )
4198 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4202 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4203 int value = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
4204 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
4205 color.setRed( value );
4206 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
4207 color.setGreen( value );
4208 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
4209 color.setBlue( value );
4210 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
4211 color.setAlpha( value );
4212 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
4213 color.setHsv( value, color.hsvSaturation(), color.value(), color.alpha() );
4214 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
4215 color.setHsvF( color.hsvHueF(), value / 100.0, color.valueF(), color.alphaF() );
4216 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
4217 color.setHsvF( color.hsvHueF(), color.hsvSaturationF(), value / 100.0, color.alphaF() );
4218 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
4219 color.setHsl( value, color.hslSaturation(), color.lightness(), color.alpha() );
4220 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
4221 color.setHslF( color.hslHueF(), value / 100.0, color.lightnessF(), color.alphaF() );
4222 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
4223 color.setHslF( color.hslHueF(), color.hslSaturationF(), value / 100.0, color.alphaF() );
4224 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
4225 color.setCmykF( value / 100.0, color.magentaF(), color.yellowF(), color.blackF(), color.alphaF() );
4226 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
4227 color.setCmykF( color.cyanF(), value / 100.0, color.yellowF(), color.blackF(), color.alphaF() );
4228 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
4229 color.setCmykF( color.cyanF(), color.magentaF(), value / 100.0, color.blackF(), color.alphaF() );
4230 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
4231 color.setCmykF( color.cyanF(), color.magentaF(), color.yellowF(), value / 100.0, color.alphaF() );
4234 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
4243 if ( ! color.isValid() )
4245 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4249 color = color.darker( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
4257 if ( ! color.isValid() )
4259 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4263 color = color.lighter( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
4270 QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
4272 if ( !geom.isNull() )
4273 return QVariant::fromValue( geom );
4279 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4280 QString sAuthId = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4281 QString dAuthId = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4284 if ( ! s.isValid() )
4285 return QVariant::fromValue( fGeom );
4288 return QVariant::fromValue( fGeom );
4297 return QVariant::fromValue( fGeom );
4311 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
4314 QgsFeatureId fid = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4324 result = QVariant::fromValue( fet );
4334 std::unique_ptr<QgsVectorLayerFeatureSource> featureSource = QgsExpressionUtils::getFeatureSource( values.at( 0 ), parent );
4337 if ( !featureSource )
4342 QString attribute = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4343 int attributeId = featureSource->fields().lookupField( attribute );
4344 if ( attributeId == -1 )
4349 const QVariant &attVal = values.at( 2 );
4351 const QString cacheValueKey = QStringLiteral(
"getfeature:%1:%2:%3" ).arg( featureSource->id(), QString::number( attributeId ), attVal.toString() );
4373 res = QVariant::fromValue( fet );
4388 if ( !values.isEmpty() )
4391 if ( col && ( values.size() == 1 || !values.at( 1 ).isValid() ) )
4392 fieldName = col->
name();
4393 else if ( values.size() == 2 )
4394 fieldName = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4397 QVariant value = values.at( 0 );
4402 if ( fieldIndex == -1 )
4404 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: Field not found %2" ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
4408 QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
4410 const QString cacheValueKey = QStringLiteral(
"repvalfcnval:%1:%2:%3" ).arg( layer ? layer->
id() : QStringLiteral(
"[None]" ), fieldName, value.toString() );
4419 const QString cacheKey = QStringLiteral(
"repvalfcn:%1:%2" ).arg( layer ? layer->
id() : QStringLiteral(
"[None]" ), fieldName );
4437 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: function cannot be evaluated without a context." ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
4445 QgsMapLayer *layer = QgsExpressionUtils::getMapLayer( values.at( 0 ), parent );
4451 QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4452 if ( QString::compare( layerProperty, QStringLiteral(
"name" ), Qt::CaseInsensitive ) == 0 )
4453 return layer->
name();
4454 else if ( QString::compare( layerProperty, QStringLiteral(
"id" ), Qt::CaseInsensitive ) == 0 )
4456 else if ( QString::compare( layerProperty, QStringLiteral(
"title" ), Qt::CaseInsensitive ) == 0 )
4458 else if ( QString::compare( layerProperty, QStringLiteral(
"abstract" ), Qt::CaseInsensitive ) == 0 )
4460 else if ( QString::compare( layerProperty, QStringLiteral(
"keywords" ), Qt::CaseInsensitive ) == 0 )
4462 QStringList keywords;
4464 for (
auto it = keywordMap.constBegin(); it != keywordMap.constEnd(); ++it )
4466 keywords.append( it.value() );
4468 if ( !keywords.isEmpty() )
4472 else if ( QString::compare( layerProperty, QStringLiteral(
"data_url" ), Qt::CaseInsensitive ) == 0 )
4474 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution" ), Qt::CaseInsensitive ) == 0 )
4478 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution_url" ), Qt::CaseInsensitive ) == 0 )
4480 else if ( QString::compare( layerProperty, QStringLiteral(
"source" ), Qt::CaseInsensitive ) == 0 )
4482 else if ( QString::compare( layerProperty, QStringLiteral(
"min_scale" ), Qt::CaseInsensitive ) == 0 )
4484 else if ( QString::compare( layerProperty, QStringLiteral(
"max_scale" ), Qt::CaseInsensitive ) == 0 )
4486 else if ( QString::compare( layerProperty, QStringLiteral(
"crs" ), Qt::CaseInsensitive ) == 0 )
4488 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_definition" ), Qt::CaseInsensitive ) == 0 )
4490 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_description" ), Qt::CaseInsensitive ) == 0 )
4492 else if ( QString::compare( layerProperty, QStringLiteral(
"extent" ), Qt::CaseInsensitive ) == 0 )
4495 QVariant result = QVariant::fromValue( extentGeom );
4498 else if ( QString::compare( layerProperty, QStringLiteral(
"type" ), Qt::CaseInsensitive ) == 0 )
4500 switch ( layer->
type() )
4503 return QCoreApplication::translate(
"expressions",
"Vector" );
4505 return QCoreApplication::translate(
"expressions",
"Raster" );
4507 return QCoreApplication::translate(
"expressions",
"Mesh" );
4509 return QCoreApplication::translate(
"expressions",
"Plugin" );
4518 if ( QString::compare( layerProperty, QStringLiteral(
"storage_type" ), Qt::CaseInsensitive ) == 0 )
4520 else if ( QString::compare( layerProperty, QStringLiteral(
"geometry_type" ), Qt::CaseInsensitive ) == 0 )
4522 else if ( QString::compare( layerProperty, QStringLiteral(
"feature_count" ), Qt::CaseInsensitive ) == 0 )
4524 else if ( QString::compare( layerProperty, QStringLiteral(
"path" ), Qt::CaseInsensitive ) == 0 )
4529 return decodedUri.value( QStringLiteral(
"path" ) );
4540 QgsMapLayer *layer = QgsExpressionUtils::getMapLayer( values.at( 0 ), parent );
4543 parent->
setEvalErrorString( QObject::tr(
"Cannot find layer %1" ).arg( values.at( 0 ).toString() ) );
4553 const QString uriPart = values.at( 1 ).toString();
4557 if ( !uriPart.isNull() )
4559 return decodedUri.value( values.at( 1 ).toString() );
4569 QString layerIdOrName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4576 if ( !layersByName.isEmpty() )
4578 layer = layersByName.at( 0 );
4589 int band = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4590 if ( band < 1 || band > rl->
bandCount() )
4592 parent->
setEvalErrorString( QObject::tr(
"Invalid band number %1 for layer %2" ).arg( band ).arg( layerIdOrName ) );
4596 QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4599 if ( QString::compare( layerProperty, QStringLiteral(
"avg" ), Qt::CaseInsensitive ) == 0 )
4601 else if ( QString::compare( layerProperty, QStringLiteral(
"stdev" ), Qt::CaseInsensitive ) == 0 )
4603 else if ( QString::compare( layerProperty, QStringLiteral(
"min" ), Qt::CaseInsensitive ) == 0 )
4605 else if ( QString::compare( layerProperty, QStringLiteral(
"max" ), Qt::CaseInsensitive ) == 0 )
4607 else if ( QString::compare( layerProperty, QStringLiteral(
"range" ), Qt::CaseInsensitive ) == 0 )
4609 else if ( QString::compare( layerProperty, QStringLiteral(
"sum" ), Qt::CaseInsensitive ) == 0 )
4613 parent->
setEvalErrorString( QObject::tr(
"Invalid raster statistic: '%1'" ).arg( layerProperty ) );
4643 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4644 bool ascending = values.value( 1 ).toBool();
4651 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).length();
4656 return QVariant( QgsExpressionUtils::getListValue( values.at( 0 ), parent ).contains( values.at( 1 ) ) );
4661 QVariantList listA = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4662 QVariantList listB = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
4664 for (
const auto &item : listB )
4666 if ( listA.contains( item ) )
4670 return QVariant( match == listB.count() );
4675 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).indexOf( values.at( 1 ) );
4680 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4681 const int pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4682 if ( pos < 0 || pos >= list.length() )
return QVariant();
4683 return list.at( pos );
4688 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4689 return list.value( 0 );
4694 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4695 return list.value( list.size() - 1 );
4698 static QVariant convertToSameType(
const QVariant &value, QVariant::Type type )
4700 QVariant result = value;
4701 result.convert( static_cast<int>( type ) );
4707 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4708 list.append( values.at( 1 ) );
4709 return convertToSameType( list, values.at( 0 ).type() );
4714 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4715 list.prepend( values.at( 1 ) );
4716 return convertToSameType( list, values.at( 0 ).type() );
4721 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4722 list.insert( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), values.at( 2 ) );
4723 return convertToSameType( list, values.at( 0 ).type() );
4728 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4729 list.removeAt( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ) );
4730 return convertToSameType( list, values.at( 0 ).type() );
4735 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4736 list.removeAll( values.at( 1 ) );
4737 return convertToSameType( list, values.at( 0 ).type() );
4743 for (
const QVariant &cur : values )
4745 list += QgsExpressionUtils::getListValue( cur, parent );
4747 return convertToSameType( list, values.at( 0 ).type() );
4752 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4753 int start_pos = QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent );
4754 const int end_pos = QgsExpressionUtils::getNativeIntValue( values.at( 2 ), parent );
4755 int slice_length = 0;
4757 if ( start_pos < 0 )
4759 start_pos = list.length() + start_pos;
4763 slice_length = end_pos - start_pos + 1;
4767 slice_length = list.length() + end_pos - start_pos + 1;
4770 if ( slice_length < 0 )
4774 list = list.mid( start_pos, slice_length );
4780 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4781 std::reverse( list.begin(), list.end() );
4787 const QVariantList array1 = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4788 const QVariantList array2 = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
4789 for (
const QVariant &cur : array2 )
4791 if ( array1.contains( cur ) )
4792 return QVariant(
true );
4794 return QVariant(
false );
4799 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4801 QVariantList distinct;
4803 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
4805 if ( !distinct.contains( *it ) )
4807 distinct += ( *it );
4816 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4817 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4818 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4822 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
4824 str += ( !( *it ).toString().isEmpty() ) ? ( *it ).toString() : empty;
4825 if ( it != ( array.constEnd() - 1 ) )
4831 return QVariant( str );
4836 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4837 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4838 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4840 QStringList list = str.split( delimiter );
4843 for ( QStringList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
4845 array += ( !( *it ).isEmpty() ) ? *it : empty;
4853 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4854 QJsonDocument document = QJsonDocument::fromJson( str.toUtf8() );
4855 if ( document.isNull() )
4858 return document.toVariant();
4864 QJsonDocument document = QJsonDocument::fromVariant( values.at( 0 ) );
4865 return document.toJson( QJsonDocument::Compact );
4870 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4871 if ( str.isEmpty() )
4872 return QVariantMap();
4873 str = str.trimmed();
4880 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4887 for (
int i = 0; i + 1 < values.length(); i += 2 )
4889 result.insert( QgsExpressionUtils::getStringValue( values.at( i ), parent ), values.at( i + 1 ) );
4896 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).value( values.at( 1 ).toString() );
4901 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).contains( values.at( 1 ).toString() );
4906 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4907 map.remove( values.at( 1 ).toString() );
4913 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4914 map.insert( values.at( 1 ).toString(), values.at( 2 ) );
4921 for (
const QVariant &cur : values )
4923 const QVariantMap curMap = QgsExpressionUtils::getMapValue( cur, parent );
4924 for ( QVariantMap::const_iterator it = curMap.constBegin(); it != curMap.constEnd(); ++it )
4925 result.insert( it.key(), it.value() );
4932 return QStringList( QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).keys() );
4937 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).values();
4942 QString envVarName = values.at( 0 ).toString();
4943 return QProcessEnvironment::systemEnvironment().value( envVarName );
4948 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4949 return QFileInfo( file ).completeBaseName();
4954 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4955 return QFileInfo( file ).completeSuffix();
4960 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4961 return QFileInfo::exists( file );
4966 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4967 return QFileInfo( file ).fileName();
4972 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4973 return QFileInfo( file ).isFile();
4978 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4979 return QFileInfo( file ).isDir();
4984 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4985 return QDir::toNativeSeparators( QFileInfo( file ).path() );
4990 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4991 return QFileInfo( file ).size();
5003 static QMutex sFunctionsMutex( QMutex::Recursive );
5004 QMutexLocker locker( &sFunctionsMutex );
5006 if ( sFunctions.isEmpty() )
5018 aggParamsArray << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true );
5024 <<
new QgsStaticExpressionFunction( QStringLiteral(
"azimuth" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point_b" ) ), fcnAzimuth, QStringList() << QStringLiteral(
"Math" ) << QStringLiteral(
"GeometryGroup" ) )
5025 <<
new QgsStaticExpressionFunction( QStringLiteral(
"inclination" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point_b" ) ), fcnInclination, QStringList() << QStringLiteral(
"Math" ) << QStringLiteral(
"GeometryGroup" ) )
5026 <<
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" ) )
5041 QgsStaticExpressionFunction *randFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"rand" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"max" ) ), fcnRnd, QStringLiteral(
"Math" ) );
5043 sFunctions << randFunc;
5045 QgsStaticExpressionFunction *randfFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"randf" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"min" ),
true, 0.0 ) << QgsExpressionFunction::Parameter( QStringLiteral(
"max" ),
true, 1.0 ), fcnRndF, QStringLiteral(
"Math" ) );
5047 sFunctions << randfFunc;
5050 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max" ), -1, fcnMax, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5051 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min" ), -1, fcnMin, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5052 <<
new QgsStaticExpressionFunction( QStringLiteral(
"clamp" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"max" ) ), fcnClamp, QStringLiteral(
"Math" ) )
5053 <<
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" ) )
5054 <<
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" ) )
5055 <<
new QgsStaticExpressionFunction( QStringLiteral(
"floor" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnFloor, QStringLiteral(
"Math" ) )
5056 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ceil" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnCeil, QStringLiteral(
"Math" ) )
5057 <<
new QgsStaticExpressionFunction( QStringLiteral(
"pi" ), 0, fcnPi, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$pi" ) )
5058 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_int" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToInt, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"toint" ) )
5059 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_real" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToReal, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"toreal" ) )
5060 <<
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" ) )
5061 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_datetime" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ),
true, QVariant() ), fcnToDateTime, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todatetime" ) )
5062 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_date" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ),
true, QVariant() ), fcnToDate, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todate" ) )
5063 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_time" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ),
true, QVariant() ), fcnToTime, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"totime" ) )
5064 <<
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" ) )
5065 <<
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" ) )
5066 <<
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" ) )
5067 <<
new QgsStaticExpressionFunction( QStringLiteral(
"coalesce" ), -1, fcnCoalesce, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5068 <<
new QgsStaticExpressionFunction( QStringLiteral(
"nullif" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value2" ) ), fcnNullIf, QStringLiteral(
"Conditionals" ) )
5069 <<
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 )
5070 <<
new QgsStaticExpressionFunction( QStringLiteral(
"try" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"alternative" ),
true, QVariant() ), fcnTry, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
true )
5072 <<
new QgsStaticExpressionFunction( QStringLiteral(
"aggregate" ),
5074 << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5075 << QgsExpressionFunction::Parameter( QStringLiteral(
"aggregate" ) )
5076 << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ),
false, QVariant(),
true )
5077 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter" ),
true, QVariant(),
true )
5078 << QgsExpressionFunction::Parameter( QStringLiteral(
"concatenator" ),
true )
5079 << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true ),
5081 QStringLiteral(
"Aggregates" ),
5090 if ( !node->
args() )
5093 QSet<QString> referencedVars;
5105 return referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() );
5114 if ( !node->
args() )
5115 return QSet<QString>();
5117 QSet<QString> referencedCols;
5118 QSet<QString> referencedVars;
5133 if ( referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() ) )
5136 return referencedCols;
5142 << QgsExpressionFunction::Parameter( QStringLiteral(
"relation" ) )
5143 << QgsExpressionFunction::Parameter( QStringLiteral(
"aggregate" ) )
5144 << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ),
false, QVariant(),
true )
5145 << QgsExpressionFunction::Parameter( QStringLiteral(
"concatenator" ),
true )
5146 << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true ),
5149 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count" ), aggParams, fcnAggregateCount, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5150 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_distinct" ), aggParams, fcnAggregateCountDistinct, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5151 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_missing" ), aggParams, fcnAggregateCountMissing, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5152 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minimum" ), aggParams, fcnAggregateMin, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5153 <<
new QgsStaticExpressionFunction( QStringLiteral(
"maximum" ), aggParams, fcnAggregateMax, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5154 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sum" ), aggParams, fcnAggregateSum, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5155 <<
new QgsStaticExpressionFunction( QStringLiteral(
"mean" ), aggParams, fcnAggregateMean, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5156 <<
new QgsStaticExpressionFunction( QStringLiteral(
"median" ), aggParams, fcnAggregateMedian, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5157 <<
new QgsStaticExpressionFunction( QStringLiteral(
"stdev" ), aggParams, fcnAggregateStdev, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5158 <<
new QgsStaticExpressionFunction( QStringLiteral(
"range" ), aggParams, fcnAggregateRange, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5159 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minority" ), aggParams, fcnAggregateMinority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5160 <<
new QgsStaticExpressionFunction( QStringLiteral(
"majority" ), aggParams, fcnAggregateMajority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5161 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q1" ), aggParams, fcnAggregateQ1, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5162 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q3" ), aggParams, fcnAggregateQ3, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5163 <<
new QgsStaticExpressionFunction( QStringLiteral(
"iqr" ), aggParams, fcnAggregateIQR, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5164 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min_length" ), aggParams, fcnAggregateMinLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5165 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max_length" ), aggParams, fcnAggregateMaxLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5166 <<
new QgsStaticExpressionFunction( QStringLiteral(
"collect" ), aggParams, fcnAggregateCollectGeometry, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5167 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concatenate" ), aggParamsConcat, fcnAggregateStringConcat, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5168 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concatenate_unique" ), aggParamsConcat, fcnAggregateStringConcatUnique, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5169 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_agg" ), aggParamsArray, fcnAggregateArray, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5171 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_match" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) ), fcnRegexpMatch, QStringList() << QStringLiteral(
"Conditionals" ) << QStringLiteral(
"String" ) )
5172 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_matches" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"emptyvalue" ),
true,
"" ), fcnRegexpMatches, QStringLiteral(
"Arrays" ) )
5174 <<
new QgsStaticExpressionFunction( QStringLiteral(
"now" ), 0, fcnNow, QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$now" ) )
5176 << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime2" ) ),
5177 fcnAge, QStringLiteral(
"Date and Time" ) )
5178 <<
new QgsStaticExpressionFunction( QStringLiteral(
"year" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnYear, QStringLiteral(
"Date and Time" ) )
5179 <<
new QgsStaticExpressionFunction( QStringLiteral(
"month" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnMonth, QStringLiteral(
"Date and Time" ) )
5180 <<
new QgsStaticExpressionFunction( QStringLiteral(
"week" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnWeek, QStringLiteral(
"Date and Time" ) )
5181 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnDay, QStringLiteral(
"Date and Time" ) )
5182 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hour" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), fcnHour, QStringLiteral(
"Date and Time" ) )
5183 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minute" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), fcnMinute, QStringLiteral(
"Date and Time" ) )
5184 <<
new QgsStaticExpressionFunction( QStringLiteral(
"second" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), fcnSeconds, QStringLiteral(
"Date and Time" ) )
5185 <<
new QgsStaticExpressionFunction( QStringLiteral(
"epoch" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnEpoch, QStringLiteral(
"Date and Time" ) )
5186 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day_of_week" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnDayOfWeek, QStringLiteral(
"Date and Time" ) )
5187 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lower" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnLower, QStringLiteral(
"String" ) )
5188 <<
new QgsStaticExpressionFunction( QStringLiteral(
"upper" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnUpper, QStringLiteral(
"String" ) )
5189 <<
new QgsStaticExpressionFunction( QStringLiteral(
"title" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnTitle, QStringLiteral(
"String" ) )
5190 <<
new QgsStaticExpressionFunction( QStringLiteral(
"trim" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnTrim, QStringLiteral(
"String" ) )
5191 <<
new QgsStaticExpressionFunction( QStringLiteral(
"levenshtein" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"string2" ) ), fcnLevenshtein, QStringLiteral(
"Fuzzy Matching" ) )
5192 <<
new QgsStaticExpressionFunction( QStringLiteral(
"longest_common_substring" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"string2" ) ), fcnLCS, QStringLiteral(
"Fuzzy Matching" ) )
5193 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hamming_distance" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"string2" ) ), fcnHamming, QStringLiteral(
"Fuzzy Matching" ) )
5194 <<
new QgsStaticExpressionFunction( QStringLiteral(
"soundex" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnSoundex, QStringLiteral(
"Fuzzy Matching" ) )
5195 <<
new QgsStaticExpressionFunction( QStringLiteral(
"char" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"code" ) ), fcnChar, QStringLiteral(
"String" ) )
5196 <<
new QgsStaticExpressionFunction( QStringLiteral(
"wordwrap" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"text" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"delimiter" ),
true,
"" ), fcnWordwrap, QStringLiteral(
"String" ) )
5197 <<
new QgsStaticExpressionFunction( QStringLiteral(
"length" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"text" ),
true,
"" ), fcnLength, QStringList() << QStringLiteral(
"String" ) << QStringLiteral(
"GeometryGroup" ) )
5198 <<
new QgsStaticExpressionFunction( QStringLiteral(
"replace" ), -1, fcnReplace, QStringLiteral(
"String" ) )
5199 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_replace" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"input_string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) )
5200 << QgsExpressionFunction::Parameter( QStringLiteral(
"replacement" ) ), fcnRegexpReplace, QStringLiteral(
"String" ) )
5201 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_substr" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"input_string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) ), fcnRegexpSubstr, QStringLiteral(
"String" ) )
5202 <<
new QgsStaticExpressionFunction( QStringLiteral(
"substr" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"start " ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ),
true ), fcnSubstr, QStringLiteral(
"String" ), QString(),
5203 false, QSet< QString >(),
false, QStringList(),
true )
5204 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concat" ), -1, fcnConcat, QStringLiteral(
"String" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5205 <<
new QgsStaticExpressionFunction( QStringLiteral(
"strpos" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"haystack" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"needle" ) ), fcnStrpos, QStringLiteral(
"String" ) )
5206 <<
new QgsStaticExpressionFunction( QStringLiteral(
"left" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ) ), fcnLeft, QStringLiteral(
"String" ) )
5207 <<
new QgsStaticExpressionFunction( QStringLiteral(
"right" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ) ), fcnRight, QStringLiteral(
"String" ) )
5208 <<
new QgsStaticExpressionFunction( QStringLiteral(
"rpad" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"width" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"fill" ) ), fcnRPad, QStringLiteral(
"String" ) )
5209 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lpad" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"width" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"fill" ) ), fcnLPad, QStringLiteral(
"String" ) )
5210 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format" ), -1, fcnFormatString, QStringLiteral(
"String" ) )
5211 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format_number" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"number" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"places" ) ), fcnFormatNumber, QStringLiteral(
"String" ) )
5212 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format_date" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ) ), fcnFormatDate, QStringList() << QStringLiteral(
"String" ) << QStringLiteral(
"Date and Time" ) )
5213 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_grayscale_average" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"color" ) ), fcnColorGrayscaleAverage, QStringLiteral(
"Color" ) )
5214 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_mix_rgb" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"color1" ) )
5215 << QgsExpressionFunction::Parameter( QStringLiteral(
"color2" ) )
5216 << QgsExpressionFunction::Parameter( QStringLiteral(
"ratio" ) ),
5217 fcnColorMixRgb, QStringLiteral(
"Color" ) )
5219 << QgsExpressionFunction::Parameter( QStringLiteral(
"green" ) )
5220 << QgsExpressionFunction::Parameter( QStringLiteral(
"blue" ) ),
5221 fcnColorRgb, QStringLiteral(
"Color" ) )
5223 << QgsExpressionFunction::Parameter( QStringLiteral(
"green" ) )
5224 << QgsExpressionFunction::Parameter( QStringLiteral(
"blue" ) )
5225 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
5226 fncColorRgba, QStringLiteral(
"Color" ) )
5227 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ramp_color" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"ramp_name" ) )
5228 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ),
5231 << QgsExpressionFunction::Parameter( QStringLiteral(
"discrete" ),
true,
false ),
5232 fcnCreateRamp, QStringLiteral(
"Color" ) )
5234 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
5235 << QgsExpressionFunction::Parameter( QStringLiteral(
"lightness" ) ),
5236 fcnColorHsl, QStringLiteral(
"Color" ) )
5238 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
5239 << QgsExpressionFunction::Parameter( QStringLiteral(
"lightness" ) )
5240 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
5241 fncColorHsla, QStringLiteral(
"Color" ) )
5243 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
5244 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ),
5245 fcnColorHsv, QStringLiteral(
"Color" ) )
5247 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
5248 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) )
5249 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
5250 fncColorHsva, QStringLiteral(
"Color" ) )
5252 << QgsExpressionFunction::Parameter( QStringLiteral(
"magenta" ) )
5253 << QgsExpressionFunction::Parameter( QStringLiteral(
"yellow" ) )
5254 << QgsExpressionFunction::Parameter( QStringLiteral(
"black" ) ),
5255 fcnColorCmyk, QStringLiteral(
"Color" ) )
5257 << QgsExpressionFunction::Parameter( QStringLiteral(
"magenta" ) )
5258 << QgsExpressionFunction::Parameter( QStringLiteral(
"yellow" ) )
5259 << QgsExpressionFunction::Parameter( QStringLiteral(
"black" ) )
5260 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
5261 fncColorCmyka, QStringLiteral(
"Color" ) )
5263 << QgsExpressionFunction::Parameter( QStringLiteral(
"component" ) ),
5264 fncColorPart, QStringLiteral(
"Color" ) )
5266 << QgsExpressionFunction::Parameter( QStringLiteral(
"factor" ) ),
5267 fncDarker, QStringLiteral(
"Color" ) )
5269 << QgsExpressionFunction::Parameter( QStringLiteral(
"factor" ) ),
5270 fncLighter, QStringLiteral(
"Color" ) )
5271 <<
new QgsStaticExpressionFunction( QStringLiteral(
"set_color_part" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"color" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"component" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fncSetColorPart, QStringLiteral(
"Color" ) )
5274 <<
new QgsStaticExpressionFunction( QStringLiteral(
"base_file_name" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"path" ) ),
5275 fcnBaseFileName, QStringLiteral(
"Files and Paths" ) )
5277 fcnFileSuffix, QStringLiteral(
"Files and Paths" ) )
5279 fcnFileExists, QStringLiteral(
"Files and Paths" ) )
5281 fcnFileName, QStringLiteral(
"Files and Paths" ) )
5283 fcnPathIsFile, QStringLiteral(
"Files and Paths" ) )
5285 fcnPathIsDir, QStringLiteral(
"Files and Paths" ) )
5287 fcnFilePath, QStringLiteral(
"Files and Paths" ) )
5289 fcnFileSize, QStringLiteral(
"Files and Paths" ) )
5294 QgsStaticExpressionFunction *geomFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$geometry" ), 0, fcnGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5296 sFunctions << geomFunc;
5298 QgsStaticExpressionFunction *areaFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$area" ), 0, fcnGeomArea, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5300 sFunctions << areaFunc;
5302 sFunctions <<
new QgsStaticExpressionFunction( QStringLiteral(
"area" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnArea, QStringLiteral(
"GeometryGroup" ) );
5304 QgsStaticExpressionFunction *lengthFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$length" ), 0, fcnGeomLength, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5306 sFunctions << lengthFunc;
5308 QgsStaticExpressionFunction *perimeterFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$perimeter" ), 0, fcnGeomPerimeter, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5310 sFunctions << perimeterFunc;
5312 sFunctions <<
new QgsStaticExpressionFunction( QStringLiteral(
"perimeter" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnPerimeter, QStringLiteral(
"GeometryGroup" ) );
5314 QgsStaticExpressionFunction *xFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$x" ), 0, fcnX, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5316 sFunctions << xFunc;
5318 QgsStaticExpressionFunction *yFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$y" ), 0, fcnY, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5320 sFunctions << yFunc;
5323 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomX, QStringLiteral(
"GeometryGroup" ) )
5324 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomY, QStringLiteral(
"GeometryGroup" ) )
5325 <<
new QgsStaticExpressionFunction( QStringLiteral(
"z" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomZ, QStringLiteral(
"GeometryGroup" ) )
5326 <<
new QgsStaticExpressionFunction( QStringLiteral(
"m" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomM, QStringLiteral(
"GeometryGroup" ) )
5327 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_n" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"index" ) ), fcnPointN, QStringLiteral(
"GeometryGroup" ) )
5328 <<
new QgsStaticExpressionFunction( QStringLiteral(
"start_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnStartPoint, QStringLiteral(
"GeometryGroup" ) )
5329 <<
new QgsStaticExpressionFunction( QStringLiteral(
"end_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnEndPoint, QStringLiteral(
"GeometryGroup" ) )
5330 <<
new QgsStaticExpressionFunction( QStringLiteral(
"nodes_to_points" ), -1, fcnNodesToPoints, QStringLiteral(
"GeometryGroup" ) )
5331 <<
new QgsStaticExpressionFunction( QStringLiteral(
"segments_to_lines" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnSegmentsToLines, QStringLiteral(
"GeometryGroup" ) )
5332 <<
new QgsStaticExpressionFunction( QStringLiteral(
"collect_geometries" ), -1, fcnCollectGeometries, QStringLiteral(
"GeometryGroup" ) )
5333 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_point" ), -1, fcnMakePoint, QStringLiteral(
"GeometryGroup" ) )
5335 << QgsExpressionFunction::Parameter( QStringLiteral(
"y" ) )
5336 << QgsExpressionFunction::Parameter( QStringLiteral(
"m" ) ),
5337 fcnMakePointM, QStringLiteral(
"GeometryGroup" ) )
5338 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_line" ), -1, fcnMakeLine, QStringLiteral(
"GeometryGroup" ) )
5339 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_polygon" ), -1, fcnMakePolygon, QStringLiteral(
"GeometryGroup" ) )
5340 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_triangle" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5341 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5342 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
5343 fcnMakeTriangle, QStringLiteral(
"GeometryGroup" ) )
5345 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5346 << QgsExpressionFunction::Parameter( QStringLiteral(
"radius" ) )
5347 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 36 ),
5348 fcnMakeCircle, QStringLiteral(
"GeometryGroup" ) )
5350 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5351 << QgsExpressionFunction::Parameter( QStringLiteral(
"semi_major_axis" ) )
5352 << QgsExpressionFunction::Parameter( QStringLiteral(
"semi_minor_axis" ) )
5353 << QgsExpressionFunction::Parameter( QStringLiteral(
"azimuth" ) )
5354 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 36 ),
5355 fcnMakeEllipse, QStringLiteral(
"GeometryGroup" ) )
5357 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5358 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5359 << QgsExpressionFunction::Parameter( QStringLiteral(
"number_sides" ) )
5360 << QgsExpressionFunction::Parameter( QStringLiteral(
"circle" ),
true, 0 ),
5361 fcnMakeRegularPolygon, QStringLiteral(
"GeometryGroup" ) )
5363 << QgsExpressionFunction::Parameter( QStringLiteral(
"point1" ) )
5364 << QgsExpressionFunction::Parameter( QStringLiteral(
"point2" ) ),
5365 fcnMakeSquare, QStringLiteral(
"GeometryGroup" ) )
5367 << QgsExpressionFunction::Parameter( QStringLiteral(
"point1" ) )
5368 << QgsExpressionFunction::Parameter( QStringLiteral(
"point2" ) )
5369 << QgsExpressionFunction::Parameter( QStringLiteral(
"point3" ) )
5370 << QgsExpressionFunction::Parameter( QStringLiteral(
"option" ),
true, 0 ),
5371 fcnMakeRectangleFrom3Points, QStringLiteral(
"GeometryGroup" ) );
5372 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" ) );
5374 sFunctions << xAtFunc;
5376 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" ) );
5378 sFunctions << yAtFunc;
5381 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_min" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnXMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmin" ) )
5382 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_max" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnXMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmax" ) )
5383 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_min" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnYMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymin" ) )
5384 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_max" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnYMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymax" ) )
5385 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_wkt" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"text" ) ), fcnGeomFromWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromWKT" ) )
5386 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_gml" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"gml" ) ), fcnGeomFromGML, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromGML" ) )
5387 <<
new QgsStaticExpressionFunction( QStringLiteral(
"flip_coordinates" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnFlipCoordinates, QStringLiteral(
"GeometryGroup" ) )
5388 <<
new QgsStaticExpressionFunction( QStringLiteral(
"relate" ), -1, fcnRelate, QStringLiteral(
"GeometryGroup" ) )
5389 <<
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" ) )
5391 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5392 fcnDisjoint, QStringLiteral(
"GeometryGroup" ) )
5393 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersects" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry a" ) )
5394 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5395 fcnIntersects, QStringLiteral(
"GeometryGroup" ) )
5397 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5398 fcnTouches, QStringLiteral(
"GeometryGroup" ) )
5400 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5401 fcnCrosses, QStringLiteral(
"GeometryGroup" ) )
5403 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5404 fcnContains, QStringLiteral(
"GeometryGroup" ) )
5406 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5407 fcnOverlaps, QStringLiteral(
"GeometryGroup" ) )
5409 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5410 fcnWithin, QStringLiteral(
"GeometryGroup" ) )
5412 << QgsExpressionFunction::Parameter( QStringLiteral(
"dx" ) )
5413 << QgsExpressionFunction::Parameter( QStringLiteral(
"dy" ) ),
5414 fcnTranslate, QStringLiteral(
"GeometryGroup" ) )
5415 <<
new QgsStaticExpressionFunction( QStringLiteral(
"buffer" ), -1, fcnBuffer, QStringLiteral(
"GeometryGroup" ) )
5417 fcnForceRHR, QStringLiteral(
"GeometryGroup" ) )
5419 << QgsExpressionFunction::Parameter( QStringLiteral(
"azimuth" ) )
5420 << QgsExpressionFunction::Parameter( QStringLiteral(
"width" ) )
5421 << QgsExpressionFunction::Parameter( QStringLiteral(
"outer_radius" ) )
5422 << QgsExpressionFunction::Parameter( QStringLiteral(
"inner_radius" ),
true, 0.0 ), fcnWedgeBuffer, QStringLiteral(
"GeometryGroup" ) )
5423 <<
new QgsStaticExpressionFunction( QStringLiteral(
"tapered_buffer" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5424 << QgsExpressionFunction::Parameter( QStringLiteral(
"start_width" ) )
5425 << QgsExpressionFunction::Parameter( QStringLiteral(
"end_width" ) )
5426 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
5427 , fcnTaperedBuffer, QStringLiteral(
"GeometryGroup" ) )
5428 <<
new QgsStaticExpressionFunction( QStringLiteral(
"buffer_by_m" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5429 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
5430 , fcnBufferByM, QStringLiteral(
"GeometryGroup" ) )
5431 <<
new QgsStaticExpressionFunction( QStringLiteral(
"offset_curve" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5432 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) )
5433 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
5435 << QgsExpressionFunction::Parameter( QStringLiteral(
"miter_limit" ),
true, 2.0 ),
5436 fcnOffsetCurve, QStringLiteral(
"GeometryGroup" ) )
5437 <<
new QgsStaticExpressionFunction( QStringLiteral(
"single_sided_buffer" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5438 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) )
5439 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
5441 << QgsExpressionFunction::Parameter( QStringLiteral(
"miter_limit" ),
true, 2.0 ),
5442 fcnSingleSidedBuffer, QStringLiteral(
"GeometryGroup" ) )
5444 << QgsExpressionFunction::Parameter( QStringLiteral(
"start_distance" ) )
5445 << QgsExpressionFunction::Parameter( QStringLiteral(
"end_distance" ) ),
5446 fcnExtend, QStringLiteral(
"GeometryGroup" ) )
5447 <<
new QgsStaticExpressionFunction( QStringLiteral(
"centroid" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnCentroid, QStringLiteral(
"GeometryGroup" ) )
5448 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_on_surface" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnPointOnSurface, QStringLiteral(
"GeometryGroup" ) )
5449 <<
new QgsStaticExpressionFunction( QStringLiteral(
"pole_of_inaccessibility" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5450 << QgsExpressionFunction::Parameter( QStringLiteral(
"tolerance" ) ), fcnPoleOfInaccessibility, QStringLiteral(
"GeometryGroup" ) )
5451 <<
new QgsStaticExpressionFunction( QStringLiteral(
"reverse" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnReverse, QStringLiteral(
"GeometryGroup" ) )
5452 <<
new QgsStaticExpressionFunction( QStringLiteral(
"exterior_ring" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnExteriorRing, QStringLiteral(
"GeometryGroup" ) )
5453 <<
new QgsStaticExpressionFunction( QStringLiteral(
"interior_ring_n" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5454 << QgsExpressionFunction::Parameter( QStringLiteral(
"index" ) ),
5455 fcnInteriorRingN, QStringLiteral(
"GeometryGroup" ) )
5457 << QgsExpressionFunction::Parameter( QStringLiteral(
"index" ) ),
5458 fcnGeometryN, QStringLiteral(
"GeometryGroup" ) )
5459 <<
new QgsStaticExpressionFunction( QStringLiteral(
"boundary" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnBoundary, QStringLiteral(
"GeometryGroup" ) )
5460 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_merge" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnLineMerge, QStringLiteral(
"GeometryGroup" ) )
5461 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnBounds, QStringLiteral(
"GeometryGroup" ) )
5462 <<
new QgsStaticExpressionFunction( QStringLiteral(
"simplify" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"tolerance" ) ), fcnSimplify, QStringLiteral(
"GeometryGroup" ) )
5463 <<
new QgsStaticExpressionFunction( QStringLiteral(
"simplify_vw" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"tolerance" ) ), fcnSimplifyVW, QStringLiteral(
"GeometryGroup" ) )
5464 <<
new QgsStaticExpressionFunction( QStringLiteral(
"smooth" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"iterations" ),
true, 1 )
5465 << QgsExpressionFunction::Parameter( QStringLiteral(
"offset" ),
true, 0.25 )
5466 << QgsExpressionFunction::Parameter( QStringLiteral(
"min_length" ),
true, -1 )
5467 << QgsExpressionFunction::Parameter( QStringLiteral(
"max_angle" ),
true, 180 ), fcnSmooth, QStringLiteral(
"GeometryGroup" ) )
5468 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_points" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomNumPoints, QStringLiteral(
"GeometryGroup" ) )
5469 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_interior_rings" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumInteriorRings, QStringLiteral(
"GeometryGroup" ) )
5470 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_rings" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumRings, QStringLiteral(
"GeometryGroup" ) )
5471 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_geometries" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumGeometries, QStringLiteral(
"GeometryGroup" ) )
5472 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_width" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnBoundsWidth, QStringLiteral(
"GeometryGroup" ) )
5473 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_height" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnBoundsHeight, QStringLiteral(
"GeometryGroup" ) )
5474 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_closed" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnIsClosed, QStringLiteral(
"GeometryGroup" ) )
5475 <<
new QgsStaticExpressionFunction( QStringLiteral(
"convex_hull" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnConvexHull, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"convexHull" ) )
5477 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
5478 fcnOrientedBBox, QStringLiteral(
"GeometryGroup" ) )
5480 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5481 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 36 ),
5482 fcnMinimalCircle, QStringLiteral(
"GeometryGroup" ) )
5483 <<
new QgsStaticExpressionFunction( QStringLiteral(
"difference" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry_a" ) )
5484 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry_b" ) ),
5485 fcnDifference, QStringLiteral(
"GeometryGroup" ) )
5487 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5488 fcnDistance, QStringLiteral(
"GeometryGroup" ) )
5489 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hausdorff_distance" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) )
5490 << QgsExpressionFunction::Parameter( QStringLiteral(
"densify_fraction" ),
true ),
5491 fcnHausdorffDistance, QStringLiteral(
"GeometryGroup" ) )
5492 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersection" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry_a" ) )
5493 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry_b" ) ),
5494 fcnIntersection, QStringLiteral(
"GeometryGroup" ) )
5495 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sym_difference" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
5496 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5497 fcnSymDifference, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"symDifference" ) )
5499 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5500 fcnCombine, QStringLiteral(
"GeometryGroup" ) )
5502 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5503 fcnCombine, QStringLiteral(
"GeometryGroup" ) )
5504 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_to_wkt" ), -1, fcnGeomToWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomToWKT" ) )
5505 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geometry" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"feature" ) ), fcnGetGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true )
5507 << QgsExpressionFunction::Parameter( QStringLiteral(
"source_auth_id" ) )
5508 << QgsExpressionFunction::Parameter( QStringLiteral(
"dest_auth_id" ) ),
5509 fcnTransformGeometry, QStringLiteral(
"GeometryGroup" ) )
5511 << QgsExpressionFunction::Parameter( QStringLiteral(
"x" ) )
5512 << QgsExpressionFunction::Parameter( QStringLiteral(
"y" ) ),
5513 fcnExtrude, QStringLiteral(
"GeometryGroup" ), QString() );
5515 QgsStaticExpressionFunction *orderPartsFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"order_parts" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) )
5516 << QgsExpressionFunction::Parameter( QStringLiteral(
"orderby" ) )
5517 << QgsExpressionFunction::Parameter( QStringLiteral(
"ascending" ) ),
5518 fcnOrderParts, QStringLiteral(
"GeometryGroup" ), QString() );
5523 const QList< QgsExpressionNode *> argList = node->
args()->
list();
5526 if ( !argNode->isStatic( parent, context ) )
5534 QString expString = argNode->
eval( parent, context ).toString();
5550 QString expression = argNode->
eval( parent, context ).toString();
5558 sFunctions << orderPartsFunc;
5561 <<
new QgsStaticExpressionFunction( QStringLiteral(
"closest_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
5562 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5563 fcnClosestPoint, QStringLiteral(
"GeometryGroup" ) )
5564 <<
new QgsStaticExpressionFunction( QStringLiteral(
"shortest_line" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
5565 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5566 fcnShortestLine, QStringLiteral(
"GeometryGroup" ) )
5567 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_interpolate_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5568 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) ), fcnLineInterpolatePoint, QStringLiteral(
"GeometryGroup" ) )
5569 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_interpolate_angle" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5570 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) ), fcnLineInterpolateAngle, QStringLiteral(
"GeometryGroup" ) )
5571 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_locate_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5572 << QgsExpressionFunction::Parameter( QStringLiteral(
"point" ) ), fcnLineLocatePoint, QStringLiteral(
"GeometryGroup" ) )
5573 <<
new QgsStaticExpressionFunction( QStringLiteral(
"angle_at_vertex" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5574 << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ) ), fcnAngleAtVertex, QStringLiteral(
"GeometryGroup" ) )
5575 <<
new QgsStaticExpressionFunction( QStringLiteral(
"distance_to_vertex" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5576 << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ) ), fcnDistanceToVertex, QStringLiteral(
"GeometryGroup" ) )
5577 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_substring" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5578 << QgsExpressionFunction::Parameter( QStringLiteral(
"start_distance" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"end_distance" ) ), fcnLineSubset, QStringLiteral(
"GeometryGroup" ) );
5583 QgsStaticExpressionFunction *idFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$id" ), 0, fcnFeatureId, QStringLiteral(
"Record and Attributes" ) );
5585 sFunctions << idFunc;
5587 QgsStaticExpressionFunction *currentFeatureFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$currentfeature" ), 0, fcnFeature, QStringLiteral(
"Record and Attributes" ) );
5589 sFunctions << currentFeatureFunc;
5591 QgsStaticExpressionFunction *uuidFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"uuid" ), 0, fcnUuid, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$uuid" ) );
5593 sFunctions << uuidFunc;
5597 << QgsExpressionFunction::Parameter( QStringLiteral(
"attribute" ) )
5598 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ),
5599 fcnGetFeature, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"QgsExpressionUtils::getFeature" ) )
5600 <<
new QgsStaticExpressionFunction( QStringLiteral(
"get_feature_by_id" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5601 << QgsExpressionFunction::Parameter( QStringLiteral(
"feature_id" ) ),
5602 fcnGetFeatureById, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false )
5603 <<
new QgsStaticExpressionFunction( QStringLiteral(
"attributes" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"feature" ),
true ),
5606 QgsStaticExpressionFunction *isSelectedFunc =
new QgsStaticExpressionFunction(
5607 QStringLiteral(
"is_selected" ),
5610 QStringLiteral(
"Record and Attributes" ),
5616 sFunctions << isSelectedFunc;
5619 <<
new QgsStaticExpressionFunction(
5620 QStringLiteral(
"num_selected" ),
5623 QStringLiteral(
"Record and Attributes" ),
5630 <<
new QgsStaticExpressionFunction(
5631 QStringLiteral(
"sqlite_fetch_and_increment" ),
5633 << QgsExpressionFunction::Parameter( QStringLiteral(
"database" ) )
5634 << QgsExpressionFunction::Parameter( QStringLiteral(
"table" ) )
5635 << QgsExpressionFunction::Parameter( QStringLiteral(
"id_field" ) )
5636 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter_attribute" ) )
5637 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter_value" ) )
5638 << QgsExpressionFunction::Parameter( QStringLiteral(
"default_values" ),
true ),
5639 fcnSqliteFetchAndIncrement,
5640 QStringLiteral(
"Record and Attributes" )
5644 QgsStaticExpressionFunction *representValueFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"represent_value" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"attribute" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"field_name" ),
true ), fcnRepresentValue, QStringLiteral(
"Record and Attributes" ) );
5658 parent->
setEvalErrorString( tr(
"If represent_value is called with 1 parameter, it must be an attribute." ) );
5668 parent->
setEvalErrorString( tr(
"represent_value must be called with exactly 1 or 2 parameters." ) );
5674 sFunctions << representValueFunc;
5678 <<
new QgsStaticExpressionFunction( QStringLiteral(
"layer_property" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5679 << QgsExpressionFunction::Parameter( QStringLiteral(
"property" ) ),
5680 fcnGetLayerProperty, QStringLiteral(
"General" ) )
5681 <<
new QgsStaticExpressionFunction( QStringLiteral(
"decode_uri" ),
5683 << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5684 << QgsExpressionFunction::Parameter( QStringLiteral(
"part" ),
true ),
5685 fcnDecodeUri, QStringLiteral(
"Map Layers" ) )
5686 <<
new QgsStaticExpressionFunction( QStringLiteral(
"raster_statistic" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5687 << QgsExpressionFunction::Parameter( QStringLiteral(
"band" ) )
5688 << QgsExpressionFunction::Parameter( QStringLiteral(
"statistic" ) ), fcnGetRasterBandStat, QStringLiteral(
"Rasters" ) );
5691 QgsStaticExpressionFunction *varFunction =
new QgsStaticExpressionFunction( QStringLiteral(
"var" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"name" ) ), fcnGetVariable, QStringLiteral(
"General" ) );
5704 if ( !argNode->
isStatic( parent, context ) )
5707 QString varName = argNode->
eval( parent, context ).toString();
5710 return scope ? scope->
isStatic( varName ) :
false;
5726 if ( argNode->
isStatic( parent, context ) )
5728 QString expString = argNode->
eval( parent, context ).toString();
5740 sFunctions << evalFunc;
5742 QgsStaticExpressionFunction *attributeFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"attribute" ), -1, fcnAttribute, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES );
5746 const QList< QgsExpressionNode *> argList = node->
args()->
list();
5749 if ( !argNode->isStatic( parent, context ) )
5761 sFunctions << attributeFunc;
5764 <<
new QgsStaticExpressionFunction( QStringLiteral(
"env" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"name" ) ), fcnEnvVar, QStringLiteral(
"General" ), QString() )
5766 <<
new QgsStaticExpressionFunction( QStringLiteral(
"raster_value" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"band" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point" ) ), fcnRasterValue, QStringLiteral(
"Rasters" ) )
5771 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array" ), -1, fcnArray, QStringLiteral(
"Arrays" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5772 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_sort" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"ascending" ),
true,
true ), fcnArraySort, QStringLiteral(
"Arrays" ) )
5773 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_length" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayLength, QStringLiteral(
"Arrays" ) )
5774 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_contains" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayContains, QStringLiteral(
"Arrays" ) )
5775 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_all" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"array_b" ) ), fcnArrayAll, QStringLiteral(
"Arrays" ) )
5776 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_find" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayFind, QStringLiteral(
"Arrays" ) )
5777 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_get" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"pos" ) ), fcnArrayGet, QStringLiteral(
"Arrays" ) )
5778 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_first" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayFirst, QStringLiteral(
"Arrays" ) )
5779 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_last" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayLast, QStringLiteral(
"Arrays" ) )
5780 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_append" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayAppend, QStringLiteral(
"Arrays" ) )
5781 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_prepend" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayPrepend, QStringLiteral(
"Arrays" ) )
5782 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_insert" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"pos" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayInsert, QStringLiteral(
"Arrays" ) )
5783 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_remove_at" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"pos" ) ), fcnArrayRemoveAt, QStringLiteral(
"Arrays" ) )
5784 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_remove_all" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayRemoveAll, QStringLiteral(
"Arrays" ) )
5785 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_cat" ), -1, fcnArrayCat, QStringLiteral(
"Arrays" ) )
5786 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_slice" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"start_pos" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"end_pos" ) ), fcnArraySlice, QStringLiteral(
"Arrays" ) )
5787 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_reverse" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayReverse, QStringLiteral(
"Arrays" ) )
5788 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_intersect" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"array2" ) ), fcnArrayIntersect, QStringLiteral(
"Arrays" ) )
5789 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_distinct" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayDistinct, QStringLiteral(
"Arrays" ) )
5790 <<
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" ) )
5791 <<
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" ) )
5792 <<
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" ) )
5795 <<
new QgsStaticExpressionFunction( QStringLiteral(
"json_to_map" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnLoadJson, QStringLiteral(
"Maps" ) )
5796 <<
new QgsStaticExpressionFunction( QStringLiteral(
"from_json" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnLoadJson, QStringLiteral(
"Maps" ) )
5797 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_to_json" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnWriteJson, QStringLiteral(
"Maps" ) )
5798 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_json" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"json_string" ) ), fcnWriteJson, QStringLiteral(
"Maps" ) )
5799 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hstore_to_map" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnHstoreToMap, QStringLiteral(
"Maps" ) )
5800 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_to_hstore" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnMapToHstore, QStringLiteral(
"Maps" ) )
5801 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map" ), -1, fcnMap, QStringLiteral(
"Maps" ) )
5802 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_get" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ), fcnMapGet, QStringLiteral(
"Maps" ) )
5803 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_exist" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ), fcnMapExist, QStringLiteral(
"Maps" ) )
5804 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_delete" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ), fcnMapDelete, QStringLiteral(
"Maps" ) )
5805 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_insert" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnMapInsert, QStringLiteral(
"Maps" ) )
5806 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_concat" ), -1, fcnMapConcat, QStringLiteral(
"Maps" ) )
5807 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_akeys" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnMapAKeys, QStringLiteral(
"Maps" ) )
5808 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_avals" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnMapAVals, QStringLiteral(
"Maps" ) )
5816 sOwnedFunctions <<
func;
5817 sBuiltinFunctions << func->name();
5818 sBuiltinFunctions.append( func->aliases() );
5828 QStringLiteral(
"Arrays" ) )
5839 if ( args->
count() < 2 )
5842 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
5852 QVariantList result;
5854 if ( args->
count() < 2 )
5858 QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
5861 std::unique_ptr< QgsExpressionContext > tempContext;
5864 tempContext = qgis::make_unique< QgsExpressionContext >();
5865 subContext = tempContext.get();
5871 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
5874 result << args->
at( 1 )->
eval( parent, subContext );
5899 if ( args->
count() < 2 )
5903 args->
at( 0 )->
prepare( parent, context );
5907 subContext = *context;
5913 args->
at( 1 )->
prepare( parent, &subContext );
5922 QStringLiteral(
"Arrays" ) )
5933 if ( args->
count() < 2 )
5936 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
5946 QVariantList result;
5948 if ( args->
count() < 2 )
5952 const QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
5955 std::unique_ptr< QgsExpressionContext > tempContext;
5958 tempContext = qgis::make_unique< QgsExpressionContext >();
5959 subContext = tempContext.get();
5965 for (
const QVariant &value : array )
5968 if ( args->
at( 1 )->
eval( parent, subContext ).toBool() )
5994 if ( args->
count() < 2 )
5998 args->
at( 0 )->
prepare( parent, context );
6002 subContext = *context;
6008 args->
at( 1 )->
prepare( parent, &subContext );
6017 QStringLiteral(
"General" ) )
6028 if ( args->
count() < 3 )
6032 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
6034 QVariant
name = args->
at( 0 )->
eval( parent, context );
6035 QVariant value = args->
at( 1 )->
eval( parent, context );
6038 appendTemporaryVariable( context, name.toString(), value );
6039 if ( args->
at( 2 )->
isStatic( parent, context ) )
6041 popTemporaryVariable( context );
6052 if ( args->
count() < 3 )
6056 QVariant
name = args->
at( 0 )->
eval( parent, context );
6057 QVariant value = args->
at( 1 )->
eval( parent, context );
6060 std::unique_ptr< QgsExpressionContext > tempContext;
6061 if ( !updatedContext )
6063 tempContext = qgis::make_unique< QgsExpressionContext >();
6064 updatedContext = tempContext.get();
6067 appendTemporaryVariable( updatedContext, name.toString(), value );
6068 result = args->
at( 2 )->
eval( parent, updatedContext );
6071 popTemporaryVariable( updatedContext );
6092 if ( args->
count() < 3 )
6097 QVariant value = args->
at( 1 )->
prepare( parent, context );
6100 std::unique_ptr< QgsExpressionContext > tempContext;
6101 if ( !updatedContext )
6103 tempContext = qgis::make_unique< QgsExpressionContext >();
6104 updatedContext = tempContext.get();
6107 appendTemporaryVariable( updatedContext, name.toString(), value );
6108 args->
at( 2 )->
prepare( parent, updatedContext );
6111 popTemporaryVariable( updatedContext );
6116 void QgsWithVariableExpressionFunction::popTemporaryVariable(
const QgsExpressionContext *context )
const 6122 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 ...
QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Returns result of evaluating the function.
QgsArrayFilterExpressionFunction()
double angleAtVertex(int vertex) const
Returns the bisector angle for this geometry at the specified vertex.
void setPrepareFunction(const std::function< bool(const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext *)> &prepareFunc)
Set a function that will be called in the prepare step to determine if the function is static or not...
QVector< QgsRingSequence > QgsCoordinateSequence
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
QgsExpressionContextScope * activeScopeForVariable(const QString &name)
Returns the currently active scope from the context for a specified variable name.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
First quartile (numeric fields only)
Number of missing (null) values.
A class to represent a 2D point.
QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request. ...
bool 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.
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.
QString toProj4() const
Returns a Proj4 string representation of this CRS.
double maximumValue
The maximum cell value in the raster band.
double seconds() const
Returns the interval duration in seconds.
Multi line string geometry collection.
QgsGeometry interpolate(double distance) const
Returns an interpolated point on the geometry at the specified distance.
Curve polygon geometry type.
bool overlaps(const QgsGeometry &geometry) const
Returns true if the geometry overlaps another geometry.
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)
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
static QString encodeColor(const QColor &color)
void setVariable(const QString &name, const QVariant &value, bool isStatic=false)
Convenience method for setting a variable in the context scope by name name and value.
QgsGeometry poleOfInaccessibility(double precision, double *distanceToBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
QString errorMessage() const
Returns the most recent error message encountered by the database.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QVariant(* FcnEval)(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node)
Function definition for evaluation against an expression context, using a list of values as parameter...
QgsGeometry mergeLines() const
Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line ...
#define ENSURE_NO_EVAL_ERROR
QgsUnitTypes::AreaUnit areaUnits() const
Returns the desired areal units for calculations involving geomCalculator(), e.g., "$area".
double stdDev
The standard deviation of the cell values.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets feature ID that should be fetched.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
CORE_EXPORT QString build(const QVariantMap &map)
Build a hstore-formatted string from a QVariantMap.
QgsRasterDataProvider * dataProvider() override
Returns the 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.
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...
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer for a (multi)linestring geometry, where the width at each node is ...
virtual QgsCurve * curveSubstring(double startDistance, double endDistance) const =0
Returns a new curve representing a substring of this curve.
Utility class for identifying a unique vertex within a geometry.
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a variable width buffer ("tapered buffer") for a (multi)curve geometry.
virtual QSet< QString > referencedVariables() const =0
Returns a set of all variables which are used in this expression.
virtual bool handlesNull() const
Returns true if the function handles NULL values in arguments by itself, and the default NULL value h...
static Aggregate stringToAggregate(const QString &string, bool *ok=nullptr)
Converts a string to a aggregate type.
int ringCount(int part=0) const override
Returns the number of rings of which this geometry is built.
bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
This will be called during the prepare step() of an expression if it is not static.
int step()
Steps to the next record in the statement, returning the sqlite3 result code.
QList< QgsRelation > relationsByName(const QString &name) const
Returns a list of relations with matching names.
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
Minimum length of string (string fields only)
virtual QgsPolygon * toPolygon(unsigned int segments=36) const
Returns a segmented polygon.
const QgsExpressionFunction::ParameterList & parameters() const
Returns the list of named parameters for the function, if set.
QgsGeometry convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry. ...
static QString geometryDisplayString(GeometryType type)
Returns a display string for a geometry type.
double width() const
Returns the width of the rectangle.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
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".
An expression node which takes it value from a feature's field.
QgsGeometry smooth(unsigned int iterations=1, double offset=0.25, double minimumDistance=-1.0, double maxAngle=180.0) const
Smooths a geometry by rounding off corners using the Chaikin algorithm.
bool crosses(const QgsGeometry &geometry) const
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...
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.
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.
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...