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 return QVariant( QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent ) );
1027 for (
const QVariant &value : values )
1029 if ( value.isNull() )
1038 const QVariant val1 = values.at( 0 );
1039 const QVariant val2 = values.at( 1 );
1049 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1050 return QVariant( str.toLower() );
1054 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1055 return QVariant( str.toUpper() );
1059 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1060 QStringList elems = str.split(
' ' );
1061 for (
int i = 0; i < elems.size(); i++ )
1063 if ( elems[i].size() > 1 )
1064 elems[i] = elems[i].at( 0 ).toUpper() + elems[i].mid( 1 ).toLower();
1066 return QVariant( elems.join( QStringLiteral(
" " ) ) );
1071 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1072 return QVariant( str.trimmed() );
1077 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1078 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1084 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1085 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1091 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1092 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1099 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1105 QChar character = QChar( QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent ) );
1106 return QVariant( QString( character ) );
1111 if ( values.length() == 2 || values.length() == 3 )
1113 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1114 qlonglong wrap = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1116 QString customdelimiter = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1130 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1134 return QVariant( geom.
length() );
1138 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1139 return QVariant( str.length() );
1144 if ( values.count() == 2 && values.at( 1 ).type() == QVariant::Map )
1146 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1147 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 1 ), parent );
1149 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
1151 str = str.replace( it.key(), it.value().toString() );
1154 return QVariant( str );
1156 else if ( values.count() == 3 )
1158 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1159 QVariantList before;
1161 bool isSingleReplacement =
false;
1163 if ( values.at( 1 ).type() != QVariant::List && values.at( 2 ).type() != QVariant::StringList )
1165 before = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1169 before = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
1172 if ( values.at( 2 ).type() != QVariant::List && values.at( 2 ).type() != QVariant::StringList )
1174 after = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1175 isSingleReplacement =
true;
1179 after = QgsExpressionUtils::getListValue( values.at( 2 ), parent );
1182 if ( !isSingleReplacement && before.length() != after.length() )
1184 parent->
setEvalErrorString( QObject::tr(
"Invalid pair of array, length not identical" ) );
1188 for (
int i = 0; i < before.length(); i++ )
1190 str = str.replace( before.at( i ).toString(), after.at( isSingleReplacement ? 0 : i ).toString() );
1193 return QVariant( str );
1197 parent->
setEvalErrorString( QObject::tr(
"Function replace requires 2 or 3 arguments" ) );
1203 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1204 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1205 QString after = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1207 QRegularExpression re( regexp );
1208 if ( !re.isValid() )
1210 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1213 return QVariant( str.replace( re, after ) );
1218 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1219 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1221 QRegularExpression re( regexp );
1222 if ( !re.isValid() )
1224 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1227 return QVariant( ( str.indexOf( re ) + 1 ) );
1232 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1233 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1234 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1236 QRegularExpression re( regexp );
1237 if ( !re.isValid() )
1239 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1243 QRegularExpressionMatch matches = re.match( str );
1244 if ( matches.hasMatch() )
1247 QStringList list = matches.capturedTexts();
1250 for ( QStringList::const_iterator it = ++list.constBegin(); it != list.constEnd(); ++it )
1252 array += ( !( *it ).isEmpty() ) ? *it : empty;
1255 return QVariant( array );
1265 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1266 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1268 QRegularExpression re( regexp );
1269 if ( !re.isValid() )
1271 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1276 QRegularExpressionMatch match = re.match( str );
1277 if ( match.hasMatch() )
1280 if ( match.lastCapturedIndex() > 0 )
1283 return QVariant( match.captured( 1 ) );
1288 return QVariant( match.captured( 0 ) );
1293 return QVariant(
"" );
1299 return QUuid::createUuid().toString();
1304 if ( !values.at( 0 ).isValid() || !values.at( 1 ).isValid() )
1307 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1308 qlonglong from = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1311 if ( values.at( 2 ).isValid() )
1312 len = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
1318 from = str.size() + from;
1324 else if ( from > 0 )
1332 len = str.size() + len - from;
1339 return QVariant( str.mid( from, len ) );
1345 return QVariant( static_cast< int >( f.id() ) );
1350 QgsRasterLayer *layer = QgsExpressionUtils::getRasterLayer( values.at( 0 ), parent );
1353 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster layer." ) );
1357 int bandNb = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1358 if ( bandNb < 1 || bandNb > layer->
bandCount() )
1360 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster band number." ) );
1364 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
1367 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid point geometry." ) );
1375 if ( multiPoint.count() == 1 )
1377 point = multiPoint[0];
1387 return std::isnan( value ) ? QVariant() : value;
1401 if ( values.size() == 1 )
1403 attr = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1406 else if ( values.size() == 2 )
1408 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1409 attr = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1413 parent->
setEvalErrorString( QObject::tr(
"Function `attribute` requires one or two parameters. %1 given." ).arg( values.length() ) );
1425 if ( values.isEmpty() )
1428 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1430 else if ( values.size() == 1 )
1432 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1433 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1435 else if ( values.size() == 2 )
1437 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1438 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
1442 parent->
setEvalErrorString( QObject::tr(
"Function `is_selected` requires no more than two parameters. %1 given." ).arg( values.length() ) );
1446 if ( !layer || !feature.
isValid() )
1448 return QVariant( QVariant::Bool );
1458 if ( values.isEmpty() )
1459 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1460 else if ( values.count() == 1 )
1461 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1464 parent->
setEvalErrorString( QObject::tr(
"Function `num_selected` requires no more than one parameter. %1 given." ).arg( values.length() ) );
1470 return QVariant( QVariant::LongLong );
1478 static QMap<QString, qlonglong> counterCache;
1479 QVariant functionResult;
1481 std::function<void()> fetchAndIncrementFunc = [ =, &functionResult ]()
1484 const QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1489 database = decodedUri.value( QStringLiteral(
"path" ) ).toString();
1490 if ( database.isEmpty() )
1492 parent->
setEvalErrorString( QObject::tr(
"Could not extract file path from layer `%1`." ).arg( layer->
name() ) );
1497 database = values.at( 0 ).toString();
1500 const QString table = values.at( 1 ).toString();
1501 const QString idColumn = values.at( 2 ).toString();
1502 const QString filterAttribute = values.at( 3 ).toString();
1503 const QVariant filterValue = values.at( 4 ).toString();
1504 const QVariantMap defaultValues = values.at( 5 ).toMap();
1510 if ( sqliteDb.
open_v2( database, SQLITE_OPEN_READWRITE,
nullptr ) != SQLITE_OK )
1513 functionResult = QVariant();
1517 QString errorMessage;
1518 QString currentValSql;
1520 qlonglong nextId = 0;
1521 bool cachedMode =
false;
1522 bool valueRetrieved =
false;
1524 QString cacheString = QStringLiteral(
"%1:%2:%3:%4:%5" ).arg( database, table, idColumn, filterAttribute, filterValue.toString() );
1531 auto cachedCounter = counterCache.find( cacheString );
1533 if ( cachedCounter != counterCache.end() )
1535 qlonglong &cachedValue = cachedCounter.value();
1536 nextId = cachedValue;
1538 cachedValue = nextId;
1539 valueRetrieved =
true;
1544 if ( !cachedMode || !valueRetrieved )
1546 int result = SQLITE_ERROR;
1549 if ( !filterAttribute.isNull() )
1554 sqliteStatement = sqliteDb.
prepare( currentValSql, result );
1556 if ( result == SQLITE_OK )
1559 if ( sqliteStatement.
step() == SQLITE_ROW )
1565 if ( cachedMode && result == SQLITE_OK )
1567 counterCache.insert( cacheString, nextId );
1571 counterCache.remove( cacheString );
1574 valueRetrieved =
true;
1578 if ( valueRetrieved )
1587 if ( !filterAttribute.isNull() )
1593 for ( QVariantMap::const_iterator iter = defaultValues.constBegin(); iter != defaultValues.constEnd(); ++iter )
1596 vals << iter.value().toString();
1599 upsertSql += QLatin1String(
" (" ) + cols.join(
',' ) +
')';
1600 upsertSql += QLatin1String(
" VALUES " );
1601 upsertSql +=
'(' + vals.join(
',' ) +
')';
1603 int result = SQLITE_ERROR;
1607 if ( transaction->
executeSql( upsertSql, errorMessage ) )
1614 result = sqliteDb.
exec( upsertSql, errorMessage );
1616 if ( result == SQLITE_OK )
1618 functionResult = QVariant( nextId );
1623 parent->
setEvalErrorString( QStringLiteral(
"Could not increment value: SQLite error: \"%1\" (%2)." ).arg( errorMessage, QString::number( result ) ) );
1624 functionResult = QVariant();
1629 functionResult = QVariant();
1634 return functionResult;
1640 for (
const QVariant &value : values )
1642 concat += QgsExpressionUtils::getStringValue( value, parent );
1649 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1650 return string.indexOf( QgsExpressionUtils::getStringValue( values.at( 1 ), parent ) ) + 1;
1655 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1656 qlonglong pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1657 return string.right( pos );
1662 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1663 qlonglong pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1664 return string.left( pos );
1669 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1670 qlonglong length = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1671 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1672 return string.leftJustified( length, fill.at( 0 ), true );
1677 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1678 qlonglong length = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1679 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1680 return string.rightJustified( length, fill.at( 0 ), true );
1685 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1686 for (
int n = 1; n < values.length(); n++ )
1688 string =
string.arg( QgsExpressionUtils::getStringValue( values.at( n ), parent ) );
1696 return QVariant( QDateTime::currentDateTime() );
1701 return QVariant( QgsExpressionUtils::getDateValue( values.at( 0 ), parent ) );
1706 return QVariant( QgsExpressionUtils::getTimeValue( values.at( 0 ), parent ) );
1711 return QVariant::fromValue( QgsExpressionUtils::getInterval( values.at( 0 ), parent ) );
1720 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1721 QString axis = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1722 int precision = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
1724 QString formatString;
1725 if ( values.count() > 3 )
1726 formatString = QgsExpressionUtils::getStringValue( values.at( 3 ), parent );
1728 QgsCoordinateFormatter::FormatFlags flags =
nullptr;
1729 if ( formatString.compare( QLatin1String(
"suffix" ), Qt::CaseInsensitive ) == 0 )
1733 else if ( formatString.compare( QLatin1String(
"aligned" ), Qt::CaseInsensitive ) == 0 )
1737 else if ( ! formatString.isEmpty() )
1739 parent->
setEvalErrorString( QObject::tr(
"Invalid formatting parameter: '%1'. It must be empty, or 'suffix' or 'aligned'." ).arg( formatString ) );
1743 if ( axis.compare( QLatin1String(
"x" ), Qt::CaseInsensitive ) == 0 )
1747 else if ( axis.compare( QLatin1String(
"y" ), Qt::CaseInsensitive ) == 0 )
1753 parent->
setEvalErrorString( QObject::tr(
"Invalid axis name: '%1'. It must be either 'x' or 'y'." ).arg( axis ) );
1761 return floatToDegreeFormat( format, values, context, parent, node );
1767 return floatToDegreeFormat( format, values, context, parent, node );
1772 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1773 QDateTime d2 = QgsExpressionUtils::getDateTimeValue( values.at( 1 ), parent );
1774 qint64 seconds = d2.secsTo( d1 );
1775 return QVariant::fromValue(
QgsInterval( seconds ) );
1780 if ( !values.at( 0 ).canConvert<QDate>() )
1783 QDate date = QgsExpressionUtils::getDateValue( values.at( 0 ), parent );
1784 if ( !date.isValid() )
1789 return date.dayOfWeek() % 7;
1794 QVariant value = values.at( 0 );
1795 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1798 return QVariant( inter.
days() );
1802 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1803 return QVariant( d1.date().day() );
1809 QVariant value = values.at( 0 );
1810 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1813 return QVariant( inter.
years() );
1817 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1818 return QVariant( d1.date().year() );
1824 QVariant value = values.at( 0 );
1825 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1828 return QVariant( inter.
months() );
1832 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1833 return QVariant( d1.date().month() );
1839 QVariant value = values.at( 0 );
1840 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1843 return QVariant( inter.
weeks() );
1847 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1848 return QVariant( d1.date().weekNumber() );
1854 QVariant value = values.at( 0 );
1855 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1858 return QVariant( inter.
hours() );
1862 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1863 return QVariant( t1.hour() );
1869 QVariant value = values.at( 0 );
1870 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1873 return QVariant( inter.
minutes() );
1877 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1878 return QVariant( t1.minute() );
1884 QVariant value = values.at( 0 );
1885 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1888 return QVariant( inter.
seconds() );
1892 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1893 return QVariant( t1.second() );
1899 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1902 return QVariant( dt.toMSecsSinceEpoch() );
1910 #define ENSURE_GEOM_TYPE(f, g, geomtype) \ 1911 if ( !(f).hasGeometry() ) \ 1912 return QVariant(); \ 1913 QgsGeometry g = (f).geometry(); \ 1914 if ( (g).type() != (geomtype) ) \ 1921 if ( g.isMultipart() )
1923 return g.asMultiPoint().at( 0 ).x();
1927 return g.asPoint().x();
1935 if ( g.isMultipart() )
1937 return g.asMultiPoint().at( 0 ).y();
1941 return g.asPoint().y();
1947 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1959 QVariant result( centroid.
asPoint().
x() );
1965 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1977 QVariant result( centroid.
asPoint().
y() );
1983 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1998 if ( collection->numGeometries() == 1 )
2000 if (
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( collection->geometryN( 0 ) ) )
2011 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2026 if ( collection->numGeometries() == 1 )
2028 if (
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( collection->geometryN( 0 ) ) )
2039 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2044 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
2071 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2088 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2105 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2110 bool ignoreClosing =
false;
2111 if ( values.length() > 1 )
2113 ignoreClosing = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
2123 bool skipLast =
false;
2124 if ( ignoreClosing && ring.count() > 2 && ring.first() == ring.last() )
2129 for (
int i = 0; i < ( skipLast ? ring.count() - 1 : ring.count() ); ++ i )
2131 mp->addGeometry( ring.at( i ).clone() );
2141 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2152 for (
int i = 0; i < line->numPoints() - 1; ++i )
2156 << line->pointN( i )
2157 << line->pointN( i + 1 ) );
2158 ml->addGeometry( segment );
2168 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2178 if ( collection->numGeometries() == 1 )
2185 if ( !curvePolygon )
2189 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
2195 QVariant result = curve ? QVariant::fromValue(
QgsGeometry( curve ) ) : QVariant();
2201 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2211 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
2217 QVariant result = part ? QVariant::fromValue(
QgsGeometry( part ) ) : QVariant();
2223 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2232 return QVariant::fromValue(
QgsGeometry( boundary ) );
2237 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2246 return QVariant::fromValue( merged );
2251 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2256 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2259 if ( simplified.isNull() )
2267 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2272 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2277 if ( simplified.
isNull() )
2285 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2290 int iterations = std::min( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), 10 );
2291 double offset = qBound( 0.0, QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ), 0.5 );
2292 double minLength = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2293 double maxAngle = qBound( 0.0, QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent ), 180.0 );
2304 if ( values.count() < 2 || values.count() > 4 )
2306 parent->
setEvalErrorString( QObject::tr(
"Function make_point requires 2-4 arguments" ) );
2310 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2311 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2312 double z = values.count() >= 3 ? QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) : 0.0;
2313 double m = values.count() >= 4 ? QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) : 0.0;
2314 switch ( values.count() )
2328 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2329 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2330 double m = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2336 if ( values.count() < 2 )
2342 lineString->
clear();
2344 for (
const QVariant &value : values )
2346 QgsGeometry geom = QgsExpressionUtils::getGeometry( value, parent );
2360 return QVariant::fromValue(
QgsGeometry( lineString ) );
2365 if ( values.count() < 1 )
2367 parent->
setEvalErrorString( QObject::tr(
"Function make_polygon requires an argument" ) );
2371 QgsGeometry outerRing = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2375 std::unique_ptr< QgsPolygon > polygon = qgis::make_unique< QgsPolygon >();
2382 if ( collection->numGeometries() == 1 )
2389 if ( !exteriorRing )
2392 polygon->setExteriorRing( exteriorRing->segmentize() );
2395 for (
int i = 1; i < values.count(); ++i )
2397 QgsGeometry ringGeom = QgsExpressionUtils::getGeometry( values.at( i ), parent );
2409 if ( collection->numGeometries() == 1 )
2419 polygon->addInteriorRing( ring->
segmentize() );
2422 return QVariant::fromValue(
QgsGeometry( std::move( polygon ) ) );
2427 std::unique_ptr<QgsTriangle> tr(
new QgsTriangle() );
2428 std::unique_ptr<QgsLineString> lineString(
new QgsLineString() );
2429 lineString->clear();
2431 for (
const QVariant &value : values )
2433 QgsGeometry geom = QgsExpressionUtils::getGeometry( value, parent );
2445 if ( collection->numGeometries() == 1 )
2455 lineString->addVertex( *point );
2458 tr->setExteriorRing( lineString.release() );
2460 return QVariant::fromValue(
QgsGeometry( tr.release() ) );
2465 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2472 double radius = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2473 double segment = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
2485 if ( collection->numGeometries() == 1 )
2500 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2507 double majorAxis = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2508 double minorAxis = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2509 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2510 double segment = QgsExpressionUtils::getIntValue( values.at( 4 ), parent );
2521 if ( collection->numGeometries() == 1 )
2530 QgsEllipse elp( *point, majorAxis, minorAxis, azimuth );
2537 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2544 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2551 unsigned int nbEdges =
static_cast<unsigned int>( QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) );
2554 parent->
setEvalErrorString( QObject::tr(
"Number of edges/sides must be greater than 2" ) );
2561 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (inscribed) or 1 (circumscribed)" ) );
2570 if ( collection->numGeometries() == 1 )
2584 if ( collection->numGeometries() == 1 )
2601 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2607 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2617 return QVariant::fromValue(
QgsGeometry( square.toPolygon() ) );
2622 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2628 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2634 QgsGeometry pt3 = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
2643 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (distance) or 1 (projected)" ) );
2650 return QVariant::fromValue(
QgsGeometry( rect.toPolygon() ) );
2656 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
2665 if ( idx < 0 || idx >= g.constGet()->nCoordinates() )
2672 return QVariant( QPointF( p.
x(), p.
y() ) );
2677 QVariant v = pointAt( values, f, parent );
2678 if ( v.type() == QVariant::PointF )
2679 return QVariant( v.toPointF().x() );
2685 QVariant v = pointAt( values, f, parent );
2686 if ( v.type() == QVariant::PointF )
2687 return QVariant( v.toPointF().y() );
2696 return QVariant::fromValue( geom );
2698 return QVariant( QVariant::UserType );
2702 QString wkt = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2704 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2709 QString gml = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2711 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2724 return QVariant( area );
2728 return QVariant( f.geometry().area() );
2734 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2739 return QVariant( geom.
area() );
2751 return QVariant( len );
2755 return QVariant( f.geometry().length() );
2768 return QVariant( len );
2772 return f.geometry().isNull() ? QVariant( 0 ) : QVariant( f.geometry().constGet()->perimeter() );
2778 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2784 return QVariant( geom.
length() );
2789 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2795 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2804 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2817 for (
int i = 0; i < collection->numGeometries(); ++i )
2820 if ( !curvePolygon )
2832 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2839 return QVariant( curvePolygon->
ringCount() );
2841 bool foundPoly =
false;
2850 if ( !curvePolygon )
2861 return QVariant( ringCount );
2866 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2868 QVariant result = !geomBounds.
isNull() ? QVariant::fromValue( geomBounds ) : QVariant();
2874 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2880 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2886 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2892 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2898 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2904 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2910 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2914 std::unique_ptr< QgsAbstractGeometry > flipped( geom.
constGet()->
clone() );
2916 return QVariant::fromValue(
QgsGeometry( std::move( flipped ) ) );
2921 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2930 if ( collection->numGeometries() == 1 )
2940 return QVariant::fromValue( curve->
isClosed() );
2945 if ( values.length() < 2 || values.length() > 3 )
2948 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2949 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2951 if ( fGeom.
isNull() || sGeom.isNull() )
2956 if ( values.length() == 2 )
2959 QString result = engine->relate( sGeom.constGet() );
2960 return QVariant::fromValue( result );
2965 QString pattern = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
2966 bool result = engine->relatePattern( sGeom.constGet(), pattern );
2967 return QVariant::fromValue( result );
2973 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2974 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2975 return fGeom.
intersects( sGeom.boundingBox() ) ? TVL_True : TVL_False;
2979 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2980 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2981 return fGeom.
disjoint( sGeom ) ? TVL_True : TVL_False;
2985 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2986 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2987 return fGeom.
intersects( sGeom ) ? TVL_True : TVL_False;
2991 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2992 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2993 return fGeom.
touches( sGeom ) ? TVL_True : TVL_False;
2997 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2998 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2999 return fGeom.
crosses( sGeom ) ? TVL_True : TVL_False;
3003 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3004 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3005 return fGeom.
contains( sGeom ) ? TVL_True : TVL_False;
3009 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3010 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3011 return fGeom.
overlaps( sGeom ) ? TVL_True : TVL_False;
3015 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3016 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3017 return fGeom.
within( sGeom ) ? TVL_True : TVL_False;
3021 if ( values.length() < 2 || values.length() > 3 )
3024 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3025 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3027 if ( values.length() == 3 )
3028 seg = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3031 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3037 const QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3039 return !reoriented.
isNull() ? QVariant::fromValue( reoriented ) : QVariant();
3044 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3050 if ( collection->numGeometries() == 1 )
3059 parent->
setEvalErrorString( QObject::tr(
"Function `wedge_buffer` requires a point value for the center." ) );
3063 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3064 double width = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3065 double outerRadius = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3066 double innerRadius = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
3069 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
3075 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3078 parent->
setEvalErrorString( QObject::tr(
"Function `tapered_buffer` requires a line geometry." ) );
3082 double startWidth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3083 double endWidth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3084 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) );
3087 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3093 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3096 parent->
setEvalErrorString( QObject::tr(
"Function `buffer_by_m` requires a line geometry." ) );
3100 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3103 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3109 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3110 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3111 qlonglong segments = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3115 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3118 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3124 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3125 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3126 qlonglong segments = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3130 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3133 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3139 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3140 double distStart = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3141 double distEnd = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3144 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3150 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3151 double dx = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3152 double dy = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3154 return QVariant::fromValue( fGeom );
3158 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3160 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3165 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3167 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3173 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3174 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3176 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3182 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3184 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3191 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3192 unsigned int segments = 36;
3193 if ( values.length() == 2 )
3194 segments = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3196 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3202 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3204 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3210 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3211 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3213 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3219 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3231 result = reversed ? QVariant::fromValue(
QgsGeometry( reversed ) ) : QVariant();
3239 if (
const QgsCurve *curve = qgsgeometry_cast<const QgsCurve * >( collection->
geometryN( i ) ) )
3248 result = reversed ? QVariant::fromValue(
QgsGeometry( std::move( reversed ) ) ) : QVariant();
3255 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3264 if ( collection->numGeometries() == 1 )
3275 QVariant result = exterior ? QVariant::fromValue(
QgsGeometry( exterior ) ) : QVariant();
3281 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3282 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3283 return QVariant( fGeom.
distance( sGeom ) );
3288 QgsGeometry g1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3289 QgsGeometry g2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3292 if ( values.length() == 3 && values.at( 2 ).isValid() )
3294 double densify = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3295 densify = qBound( 0.0, densify, 1.0 );
3303 return res > -1 ? QVariant( res ) : QVariant();
3308 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3309 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3311 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3316 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3317 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3319 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3324 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3325 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3327 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3332 if ( values.length() < 1 || values.length() > 2 )
3335 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3337 if ( values.length() == 2 )
3338 prec = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3339 QString wkt = fGeom.
asWkt( prec );
3340 return QVariant( wkt );
3345 if ( values.length() != 2 )
3347 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires exactly two parameters. %1 given." ).arg( values.length() ) );
3351 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3352 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3359 if ( collection->numGeometries() == 1 )
3367 if ( !pt2 && fGeom2.isMultipart() )
3369 if (
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( fGeom2.constGet() ) )
3371 if ( collection->numGeometries() == 1 )
3380 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires two points as arguments." ) );
3385 if ( pt1->x() == pt2->x() )
3387 if ( pt1->y() < pt2->y() )
3389 else if ( pt1->y() > pt2->y() )
3395 if ( pt1->y() == pt2->y() )
3397 if ( pt1->x() < pt2->x() )
3399 else if ( pt1->x() > pt2->x() )
3400 return M_PI + ( M_PI_2 );
3405 if ( pt1->x() < pt2->x() )
3407 if ( pt1->y() < pt2->y() )
3409 return std::atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) );
3413 return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
3420 if ( pt1->y() > pt2->y() )
3422 return std::atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) )
3427 return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
3428 + ( M_PI + ( M_PI_2 ) );
3435 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3439 parent->
setEvalErrorString( QStringLiteral(
"'project' requires a point geometry" ) );
3443 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3444 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3445 double inclination = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3448 QgsPoint newPoint = p->
project( distance, 180.0 * azimuth / M_PI, 180.0 * inclination / M_PI );
3455 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3456 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3463 if ( collection->numGeometries() == 1 )
3470 if ( !pt2 && fGeom2.isMultipart() )
3472 if (
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( fGeom2.constGet() ) )
3474 if ( collection->numGeometries() == 1 )
3484 parent->
setEvalErrorString( QStringLiteral(
"Function 'inclination' requires two points as arguments." ) );
3488 return pt1->inclination( *pt2 );
3494 if ( values.length() != 3 )
3497 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3498 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3499 double y = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3503 QVariant result = geom.
constGet() ? QVariant::fromValue( geom ) : QVariant();
3509 if ( values.length() < 2 )
3512 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3515 return values.at( 0 );
3517 QString expString = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3518 QVariant cachedExpression;
3523 if ( cachedExpression.isValid() )
3530 bool asc = values.value( 2 ).toBool();
3548 Q_ASSERT( collection );
3552 QgsExpressionSorter sorter( orderBy );
3554 QList<QgsFeature> partFeatures;
3555 partFeatures.reserve( collection->
partCount() );
3556 for (
int i = 0; i < collection->
partCount(); ++i )
3562 sorter.sortFeatures( partFeatures, unconstedContext );
3566 Q_ASSERT( orderedGeom );
3571 for (
const QgsFeature &feature : qgis::as_const( partFeatures ) )
3573 orderedGeom->
addGeometry( feature.geometry().constGet()->clone() );
3576 QVariant result = QVariant::fromValue(
QgsGeometry( orderedGeom ) );
3579 delete unconstedContext;
3586 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3587 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3591 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3597 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3598 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3602 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3608 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3609 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3613 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3619 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3622 parent->
setEvalErrorString( QObject::tr(
"line_substring requires a curve geometry input" ) );
3628 curve = qgsgeometry_cast< const QgsCurve * >( lineGeom.
constGet() );
3633 if ( collection->numGeometries() > 0 )
3642 double startDistance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3643 double endDistance = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3645 std::unique_ptr< QgsCurve > substring( curve->
curveSubstring( startDistance, endDistance ) );
3647 return !result.isNull() ? QVariant::fromValue( result ) : QVariant();
3652 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3653 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3660 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3661 qlonglong vertex = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3666 vertex = count + vertex;
3674 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3675 qlonglong vertex = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3680 vertex = count + vertex;
3688 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3689 QgsGeometry pointGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3693 return distance >= 0 ? distance : QVariant();
3698 if ( values.length() == 2 && values.at( 1 ).toInt() != 0 )
3700 double number = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
3701 return qgsRound( number, QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3704 if ( values.length() >= 1 )
3706 double number = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3707 return QVariant( qlonglong( std::round( number ) ) );
3722 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
3723 int places = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3729 QLocale locale = QLocale();
3730 locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
3731 return locale.toString( value,
'f', places );
3736 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
3737 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3738 return dt.toString( format );
3744 int avg = ( color.red() + color.green() + color.blue() ) / 3;
3745 int alpha = color.alpha();
3747 color.setRgb( avg, avg, avg, alpha );
3756 double ratio = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3761 else if ( ratio < 0 )
3766 int red = color1.red() * ( 1 - ratio ) + color2.red() * ratio;
3767 int green = color1.green() * ( 1 - ratio ) + color2.green() * ratio;
3768 int blue = color1.blue() * ( 1 - ratio ) + color2.blue() * ratio;
3769 int alpha = color1.alpha() * ( 1 - ratio ) + color2.alpha() * ratio;
3771 QColor newColor( red, green, blue, alpha );
3778 int red = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3779 int green = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3780 int blue = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3781 QColor color = QColor( red, green, blue );
3782 if ( ! color.isValid() )
3784 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( red ).arg( green ).arg( blue ) );
3785 color = QColor( 0, 0, 0 );
3788 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3793 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
3794 QVariant value = node->
eval( parent, context );
3798 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
3800 value = node->
eval( parent, context );
3808 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
3810 QVariant value = node->
eval( parent, context );
3812 if ( value.toBool() )
3814 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
3816 value = node->
eval( parent, context );
3821 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
3823 value = node->
eval( parent, context );
3831 int red = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3832 int green = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3833 int blue = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3834 int alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
3835 QColor color = QColor( red, green, blue, alpha );
3836 if ( ! color.isValid() )
3838 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( red ).arg( green ).arg( blue ).arg( alpha ) );
3839 color = QColor( 0, 0, 0 );
3850 expRamp = QgsExpressionUtils::getRamp( values.at( 0 ), parent );
3855 QString rampName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
3859 parent->
setEvalErrorString( QObject::tr(
"\"%1\" is not a valid color ramp" ).arg( rampName ) );
3864 double value = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3865 QColor color = ramp->
color( value );
3872 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3874 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3876 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3878 QColor color = QColor::fromHslF( hue, saturation, lightness );
3880 if ( ! color.isValid() )
3882 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( lightness ) );
3883 color = QColor( 0, 0, 0 );
3886 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3892 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3894 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3896 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3898 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
3900 QColor color = QColor::fromHslF( hue, saturation, lightness, alpha );
3901 if ( ! color.isValid() )
3903 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
3904 color = QColor( 0, 0, 0 );
3912 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3914 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3916 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3918 QColor color = QColor::fromHsvF( hue, saturation, value );
3920 if ( ! color.isValid() )
3922 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( value ) );
3923 color = QColor( 0, 0, 0 );
3926 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3932 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3934 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3936 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3938 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
3940 QColor color = QColor::fromHsvF( hue, saturation, value, alpha );
3941 if ( ! color.isValid() )
3943 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
3944 color = QColor( 0, 0, 0 );
3952 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
3954 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3956 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3958 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
3960 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black );
3962 if ( ! color.isValid() )
3964 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ) );
3965 color = QColor( 0, 0, 0 );
3968 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3974 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
3976 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3978 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3980 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
3982 double alpha = QgsExpressionUtils::getIntValue( values.at( 4 ), parent ) / 255.0;
3984 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
3985 if ( ! color.isValid() )
3987 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
3988 color = QColor( 0, 0, 0 );
3996 if ( ! color.isValid() )
3998 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4002 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4003 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
4005 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
4006 return color.green();
4007 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
4008 return color.blue();
4009 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
4010 return color.alpha();
4011 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
4012 return color.hsvHueF() * 360;
4013 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
4014 return color.hsvSaturationF() * 100;
4015 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
4016 return color.valueF() * 100;
4017 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
4018 return color.hslHueF() * 360;
4019 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
4020 return color.hslSaturationF() * 100;
4021 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
4022 return color.lightnessF() * 100;
4023 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
4024 return color.cyanF() * 100;
4025 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
4026 return color.magentaF() * 100;
4027 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
4028 return color.yellowF() * 100;
4029 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
4030 return color.blackF() * 100;
4032 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
4038 const QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4039 if ( map.count() < 1 )
4041 parent->
setEvalErrorString( QObject::tr(
"A minimum of two colors is required to create a ramp" ) );
4045 QList< QColor > colors;
4047 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
4050 if ( !colors.last().isValid() )
4052 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( it.value().toString() ) );
4056 double step = it.key().toDouble();
4057 if ( it == map.constBegin() )
4062 else if ( it == map.constEnd() )
4072 bool discrete = values.at( 1 ).toBool();
4074 return QVariant::fromValue(
QgsGradientColorRamp( colors.first(), colors.last(), discrete, stops ) );
4080 if ( ! color.isValid() )
4082 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4086 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4087 int value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
4088 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
4089 color.setRed( value );
4090 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
4091 color.setGreen( value );
4092 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
4093 color.setBlue( value );
4094 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
4095 color.setAlpha( value );
4096 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
4097 color.setHsv( value, color.hsvSaturation(), color.value(), color.alpha() );
4098 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
4099 color.setHsvF( color.hsvHueF(), value / 100.0, color.valueF(), color.alphaF() );
4100 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
4101 color.setHsvF( color.hsvHueF(), color.hsvSaturationF(), value / 100.0, color.alphaF() );
4102 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
4103 color.setHsl( value, color.hslSaturation(), color.lightness(), color.alpha() );
4104 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
4105 color.setHslF( color.hslHueF(), value / 100.0, color.lightnessF(), color.alphaF() );
4106 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
4107 color.setHslF( color.hslHueF(), color.hslSaturationF(), value / 100.0, color.alphaF() );
4108 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
4109 color.setCmykF( value / 100.0, color.magentaF(), color.yellowF(), color.blackF(), color.alphaF() );
4110 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
4111 color.setCmykF( color.cyanF(), value / 100.0, color.yellowF(), color.blackF(), color.alphaF() );
4112 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
4113 color.setCmykF( color.cyanF(), color.magentaF(), value / 100.0, color.blackF(), color.alphaF() );
4114 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
4115 color.setCmykF( color.cyanF(), color.magentaF(), color.yellowF(), value / 100.0, color.alphaF() );
4118 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
4127 if ( ! color.isValid() )
4129 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4133 color = color.darker( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
4141 if ( ! color.isValid() )
4143 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
4147 color = color.lighter( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
4154 QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
4156 if ( !geom.isNull() )
4157 return QVariant::fromValue( geom );
4163 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
4164 QString sAuthId = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4165 QString dAuthId = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4168 if ( ! s.isValid() )
4169 return QVariant::fromValue( fGeom );
4172 return QVariant::fromValue( fGeom );
4181 return QVariant::fromValue( fGeom );
4195 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
4198 QgsFeatureId fid = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4208 result = QVariant::fromValue( fet );
4218 std::unique_ptr<QgsVectorLayerFeatureSource> featureSource = QgsExpressionUtils::getFeatureSource( values.at( 0 ), parent );
4221 if ( !featureSource )
4226 QString attribute = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4227 int attributeId = featureSource->fields().lookupField( attribute );
4228 if ( attributeId == -1 )
4233 const QVariant &attVal = values.at( 2 );
4235 const QString cacheValueKey = QStringLiteral(
"getfeature:%1:%2:%3" ).arg( featureSource->id(), QString::number( attributeId ), attVal.toString() );
4257 res = QVariant::fromValue( fet );
4272 if ( !values.isEmpty() )
4275 if ( col && ( values.size() == 1 || !values.at( 1 ).isValid() ) )
4276 fieldName = col->
name();
4277 else if ( values.size() == 2 )
4278 fieldName = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4281 QVariant value = values.at( 0 );
4286 if ( fieldIndex == -1 )
4288 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: Field not found %2" ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
4292 QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
4294 const QString cacheValueKey = QStringLiteral(
"repvalfcnval:%1:%2:%3" ).arg( layer ? layer->
id() : QStringLiteral(
"[None]" ), fieldName, value.toString() );
4303 const QString cacheKey = QStringLiteral(
"repvalfcn:%1:%2" ).arg( layer ? layer->
id() : QStringLiteral(
"[None]" ), fieldName );
4321 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: function cannot be evaluated without a context." ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
4329 QgsMapLayer *layer = QgsExpressionUtils::getMapLayer( values.at( 0 ), parent );
4335 QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4336 if ( QString::compare( layerProperty, QStringLiteral(
"name" ), Qt::CaseInsensitive ) == 0 )
4337 return layer->
name();
4338 else if ( QString::compare( layerProperty, QStringLiteral(
"id" ), Qt::CaseInsensitive ) == 0 )
4340 else if ( QString::compare( layerProperty, QStringLiteral(
"title" ), Qt::CaseInsensitive ) == 0 )
4342 else if ( QString::compare( layerProperty, QStringLiteral(
"abstract" ), Qt::CaseInsensitive ) == 0 )
4344 else if ( QString::compare( layerProperty, QStringLiteral(
"keywords" ), Qt::CaseInsensitive ) == 0 )
4346 QStringList keywords;
4348 for (
auto it = keywordMap.constBegin(); it != keywordMap.constEnd(); ++it )
4350 keywords.append( it.value() );
4352 if ( !keywords.isEmpty() )
4356 else if ( QString::compare( layerProperty, QStringLiteral(
"data_url" ), Qt::CaseInsensitive ) == 0 )
4358 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution" ), Qt::CaseInsensitive ) == 0 )
4362 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution_url" ), Qt::CaseInsensitive ) == 0 )
4364 else if ( QString::compare( layerProperty, QStringLiteral(
"source" ), Qt::CaseInsensitive ) == 0 )
4366 else if ( QString::compare( layerProperty, QStringLiteral(
"min_scale" ), Qt::CaseInsensitive ) == 0 )
4368 else if ( QString::compare( layerProperty, QStringLiteral(
"max_scale" ), Qt::CaseInsensitive ) == 0 )
4370 else if ( QString::compare( layerProperty, QStringLiteral(
"crs" ), Qt::CaseInsensitive ) == 0 )
4372 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_definition" ), Qt::CaseInsensitive ) == 0 )
4374 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_description" ), Qt::CaseInsensitive ) == 0 )
4376 else if ( QString::compare( layerProperty, QStringLiteral(
"extent" ), Qt::CaseInsensitive ) == 0 )
4379 QVariant result = QVariant::fromValue( extentGeom );
4382 else if ( QString::compare( layerProperty, QStringLiteral(
"type" ), Qt::CaseInsensitive ) == 0 )
4384 switch ( layer->
type() )
4387 return QCoreApplication::translate(
"expressions",
"Vector" );
4389 return QCoreApplication::translate(
"expressions",
"Raster" );
4391 return QCoreApplication::translate(
"expressions",
"Mesh" );
4393 return QCoreApplication::translate(
"expressions",
"Plugin" );
4402 if ( QString::compare( layerProperty, QStringLiteral(
"storage_type" ), Qt::CaseInsensitive ) == 0 )
4404 else if ( QString::compare( layerProperty, QStringLiteral(
"geometry_type" ), Qt::CaseInsensitive ) == 0 )
4406 else if ( QString::compare( layerProperty, QStringLiteral(
"feature_count" ), Qt::CaseInsensitive ) == 0 )
4408 else if ( QString::compare( layerProperty, QStringLiteral(
"path" ), Qt::CaseInsensitive ) == 0 )
4413 return decodedUri.value( QStringLiteral(
"path" ) );
4424 QgsMapLayer *layer = QgsExpressionUtils::getMapLayer( values.at( 0 ), parent );
4427 parent->
setEvalErrorString( QObject::tr(
"Cannot find layer %1" ).arg( values.at( 0 ).toString() ) );
4437 const QString uriPart = values.at( 1 ).toString();
4441 if ( !uriPart.isNull() )
4443 return decodedUri.value( values.at( 1 ).toString() );
4453 QString layerIdOrName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4460 if ( !layersByName.isEmpty() )
4462 layer = layersByName.at( 0 );
4473 int band = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4474 if ( band < 1 || band > rl->
bandCount() )
4476 parent->
setEvalErrorString( QObject::tr(
"Invalid band number %1 for layer %2" ).arg( band ).arg( layerIdOrName ) );
4480 QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4483 if ( QString::compare( layerProperty, QStringLiteral(
"avg" ), Qt::CaseInsensitive ) == 0 )
4485 else if ( QString::compare( layerProperty, QStringLiteral(
"stdev" ), Qt::CaseInsensitive ) == 0 )
4487 else if ( QString::compare( layerProperty, QStringLiteral(
"min" ), Qt::CaseInsensitive ) == 0 )
4489 else if ( QString::compare( layerProperty, QStringLiteral(
"max" ), Qt::CaseInsensitive ) == 0 )
4491 else if ( QString::compare( layerProperty, QStringLiteral(
"range" ), Qt::CaseInsensitive ) == 0 )
4493 else if ( QString::compare( layerProperty, QStringLiteral(
"sum" ), Qt::CaseInsensitive ) == 0 )
4497 parent->
setEvalErrorString( QObject::tr(
"Invalid raster statistic: '%1'" ).arg( layerProperty ) );
4527 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4528 bool ascending = values.value( 1 ).toBool();
4535 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).length();
4540 return QVariant( QgsExpressionUtils::getListValue( values.at( 0 ), parent ).contains( values.at( 1 ) ) );
4545 QVariantList listA = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4546 QVariantList listB = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
4548 for (
const auto &item : listB )
4550 if ( listA.contains( item ) )
4554 return QVariant( match == listB.count() );
4559 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).indexOf( values.at( 1 ) );
4564 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4565 const qlonglong pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4566 if ( pos < 0 || pos >= list.length() )
return QVariant();
4567 return list.at( pos );
4572 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4573 return list.value( 0 );
4578 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4579 return list.value( list.size() - 1 );
4582 static QVariant convertToSameType(
const QVariant &value, QVariant::Type
type )
4584 QVariant result = value;
4585 result.convert( type );
4591 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4592 list.append( values.at( 1 ) );
4593 return convertToSameType( list, values.at( 0 ).type() );
4598 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4599 list.prepend( values.at( 1 ) );
4600 return convertToSameType( list, values.at( 0 ).type() );
4605 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4606 list.insert( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ), values.at( 2 ) );
4607 return convertToSameType( list, values.at( 0 ).type() );
4612 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4613 list.removeAt( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
4614 return convertToSameType( list, values.at( 0 ).type() );
4619 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4620 list.removeAll( values.at( 1 ) );
4621 return convertToSameType( list, values.at( 0 ).type() );
4627 for (
const QVariant &cur : values )
4629 list += QgsExpressionUtils::getListValue( cur, parent );
4631 return convertToSameType( list, values.at( 0 ).type() );
4636 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4637 qlonglong start_pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4638 const qlonglong end_pos = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
4639 qlonglong slice_length = 0;
4641 if ( start_pos < 0 )
4643 start_pos = list.length() + start_pos;
4647 slice_length = end_pos - start_pos + 1;
4651 slice_length = list.length() + end_pos - start_pos + 1;
4654 if ( slice_length < 0 )
4658 list = list.mid( start_pos, slice_length );
4664 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4665 std::reverse( list.begin(), list.end() );
4671 const QVariantList array1 = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4672 const QVariantList array2 = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
4673 for (
const QVariant &cur : array2 )
4675 if ( array1.contains( cur ) )
4676 return QVariant(
true );
4678 return QVariant(
false );
4683 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4685 QVariantList distinct;
4687 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
4689 if ( !distinct.contains( *it ) )
4691 distinct += ( *it );
4700 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4701 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4702 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4706 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
4708 str += ( !( *it ).toString().isEmpty() ) ? ( *it ).toString() : empty;
4709 if ( it != ( array.constEnd() - 1 ) )
4715 return QVariant( str );
4720 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4721 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4722 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4724 QStringList list = str.split( delimiter );
4727 for ( QStringList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
4729 array += ( !( *it ).isEmpty() ) ? *it : empty;
4737 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4738 QJsonDocument document = QJsonDocument::fromJson( str.toUtf8() );
4739 if ( document.isNull() )
4742 return document.toVariant();
4748 QJsonDocument document = QJsonDocument::fromVariant( values.at( 0 ) );
4749 return document.toJson( QJsonDocument::Compact );
4754 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4755 if ( str.isEmpty() )
4756 return QVariantMap();
4757 str = str.trimmed();
4764 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4771 for (
int i = 0; i + 1 < values.length(); i += 2 )
4773 result.insert( QgsExpressionUtils::getStringValue( values.at( i ), parent ), values.at( i + 1 ) );
4780 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).value( values.at( 1 ).toString() );
4785 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).contains( values.at( 1 ).toString() );
4790 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4791 map.remove( values.at( 1 ).toString() );
4797 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4798 map.insert( values.at( 1 ).toString(), values.at( 2 ) );
4805 for (
const QVariant &cur : values )
4807 const QVariantMap curMap = QgsExpressionUtils::getMapValue( cur, parent );
4808 for ( QVariantMap::const_iterator it = curMap.constBegin(); it != curMap.constEnd(); ++it )
4809 result.insert( it.key(), it.value() );
4816 return QStringList( QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).keys() );
4821 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).values();
4826 QString envVarName = values.at( 0 ).toString();
4827 return QProcessEnvironment::systemEnvironment().value( envVarName );
4832 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4833 return QFileInfo( file ).completeBaseName();
4838 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4839 return QFileInfo( file ).completeSuffix();
4844 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4845 return QFileInfo::exists( file );
4850 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4851 return QFileInfo( file ).fileName();
4856 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4857 return QFileInfo( file ).isFile();
4862 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4863 return QFileInfo( file ).isDir();
4868 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4869 return QDir::toNativeSeparators( QFileInfo( file ).path() );
4874 const QString file = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4875 return QFileInfo( file ).size();
4887 static QMutex sFunctionsMutex( QMutex::Recursive );
4888 QMutexLocker locker( &sFunctionsMutex );
4890 if ( sFunctions.isEmpty() )
4902 aggParamsArray << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true );
4908 <<
new QgsStaticExpressionFunction( QStringLiteral(
"azimuth" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point_b" ) ), fcnAzimuth, QStringList() << QStringLiteral(
"Math" ) << QStringLiteral(
"GeometryGroup" ) )
4909 <<
new QgsStaticExpressionFunction( QStringLiteral(
"inclination" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"point_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point_b" ) ), fcnInclination, QStringList() << QStringLiteral(
"Math" ) << QStringLiteral(
"GeometryGroup" ) )
4910 <<
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" ) )
4925 QgsStaticExpressionFunction *randFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"rand" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"max" ) ), fcnRnd, QStringLiteral(
"Math" ) );
4927 sFunctions << randFunc;
4929 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" ) );
4931 sFunctions << randfFunc;
4934 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max" ), -1, fcnMax, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4935 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min" ), -1, fcnMin, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4936 <<
new QgsStaticExpressionFunction( QStringLiteral(
"clamp" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"min" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"max" ) ), fcnClamp, QStringLiteral(
"Math" ) )
4937 <<
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" ) )
4938 <<
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" ) )
4939 <<
new QgsStaticExpressionFunction( QStringLiteral(
"floor" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnFloor, QStringLiteral(
"Math" ) )
4940 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ceil" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnCeil, QStringLiteral(
"Math" ) )
4941 <<
new QgsStaticExpressionFunction( QStringLiteral(
"pi" ), 0, fcnPi, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$pi" ) )
4942 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_int" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToInt, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"toint" ) )
4943 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_real" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToReal, QStringLiteral(
"Conversions" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"toreal" ) )
4944 <<
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" ) )
4945 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_datetime" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToDateTime, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todatetime" ) )
4946 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_date" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToDate, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"todate" ) )
4947 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_time" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnToTime, QStringList() << QStringLiteral(
"Conversions" ) << QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"totime" ) )
4948 <<
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" ) )
4949 <<
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" ) )
4950 <<
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" ) )
4951 <<
new QgsStaticExpressionFunction( QStringLiteral(
"coalesce" ), -1, fcnCoalesce, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4952 <<
new QgsStaticExpressionFunction( QStringLiteral(
"nullif" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value2" ) ), fcnNullIf, QStringLiteral(
"Conditionals" ) )
4953 <<
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 )
4954 <<
new QgsStaticExpressionFunction( QStringLiteral(
"try" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"alternative" ),
true, QVariant() ), fcnTry, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
true )
4956 <<
new QgsStaticExpressionFunction( QStringLiteral(
"aggregate" ),
4958 << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
4959 << QgsExpressionFunction::Parameter( QStringLiteral(
"aggregate" ) )
4960 << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ),
false, QVariant(),
true )
4961 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter" ),
true, QVariant(),
true )
4962 << QgsExpressionFunction::Parameter( QStringLiteral(
"concatenator" ),
true )
4963 << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true ),
4965 QStringLiteral(
"Aggregates" ),
4974 if ( !node->
args() )
4977 QSet<QString> referencedVars;
4989 return referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() );
4998 if ( !node->
args() )
4999 return QSet<QString>();
5001 QSet<QString> referencedCols;
5002 QSet<QString> referencedVars;
5017 if ( referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() ) )
5020 return referencedCols;
5026 << QgsExpressionFunction::Parameter( QStringLiteral(
"relation" ) )
5027 << QgsExpressionFunction::Parameter( QStringLiteral(
"aggregate" ) )
5028 << QgsExpressionFunction::Parameter( QStringLiteral(
"expression" ),
false, QVariant(),
true )
5029 << QgsExpressionFunction::Parameter( QStringLiteral(
"concatenator" ),
true )
5030 << QgsExpressionFunction::Parameter( QStringLiteral(
"order_by" ),
true, QVariant(),
true ),
5033 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count" ), aggParams, fcnAggregateCount, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5034 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_distinct" ), aggParams, fcnAggregateCountDistinct, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5035 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_missing" ), aggParams, fcnAggregateCountMissing, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5036 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minimum" ), aggParams, fcnAggregateMin, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5037 <<
new QgsStaticExpressionFunction( QStringLiteral(
"maximum" ), aggParams, fcnAggregateMax, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5038 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sum" ), aggParams, fcnAggregateSum, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5039 <<
new QgsStaticExpressionFunction( QStringLiteral(
"mean" ), aggParams, fcnAggregateMean, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5040 <<
new QgsStaticExpressionFunction( QStringLiteral(
"median" ), aggParams, fcnAggregateMedian, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5041 <<
new QgsStaticExpressionFunction( QStringLiteral(
"stdev" ), aggParams, fcnAggregateStdev, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5042 <<
new QgsStaticExpressionFunction( QStringLiteral(
"range" ), aggParams, fcnAggregateRange, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5043 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minority" ), aggParams, fcnAggregateMinority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5044 <<
new QgsStaticExpressionFunction( QStringLiteral(
"majority" ), aggParams, fcnAggregateMajority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5045 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q1" ), aggParams, fcnAggregateQ1, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5046 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q3" ), aggParams, fcnAggregateQ3, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5047 <<
new QgsStaticExpressionFunction( QStringLiteral(
"iqr" ), aggParams, fcnAggregateIQR, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5048 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min_length" ), aggParams, fcnAggregateMinLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5049 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max_length" ), aggParams, fcnAggregateMaxLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5050 <<
new QgsStaticExpressionFunction( QStringLiteral(
"collect" ), aggParams, fcnAggregateCollectGeometry, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5051 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concatenate" ), aggParamsConcat, fcnAggregateStringConcat, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5052 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concatenate_unique" ), aggParamsConcat, fcnAggregateStringConcatUnique, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5053 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_agg" ), aggParamsArray, fcnAggregateArray, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
5055 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_match" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) ), fcnRegexpMatch, QStringList() << QStringLiteral(
"Conditionals" ) << QStringLiteral(
"String" ) )
5056 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_matches" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"emptyvalue" ),
true,
"" ), fcnRegexpMatches, QStringLiteral(
"Arrays" ) )
5058 <<
new QgsStaticExpressionFunction( QStringLiteral(
"now" ), 0, fcnNow, QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$now" ) )
5060 << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime2" ) ),
5061 fcnAge, QStringLiteral(
"Date and Time" ) )
5062 <<
new QgsStaticExpressionFunction( QStringLiteral(
"year" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnYear, QStringLiteral(
"Date and Time" ) )
5063 <<
new QgsStaticExpressionFunction( QStringLiteral(
"month" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnMonth, QStringLiteral(
"Date and Time" ) )
5064 <<
new QgsStaticExpressionFunction( QStringLiteral(
"week" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnWeek, QStringLiteral(
"Date and Time" ) )
5065 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnDay, QStringLiteral(
"Date and Time" ) )
5066 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hour" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), fcnHour, QStringLiteral(
"Date and Time" ) )
5067 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minute" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), fcnMinute, QStringLiteral(
"Date and Time" ) )
5068 <<
new QgsStaticExpressionFunction( QStringLiteral(
"second" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ), fcnSeconds, QStringLiteral(
"Date and Time" ) )
5069 <<
new QgsStaticExpressionFunction( QStringLiteral(
"epoch" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnEpoch, QStringLiteral(
"Date and Time" ) )
5070 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day_of_week" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"date" ) ), fcnDayOfWeek, QStringLiteral(
"Date and Time" ) )
5071 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lower" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnLower, QStringLiteral(
"String" ) )
5072 <<
new QgsStaticExpressionFunction( QStringLiteral(
"upper" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnUpper, QStringLiteral(
"String" ) )
5073 <<
new QgsStaticExpressionFunction( QStringLiteral(
"title" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnTitle, QStringLiteral(
"String" ) )
5074 <<
new QgsStaticExpressionFunction( QStringLiteral(
"trim" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnTrim, QStringLiteral(
"String" ) )
5075 <<
new QgsStaticExpressionFunction( QStringLiteral(
"levenshtein" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"string2" ) ), fcnLevenshtein, QStringLiteral(
"Fuzzy Matching" ) )
5076 <<
new QgsStaticExpressionFunction( QStringLiteral(
"longest_common_substring" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"string2" ) ), fcnLCS, QStringLiteral(
"Fuzzy Matching" ) )
5077 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hamming_distance" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"string2" ) ), fcnHamming, QStringLiteral(
"Fuzzy Matching" ) )
5078 <<
new QgsStaticExpressionFunction( QStringLiteral(
"soundex" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnSoundex, QStringLiteral(
"Fuzzy Matching" ) )
5079 <<
new QgsStaticExpressionFunction( QStringLiteral(
"char" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"code" ) ), fcnChar, QStringLiteral(
"String" ) )
5080 <<
new QgsStaticExpressionFunction( QStringLiteral(
"wordwrap" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"text" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"delimiter" ),
true,
"" ), fcnWordwrap, QStringLiteral(
"String" ) )
5081 <<
new QgsStaticExpressionFunction( QStringLiteral(
"length" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"text" ),
true,
"" ), fcnLength, QStringList() << QStringLiteral(
"String" ) << QStringLiteral(
"GeometryGroup" ) )
5082 <<
new QgsStaticExpressionFunction( QStringLiteral(
"replace" ), -1, fcnReplace, QStringLiteral(
"String" ) )
5083 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_replace" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"input_string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) )
5084 << QgsExpressionFunction::Parameter( QStringLiteral(
"replacement" ) ), fcnRegexpReplace, QStringLiteral(
"String" ) )
5085 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_substr" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"input_string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"regex" ) ), fcnRegexpSubstr, QStringLiteral(
"String" ) )
5086 <<
new QgsStaticExpressionFunction( QStringLiteral(
"substr" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"start " ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ),
true ), fcnSubstr, QStringLiteral(
"String" ), QString(),
5087 false, QSet< QString >(),
false, QStringList(),
true )
5088 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concat" ), -1, fcnConcat, QStringLiteral(
"String" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5089 <<
new QgsStaticExpressionFunction( QStringLiteral(
"strpos" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"haystack" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"needle" ) ), fcnStrpos, QStringLiteral(
"String" ) )
5090 <<
new QgsStaticExpressionFunction( QStringLiteral(
"left" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ) ), fcnLeft, QStringLiteral(
"String" ) )
5091 <<
new QgsStaticExpressionFunction( QStringLiteral(
"right" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"length" ) ), fcnRight, QStringLiteral(
"String" ) )
5092 <<
new QgsStaticExpressionFunction( QStringLiteral(
"rpad" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"width" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"fill" ) ), fcnRPad, QStringLiteral(
"String" ) )
5093 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lpad" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"width" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"fill" ) ), fcnLPad, QStringLiteral(
"String" ) )
5094 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format" ), -1, fcnFormatString, QStringLiteral(
"String" ) )
5095 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format_number" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"number" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"places" ) ), fcnFormatNumber, QStringLiteral(
"String" ) )
5096 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format_date" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"datetime" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"format" ) ), fcnFormatDate, QStringList() << QStringLiteral(
"String" ) << QStringLiteral(
"Date and Time" ) )
5097 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_grayscale_average" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"color" ) ), fcnColorGrayscaleAverage, QStringLiteral(
"Color" ) )
5098 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_mix_rgb" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"color1" ) )
5099 << QgsExpressionFunction::Parameter( QStringLiteral(
"color2" ) )
5100 << QgsExpressionFunction::Parameter( QStringLiteral(
"ratio" ) ),
5101 fcnColorMixRgb, QStringLiteral(
"Color" ) )
5103 << QgsExpressionFunction::Parameter( QStringLiteral(
"green" ) )
5104 << QgsExpressionFunction::Parameter( QStringLiteral(
"blue" ) ),
5105 fcnColorRgb, QStringLiteral(
"Color" ) )
5107 << QgsExpressionFunction::Parameter( QStringLiteral(
"green" ) )
5108 << QgsExpressionFunction::Parameter( QStringLiteral(
"blue" ) )
5109 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
5110 fncColorRgba, QStringLiteral(
"Color" ) )
5111 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ramp_color" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"ramp_name" ) )
5112 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ),
5115 << QgsExpressionFunction::Parameter( QStringLiteral(
"discrete" ),
true,
false ),
5116 fcnCreateRamp, QStringLiteral(
"Color" ) )
5118 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
5119 << QgsExpressionFunction::Parameter( QStringLiteral(
"lightness" ) ),
5120 fcnColorHsl, QStringLiteral(
"Color" ) )
5122 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
5123 << QgsExpressionFunction::Parameter( QStringLiteral(
"lightness" ) )
5124 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
5125 fncColorHsla, QStringLiteral(
"Color" ) )
5127 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
5128 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ),
5129 fcnColorHsv, QStringLiteral(
"Color" ) )
5131 << QgsExpressionFunction::Parameter( QStringLiteral(
"saturation" ) )
5132 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) )
5133 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
5134 fncColorHsva, QStringLiteral(
"Color" ) )
5136 << QgsExpressionFunction::Parameter( QStringLiteral(
"magenta" ) )
5137 << QgsExpressionFunction::Parameter( QStringLiteral(
"yellow" ) )
5138 << QgsExpressionFunction::Parameter( QStringLiteral(
"black" ) ),
5139 fcnColorCmyk, QStringLiteral(
"Color" ) )
5141 << QgsExpressionFunction::Parameter( QStringLiteral(
"magenta" ) )
5142 << QgsExpressionFunction::Parameter( QStringLiteral(
"yellow" ) )
5143 << QgsExpressionFunction::Parameter( QStringLiteral(
"black" ) )
5144 << QgsExpressionFunction::Parameter( QStringLiteral(
"alpha" ) ),
5145 fncColorCmyka, QStringLiteral(
"Color" ) )
5147 << QgsExpressionFunction::Parameter( QStringLiteral(
"component" ) ),
5148 fncColorPart, QStringLiteral(
"Color" ) )
5150 << QgsExpressionFunction::Parameter( QStringLiteral(
"factor" ) ),
5151 fncDarker, QStringLiteral(
"Color" ) )
5153 << QgsExpressionFunction::Parameter( QStringLiteral(
"factor" ) ),
5154 fncLighter, QStringLiteral(
"Color" ) )
5155 <<
new QgsStaticExpressionFunction( QStringLiteral(
"set_color_part" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"color" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"component" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fncSetColorPart, QStringLiteral(
"Color" ) )
5158 <<
new QgsStaticExpressionFunction( QStringLiteral(
"base_file_name" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"path" ) ),
5159 fcnBaseFileName, QStringLiteral(
"Files and Paths" ) )
5161 fcnFileSuffix, QStringLiteral(
"Files and Paths" ) )
5163 fcnFileExists, QStringLiteral(
"Files and Paths" ) )
5165 fcnFileName, QStringLiteral(
"Files and Paths" ) )
5167 fcnPathIsFile, QStringLiteral(
"Files and Paths" ) )
5169 fcnPathIsDir, QStringLiteral(
"Files and Paths" ) )
5171 fcnFilePath, QStringLiteral(
"Files and Paths" ) )
5173 fcnFileSize, QStringLiteral(
"Files and Paths" ) )
5178 QgsStaticExpressionFunction *geomFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$geometry" ), 0, fcnGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5180 sFunctions << geomFunc;
5182 QgsStaticExpressionFunction *areaFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$area" ), 0, fcnGeomArea, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5184 sFunctions << areaFunc;
5186 sFunctions <<
new QgsStaticExpressionFunction( QStringLiteral(
"area" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnArea, QStringLiteral(
"GeometryGroup" ) );
5188 QgsStaticExpressionFunction *lengthFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$length" ), 0, fcnGeomLength, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5190 sFunctions << lengthFunc;
5192 QgsStaticExpressionFunction *perimeterFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$perimeter" ), 0, fcnGeomPerimeter, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5194 sFunctions << perimeterFunc;
5196 sFunctions <<
new QgsStaticExpressionFunction( QStringLiteral(
"perimeter" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnPerimeter, QStringLiteral(
"GeometryGroup" ) );
5198 QgsStaticExpressionFunction *xFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$x" ), 0, fcnX, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5200 sFunctions << xFunc;
5202 QgsStaticExpressionFunction *yFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$y" ), 0, fcnY, QStringLiteral(
"GeometryGroup" ), QString(),
true );
5204 sFunctions << yFunc;
5207 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomX, QStringLiteral(
"GeometryGroup" ) )
5208 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomY, QStringLiteral(
"GeometryGroup" ) )
5209 <<
new QgsStaticExpressionFunction( QStringLiteral(
"z" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomZ, QStringLiteral(
"GeometryGroup" ) )
5210 <<
new QgsStaticExpressionFunction( QStringLiteral(
"m" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomM, QStringLiteral(
"GeometryGroup" ) )
5211 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_n" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"index" ) ), fcnPointN, QStringLiteral(
"GeometryGroup" ) )
5212 <<
new QgsStaticExpressionFunction( QStringLiteral(
"start_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnStartPoint, QStringLiteral(
"GeometryGroup" ) )
5213 <<
new QgsStaticExpressionFunction( QStringLiteral(
"end_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnEndPoint, QStringLiteral(
"GeometryGroup" ) )
5214 <<
new QgsStaticExpressionFunction( QStringLiteral(
"nodes_to_points" ), -1, fcnNodesToPoints, QStringLiteral(
"GeometryGroup" ) )
5215 <<
new QgsStaticExpressionFunction( QStringLiteral(
"segments_to_lines" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnSegmentsToLines, QStringLiteral(
"GeometryGroup" ) )
5216 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_point" ), -1, fcnMakePoint, QStringLiteral(
"GeometryGroup" ) )
5218 << QgsExpressionFunction::Parameter( QStringLiteral(
"y" ) )
5219 << QgsExpressionFunction::Parameter( QStringLiteral(
"m" ) ),
5220 fcnMakePointM, QStringLiteral(
"GeometryGroup" ) )
5221 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_line" ), -1, fcnMakeLine, QStringLiteral(
"GeometryGroup" ) )
5222 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_polygon" ), -1, fcnMakePolygon, QStringLiteral(
"GeometryGroup" ) )
5223 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_triangle" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5224 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5225 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
5226 fcnMakeTriangle, QStringLiteral(
"GeometryGroup" ) )
5228 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5229 << QgsExpressionFunction::Parameter( QStringLiteral(
"radius" ) )
5230 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 36 ),
5231 fcnMakeCircle, QStringLiteral(
"GeometryGroup" ) )
5233 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5234 << QgsExpressionFunction::Parameter( QStringLiteral(
"semi_major_axis" ) )
5235 << QgsExpressionFunction::Parameter( QStringLiteral(
"semi_minor_axis" ) )
5236 << QgsExpressionFunction::Parameter( QStringLiteral(
"azimuth" ) )
5237 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 36 ),
5238 fcnMakeEllipse, QStringLiteral(
"GeometryGroup" ) )
5240 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5241 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5242 << QgsExpressionFunction::Parameter( QStringLiteral(
"number_sides" ) )
5243 << QgsExpressionFunction::Parameter( QStringLiteral(
"circle" ),
true, 0 ),
5244 fcnMakeRegularPolygon, QStringLiteral(
"GeometryGroup" ) )
5246 << QgsExpressionFunction::Parameter( QStringLiteral(
"point1" ) )
5247 << QgsExpressionFunction::Parameter( QStringLiteral(
"point2" ) ),
5248 fcnMakeSquare, QStringLiteral(
"GeometryGroup" ) )
5250 << QgsExpressionFunction::Parameter( QStringLiteral(
"point1" ) )
5251 << QgsExpressionFunction::Parameter( QStringLiteral(
"point2" ) )
5252 << QgsExpressionFunction::Parameter( QStringLiteral(
"point3" ) )
5253 << QgsExpressionFunction::Parameter( QStringLiteral(
"option" ),
true, 0 ),
5254 fcnMakeRectangleFrom3Points, QStringLiteral(
"GeometryGroup" ) );
5255 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" ) );
5257 sFunctions << xAtFunc;
5259 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" ) );
5261 sFunctions << yAtFunc;
5264 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_min" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnXMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmin" ) )
5265 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_max" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnXMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmax" ) )
5266 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_min" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnYMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymin" ) )
5267 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_max" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnYMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymax" ) )
5268 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_wkt" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"text" ) ), fcnGeomFromWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromWKT" ) )
5269 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_gml" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"gml" ) ), fcnGeomFromGML, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromGML" ) )
5270 <<
new QgsStaticExpressionFunction( QStringLiteral(
"flip_coordinates" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnFlipCoordinates, QStringLiteral(
"GeometryGroup" ) )
5271 <<
new QgsStaticExpressionFunction( QStringLiteral(
"relate" ), -1, fcnRelate, QStringLiteral(
"GeometryGroup" ) )
5272 <<
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" ) )
5274 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5275 fcnDisjoint, QStringLiteral(
"GeometryGroup" ) )
5276 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersects" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry a" ) )
5277 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5278 fcnIntersects, QStringLiteral(
"GeometryGroup" ) )
5280 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5281 fcnTouches, QStringLiteral(
"GeometryGroup" ) )
5283 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5284 fcnCrosses, QStringLiteral(
"GeometryGroup" ) )
5286 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5287 fcnContains, QStringLiteral(
"GeometryGroup" ) )
5289 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5290 fcnOverlaps, QStringLiteral(
"GeometryGroup" ) )
5292 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5293 fcnWithin, QStringLiteral(
"GeometryGroup" ) )
5295 << QgsExpressionFunction::Parameter( QStringLiteral(
"dx" ) )
5296 << QgsExpressionFunction::Parameter( QStringLiteral(
"dy" ) ),
5297 fcnTranslate, QStringLiteral(
"GeometryGroup" ) )
5298 <<
new QgsStaticExpressionFunction( QStringLiteral(
"buffer" ), -1, fcnBuffer, QStringLiteral(
"GeometryGroup" ) )
5300 fcnForceRHR, QStringLiteral(
"GeometryGroup" ) )
5302 << QgsExpressionFunction::Parameter( QStringLiteral(
"azimuth" ) )
5303 << QgsExpressionFunction::Parameter( QStringLiteral(
"width" ) )
5304 << QgsExpressionFunction::Parameter( QStringLiteral(
"outer_radius" ) )
5305 << QgsExpressionFunction::Parameter( QStringLiteral(
"inner_radius" ),
true, 0.0 ), fcnWedgeBuffer, QStringLiteral(
"GeometryGroup" ) )
5306 <<
new QgsStaticExpressionFunction( QStringLiteral(
"tapered_buffer" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5307 << QgsExpressionFunction::Parameter( QStringLiteral(
"start_width" ) )
5308 << QgsExpressionFunction::Parameter( QStringLiteral(
"end_width" ) )
5309 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
5310 , fcnTaperedBuffer, QStringLiteral(
"GeometryGroup" ) )
5311 <<
new QgsStaticExpressionFunction( QStringLiteral(
"buffer_by_m" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5312 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
5313 , fcnBufferByM, QStringLiteral(
"GeometryGroup" ) )
5314 <<
new QgsStaticExpressionFunction( QStringLiteral(
"offset_curve" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5315 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) )
5316 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
5318 << QgsExpressionFunction::Parameter( QStringLiteral(
"miter_limit" ),
true, 2.0 ),
5319 fcnOffsetCurve, QStringLiteral(
"GeometryGroup" ) )
5320 <<
new QgsStaticExpressionFunction( QStringLiteral(
"single_sided_buffer" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5321 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) )
5322 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 8.0 )
5324 << QgsExpressionFunction::Parameter( QStringLiteral(
"miter_limit" ),
true, 2.0 ),
5325 fcnSingleSidedBuffer, QStringLiteral(
"GeometryGroup" ) )
5327 << QgsExpressionFunction::Parameter( QStringLiteral(
"start_distance" ) )
5328 << QgsExpressionFunction::Parameter( QStringLiteral(
"end_distance" ) ),
5329 fcnExtend, QStringLiteral(
"GeometryGroup" ) )
5330 <<
new QgsStaticExpressionFunction( QStringLiteral(
"centroid" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnCentroid, QStringLiteral(
"GeometryGroup" ) )
5331 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_on_surface" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnPointOnSurface, QStringLiteral(
"GeometryGroup" ) )
5332 <<
new QgsStaticExpressionFunction( QStringLiteral(
"pole_of_inaccessibility" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5333 << QgsExpressionFunction::Parameter( QStringLiteral(
"tolerance" ) ), fcnPoleOfInaccessibility, QStringLiteral(
"GeometryGroup" ) )
5334 <<
new QgsStaticExpressionFunction( QStringLiteral(
"reverse" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnReverse, QStringLiteral(
"GeometryGroup" ) )
5335 <<
new QgsStaticExpressionFunction( QStringLiteral(
"exterior_ring" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnExteriorRing, QStringLiteral(
"GeometryGroup" ) )
5336 <<
new QgsStaticExpressionFunction( QStringLiteral(
"interior_ring_n" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5337 << QgsExpressionFunction::Parameter( QStringLiteral(
"index" ) ),
5338 fcnInteriorRingN, QStringLiteral(
"GeometryGroup" ) )
5340 << QgsExpressionFunction::Parameter( QStringLiteral(
"index" ) ),
5341 fcnGeometryN, QStringLiteral(
"GeometryGroup" ) )
5342 <<
new QgsStaticExpressionFunction( QStringLiteral(
"boundary" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnBoundary, QStringLiteral(
"GeometryGroup" ) )
5343 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_merge" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnLineMerge, QStringLiteral(
"GeometryGroup" ) )
5344 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnBounds, QStringLiteral(
"GeometryGroup" ) )
5345 <<
new QgsStaticExpressionFunction( QStringLiteral(
"simplify" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"tolerance" ) ), fcnSimplify, QStringLiteral(
"GeometryGroup" ) )
5346 <<
new QgsStaticExpressionFunction( QStringLiteral(
"simplify_vw" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"tolerance" ) ), fcnSimplifyVW, QStringLiteral(
"GeometryGroup" ) )
5347 <<
new QgsStaticExpressionFunction( QStringLiteral(
"smooth" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"iterations" ),
true, 1 )
5348 << QgsExpressionFunction::Parameter( QStringLiteral(
"offset" ),
true, 0.25 )
5349 << QgsExpressionFunction::Parameter( QStringLiteral(
"min_length" ),
true, -1 )
5350 << QgsExpressionFunction::Parameter( QStringLiteral(
"max_angle" ),
true, 180 ), fcnSmooth, QStringLiteral(
"GeometryGroup" ) )
5351 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_points" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnGeomNumPoints, QStringLiteral(
"GeometryGroup" ) )
5352 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_interior_rings" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumInteriorRings, QStringLiteral(
"GeometryGroup" ) )
5353 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_rings" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumRings, QStringLiteral(
"GeometryGroup" ) )
5354 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_geometries" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnGeomNumGeometries, QStringLiteral(
"GeometryGroup" ) )
5355 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_width" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnBoundsWidth, QStringLiteral(
"GeometryGroup" ) )
5356 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_height" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnBoundsHeight, QStringLiteral(
"GeometryGroup" ) )
5357 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_closed" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) ), fcnIsClosed, QStringLiteral(
"GeometryGroup" ) )
5358 <<
new QgsStaticExpressionFunction( QStringLiteral(
"convex_hull" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ), fcnConvexHull, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"convexHull" ) )
5360 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) ),
5361 fcnOrientedBBox, QStringLiteral(
"GeometryGroup" ) )
5363 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5364 << QgsExpressionFunction::Parameter( QStringLiteral(
"segments" ),
true, 36 ),
5365 fcnMinimalCircle, QStringLiteral(
"GeometryGroup" ) )
5366 <<
new QgsStaticExpressionFunction( QStringLiteral(
"difference" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry_a" ) )
5367 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry_b" ) ),
5368 fcnDifference, QStringLiteral(
"GeometryGroup" ) )
5370 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry b" ) ),
5371 fcnDistance, QStringLiteral(
"GeometryGroup" ) )
5372 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hausdorff_distance" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) )
5373 << QgsExpressionFunction::Parameter( QStringLiteral(
"densify_fraction" ),
true ),
5374 fcnHausdorffDistance, QStringLiteral(
"GeometryGroup" ) )
5375 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersection" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry_a" ) )
5376 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry_b" ) ),
5377 fcnIntersection, QStringLiteral(
"GeometryGroup" ) )
5378 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sym_difference" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
5379 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5380 fcnSymDifference, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"symDifference" ) )
5382 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5383 fcnCombine, QStringLiteral(
"GeometryGroup" ) )
5385 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5386 fcnCombine, QStringLiteral(
"GeometryGroup" ) )
5387 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_to_wkt" ), -1, fcnGeomToWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomToWKT" ) )
5388 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geometry" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"feature" ) ), fcnGetGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true )
5390 << QgsExpressionFunction::Parameter( QStringLiteral(
"source_auth_id" ) )
5391 << QgsExpressionFunction::Parameter( QStringLiteral(
"dest_auth_id" ) ),
5392 fcnTransformGeometry, QStringLiteral(
"GeometryGroup" ) )
5394 << QgsExpressionFunction::Parameter( QStringLiteral(
"x" ) )
5395 << QgsExpressionFunction::Parameter( QStringLiteral(
"y" ) ),
5396 fcnExtrude, QStringLiteral(
"GeometryGroup" ), QString() );;
5398 QgsStaticExpressionFunction *orderPartsFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"order_parts" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geom" ) )
5399 << QgsExpressionFunction::Parameter( QStringLiteral(
"orderby" ) )
5400 << QgsExpressionFunction::Parameter( QStringLiteral(
"ascending" ) ),
5401 fcnOrderParts, QStringLiteral(
"GeometryGroup" ), QString() );
5406 const QList< QgsExpressionNode *> argList = node->
args()->
list();
5409 if ( !argNode->isStatic( parent, context ) )
5417 QString expString = argNode->
eval( parent, context ).toString();
5433 QString expression = argNode->
eval( parent, context ).toString();
5441 sFunctions << orderPartsFunc;
5444 <<
new QgsStaticExpressionFunction( QStringLiteral(
"closest_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
5445 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5446 fcnClosestPoint, QStringLiteral(
"GeometryGroup" ) )
5447 <<
new QgsStaticExpressionFunction( QStringLiteral(
"shortest_line" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry1" ) )
5448 << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry2" ) ),
5449 fcnShortestLine, QStringLiteral(
"GeometryGroup" ) )
5450 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_interpolate_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5451 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) ), fcnLineInterpolatePoint, QStringLiteral(
"GeometryGroup" ) )
5452 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_interpolate_angle" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5453 << QgsExpressionFunction::Parameter( QStringLiteral(
"distance" ) ), fcnLineInterpolateAngle, QStringLiteral(
"GeometryGroup" ) )
5454 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_locate_point" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5455 << QgsExpressionFunction::Parameter( QStringLiteral(
"point" ) ), fcnLineLocatePoint, QStringLiteral(
"GeometryGroup" ) )
5456 <<
new QgsStaticExpressionFunction( QStringLiteral(
"angle_at_vertex" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5457 << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ) ), fcnAngleAtVertex, QStringLiteral(
"GeometryGroup" ) )
5458 <<
new QgsStaticExpressionFunction( QStringLiteral(
"distance_to_vertex" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5459 << QgsExpressionFunction::Parameter( QStringLiteral(
"vertex" ) ), fcnDistanceToVertex, QStringLiteral(
"GeometryGroup" ) )
5460 <<
new QgsStaticExpressionFunction( QStringLiteral(
"line_substring" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"geometry" ) )
5461 << QgsExpressionFunction::Parameter( QStringLiteral(
"start_distance" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"end_distance" ) ), fcnLineSubset, QStringLiteral(
"GeometryGroup" ) );
5466 QgsStaticExpressionFunction *idFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$id" ), 0, fcnFeatureId, QStringLiteral(
"Record and Attributes" ) );
5468 sFunctions << idFunc;
5470 QgsStaticExpressionFunction *currentFeatureFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$currentfeature" ), 0, fcnFeature, QStringLiteral(
"Record and Attributes" ) );
5472 sFunctions << currentFeatureFunc;
5474 QgsStaticExpressionFunction *uuidFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"uuid" ), 0, fcnUuid, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$uuid" ) );
5476 sFunctions << uuidFunc;
5480 << QgsExpressionFunction::Parameter( QStringLiteral(
"attribute" ) )
5481 << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ),
5482 fcnGetFeature, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"QgsExpressionUtils::getFeature" ) )
5483 <<
new QgsStaticExpressionFunction( QStringLiteral(
"get_feature_by_id" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5484 << QgsExpressionFunction::Parameter( QStringLiteral(
"feature_id" ) ),
5485 fcnGetFeatureById, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false );
5487 QgsStaticExpressionFunction *isSelectedFunc =
new QgsStaticExpressionFunction(
5488 QStringLiteral(
"is_selected" ),
5491 QStringLiteral(
"Record and Attributes" ),
5497 sFunctions << isSelectedFunc;
5500 <<
new QgsStaticExpressionFunction(
5501 QStringLiteral(
"num_selected" ),
5504 QStringLiteral(
"Record and Attributes" ),
5511 <<
new QgsStaticExpressionFunction(
5512 QStringLiteral(
"sqlite_fetch_and_increment" ),
5514 << QgsExpressionFunction::Parameter( QStringLiteral(
"database" ) )
5515 << QgsExpressionFunction::Parameter( QStringLiteral(
"table" ) )
5516 << QgsExpressionFunction::Parameter( QStringLiteral(
"id_field" ) )
5517 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter_attribute" ) )
5518 << QgsExpressionFunction::Parameter( QStringLiteral(
"filter_value" ) )
5519 << QgsExpressionFunction::Parameter( QStringLiteral(
"default_values" ),
true ),
5520 fcnSqliteFetchAndIncrement,
5521 QStringLiteral(
"Record and Attributes" )
5525 QgsStaticExpressionFunction *representValueFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"represent_value" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"attribute" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"field_name" ),
true ), fcnRepresentValue, QStringLiteral(
"Record and Attributes" ) );
5539 parent->
setEvalErrorString( tr(
"If represent_value is called with 1 parameter, it must be an attribute." ) );
5549 parent->
setEvalErrorString( tr(
"represent_value must be called with exactly 1 or 2 parameters." ) );
5555 sFunctions << representValueFunc;
5559 <<
new QgsStaticExpressionFunction( QStringLiteral(
"layer_property" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5560 << QgsExpressionFunction::Parameter( QStringLiteral(
"property" ) ),
5561 fcnGetLayerProperty, QStringLiteral(
"General" ) )
5562 <<
new QgsStaticExpressionFunction( QStringLiteral(
"decode_uri" ),
5564 << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5565 << QgsExpressionFunction::Parameter( QStringLiteral(
"part" ),
true ),
5566 fcnDecodeUri, QStringLiteral(
"Map Layers" ) )
5567 <<
new QgsStaticExpressionFunction( QStringLiteral(
"raster_statistic" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) )
5568 << QgsExpressionFunction::Parameter( QStringLiteral(
"band" ) )
5569 << QgsExpressionFunction::Parameter( QStringLiteral(
"statistic" ) ), fcnGetRasterBandStat, QStringLiteral(
"Rasters" ) );
5572 QgsStaticExpressionFunction *varFunction =
new QgsStaticExpressionFunction( QStringLiteral(
"var" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"name" ) ), fcnGetVariable, QStringLiteral(
"General" ) );
5585 if ( !argNode->
isStatic( parent, context ) )
5588 QString varName = argNode->
eval( parent, context ).toString();
5591 return scope ? scope->
isStatic( varName ) :
false;
5607 if ( argNode->
isStatic( parent, context ) )
5609 QString expString = argNode->
eval( parent, context ).toString();
5621 sFunctions << evalFunc;
5623 QgsStaticExpressionFunction *attributeFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"attribute" ), -1, fcnAttribute, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES );
5627 const QList< QgsExpressionNode *> argList = node->
args()->
list();
5630 if ( !argNode->isStatic( parent, context ) )
5642 sFunctions << attributeFunc;
5645 <<
new QgsStaticExpressionFunction( QStringLiteral(
"env" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"name" ) ), fcnEnvVar, QStringLiteral(
"General" ), QString() )
5647 <<
new QgsStaticExpressionFunction( QStringLiteral(
"raster_value" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"layer" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"band" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"point" ) ), fcnRasterValue, QStringLiteral(
"Rasters" ) )
5652 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array" ), -1, fcnArray, QStringLiteral(
"Arrays" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5653 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_sort" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"ascending" ),
true,
true ), fcnArraySort, QStringLiteral(
"Arrays" ) )
5654 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_length" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayLength, QStringLiteral(
"Arrays" ) )
5655 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_contains" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayContains, QStringLiteral(
"Arrays" ) )
5656 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_all" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array_a" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"array_b" ) ), fcnArrayAll, QStringLiteral(
"Arrays" ) )
5657 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_find" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayFind, QStringLiteral(
"Arrays" ) )
5658 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_get" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"pos" ) ), fcnArrayGet, QStringLiteral(
"Arrays" ) )
5659 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_first" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayFirst, QStringLiteral(
"Arrays" ) )
5660 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_last" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayLast, QStringLiteral(
"Arrays" ) )
5661 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_append" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayAppend, QStringLiteral(
"Arrays" ) )
5662 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_prepend" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayPrepend, QStringLiteral(
"Arrays" ) )
5663 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_insert" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"pos" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayInsert, QStringLiteral(
"Arrays" ) )
5664 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_remove_at" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"pos" ) ), fcnArrayRemoveAt, QStringLiteral(
"Arrays" ) )
5665 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_remove_all" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnArrayRemoveAll, QStringLiteral(
"Arrays" ) )
5666 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_cat" ), -1, fcnArrayCat, QStringLiteral(
"Arrays" ) )
5667 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_slice" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"start_pos" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"end_pos" ) ), fcnArraySlice, QStringLiteral(
"Arrays" ) )
5668 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_reverse" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayReverse, QStringLiteral(
"Arrays" ) )
5669 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_intersect" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array1" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"array2" ) ), fcnArrayIntersect, QStringLiteral(
"Arrays" ) )
5670 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_distinct" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"array" ) ), fcnArrayDistinct, QStringLiteral(
"Arrays" ) )
5671 <<
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" ) )
5672 <<
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" ) )
5673 <<
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" ) )
5676 <<
new QgsStaticExpressionFunction( QStringLiteral(
"json_to_map" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnLoadJson, QStringLiteral(
"Maps" ) )
5677 <<
new QgsStaticExpressionFunction( QStringLiteral(
"from_json" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnLoadJson, QStringLiteral(
"Maps" ) )
5678 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_to_json" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnWriteJson, QStringLiteral(
"Maps" ) )
5679 <<
new QgsStaticExpressionFunction( QStringLiteral(
"to_json" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"json_string" ) ), fcnWriteJson, QStringLiteral(
"Maps" ) )
5680 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hstore_to_map" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"string" ) ), fcnHstoreToMap, QStringLiteral(
"Maps" ) )
5681 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_to_hstore" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnMapToHstore, QStringLiteral(
"Maps" ) )
5682 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map" ), -1, fcnMap, QStringLiteral(
"Maps" ) )
5683 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_get" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ), fcnMapGet, QStringLiteral(
"Maps" ) )
5684 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_exist" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ), fcnMapExist, QStringLiteral(
"Maps" ) )
5685 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_delete" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ), fcnMapDelete, QStringLiteral(
"Maps" ) )
5686 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_insert" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"key" ) ) << QgsExpressionFunction::Parameter( QStringLiteral(
"value" ) ), fcnMapInsert, QStringLiteral(
"Maps" ) )
5687 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_concat" ), -1, fcnMapConcat, QStringLiteral(
"Maps" ) )
5688 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_akeys" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnMapAKeys, QStringLiteral(
"Maps" ) )
5689 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_avals" ),
QgsExpressionFunction::ParameterList() << QgsExpressionFunction::Parameter( QStringLiteral(
"map" ) ), fcnMapAVals, QStringLiteral(
"Maps" ) )
5697 sOwnedFunctions <<
func;
5698 sBuiltinFunctions << func->name();
5699 sBuiltinFunctions.append( func->aliases() );
5709 QStringLiteral(
"Arrays" ) )
5720 if ( args->
count() < 2 )
5723 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
5733 QVariantList result;
5735 if ( args->
count() < 2 )
5739 QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
5742 std::unique_ptr< QgsExpressionContext > tempContext;
5745 tempContext = qgis::make_unique< QgsExpressionContext >();
5746 subContext = tempContext.get();
5752 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
5755 result << args->
at( 1 )->
eval( parent, subContext );
5780 if ( args->
count() < 2 )
5784 args->
at( 0 )->
prepare( parent, context );
5788 subContext = *context;
5794 args->
at( 1 )->
prepare( parent, &subContext );
5803 QStringLiteral(
"Arrays" ) )
5814 if ( args->
count() < 2 )
5817 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
5827 QVariantList result;
5829 if ( args->
count() < 2 )
5833 const QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
5836 std::unique_ptr< QgsExpressionContext > tempContext;
5839 tempContext = qgis::make_unique< QgsExpressionContext >();
5840 subContext = tempContext.get();
5846 for (
const QVariant &value : array )
5849 if ( args->
at( 1 )->
eval( parent, subContext ).toBool() )
5875 if ( args->
count() < 2 )
5879 args->
at( 0 )->
prepare( parent, context );
5883 subContext = *context;
5889 args->
at( 1 )->
prepare( parent, &subContext );
5898 QStringLiteral(
"General" ) )
5909 if ( args->
count() < 3 )
5913 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
5915 QVariant
name = args->
at( 0 )->
eval( parent, context );
5916 QVariant value = args->
at( 1 )->
eval( parent, context );
5919 appendTemporaryVariable( context, name.toString(), value );
5920 if ( args->
at( 2 )->
isStatic( parent, context ) )
5922 popTemporaryVariable( context );
5933 if ( args->
count() < 3 )
5937 QVariant
name = args->
at( 0 )->
eval( parent, context );
5938 QVariant value = args->
at( 1 )->
eval( parent, context );
5941 std::unique_ptr< QgsExpressionContext > tempContext;
5942 if ( !updatedContext )
5944 tempContext = qgis::make_unique< QgsExpressionContext >();
5945 updatedContext = tempContext.get();
5948 appendTemporaryVariable( updatedContext, name.toString(), value );
5949 result = args->
at( 2 )->
eval( parent, updatedContext );
5952 popTemporaryVariable( updatedContext );
5973 if ( args->
count() < 3 )
5978 QVariant value = args->
at( 1 )->
prepare( parent, context );
5981 std::unique_ptr< QgsExpressionContext > tempContext;
5982 if ( !updatedContext )
5984 tempContext = qgis::make_unique< QgsExpressionContext >();
5985 updatedContext = tempContext.get();
5988 appendTemporaryVariable( updatedContext, name.toString(), value );
5989 args->
at( 2 )->
prepare( parent, updatedContext );
5992 popTemporaryVariable( updatedContext );
5997 void QgsWithVariableExpressionFunction::popTemporaryVariable(
const QgsExpressionContext *context )
const 6003 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, using GEOS.
double months() const
Returns the interval duration in months (based on a 30 day month).
virtual QgsDataProvider * dataProvider()
Returns the layer's data provider, it may be 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.
int type() const override
Multi point geometry collection.
static QString wordWrap(const QString &string, int length, bool useMaxLineLength=true, const QString &customDelimiter=QString())
Automatically wraps a string by inserting new line characters at appropriate locations in the string...
QgsWithVariableExpressionFunction()
bool within(const QgsGeometry &geometry) const
Test for if geometry is within another (uses GEOS)
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
Unique pointer for sqlite3 prepared statements, which automatically finalizes the statement when the ...
QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Returns result of evaluating the function.
QgsArrayFilterExpressionFunction()
double angleAtVertex(int vertex) const
Returns the bisector angle for this geometry at the specified vertex.
void setPrepareFunction(const std::function< bool(const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext *)> &prepareFunc)
Set a function that will be called in the prepare step to determine if the function is static or not...
QVector< QgsRingSequence > QgsCoordinateSequence
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
QgsExpressionContextScope * activeScopeForVariable(const QString &name)
Returns the currently active scope from the context for a specified variable name.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
First quartile (numeric fields only)
Number of missing (null) values.
A class to represent a 2D point.
QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request. ...
bool hasCachedValue(const QString &key) const
Returns true if the expression context contains a cached value with a matching key.
int selectedFeatureCount() const
Returns the number of features that are selected in this layer.
QString providerType() const
Returns the provider type (provider key) for this layer.
int exec(const QString &sql, QString &errorMessage) const
Executes the sql command in the database.
static QString quotedIdentifier(const QString &identifier)
Returns a properly quoted version of identifier.
Abstract base class for color ramps.
QgsVectorLayer referencingLayer
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
QVariant evaluate()
Evaluate the feature and return the result.
QString toProj4() const
Returns a Proj4 string representation of this CRS.
double maximumValue
The maximum cell value in the raster band.
double seconds() const
Returns the interval duration in seconds.
Multi line string geometry collection.
QgsGeometry interpolate(double distance) const
Returns an interpolated point on the geometry at the specified distance.
Curve polygon geometry type.
bool overlaps(const QgsGeometry &geometry) const
Test for if geometry overlaps another (uses GEOS)
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
virtual QSet< QString > referencedColumns(const QgsExpressionNodeFunction *node) const
Returns a set of field names which are required for this function.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
Handles the with_variable(name, value, node) expression function.
QgsGeometry buffer(double distance, int segments) const
Returns a buffer region around this geometry having the given width and with a specified number of se...
double convertLengthMeasurement(double length, QgsUnitTypes::DistanceUnit toUnits) const
Takes a length measurement calculated by this QgsDistanceArea object and converts it to a different d...
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
Handles the array_foreach(array, expression) expression function.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QgsLayerMetadata metadata
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
QgsFields fields() const
Convenience function for retrieving the fields for the context, if set.
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
This will be called during the prepare step() of an expression if it is not static.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
Quadrilateral geometry type.
QgsGeometry intersection(const QgsGeometry &geometry) const
Returns a geometry representing the points shared by this geometry and other.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
double distanceToVertex(int vertex) const
Returns the distance along this geometry from its first vertex to the specified vertex.
double convertAreaMeasurement(double area, QgsUnitTypes::AreaUnit toUnits) const
Takes an area measurement calculated by this QgsDistanceArea object and converts it to a different ar...
QgsStaticExpressionFunction(const QString &fnname, int params, FcnEval fcn, const QString &group, const QString &helpText=QString(), bool usesGeometry=false, const QSet< QString > &referencedColumns=QSet< QString >(), bool lazyEval=false, const QStringList &aliases=QStringList(), bool handlesNull=false)
Static function for evaluation against a QgsExpressionContext, using an unnamed list of parameter val...
QVariant run(QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Evaluates the function, first evaluating all required arguments before passing them to the function's...
QgsGeometry minimalEnclosingCircle(QgsPointXY ¢er, double &radius, unsigned int segments=36) const
Returns the minimal enclosing circle for the geometry.
QgsGeometry nearestPoint(const QgsGeometry &other) const
Returns the nearest point on this geometry to another geometry.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
void clear() override
Clears the geometry, ie reset it to a null geometry.
QList< QgsExpressionFunction::Parameter > ParameterList
List of parameters, used for function definition.
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 layer's data provider, it may be nullptr.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
The RasterBandStats struct is a container for statistics about a single raster band.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QgsDistanceArea * geomCalculator()
Returns calculator used for distance and area calculations (used by $length, $area and $perimeter fun...
double mean
The mean cell value for the band. NO_DATA values are excluded.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
void addVertex(const QgsPoint &pt)
Adds a new vertex to the end of the line string.
virtual QSet< QString > referencedColumns() const =0
Abstract virtual method which returns a list of columns required to evaluate this node...
QgsGeometry variableWidthBufferByM(int segments) const
Calculates a variable width buffer for a (multi)linestring geometry, where the width at each node is ...
virtual QgsCurve * curveSubstring(double startDistance, double endDistance) const =0
Returns a new curve representing a substring of this curve.
Utility class for identifying a unique vertex within a geometry.
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a variable width buffer ("tapered buffer") for a (multi)curve geometry.
virtual QSet< QString > referencedVariables() const =0
Returns a set of all variables which are used in this expression.
virtual bool handlesNull() const
Returns true if the function handles NULL values in arguments by itself, and the default NULL value h...
static Aggregate stringToAggregate(const QString &string, bool *ok=nullptr)
Converts a string to a aggregate type.
int ringCount(int part=0) const override
Returns the number of rings of which this geometry is built.
bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
This will be called during the prepare step() of an expression if it is not static.
int step()
Steps to the next record in the statement, returning the sqlite3 result code.
QList< QgsRelation > relationsByName(const QString &name) const
Returns a list of relations with matching names.
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
Minimum length of string (string fields only)
virtual QgsPolygon * toPolygon(unsigned int segments=36) const
Returns a segmented polygon.
const QgsExpressionFunction::ParameterList & parameters() const
Returns the list of named parameters for the function, if set.
QgsGeometry convexHull() const
Returns the smallest convex polygon that contains all the points in the geometry. ...
static QString geometryDisplayString(GeometryType type)
Returns a display string for a geometry type.
double width() const
Returns the width of the rectangle.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
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
Test for if geometry crosses another (uses GEOS)
static QgsQuadrilateral rectangleFrom3Points(const QgsPoint &p1, const QgsPoint &p2, const QgsPoint &p3, ConstructionOption mode)
Construct a QgsQuadrilateral as a Rectangle from 3 points.
static const QString ALL_ATTRIBUTES
A special attribute that if set matches all attributes.
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example...
ConstructionOption
A regular polygon can be constructed inscribed in a circle or circumscribed about a circle...
virtual bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const
Will be called during prepare to determine if the function is static.
ConstructionOption
A quadrilateral can be constructed from 3 points where the second distance can be determined by the t...
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any.
QgsVectorLayer referencedLayer
Abstract base class for all nodes that can appear in an expression.
Abstract base class for curved geometry type.
Create 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
Test for if geometry touch another (uses GEOS)
sqlite3_statement_unique_ptr prepare(const QString &sql, int &resultCode) const
Prepares a sql statement, returning the result.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Abstract base class for all geometries.
An expression node for expression functions.
double minimumScale() const
Returns the minimum map scale (i.e.
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 length of geometry using GEOS.
double measurePerimeter(const QgsGeometry &geometry) const
Measures the perimeter of a polygon geometry.
QgsGeometry extrude(double x, double y)
Returns an extruded version of this geometry.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
double weeks() const
Returns the interval duration in weeks.
int numGeometries() const
Returns the number of geometries within the collection.
QgsExpressionFunction(const QString &fnname, int params, const QString &group, const QString &helpText=QString(), bool lazyEval=false, bool handlesNull=false, bool isContextual=false)
Constructor for function which uses unnamed parameters.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
virtual bool isClosed() const
Returns true if the curve is closed.
uint qHash(const QVariant &variant)
Hash for QVariant.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsUnitTypes::DistanceUnit distanceUnits() const
Returns the desired distance units for calculations involving geomCalculator(), e.g., "$length" and "$perimeter".
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
Number of distinct values.
QgsArrayForeachExpressionFunction()
QString asWkt(int precision=17) const
Exports the geometry to WKT.
QString name() const
The name of the function.
double interpolateAngle(double distance) const
Returns the angle parallel to the linestring or polygon boundary at the specified distance along the ...
A representation of the interval between two datetime values.
Handles the array_filter(array, expression) expression function.
The OrderByClause class represents an order by clause for a QgsFeatureRequest.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
double xMaximum() const
Returns the x maximum value (right side of rectangle).
virtual QStringList aliases() const
Returns a list of possible aliases for the function.
QVector< QgsPoint > QgsPointSequence
double days() const
Returns the interval duration in days.
QgsCurve * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
virtual QgsRasterBandStats bandStatistics(int bandNo, int stats=QgsRasterBandStats::All, const QgsRectangle &extent=QgsRectangle(), int sampleSize=0, QgsRasterBlockFeedback *feedback=nullptr)
Returns the band statistics.
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
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.
double scale() const
Returns the map scale.
QgsFeatureRequest & setTimeout(int timeout)
Sets the timeout (in milliseconds) for the maximum time we should wait during feature requests before...
double minutes() const
Returns the interval duration in minutes.
Line string geometry type, with support for z-dimension and m-values.
static QgsGeometry createWedgeBuffer(const QgsPoint ¢er, double azimuth, double angularWidth, double outerRadius, double innerRadius=0)
Creates a wedge shaped buffer from a center point.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
#define ENSURE_GEOM_TYPE(f, g, geomtype)
static QgsProject * instance()
Returns the QgsProject singleton instance.
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.
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 area of the geometry using GEOS.
int count() const
Returns the number of nodes in the list.
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
The geometries can be simplified using the current map2pixel context state.
bool nextFeature(QgsFeature &f)
QStringList aliases() const override
Returns a list of possible aliases for the function.
static QString quotedValue(const QVariant &value)
Returns a string representation of a literal value, including appropriate quotations where required...
Minority of values (numeric fields only)
bool vertexIdFromVertexNr(int number, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
JoinStyle
Join styles for buffers.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
bool contains(const QgsPointXY *p) const
Tests for containment of a point (uses GEOS)
Q_INVOKABLE QgsRelation relation(const QString &id) const
Gets access to a relation by its id.
QgsGeometry symDifference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
CORE_EXPORT QVariantMap parse(const QString &string)
Returns a QVariantMap object containing the key and values from a hstore-formatted string...
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
Represents a vector layer which manages a vector based data sets.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
virtual bool isDeprecated() const
Returns true if the function is deprecated and should not be presented as a valid option to users in ...
Range of values (max - min) (numeric and datetime fields only)
bool isEmpty() const override
Returns true if the geometry is empty.
qlonglong columnAsInt64(int column) const
Gets column value from the current statement row as a long long integer (64 bits).
virtual bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const
This will be called during the prepare step() of an expression if it is not static.
double lineLocatePoint(const QgsGeometry &point) const
Returns a distance representing the location along this linestring of the closest point on this lines...
bool disjoint(const QgsGeometry &geometry) const
Tests for if geometry is disjoint of another (uses GEOS)
double measureArea(const QgsGeometry &geometry) const
Measures the area of a geometry.
QString authid() const
Returns the authority identifier for the CRS.
QgsCoordinateReferenceSystem crs
Sample standard deviation of values (numeric fields only)
Aggregate
Available aggregates to calculate.
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
static int hammingDistance(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the Hamming distance between two strings.
QVariant value() const
The value of the literal.
static QColor decodeColor(const QString &str)
Represents a list of OrderByClauses, with the most important first and the least important last...
virtual int partCount() const =0
Returns count of parts contained in the geometry.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
double height() const
Returns the height of the rectangle.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
#define FEAT_FROM_CONTEXT(c, f)
A bundle of parameters controlling aggregate calculation.
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...