59 QVariantList argValues;
63 const QList< QgsExpressionNode * > argList = args->
list();
70 v = QVariant::fromValue( n );
74 v = n->eval( parent, context );
76 bool defaultParamIsNull = mParameterList.count() > arg && mParameterList.at( arg ).optional() && !mParameterList.at( arg ).defaultValue().isValid();
77 if ( QgsExpressionUtils::isNull( v ) && !defaultParamIsNull && !
handlesNull() )
80 argValues.append( v );
85 return func( argValues, context, parent, node );
123 return mGroups.isEmpty() ?
false : mGroups.contains( QStringLiteral(
"deprecated" ) );
128 return ( QString::compare( mName, other.mName, Qt::CaseInsensitive ) == 0 );
140 const QString &
group,
150 , mUsesGeometry(
false )
164 if ( mUsesGeometryFunc )
165 return mUsesGeometryFunc( node );
167 return mUsesGeometry;
172 if ( mReferencedColumnsFunc )
173 return mReferencedColumnsFunc( node );
175 return mReferencedColumns;
181 return mIsStaticFunc( node, parent, context );
189 return mPrepareFunc( node, parent, context );
201 mIsStaticFunc =
nullptr;
207 mPrepareFunc = prepareFunc;
212 if ( node && node->
args() )
214 const QList< QgsExpressionNode * > argList = node->
args()->
list();
217 if ( !argNode->isStatic( parent, context ) )
227 double start = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
228 double stop = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
229 double step = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
231 if ( step == 0.0 || ( step > 0.0 && start > stop ) || ( step < 0.0 && start < stop ) )
238 double current = start + step;
239 while ( ( ( step > 0.0 && current <= stop ) || ( step < 0.0 && current >= stop ) ) && length <= 1000000 )
254 QString
name = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
263 QString expString = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
265 return expression.evaluate( context );
270 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
271 return QVariant( std::sqrt( x ) );
276 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
277 return QVariant( std::fabs( val ) );
282 double deg = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
283 return ( deg * M_PI ) / 180;
287 double rad = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
288 return ( 180 * rad ) / M_PI;
292 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
293 return QVariant( std::sin( x ) );
297 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
298 return QVariant( std::cos( x ) );
302 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
303 return QVariant( std::tan( x ) );
307 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
308 return QVariant( std::asin( x ) );
312 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
313 return QVariant( std::acos( x ) );
317 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
318 return QVariant( std::atan( x ) );
322 double y = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
323 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
324 return QVariant( std::atan2( y, x ) );
328 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
329 return QVariant( std::exp( x ) );
333 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
336 return QVariant( std::log( x ) );
340 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
343 return QVariant( log10( x ) );
347 double b = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
348 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
349 if ( x <= 0 || b <= 0 )
351 return QVariant( std::log( x ) / std::log( b ) );
355 double min = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
356 double max = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
361 double f =
static_cast< double >( qrand() ) / RAND_MAX;
362 return QVariant( min + f * ( max - min ) );
366 qlonglong min = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
367 qlonglong max = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
372 return QVariant( min + ( qrand() % static_cast< qlonglong >( max - min + 1 ) ) );
377 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
378 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
379 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
380 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
381 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
383 if ( domainMin >= domainMax )
385 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
390 if ( val >= domainMax )
394 else if ( val <= domainMin )
400 double m = ( rangeMax - rangeMin ) / ( domainMax - domainMin );
401 double c = rangeMin - ( domainMin * m );
404 return QVariant( m * val + c );
409 double val = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
410 double domainMin = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
411 double domainMax = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
412 double rangeMin = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
413 double rangeMax = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
414 double exponent = QgsExpressionUtils::getDoubleValue( values.at( 5 ), parent );
416 if ( domainMin >= domainMax )
418 parent->
setEvalErrorString( QObject::tr(
"Domain max must be greater than domain min" ) );
428 if ( val >= domainMax )
432 else if ( val <= domainMin )
438 return QVariant( ( ( rangeMax - rangeMin ) / std::pow( domainMax - domainMin, exponent ) ) * std::pow( val - domainMin, exponent ) + rangeMin );
443 QVariant result( QVariant::Double );
444 double maxVal = std::numeric_limits<double>::quiet_NaN();
445 for (
const QVariant &val : values )
447 double testVal = val.isNull() ? std::numeric_limits<double>::quiet_NaN() : QgsExpressionUtils::getDoubleValue( val, parent );
448 if ( std::isnan( maxVal ) )
452 else if ( !std::isnan( testVal ) )
454 maxVal = std::max( maxVal, testVal );
458 if ( !std::isnan( maxVal ) )
460 result = QVariant( maxVal );
467 QVariant result( QVariant::Double );
468 double minVal = std::numeric_limits<double>::quiet_NaN();
469 for (
const QVariant &val : values )
471 double testVal = val.isNull() ? std::numeric_limits<double>::quiet_NaN() : QgsExpressionUtils::getDoubleValue( val, parent );
472 if ( std::isnan( minVal ) )
476 else if ( !std::isnan( testVal ) )
478 minVal = std::min( minVal, testVal );
482 if ( !std::isnan( minVal ) )
484 result = QVariant( minVal );
496 QVariant value = node->
eval( parent, context );
498 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( value, parent );
501 parent->
setEvalErrorString( QObject::tr(
"Cannot find layer with name or ID '%1'" ).arg( value.toString() ) );
506 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
508 value = node->
eval( parent, context );
514 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
519 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
521 QString subExpression = node->
dump();
525 if ( values.count() > 3 )
527 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
530 if ( !nl || nl->
value().isValid() )
535 if ( values.count() > 4 )
537 node = QgsExpressionUtils::getNode( values.at( 4 ), parent );
539 value = node->
eval( parent, context );
555 cacheKey = QStringLiteral(
"aggfcn:%1:%2:%3:%4:%5%6" ).arg( vl->
id(), QString::number( aggregate ), subExpression, parameters.
filter,
560 cacheKey = QStringLiteral(
"aggfcn:%1:%2:%3:%4" ).arg( vl->
id(), QString::number( aggregate ), subExpression, parameters.
filter );
570 result = vl->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
576 result = vl->
aggregate( aggregate, subExpression, parameters,
nullptr, &ok );
580 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
591 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
596 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
599 parent->
setEvalErrorString( QObject::tr(
"Cannot use relation aggregate function in this context" ) );
608 QVariant value = node->
eval( parent, context );
610 QString relationId = value.toString();
617 if ( relations.isEmpty() || relations.at( 0 ).referencedLayer() != vl )
619 parent->
setEvalErrorString( QObject::tr(
"Cannot find relation with id '%1'" ).arg( relationId ) );
624 relation = relations.at( 0 );
631 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
633 value = node->
eval( parent, context );
639 parent->
setEvalErrorString( QObject::tr(
"No such aggregate '%1'" ).arg( value.toString() ) );
644 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
646 QString subExpression = node->
dump();
650 if ( values.count() > 3 )
652 node = QgsExpressionUtils::getNode( values.at( 3 ), parent );
654 value = node->
eval( parent, context );
662 QString cacheKey = QStringLiteral(
"relagg:%1:%2:%3:%4" ).arg( vl->
id(),
663 QString::number( static_cast< int >( aggregate ) ),
674 result = childLayer->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
678 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
693 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
698 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
701 parent->
setEvalErrorString( QObject::tr(
"Cannot use aggregate function in this context" ) );
710 QString subExpression = node->
dump();
714 if ( values.count() > 1 )
716 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
719 if ( !nl || nl->
value().isValid() )
720 groupBy = node->
dump();
724 if ( values.count() > 2 )
726 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
729 if ( !nl || nl->
value().isValid() )
736 if ( !groupBy.isEmpty() )
739 QVariant groupByValue = groupByExp.
evaluate( context );
740 QString groupByClause = QStringLiteral(
"%1 %2 %3" ).arg( groupBy,
741 groupByValue.isNull() ? QStringLiteral(
"is" ) : QStringLiteral(
"=" ),
743 if ( !parameters.
filter.isEmpty() )
744 parameters.
filter = QStringLiteral(
"(%1) AND (%2)" ).arg( parameters.
filter, groupByClause );
746 parameters.
filter = groupByClause;
749 QString cacheKey = QStringLiteral(
"agg:%1:%2:%3:%4" ).arg( vl->
id(),
750 QString::number( static_cast< int >( aggregate ) ),
760 result = vl->
aggregate( aggregate, subExpression, parameters, &subContext, &ok );
764 parent->
setEvalErrorString( QObject::tr(
"Could not calculate aggregate for: %1" ).arg( subExpression ) );
870 if ( values.count() > 3 )
874 QVariant value = node->
eval( parent, context );
892 QVariant scale = context->
variable( QStringLiteral(
"map_scale" ) );
894 if ( !scale.isValid() || scale.isNull() )
897 const double v = scale.toDouble( &ok );
905 double minValue = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
906 double testValue = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
907 double maxValue = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
910 if ( testValue <= minValue )
912 return QVariant( minValue );
914 else if ( testValue >= maxValue )
916 return QVariant( maxValue );
920 return QVariant( testValue );
926 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
927 return QVariant( std::floor( x ) );
932 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
933 return QVariant( std::ceil( x ) );
938 return QVariant( QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) );
942 return QVariant( QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent ) );
946 return QVariant( QgsExpressionUtils::getStringValue( values.at( 0 ), parent ) );
951 return QVariant( QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent ) );
956 for (
const QVariant &value : values )
958 if ( value.isNull() )
966 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
967 return QVariant( str.toLower() );
971 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
972 return QVariant( str.toUpper() );
976 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
977 QStringList elems = str.split(
' ' );
978 for (
int i = 0; i < elems.size(); i++ )
980 if ( elems[i].size() > 1 )
981 elems[i] = elems[i].at( 0 ).toUpper() + elems[i].mid( 1 ).toLower();
983 return QVariant( elems.join( QStringLiteral(
" " ) ) );
988 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
989 return QVariant( str.trimmed() );
994 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
995 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1001 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1002 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1008 QString string1 = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1009 QString string2 = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1016 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1022 QChar character = QChar( QgsExpressionUtils::getNativeIntValue( values.at( 0 ), parent ) );
1023 return QVariant( QString( character ) );
1028 if ( values.length() == 2 || values.length() == 3 )
1030 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1031 qlonglong wrap = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1033 QString customdelimiter = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1047 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1051 return QVariant( geom.
length() );
1055 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1056 return QVariant( str.length() );
1061 if ( values.count() == 2 && values.at( 1 ).type() == QVariant::Map )
1063 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1064 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 1 ), parent );
1066 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
1068 str = str.replace( it.key(), it.value().toString() );
1071 return QVariant( str );
1073 else if ( values.count() == 3 )
1075 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1076 QVariantList before;
1078 bool isSingleReplacement =
false;
1080 if ( values.at( 1 ).type() != QVariant::List && values.at( 2 ).type() != QVariant::StringList )
1082 before = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1086 before = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
1089 if ( values.at( 2 ).type() != QVariant::List && values.at( 2 ).type() != QVariant::StringList )
1091 after = QVariantList() << QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1092 isSingleReplacement =
true;
1096 after = QgsExpressionUtils::getListValue( values.at( 2 ), parent );
1099 if ( !isSingleReplacement && before.length() != after.length() )
1101 parent->
setEvalErrorString( QObject::tr(
"Invalid pair of array, length not identical" ) );
1105 for (
int i = 0; i < before.length(); i++ )
1107 str = str.replace( before.at( i ).toString(), after.at( isSingleReplacement ? 0 : i ).toString() );
1110 return QVariant( str );
1114 parent->
setEvalErrorString( QObject::tr(
"Function replace requires 2 or 3 arguments" ) );
1120 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1121 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1122 QString after = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1124 QRegularExpression re( regexp );
1125 if ( !re.isValid() )
1127 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1130 return QVariant( str.replace( re, after ) );
1135 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1136 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1138 QRegularExpression re( regexp );
1139 if ( !re.isValid() )
1141 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1144 return QVariant( ( str.indexOf( re ) + 1 ) );
1149 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1150 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1151 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1153 QRegularExpression re( regexp );
1154 if ( !re.isValid() )
1156 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1160 QRegularExpressionMatch matches = re.match( str );
1161 if ( matches.hasMatch() )
1164 QStringList list = matches.capturedTexts();
1167 for ( QStringList::const_iterator it = ++list.constBegin(); it != list.constEnd(); ++it )
1169 array += ( !( *it ).isEmpty() ) ? *it : empty;
1172 return QVariant( array );
1182 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1183 QString regexp = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1185 QRegularExpression re( regexp );
1186 if ( !re.isValid() )
1188 parent->
setEvalErrorString( QObject::tr(
"Invalid regular expression '%1': %2" ).arg( regexp, re.errorString() ) );
1193 QRegularExpressionMatch match = re.match( str );
1194 if ( match.hasMatch() )
1197 if ( match.lastCapturedIndex() > 0 )
1200 return QVariant( match.captured( 1 ) );
1205 return QVariant( match.captured( 0 ) );
1210 return QVariant(
"" );
1216 return QUuid::createUuid().toString();
1221 if ( !values.at( 0 ).isValid() || !values.at( 1 ).isValid() )
1224 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1225 qlonglong from = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1228 if ( values.at( 2 ).isValid() )
1229 len = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
1235 from = str.size() + from;
1241 else if ( from > 0 )
1249 len = str.size() + len - from;
1256 return QVariant( str.mid( from, len ) );
1262 return QVariant( static_cast< int >( f.id() ) );
1267 QgsRasterLayer *layer = QgsExpressionUtils::getRasterLayer( values.at( 0 ), parent );
1270 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster layer." ) );
1274 int bandNb = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1275 if ( bandNb < 1 || bandNb > layer->
bandCount() )
1277 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid raster band number." ) );
1281 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 2 ), parent );
1284 parent->
setEvalErrorString( QObject::tr(
"Function `raster_value` requires a valid point geometry." ) );
1292 if ( multiPoint.count() == 1 )
1294 point = multiPoint[0];
1304 return std::isnan( value ) ? QVariant() : value;
1316 QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1317 QString attr = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1327 if ( values.isEmpty() )
1330 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1332 else if ( values.size() == 1 )
1334 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1335 feature = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
1337 else if ( values.size() == 2 )
1339 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1340 feature = QgsExpressionUtils::getFeature( values.at( 1 ), parent );
1344 parent->
setEvalErrorString( QObject::tr(
"Function `is_selected` requires no more than two parameters. %1 given." ).arg( values.length() ) );
1348 if ( !layer || !feature.
isValid() )
1350 return QVariant( QVariant::Bool );
1360 if ( values.isEmpty() )
1361 layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
1362 else if ( values.count() == 1 )
1363 layer = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
1366 parent->
setEvalErrorString( QObject::tr(
"Function `num_selected` requires no more than one parameter. %1 given." ).arg( values.length() ) );
1372 return QVariant( QVariant::LongLong );
1381 for (
const QVariant &value : values )
1383 concat += QgsExpressionUtils::getStringValue( value, parent );
1390 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1391 return string.indexOf( QgsExpressionUtils::getStringValue( values.at( 1 ), parent ) ) + 1;
1396 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1397 qlonglong pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1398 return string.right( pos );
1403 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1404 qlonglong pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1405 return string.left( pos );
1410 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1411 qlonglong length = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1412 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1413 return string.leftJustified( length, fill.at( 0 ), true );
1418 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1419 qlonglong length = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1420 QString fill = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
1421 return string.rightJustified( length, fill.at( 0 ), true );
1426 if ( values.size() < 1 )
1428 parent->
setEvalErrorString( QObject::tr(
"Function format requires at least 1 argument" ) );
1432 QString
string = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
1433 for (
int n = 1; n < values.length(); n++ )
1435 string =
string.arg( QgsExpressionUtils::getStringValue( values.at( n ), parent ) );
1443 return QVariant( QDateTime::currentDateTime() );
1448 return QVariant( QgsExpressionUtils::getDateValue( values.at( 0 ), parent ) );
1453 return QVariant( QgsExpressionUtils::getTimeValue( values.at( 0 ), parent ) );
1458 return QVariant::fromValue( QgsExpressionUtils::getInterval( values.at( 0 ), parent ) );
1467 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
1468 QString axis = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
1469 int precision = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
1471 QString formatString;
1472 if ( values.count() > 3 )
1473 formatString = QgsExpressionUtils::getStringValue( values.at( 3 ), parent );
1475 QgsCoordinateFormatter::FormatFlags flags =
nullptr;
1476 if ( formatString.compare( QLatin1String(
"suffix" ), Qt::CaseInsensitive ) == 0 )
1480 else if ( formatString.compare( QLatin1String(
"aligned" ), Qt::CaseInsensitive ) == 0 )
1484 else if ( ! formatString.isEmpty() )
1486 parent->
setEvalErrorString( QObject::tr(
"Invalid formatting parameter: '%1'. It must be empty, or 'suffix' or 'aligned'." ).arg( formatString ) );
1490 if ( axis.compare( QLatin1String(
"x" ), Qt::CaseInsensitive ) == 0 )
1494 else if ( axis.compare( QLatin1String(
"y" ), Qt::CaseInsensitive ) == 0 )
1500 parent->
setEvalErrorString( QObject::tr(
"Invalid axis name: '%1'. It must be either 'x' or 'y'." ).arg( axis ) );
1508 return floatToDegreeFormat( format, values, context, parent, node );
1514 return floatToDegreeFormat( format, values, context, parent, node );
1519 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1520 QDateTime d2 = QgsExpressionUtils::getDateTimeValue( values.at( 1 ), parent );
1521 qint64 seconds = d2.secsTo( d1 );
1522 return QVariant::fromValue(
QgsInterval( seconds ) );
1527 if ( !values.at( 0 ).canConvert<QDate>() )
1530 QDate date = QgsExpressionUtils::getDateValue( values.at( 0 ), parent );
1531 if ( !date.isValid() )
1536 return date.dayOfWeek() % 7;
1541 QVariant value = values.at( 0 );
1542 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1545 return QVariant( inter.
days() );
1549 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1550 return QVariant( d1.date().day() );
1556 QVariant value = values.at( 0 );
1557 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1560 return QVariant( inter.
years() );
1564 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1565 return QVariant( d1.date().year() );
1571 QVariant value = values.at( 0 );
1572 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1575 return QVariant( inter.
months() );
1579 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1580 return QVariant( d1.date().month() );
1586 QVariant value = values.at( 0 );
1587 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1590 return QVariant( inter.
weeks() );
1594 QDateTime d1 = QgsExpressionUtils::getDateTimeValue( value, parent );
1595 return QVariant( d1.date().weekNumber() );
1601 QVariant value = values.at( 0 );
1602 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1605 return QVariant( inter.
hours() );
1609 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1610 return QVariant( t1.hour() );
1616 QVariant value = values.at( 0 );
1617 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1620 return QVariant( inter.
minutes() );
1624 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1625 return QVariant( t1.minute() );
1631 QVariant value = values.at( 0 );
1632 QgsInterval inter = QgsExpressionUtils::getInterval( value, parent,
false );
1635 return QVariant( inter.
seconds() );
1639 QTime t1 = QgsExpressionUtils::getTimeValue( value, parent );
1640 return QVariant( t1.second() );
1646 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
1649 return QVariant( dt.toMSecsSinceEpoch() );
1657 #define ENSURE_GEOM_TYPE(f, g, geomtype) \ 1658 if ( !(f).hasGeometry() ) \ 1659 return QVariant(); \ 1660 QgsGeometry g = (f).geometry(); \ 1661 if ( (g).type() != (geomtype) ) \ 1668 if ( g.isMultipart() )
1670 return g.asMultiPoint().at( 0 ).x();
1674 return g.asPoint().x();
1682 if ( g.isMultipart() )
1684 return g.asMultiPoint().at( 0 ).y();
1688 return g.asPoint().y();
1694 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1706 QVariant result( centroid.
asPoint().
x() );
1712 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1724 QVariant result( centroid.
asPoint().
y() );
1730 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1745 if ( collection->numGeometries() == 1 )
1747 if (
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( collection->geometryN( 0 ) ) )
1758 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1773 if ( collection->numGeometries() == 1 )
1775 if (
const QgsPoint *point = qgsgeometry_cast< const QgsPoint * >( collection->geometryN( 0 ) ) )
1786 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1792 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
1807 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1824 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1841 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1846 bool ignoreClosing =
false;
1847 if ( values.length() > 1 )
1849 ignoreClosing = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
1859 bool skipLast =
false;
1860 if ( ignoreClosing && ring.count() > 2 && ring.first() == ring.last() )
1865 for (
int i = 0; i < ( skipLast ? ring.count() - 1 : ring.count() ); ++ i )
1867 mp->addGeometry( ring.at( i ).clone() );
1877 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1888 for (
int i = 0; i < line->numPoints() - 1; ++i )
1892 << line->pointN( i )
1893 << line->pointN( i + 1 ) );
1894 ml->addGeometry( segment );
1904 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1914 if ( collection->numGeometries() == 1 )
1921 if ( !curvePolygon )
1925 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
1931 QVariant result = curve ? QVariant::fromValue(
QgsGeometry( curve ) ) : QVariant();
1937 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1947 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) - 1;
1953 QVariant result = part ? QVariant::fromValue(
QgsGeometry( part ) ) : QVariant();
1959 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1968 return QVariant::fromValue(
QgsGeometry( boundary ) );
1973 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1982 return QVariant::fromValue( merged );
1987 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
1992 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
1995 if ( simplified.isNull() )
2003 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2008 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2013 if ( simplified.
isNull() )
2021 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2026 int iterations = std::min( QgsExpressionUtils::getNativeIntValue( values.at( 1 ), parent ), 10 );
2027 double offset = qBound( 0.0, QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ), 0.5 );
2028 double minLength = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2029 double maxAngle = qBound( 0.0, QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent ), 180.0 );
2040 if ( values.count() < 2 || values.count() > 4 )
2042 parent->
setEvalErrorString( QObject::tr(
"Function make_point requires 2-4 arguments" ) );
2046 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2047 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2048 double z = values.count() >= 3 ? QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent ) : 0.0;
2049 double m = values.count() >= 4 ? QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent ) : 0.0;
2050 switch ( values.count() )
2064 double x = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
2065 double y = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2066 double m = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2072 if ( values.count() < 2 )
2078 lineString->
clear();
2080 for (
const QVariant &value : values )
2082 QgsGeometry geom = QgsExpressionUtils::getGeometry( value, parent );
2096 return QVariant::fromValue(
QgsGeometry( lineString ) );
2101 if ( values.count() < 1 )
2103 parent->
setEvalErrorString( QObject::tr(
"Function make_polygon requires an argument" ) );
2107 QgsGeometry outerRing = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2111 std::unique_ptr< QgsPolygon > polygon = qgis::make_unique< QgsPolygon >();
2118 if ( collection->numGeometries() == 1 )
2125 if ( !exteriorRing )
2128 polygon->setExteriorRing( exteriorRing->segmentize() );
2131 for (
int i = 1; i < values.count(); ++i )
2133 QgsGeometry ringGeom = QgsExpressionUtils::getGeometry( values.at( i ), parent );
2145 if ( collection->numGeometries() == 1 )
2155 polygon->addInteriorRing( ring->
segmentize() );
2158 return QVariant::fromValue(
QgsGeometry( std::move( polygon ) ) );
2163 std::unique_ptr<QgsTriangle> tr(
new QgsTriangle() );
2164 std::unique_ptr<QgsLineString> lineString(
new QgsLineString() );
2165 lineString->clear();
2167 for (
const QVariant &value : values )
2169 QgsGeometry geom = QgsExpressionUtils::getGeometry( value, parent );
2181 if ( collection->numGeometries() == 1 )
2191 lineString->addVertex( *point );
2194 tr->setExteriorRing( lineString.release() );
2196 return QVariant::fromValue(
QgsGeometry( tr.release() ) );
2201 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2208 double radius = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2209 double segment = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
2221 if ( collection->numGeometries() == 1 )
2236 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2243 double majorAxis = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2244 double minorAxis = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2245 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2246 double segment = QgsExpressionUtils::getIntValue( values.at( 4 ), parent );
2257 if ( collection->numGeometries() == 1 )
2266 QgsEllipse elp( *point, majorAxis, minorAxis, azimuth );
2273 QgsGeometry pt1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2280 QgsGeometry pt2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2287 unsigned int nbEdges =
static_cast<unsigned int>( QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) );
2290 parent->
setEvalErrorString( QObject::tr(
"Number of edges/sides must be greater than 2" ) );
2297 parent->
setEvalErrorString( QObject::tr(
"Option can be 0 (inscribed) or 1 (circumscribed)" ) );
2306 if ( collection->numGeometries() == 1 )
2320 if ( collection->numGeometries() == 1 )
2338 qlonglong idx = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
2347 if ( idx < 0 || idx >= g.constGet()->nCoordinates() )
2354 return QVariant( QPointF( p.
x(), p.
y() ) );
2359 QVariant v = pointAt( values, f, parent );
2360 if ( v.type() == QVariant::PointF )
2361 return QVariant( v.toPointF().x() );
2367 QVariant v = pointAt( values, f, parent );
2368 if ( v.type() == QVariant::PointF )
2369 return QVariant( v.toPointF().y() );
2378 return QVariant::fromValue( geom );
2380 return QVariant( QVariant::UserType );
2384 QString wkt = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2386 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2391 QString gml = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
2393 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2406 return QVariant( area );
2410 return QVariant( f.geometry().area() );
2416 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2421 return QVariant( geom.
area() );
2433 return QVariant( len );
2437 return QVariant( f.geometry().length() );
2450 return QVariant( len );
2454 return f.geometry().isNull() ? QVariant( 0 ) : QVariant( f.geometry().constGet()->perimeter() );
2460 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2466 return QVariant( geom.
length() );
2471 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2477 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2486 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2499 for (
int i = 0; i < collection->numGeometries(); ++i )
2502 if ( !curvePolygon )
2514 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2521 return QVariant( curvePolygon->
ringCount() );
2523 bool foundPoly =
false;
2532 if ( !curvePolygon )
2543 return QVariant( ringCount );
2548 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2550 QVariant result = !geomBounds.
isNull() ? QVariant::fromValue( geomBounds ) : QVariant();
2556 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2562 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2568 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2574 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2580 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2586 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2592 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2596 std::unique_ptr< QgsAbstractGeometry > flipped( geom.
constGet()->
clone() );
2598 return QVariant::fromValue(
QgsGeometry( std::move( flipped ) ) );
2603 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2612 if ( collection->numGeometries() == 1 )
2622 return QVariant::fromValue( curve->
isClosed() );
2627 if ( values.length() < 2 || values.length() > 3 )
2630 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2631 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2633 if ( fGeom.
isNull() || sGeom.isNull() )
2638 if ( values.length() == 2 )
2641 QString result = engine->relate( sGeom.constGet() );
2642 return QVariant::fromValue( result );
2647 QString pattern = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
2648 bool result = engine->relatePattern( sGeom.constGet(), pattern );
2649 return QVariant::fromValue( result );
2655 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2656 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2657 return fGeom.
intersects( sGeom.boundingBox() ) ? TVL_True : TVL_False;
2661 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2662 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2663 return fGeom.
disjoint( sGeom ) ? TVL_True : TVL_False;
2667 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2668 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2669 return fGeom.
intersects( sGeom ) ? TVL_True : TVL_False;
2673 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2674 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2675 return fGeom.
touches( sGeom ) ? TVL_True : TVL_False;
2679 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2680 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2681 return fGeom.
crosses( sGeom ) ? TVL_True : TVL_False;
2685 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2686 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2687 return fGeom.
contains( sGeom ) ? TVL_True : TVL_False;
2691 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2692 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2693 return fGeom.
overlaps( sGeom ) ? TVL_True : TVL_False;
2697 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2698 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2699 return fGeom.
within( sGeom ) ? TVL_True : TVL_False;
2703 if ( values.length() < 2 || values.length() > 3 )
2706 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2707 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2709 if ( values.length() == 3 )
2710 seg = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
2713 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2719 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2725 if ( collection->numGeometries() == 1 )
2734 parent->
setEvalErrorString( QObject::tr(
"Function `wedge_buffer` requires a point value for the center." ) );
2738 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2739 double width = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2740 double outerRadius = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2741 double innerRadius = QgsExpressionUtils::getDoubleValue( values.at( 4 ), parent );
2744 QVariant result = !geom.isNull() ? QVariant::fromValue( geom ) : QVariant();
2750 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2753 parent->
setEvalErrorString( QObject::tr(
"Function `tapered_buffer` requires a line geometry." ) );
2757 double startWidth = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2758 double endWidth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2759 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) );
2762 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2768 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2771 parent->
setEvalErrorString( QObject::tr(
"Function `buffer_by_m` requires a line geometry." ) );
2775 int segments =
static_cast< int >( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
2778 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2784 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2785 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2786 qlonglong segments = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
2790 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2793 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2799 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2800 double dist = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2801 qlonglong segments = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
2805 double miterLimit = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
2808 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2814 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2815 double distStart = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2816 double distEnd = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2819 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2825 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2826 double dx = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2827 double dy = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2829 return QVariant::fromValue( fGeom );
2833 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2835 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2840 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2842 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2848 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2849 double tolerance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2851 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2857 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2859 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2866 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2867 unsigned int segments = 36;
2868 if ( values.length() == 2 )
2869 segments = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
2871 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2877 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2879 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2885 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2886 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2888 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2894 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2906 result = reversed ? QVariant::fromValue(
QgsGeometry( reversed ) ) : QVariant();
2914 if (
const QgsCurve *curve = qgsgeometry_cast<const QgsCurve * >( collection->
geometryN( i ) ) )
2923 result = reversed ? QVariant::fromValue(
QgsGeometry( std::move( reversed ) ) ) : QVariant();
2930 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2939 if ( collection->numGeometries() == 1 )
2950 QVariant result = exterior ? QVariant::fromValue(
QgsGeometry( exterior ) ) : QVariant();
2956 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2957 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2958 return QVariant( fGeom.
distance( sGeom ) );
2963 QgsGeometry g1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2964 QgsGeometry g2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2967 if ( values.length() == 3 && values.at( 2 ).isValid() )
2969 double densify = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
2970 densify = qBound( 0.0, densify, 1.0 );
2978 return res > -1 ? QVariant( res ) : QVariant();
2983 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2984 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2986 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2991 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
2992 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
2994 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
2999 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3000 QgsGeometry sGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3002 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3007 if ( values.length() < 1 || values.length() > 2 )
3010 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3012 if ( values.length() == 2 )
3013 prec = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3014 QString wkt = fGeom.
asWkt( prec );
3015 return QVariant( wkt );
3020 if ( values.length() != 2 )
3022 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires exactly two parameters. %1 given." ).arg( values.length() ) );
3026 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3027 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3034 if ( collection->numGeometries() == 1 )
3042 if ( !pt2 && fGeom2.isMultipart() )
3044 if (
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( fGeom2.constGet() ) )
3046 if ( collection->numGeometries() == 1 )
3055 parent->
setEvalErrorString( QObject::tr(
"Function `azimuth` requires two points as arguments." ) );
3060 if ( pt1->x() == pt2->x() )
3062 if ( pt1->y() < pt2->y() )
3064 else if ( pt1->y() > pt2->y() )
3070 if ( pt1->y() == pt2->y() )
3072 if ( pt1->x() < pt2->x() )
3074 else if ( pt1->x() > pt2->x() )
3075 return M_PI + ( M_PI_2 );
3080 if ( pt1->x() < pt2->x() )
3082 if ( pt1->y() < pt2->y() )
3084 return std::atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) );
3088 return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
3095 if ( pt1->y() > pt2->y() )
3097 return std::atan( std::fabs( pt1->x() - pt2->x() ) / std::fabs( pt1->y() - pt2->y() ) )
3102 return std::atan( std::fabs( pt1->y() - pt2->y() ) / std::fabs( pt1->x() - pt2->x() ) )
3103 + ( M_PI + ( M_PI_2 ) );
3110 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3114 parent->
setEvalErrorString( QStringLiteral(
"'project' requires a point geometry" ) );
3118 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3119 double azimuth = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3120 double inclination = QgsExpressionUtils::getDoubleValue( values.at( 3 ), parent );
3123 QgsPoint newPoint = p->
project( distance, 180.0 * azimuth / M_PI, 180.0 * inclination / M_PI );
3130 QgsGeometry fGeom1 = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3131 QgsGeometry fGeom2 = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3138 if ( collection->numGeometries() == 1 )
3145 if ( !pt2 && fGeom2.isMultipart() )
3147 if (
const QgsGeometryCollection *collection = qgsgeometry_cast< const QgsGeometryCollection * >( fGeom2.constGet() ) )
3149 if ( collection->numGeometries() == 1 )
3159 parent->
setEvalErrorString( QStringLiteral(
"Function 'inclination' requires two points as arguments." ) );
3163 return pt1->inclination( *pt2 );
3169 if ( values.length() != 3 )
3172 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3173 double x = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3174 double y = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3178 QVariant result = geom.
constGet() ? QVariant::fromValue( geom ) : QVariant();
3184 if ( values.length() < 2 )
3187 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3190 return values.at( 0 );
3192 QString expString = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3193 QVariant cachedExpression;
3198 if ( cachedExpression.isValid() )
3205 bool asc = values.value( 2 ).toBool();
3223 Q_ASSERT( collection );
3227 QgsExpressionSorter sorter( orderBy );
3229 QList<QgsFeature> partFeatures;
3230 partFeatures.reserve( collection->
partCount() );
3231 for (
int i = 0; i < collection->
partCount(); ++i )
3237 sorter.sortFeatures( partFeatures, unconstedContext );
3241 Q_ASSERT( orderedGeom );
3246 for (
const QgsFeature &feature : qgis::as_const( partFeatures ) )
3248 orderedGeom->
addGeometry( feature.geometry().constGet()->clone() );
3251 QVariant result = QVariant::fromValue(
QgsGeometry( orderedGeom ) );
3254 delete unconstedContext;
3261 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3262 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3266 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3272 QgsGeometry fromGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3273 QgsGeometry toGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3277 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3283 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3284 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3288 QVariant result = !geom.
isNull() ? QVariant::fromValue( geom ) : QVariant();
3294 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3297 parent->
setEvalErrorString( QObject::tr(
"line_substring requires a curve geometry input" ) );
3303 curve = qgsgeometry_cast< const QgsCurve * >( lineGeom.
constGet() );
3308 if ( collection->numGeometries() > 0 )
3317 double startDistance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3318 double endDistance = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3320 std::unique_ptr< QgsCurve > substring( curve->
curveSubstring( startDistance, endDistance ) );
3322 return !result.isNull() ? QVariant::fromValue( result ) : QVariant();
3327 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3328 double distance = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3335 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3336 qlonglong vertex = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3343 QgsGeometry geom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3344 qlonglong vertex = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3351 QgsGeometry lineGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3352 QgsGeometry pointGeom = QgsExpressionUtils::getGeometry( values.at( 1 ), parent );
3356 return distance >= 0 ? distance : QVariant();
3361 if ( values.length() == 2 && values.at( 1 ).toInt() != 0 )
3363 double number = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
3364 return qgsRound( number, QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3367 if ( values.length() >= 1 )
3369 double number = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3370 return QVariant( qlonglong( std::round( number ) ) );
3385 double value = QgsExpressionUtils::getDoubleValue( values.at( 0 ), parent );
3386 int places = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3392 QLocale locale = QLocale();
3393 locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
3394 return locale.toString( value,
'f', places );
3399 QDateTime dt = QgsExpressionUtils::getDateTimeValue( values.at( 0 ), parent );
3400 QString format = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3401 return dt.toString( format );
3407 int avg = ( color.red() + color.green() + color.blue() ) / 3;
3408 int alpha = color.alpha();
3410 color.setRgb( avg, avg, avg, alpha );
3419 double ratio = QgsExpressionUtils::getDoubleValue( values.at( 2 ), parent );
3424 else if ( ratio < 0 )
3429 int red = color1.red() * ( 1 - ratio ) + color2.red() * ratio;
3430 int green = color1.green() * ( 1 - ratio ) + color2.green() * ratio;
3431 int blue = color1.blue() * ( 1 - ratio ) + color2.blue() * ratio;
3432 int alpha = color1.alpha() * ( 1 - ratio ) + color2.alpha() * ratio;
3434 QColor newColor( red, green, blue, alpha );
3441 int red = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3442 int green = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3443 int blue = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3444 QColor color = QColor( red, green, blue );
3445 if ( ! color.isValid() )
3447 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( red ).arg( green ).arg( blue ) );
3448 color = QColor( 0, 0, 0 );
3451 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3456 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
3457 QVariant value = node->
eval( parent, context );
3461 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
3463 value = node->
eval( parent, context );
3471 QgsExpressionNode *node = QgsExpressionUtils::getNode( values.at( 0 ), parent );
3473 QVariant value = node->
eval( parent, context );
3475 if ( value.toBool() )
3477 node = QgsExpressionUtils::getNode( values.at( 1 ), parent );
3479 value = node->
eval( parent, context );
3484 node = QgsExpressionUtils::getNode( values.at( 2 ), parent );
3486 value = node->
eval( parent, context );
3494 int red = QgsExpressionUtils::getIntValue( values.at( 0 ), parent );
3495 int green = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3496 int blue = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3497 int alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent );
3498 QColor color = QColor( red, green, blue, alpha );
3499 if ( ! color.isValid() )
3501 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( red ).arg( green ).arg( blue ).arg( alpha ) );
3502 color = QColor( 0, 0, 0 );
3513 expRamp = QgsExpressionUtils::getRamp( values.at( 0 ), parent );
3518 QString rampName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
3522 parent->
setEvalErrorString( QObject::tr(
"\"%1\" is not a valid color ramp" ).arg( rampName ) );
3527 double value = QgsExpressionUtils::getDoubleValue( values.at( 1 ), parent );
3528 QColor color = ramp->
color( value );
3535 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3537 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3539 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3541 QColor color = QColor::fromHslF( hue, saturation, lightness );
3543 if ( ! color.isValid() )
3545 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( lightness ) );
3546 color = QColor( 0, 0, 0 );
3549 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3555 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3557 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3559 double lightness = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3561 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
3563 QColor color = QColor::fromHslF( hue, saturation, lightness, alpha );
3564 if ( ! color.isValid() )
3566 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( lightness ).arg( alpha ) );
3567 color = QColor( 0, 0, 0 );
3575 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3577 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3579 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3581 QColor color = QColor::fromHsvF( hue, saturation, value );
3583 if ( ! color.isValid() )
3585 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3' to color" ).arg( hue ).arg( saturation ).arg( value ) );
3586 color = QColor( 0, 0, 0 );
3589 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3595 double hue = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 360.0;
3597 double saturation = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3599 double value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3601 double alpha = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 255.0;
3603 QColor color = QColor::fromHsvF( hue, saturation, value, alpha );
3604 if ( ! color.isValid() )
3606 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( hue ).arg( saturation ).arg( value ).arg( alpha ) );
3607 color = QColor( 0, 0, 0 );
3615 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
3617 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3619 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3621 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
3623 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black );
3625 if ( ! color.isValid() )
3627 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ) );
3628 color = QColor( 0, 0, 0 );
3631 return QStringLiteral(
"%1,%2,%3" ).arg( color.red() ).arg( color.green() ).arg( color.blue() );
3637 double cyan = QgsExpressionUtils::getIntValue( values.at( 0 ), parent ) / 100.0;
3639 double magenta = QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) / 100.0;
3641 double yellow = QgsExpressionUtils::getIntValue( values.at( 2 ), parent ) / 100.0;
3643 double black = QgsExpressionUtils::getIntValue( values.at( 3 ), parent ) / 100.0;
3645 double alpha = QgsExpressionUtils::getIntValue( values.at( 4 ), parent ) / 255.0;
3647 QColor color = QColor::fromCmykF( cyan, magenta, yellow, black, alpha );
3648 if ( ! color.isValid() )
3650 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1:%2:%3:%4:%5' to color" ).arg( cyan ).arg( magenta ).arg( yellow ).arg( black ).arg( alpha ) );
3651 color = QColor( 0, 0, 0 );
3659 if ( ! color.isValid() )
3661 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
3665 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3666 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
3668 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
3669 return color.green();
3670 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
3671 return color.blue();
3672 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
3673 return color.alpha();
3674 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
3675 return color.hsvHueF() * 360;
3676 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
3677 return color.hsvSaturationF() * 100;
3678 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
3679 return color.valueF() * 100;
3680 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
3681 return color.hslHueF() * 360;
3682 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
3683 return color.hslSaturationF() * 100;
3684 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
3685 return color.lightnessF() * 100;
3686 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
3687 return color.cyanF() * 100;
3688 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
3689 return color.magentaF() * 100;
3690 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
3691 return color.yellowF() * 100;
3692 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
3693 return color.blackF() * 100;
3695 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
3701 const QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
3702 if ( map.count() < 1 )
3704 parent->
setEvalErrorString( QObject::tr(
"A minimum of two colors is required to create a ramp" ) );
3708 QList< QColor > colors;
3710 for ( QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it )
3713 if ( !colors.last().isValid() )
3715 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( it.value().toString() ) );
3719 double step = it.key().toDouble();
3720 if ( it == map.constBegin() )
3725 else if ( it == map.constEnd() )
3735 bool discrete = values.at( 1 ).toBool();
3737 return QVariant::fromValue(
QgsGradientColorRamp( colors.first(), colors.last(), discrete, stops ) );
3743 if ( ! color.isValid() )
3745 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
3749 QString part = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3750 int value = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
3751 if ( part.compare( QLatin1String(
"red" ), Qt::CaseInsensitive ) == 0 )
3752 color.setRed( value );
3753 else if ( part.compare( QLatin1String(
"green" ), Qt::CaseInsensitive ) == 0 )
3754 color.setGreen( value );
3755 else if ( part.compare( QLatin1String(
"blue" ), Qt::CaseInsensitive ) == 0 )
3756 color.setBlue( value );
3757 else if ( part.compare( QLatin1String(
"alpha" ), Qt::CaseInsensitive ) == 0 )
3758 color.setAlpha( value );
3759 else if ( part.compare( QLatin1String(
"hue" ), Qt::CaseInsensitive ) == 0 )
3760 color.setHsv( value, color.hsvSaturation(), color.value(), color.alpha() );
3761 else if ( part.compare( QLatin1String(
"saturation" ), Qt::CaseInsensitive ) == 0 )
3762 color.setHsvF( color.hsvHueF(), value / 100.0, color.valueF(), color.alphaF() );
3763 else if ( part.compare( QLatin1String(
"value" ), Qt::CaseInsensitive ) == 0 )
3764 color.setHsvF( color.hsvHueF(), color.hsvSaturationF(), value / 100.0, color.alphaF() );
3765 else if ( part.compare( QLatin1String(
"hsl_hue" ), Qt::CaseInsensitive ) == 0 )
3766 color.setHsl( value, color.hslSaturation(), color.lightness(), color.alpha() );
3767 else if ( part.compare( QLatin1String(
"hsl_saturation" ), Qt::CaseInsensitive ) == 0 )
3768 color.setHslF( color.hslHueF(), value / 100.0, color.lightnessF(), color.alphaF() );
3769 else if ( part.compare( QLatin1String(
"lightness" ), Qt::CaseInsensitive ) == 0 )
3770 color.setHslF( color.hslHueF(), color.hslSaturationF(), value / 100.0, color.alphaF() );
3771 else if ( part.compare( QLatin1String(
"cyan" ), Qt::CaseInsensitive ) == 0 )
3772 color.setCmykF( value / 100.0, color.magentaF(), color.yellowF(), color.blackF(), color.alphaF() );
3773 else if ( part.compare( QLatin1String(
"magenta" ), Qt::CaseInsensitive ) == 0 )
3774 color.setCmykF( color.cyanF(), value / 100.0, color.yellowF(), color.blackF(), color.alphaF() );
3775 else if ( part.compare( QLatin1String(
"yellow" ), Qt::CaseInsensitive ) == 0 )
3776 color.setCmykF( color.cyanF(), color.magentaF(), value / 100.0, color.blackF(), color.alphaF() );
3777 else if ( part.compare( QLatin1String(
"black" ), Qt::CaseInsensitive ) == 0 )
3778 color.setCmykF( color.cyanF(), color.magentaF(), color.yellowF(), value / 100.0, color.alphaF() );
3781 parent->
setEvalErrorString( QObject::tr(
"Unknown color component '%1'" ).arg( part ) );
3790 if ( ! color.isValid() )
3792 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
3796 color = color.darker( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3804 if ( ! color.isValid() )
3806 parent->
setEvalErrorString( QObject::tr(
"Cannot convert '%1' to color" ).arg( values.at( 0 ).toString() ) );
3810 color = color.lighter( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
3817 QgsFeature feat = QgsExpressionUtils::getFeature( values.at( 0 ), parent );
3819 if ( !geom.isNull() )
3820 return QVariant::fromValue( geom );
3826 QgsGeometry fGeom = QgsExpressionUtils::getGeometry( values.at( 0 ), parent );
3827 QString sAuthId = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3828 QString dAuthId = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
3831 if ( ! s.isValid() )
3832 return QVariant::fromValue( fGeom );
3835 return QVariant::fromValue( fGeom );
3844 return QVariant::fromValue( fGeom );
3858 QgsVectorLayer *vl = QgsExpressionUtils::getVectorLayer( values.at( 0 ), parent );
3861 QgsFeatureId fid = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
3871 result = QVariant::fromValue( fet );
3881 std::unique_ptr<QgsVectorLayerFeatureSource> featureSource = QgsExpressionUtils::getFeatureSource( values.at( 0 ), parent );
3884 if ( !featureSource )
3889 QString attribute = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3890 int attributeId = featureSource->fields().lookupField( attribute );
3891 if ( attributeId == -1 )
3896 const QVariant &attVal = values.at( 2 );
3898 const QString cacheValueKey = QStringLiteral(
"getfeature:%1:%2:%3" ).arg( featureSource->id(), QString::number( attributeId ), attVal.toString() );
3920 res = QVariant::fromValue( fet );
3935 if ( !values.isEmpty() )
3938 if ( col && ( values.size() == 1 || !values.at( 1 ).isValid() ) )
3939 fieldName = col->
name();
3940 else if ( values.size() == 2 )
3941 fieldName = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3944 QVariant value = values.at( 0 );
3949 if ( fieldIndex == -1 )
3951 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: Field not found %2" ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
3955 QgsVectorLayer *layer = QgsExpressionUtils::getVectorLayer( context->
variable( QStringLiteral(
"layer" ) ), parent );
3957 const QString cacheValueKey = QStringLiteral(
"repvalfcnval:%1:%2:%3" ).arg( layer ? layer->
id() : QStringLiteral(
"[None]" ), fieldName, value.toString() );
3966 const QString cacheKey = QStringLiteral(
"repvalfcn:%1:%2" ).arg( layer ? layer->
id() : QStringLiteral(
"[None]" ), fieldName );
3984 parent->
setEvalErrorString( QCoreApplication::translate(
"expression",
"%1: function cannot be evaluated without a context." ).arg( QStringLiteral(
"represent_value" ), fieldName ) );
3992 QgsMapLayer *layer = QgsExpressionUtils::getMapLayer( values.at( 0 ), parent );
3998 QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
3999 if ( QString::compare( layerProperty, QStringLiteral(
"name" ), Qt::CaseInsensitive ) == 0 )
4000 return layer->
name();
4001 else if ( QString::compare( layerProperty, QStringLiteral(
"id" ), Qt::CaseInsensitive ) == 0 )
4003 else if ( QString::compare( layerProperty, QStringLiteral(
"title" ), Qt::CaseInsensitive ) == 0 )
4005 else if ( QString::compare( layerProperty, QStringLiteral(
"abstract" ), Qt::CaseInsensitive ) == 0 )
4007 else if ( QString::compare( layerProperty, QStringLiteral(
"keywords" ), Qt::CaseInsensitive ) == 0 )
4009 QStringList keywords;
4011 for (
auto it = keywordMap.constBegin(); it != keywordMap.constEnd(); ++it )
4013 keywords.append( it.value() );
4015 if ( !keywords.isEmpty() )
4019 else if ( QString::compare( layerProperty, QStringLiteral(
"data_url" ), Qt::CaseInsensitive ) == 0 )
4021 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution" ), Qt::CaseInsensitive ) == 0 )
4025 else if ( QString::compare( layerProperty, QStringLiteral(
"attribution_url" ), Qt::CaseInsensitive ) == 0 )
4027 else if ( QString::compare( layerProperty, QStringLiteral(
"source" ), Qt::CaseInsensitive ) == 0 )
4029 else if ( QString::compare( layerProperty, QStringLiteral(
"min_scale" ), Qt::CaseInsensitive ) == 0 )
4031 else if ( QString::compare( layerProperty, QStringLiteral(
"max_scale" ), Qt::CaseInsensitive ) == 0 )
4033 else if ( QString::compare( layerProperty, QStringLiteral(
"crs" ), Qt::CaseInsensitive ) == 0 )
4035 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_definition" ), Qt::CaseInsensitive ) == 0 )
4037 else if ( QString::compare( layerProperty, QStringLiteral(
"crs_description" ), Qt::CaseInsensitive ) == 0 )
4039 else if ( QString::compare( layerProperty, QStringLiteral(
"extent" ), Qt::CaseInsensitive ) == 0 )
4042 QVariant result = QVariant::fromValue( extentGeom );
4045 else if ( QString::compare( layerProperty, QStringLiteral(
"type" ), Qt::CaseInsensitive ) == 0 )
4047 switch ( layer->
type() )
4050 return QCoreApplication::translate(
"expressions",
"Vector" );
4052 return QCoreApplication::translate(
"expressions",
"Raster" );
4054 return QCoreApplication::translate(
"expressions",
"Mesh" );
4056 return QCoreApplication::translate(
"expressions",
"Plugin" );
4065 if ( QString::compare( layerProperty, QStringLiteral(
"storage_type" ), Qt::CaseInsensitive ) == 0 )
4067 else if ( QString::compare( layerProperty, QStringLiteral(
"geometry_type" ), Qt::CaseInsensitive ) == 0 )
4069 else if ( QString::compare( layerProperty, QStringLiteral(
"feature_count" ), Qt::CaseInsensitive ) == 0 )
4079 QString layerIdOrName = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4086 if ( !layersByName.isEmpty() )
4088 layer = layersByName.at( 0 );
4099 int band = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4100 if ( band < 1 || band > rl->
bandCount() )
4102 parent->
setEvalErrorString( QObject::tr(
"Invalid band number %1 for layer %2" ).arg( band ).arg( layerIdOrName ) );
4106 QString layerProperty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4109 if ( QString::compare( layerProperty, QStringLiteral(
"avg" ), Qt::CaseInsensitive ) == 0 )
4111 else if ( QString::compare( layerProperty, QStringLiteral(
"stdev" ), Qt::CaseInsensitive ) == 0 )
4113 else if ( QString::compare( layerProperty, QStringLiteral(
"min" ), Qt::CaseInsensitive ) == 0 )
4115 else if ( QString::compare( layerProperty, QStringLiteral(
"max" ), Qt::CaseInsensitive ) == 0 )
4117 else if ( QString::compare( layerProperty, QStringLiteral(
"range" ), Qt::CaseInsensitive ) == 0 )
4119 else if ( QString::compare( layerProperty, QStringLiteral(
"sum" ), Qt::CaseInsensitive ) == 0 )
4123 parent->
setEvalErrorString( QObject::tr(
"Invalid raster statistic: '%1'" ).arg( layerProperty ) );
4153 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).length();
4158 return QVariant( QgsExpressionUtils::getListValue( values.at( 0 ), parent ).contains( values.at( 1 ) ) );
4163 return QgsExpressionUtils::getListValue( values.at( 0 ), parent ).indexOf( values.at( 1 ) );
4168 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4169 const qlonglong pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4170 if ( pos < 0 || pos >= list.length() )
return QVariant();
4171 return list.at( pos );
4176 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4177 return list.value( 0 );
4182 const QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4183 return list.value( list.size() - 1 );
4186 static QVariant convertToSameType(
const QVariant &value, QVariant::Type type )
4188 QVariant result = value;
4189 result.convert( type );
4195 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4196 list.append( values.at( 1 ) );
4197 return convertToSameType( list, values.at( 0 ).type() );
4202 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4203 list.prepend( values.at( 1 ) );
4204 return convertToSameType( list, values.at( 0 ).type() );
4209 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4210 list.insert( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ), values.at( 2 ) );
4211 return convertToSameType( list, values.at( 0 ).type() );
4216 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4217 list.removeAt( QgsExpressionUtils::getIntValue( values.at( 1 ), parent ) );
4218 return convertToSameType( list, values.at( 0 ).type() );
4223 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4224 list.removeAll( values.at( 1 ) );
4225 return convertToSameType( list, values.at( 0 ).type() );
4231 for (
const QVariant &cur : values )
4233 list += QgsExpressionUtils::getListValue( cur, parent );
4235 return convertToSameType( list, values.at( 0 ).type() );
4240 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4241 qlonglong start_pos = QgsExpressionUtils::getIntValue( values.at( 1 ), parent );
4242 const qlonglong end_pos = QgsExpressionUtils::getIntValue( values.at( 2 ), parent );
4243 qlonglong slice_length = 0;
4245 if ( start_pos < 0 )
4247 start_pos = list.length() + start_pos;
4251 slice_length = end_pos - start_pos + 1;
4255 slice_length = list.length() + end_pos - start_pos + 1;
4258 if ( slice_length < 0 )
4262 list = list.mid( start_pos, slice_length );
4268 QVariantList list = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4269 std::reverse( list.begin(), list.end() );
4275 const QVariantList array1 = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4276 const QVariantList array2 = QgsExpressionUtils::getListValue( values.at( 1 ), parent );
4277 for (
const QVariant &cur : array2 )
4279 if ( array1.contains( cur ) )
4280 return QVariant(
true );
4282 return QVariant(
false );
4287 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4289 QVariantList distinct;
4291 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
4293 if ( !distinct.contains( *it ) )
4295 distinct += ( *it );
4304 QVariantList array = QgsExpressionUtils::getListValue( values.at( 0 ), parent );
4305 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4306 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4310 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
4312 str += ( !( *it ).toString().isEmpty() ) ? ( *it ).toString() : empty;
4313 if ( it != ( array.constEnd() - 1 ) )
4319 return QVariant( str );
4324 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4325 QString delimiter = QgsExpressionUtils::getStringValue( values.at( 1 ), parent );
4326 QString empty = QgsExpressionUtils::getStringValue( values.at( 2 ), parent );
4328 QStringList list = str.split( delimiter );
4331 for ( QStringList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it )
4333 array += ( !( *it ).isEmpty() ) ? *it : empty;
4341 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4342 QJsonDocument document = QJsonDocument::fromJson( str.toUtf8() );
4343 if ( document.isNull() || !document.isObject() )
4344 return QVariantMap();
4346 return document.object().toVariantMap();
4351 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4352 QJsonObject
object = QJsonObject::fromVariantMap( map );
4353 QJsonDocument document(
object );
4354 return document.toJson( QJsonDocument::Compact );
4359 QString str = QgsExpressionUtils::getStringValue( values.at( 0 ), parent );
4360 if ( str.isEmpty() )
4361 return QVariantMap();
4362 str = str.trimmed();
4369 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4376 for (
int i = 0; i + 1 < values.length(); i += 2 )
4378 result.insert( QgsExpressionUtils::getStringValue( values.at( i ), parent ), values.at( i + 1 ) );
4385 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).value( values.at( 1 ).toString() );
4390 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).contains( values.at( 1 ).toString() );
4395 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4396 map.remove( values.at( 1 ).toString() );
4402 QVariantMap map = QgsExpressionUtils::getMapValue( values.at( 0 ), parent );
4403 map.insert( values.at( 1 ).toString(), values.at( 2 ) );
4410 for (
const QVariant &cur : values )
4412 const QVariantMap curMap = QgsExpressionUtils::getMapValue( cur, parent );
4413 for ( QVariantMap::const_iterator it = curMap.constBegin(); it != curMap.constEnd(); ++it )
4414 result.insert( it.key(), it.value() );
4421 return QStringList( QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).keys() );
4426 return QgsExpressionUtils::getMapValue( values.at( 0 ), parent ).values();
4431 QString envVarName = values.at( 0 ).toString();
4432 return QProcessEnvironment::systemEnvironment().value( envVarName );
4441 static QMutex sFunctionsMutex( QMutex::Recursive );
4442 QMutexLocker locker( &sFunctionsMutex );
4444 if ( sFunctions.isEmpty() )
4474 sFunctions << randFunc;
4478 sFunctions << randfFunc;
4481 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max" ), -1, fcnMax, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4482 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min" ), -1, fcnMin, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4484 <<
new QgsStaticExpressionFunction( QStringLiteral(
"scale_linear" ), 5, fcnLinearScale, QStringLiteral(
"Math" ) )
4485 <<
new QgsStaticExpressionFunction( QStringLiteral(
"scale_exp" ), 6, fcnExpScale, QStringLiteral(
"Math" ) )
4486 <<
new QgsStaticExpressionFunction( QStringLiteral(
"floor" ), 1, fcnFloor, QStringLiteral(
"Math" ) )
4487 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ceil" ), 1, fcnCeil, QStringLiteral(
"Math" ) )
4488 <<
new QgsStaticExpressionFunction( QStringLiteral(
"pi" ), 0, fcnPi, QStringLiteral(
"Math" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$pi" ) )
4491 <<
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" ) )
4492 <<
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" ) )
4493 <<
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" ) )
4494 <<
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" ) )
4495 <<
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" ) )
4498 <<
new QgsStaticExpressionFunction( QStringLiteral(
"coalesce" ), -1, fcnCoalesce, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4499 <<
new QgsStaticExpressionFunction( QStringLiteral(
"if" ), 3, fcnIf, QStringLiteral(
"Conditionals" ), QString(),
false, QSet<QString>(),
true )
4502 <<
new QgsStaticExpressionFunction( QStringLiteral(
"aggregate" ),
4510 QStringLiteral(
"Aggregates" ),
4519 if ( !node->
args() )
4522 QSet<QString> referencedVars;
4534 return referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() );
4543 if ( !node->
args() )
4544 return QSet<QString>();
4546 QSet<QString> referencedCols;
4547 QSet<QString> referencedVars;
4562 if ( referencedVars.contains( QStringLiteral(
"parent" ) ) || referencedVars.contains( QString() ) )
4565 return referencedCols;
4573 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count" ), aggParams, fcnAggregateCount, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4574 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_distinct" ), aggParams, fcnAggregateCountDistinct, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4575 <<
new QgsStaticExpressionFunction( QStringLiteral(
"count_missing" ), aggParams, fcnAggregateCountMissing, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4576 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minimum" ), aggParams, fcnAggregateMin, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4577 <<
new QgsStaticExpressionFunction( QStringLiteral(
"maximum" ), aggParams, fcnAggregateMax, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4578 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sum" ), aggParams, fcnAggregateSum, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4579 <<
new QgsStaticExpressionFunction( QStringLiteral(
"mean" ), aggParams, fcnAggregateMean, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4580 <<
new QgsStaticExpressionFunction( QStringLiteral(
"median" ), aggParams, fcnAggregateMedian, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4581 <<
new QgsStaticExpressionFunction( QStringLiteral(
"stdev" ), aggParams, fcnAggregateStdev, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4582 <<
new QgsStaticExpressionFunction( QStringLiteral(
"range" ), aggParams, fcnAggregateRange, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4583 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minority" ), aggParams, fcnAggregateMinority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4584 <<
new QgsStaticExpressionFunction( QStringLiteral(
"majority" ), aggParams, fcnAggregateMajority, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4585 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q1" ), aggParams, fcnAggregateQ1, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4586 <<
new QgsStaticExpressionFunction( QStringLiteral(
"q3" ), aggParams, fcnAggregateQ3, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4587 <<
new QgsStaticExpressionFunction( QStringLiteral(
"iqr" ), aggParams, fcnAggregateIQR, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4588 <<
new QgsStaticExpressionFunction( QStringLiteral(
"min_length" ), aggParams, fcnAggregateMinLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4589 <<
new QgsStaticExpressionFunction( QStringLiteral(
"max_length" ), aggParams, fcnAggregateMaxLength, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4590 <<
new QgsStaticExpressionFunction( QStringLiteral(
"collect" ), aggParams, fcnAggregateCollectGeometry, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4591 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concatenate" ), aggParams <<
QgsExpressionFunction::Parameter( QStringLiteral(
"concatenator" ),
true ), fcnAggregateStringConcat, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4592 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_agg" ), aggParams, fcnAggregateArray, QStringLiteral(
"Aggregates" ), QString(),
false, QSet<QString>(),
true )
4597 <<
new QgsStaticExpressionFunction( QStringLiteral(
"now" ), 0, fcnNow, QStringLiteral(
"Date and Time" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$now" ) )
4598 <<
new QgsStaticExpressionFunction( QStringLiteral(
"age" ), 2, fcnAge, QStringLiteral(
"Date and Time" ) )
4599 <<
new QgsStaticExpressionFunction( QStringLiteral(
"year" ), 1, fcnYear, QStringLiteral(
"Date and Time" ) )
4600 <<
new QgsStaticExpressionFunction( QStringLiteral(
"month" ), 1, fcnMonth, QStringLiteral(
"Date and Time" ) )
4601 <<
new QgsStaticExpressionFunction( QStringLiteral(
"week" ), 1, fcnWeek, QStringLiteral(
"Date and Time" ) )
4602 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day" ), 1, fcnDay, QStringLiteral(
"Date and Time" ) )
4603 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hour" ), 1, fcnHour, QStringLiteral(
"Date and Time" ) )
4604 <<
new QgsStaticExpressionFunction( QStringLiteral(
"minute" ), 1, fcnMinute, QStringLiteral(
"Date and Time" ) )
4605 <<
new QgsStaticExpressionFunction( QStringLiteral(
"second" ), 1, fcnSeconds, QStringLiteral(
"Date and Time" ) )
4607 <<
new QgsStaticExpressionFunction( QStringLiteral(
"day_of_week" ), 1, fcnDayOfWeek, QStringLiteral(
"Date and Time" ) )
4608 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lower" ), 1, fcnLower, QStringLiteral(
"String" ) )
4609 <<
new QgsStaticExpressionFunction( QStringLiteral(
"upper" ), 1, fcnUpper, QStringLiteral(
"String" ) )
4610 <<
new QgsStaticExpressionFunction( QStringLiteral(
"title" ), 1, fcnTitle, QStringLiteral(
"String" ) )
4611 <<
new QgsStaticExpressionFunction( QStringLiteral(
"trim" ), 1, fcnTrim, QStringLiteral(
"String" ) )
4612 <<
new QgsStaticExpressionFunction( QStringLiteral(
"levenshtein" ), 2, fcnLevenshtein, QStringLiteral(
"Fuzzy Matching" ) )
4613 <<
new QgsStaticExpressionFunction( QStringLiteral(
"longest_common_substring" ), 2, fcnLCS, QStringLiteral(
"Fuzzy Matching" ) )
4614 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hamming_distance" ), 2, fcnHamming, QStringLiteral(
"Fuzzy Matching" ) )
4615 <<
new QgsStaticExpressionFunction( QStringLiteral(
"soundex" ), 1, fcnSoundex, QStringLiteral(
"Fuzzy Matching" ) )
4616 <<
new QgsStaticExpressionFunction( QStringLiteral(
"char" ), 1, fcnChar, QStringLiteral(
"String" ) )
4619 <<
new QgsStaticExpressionFunction( QStringLiteral(
"replace" ), -1, fcnReplace, QStringLiteral(
"String" ) )
4620 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_replace" ), 3, fcnRegexpReplace, QStringLiteral(
"String" ) )
4621 <<
new QgsStaticExpressionFunction( QStringLiteral(
"regexp_substr" ), 2, fcnRegexpSubstr, QStringLiteral(
"String" ) )
4623 false, QSet< QString >(),
false, QStringList(),
true )
4624 <<
new QgsStaticExpressionFunction( QStringLiteral(
"concat" ), -1, fcnConcat, QStringLiteral(
"String" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
4625 <<
new QgsStaticExpressionFunction( QStringLiteral(
"strpos" ), 2, fcnStrpos, QStringLiteral(
"String" ) )
4626 <<
new QgsStaticExpressionFunction( QStringLiteral(
"left" ), 2, fcnLeft, QStringLiteral(
"String" ) )
4627 <<
new QgsStaticExpressionFunction( QStringLiteral(
"right" ), 2, fcnRight, QStringLiteral(
"String" ) )
4628 <<
new QgsStaticExpressionFunction( QStringLiteral(
"rpad" ), 3, fcnRPad, QStringLiteral(
"String" ) )
4629 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lpad" ), 3, fcnLPad, QStringLiteral(
"String" ) )
4630 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format" ), -1, fcnFormatString, QStringLiteral(
"String" ) )
4631 <<
new QgsStaticExpressionFunction( QStringLiteral(
"format_number" ), 2, fcnFormatNumber, QStringLiteral(
"String" ) )
4633 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_grayscale_average" ), 1, fcnColorGrayscaleAverage, QStringLiteral(
"Color" ) )
4634 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_mix_rgb" ), 3, fcnColorMixRgb, QStringLiteral(
"Color" ) )
4635 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_rgb" ), 3, fcnColorRgb, QStringLiteral(
"Color" ) )
4636 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_rgba" ), 4, fncColorRgba, QStringLiteral(
"Color" ) )
4637 <<
new QgsStaticExpressionFunction( QStringLiteral(
"ramp_color" ), 2,
fcnRampColor, QStringLiteral(
"Color" ) )
4639 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_hsl" ), 3, fcnColorHsl, QStringLiteral(
"Color" ) )
4640 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_hsla" ), 4, fncColorHsla, QStringLiteral(
"Color" ) )
4641 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_hsv" ), 3, fcnColorHsv, QStringLiteral(
"Color" ) )
4642 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_hsva" ), 4, fncColorHsva, QStringLiteral(
"Color" ) )
4643 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_cmyk" ), 4, fcnColorCmyk, QStringLiteral(
"Color" ) )
4644 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_cmyka" ), 5, fncColorCmyka, QStringLiteral(
"Color" ) )
4645 <<
new QgsStaticExpressionFunction( QStringLiteral(
"color_part" ), 2, fncColorPart, QStringLiteral(
"Color" ) )
4646 <<
new QgsStaticExpressionFunction( QStringLiteral(
"darker" ), 2, fncDarker, QStringLiteral(
"Color" ) )
4647 <<
new QgsStaticExpressionFunction( QStringLiteral(
"lighter" ), 2, fncLighter, QStringLiteral(
"Color" ) )
4648 <<
new QgsStaticExpressionFunction( QStringLiteral(
"set_color_part" ), 3, fncSetColorPart, QStringLiteral(
"Color" ) )
4653 QgsStaticExpressionFunction *geomFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$geometry" ), 0, fcnGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4655 sFunctions << geomFunc;
4657 QgsStaticExpressionFunction *areaFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$area" ), 0, fcnGeomArea, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4659 sFunctions << areaFunc;
4661 sFunctions <<
new QgsStaticExpressionFunction( QStringLiteral(
"area" ), 1, fcnArea, QStringLiteral(
"GeometryGroup" ) );
4663 QgsStaticExpressionFunction *lengthFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$length" ), 0, fcnGeomLength, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4665 sFunctions << lengthFunc;
4667 QgsStaticExpressionFunction *perimeterFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$perimeter" ), 0, fcnGeomPerimeter, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4669 sFunctions << perimeterFunc;
4671 sFunctions <<
new QgsStaticExpressionFunction( QStringLiteral(
"perimeter" ), 1, fcnPerimeter, QStringLiteral(
"GeometryGroup" ) );
4673 QgsStaticExpressionFunction *xFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$x" ), 0, fcnX, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4675 sFunctions << xFunc;
4677 QgsStaticExpressionFunction *yFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$y" ), 0, fcnY, QStringLiteral(
"GeometryGroup" ), QString(),
true );
4679 sFunctions << yFunc;
4682 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x" ), 1, fcnGeomX, QStringLiteral(
"GeometryGroup" ) )
4683 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y" ), 1, fcnGeomY, QStringLiteral(
"GeometryGroup" ) )
4684 <<
new QgsStaticExpressionFunction( QStringLiteral(
"z" ), 1, fcnGeomZ, QStringLiteral(
"GeometryGroup" ) )
4685 <<
new QgsStaticExpressionFunction( QStringLiteral(
"m" ), 1, fcnGeomM, QStringLiteral(
"GeometryGroup" ) )
4686 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_n" ), 2, fcnPointN, QStringLiteral(
"GeometryGroup" ) )
4687 <<
new QgsStaticExpressionFunction( QStringLiteral(
"start_point" ), 1, fcnStartPoint, QStringLiteral(
"GeometryGroup" ) )
4688 <<
new QgsStaticExpressionFunction( QStringLiteral(
"end_point" ), 1, fcnEndPoint, QStringLiteral(
"GeometryGroup" ) )
4689 <<
new QgsStaticExpressionFunction( QStringLiteral(
"nodes_to_points" ), -1, fcnNodesToPoints, QStringLiteral(
"GeometryGroup" ) )
4690 <<
new QgsStaticExpressionFunction( QStringLiteral(
"segments_to_lines" ), 1, fcnSegmentsToLines, QStringLiteral(
"GeometryGroup" ) )
4691 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_point" ), -1, fcnMakePoint, QStringLiteral(
"GeometryGroup" ) )
4692 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_point_m" ), 3, fcnMakePointM, QStringLiteral(
"GeometryGroup" ) )
4693 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_line" ), -1, fcnMakeLine, QStringLiteral(
"GeometryGroup" ) )
4694 <<
new QgsStaticExpressionFunction( QStringLiteral(
"make_polygon" ), -1, fcnMakePolygon, QStringLiteral(
"GeometryGroup" ) )
4698 fcnMakeTriangle, QStringLiteral(
"GeometryGroup" ) )
4703 fcnMakeCircle, QStringLiteral(
"GeometryGroup" ) )
4710 fcnMakeEllipse, QStringLiteral(
"GeometryGroup" ) )
4716 fcnMakeRegularPolygon, QStringLiteral(
"GeometryGroup" ) );
4718 QgsStaticExpressionFunction *xAtFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$x_at" ), 1, fcnXat, QStringLiteral(
"GeometryGroup" ), QString(),
true, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xat" ) << QStringLiteral(
"x_at" ) );
4720 sFunctions << xAtFunc;
4722 QgsStaticExpressionFunction *yAtFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$y_at" ), 1, fcnYat, QStringLiteral(
"GeometryGroup" ), QString(),
true, QSet<QString>(),
false, QStringList() << QStringLiteral(
"yat" ) << QStringLiteral(
"y_at" ) );
4724 sFunctions << yAtFunc;
4727 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_min" ), 1, fcnXMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmin" ) )
4728 <<
new QgsStaticExpressionFunction( QStringLiteral(
"x_max" ), 1, fcnXMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"xmax" ) )
4729 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_min" ), 1, fcnYMin, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymin" ) )
4730 <<
new QgsStaticExpressionFunction( QStringLiteral(
"y_max" ), 1, fcnYMax, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"ymax" ) )
4731 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_wkt" ), 1, fcnGeomFromWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromWKT" ) )
4732 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_from_gml" ), 1, fcnGeomFromGML, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomFromGML" ) )
4733 <<
new QgsStaticExpressionFunction( QStringLiteral(
"flip_coordinates" ), 1, fcnFlipCoordinates, QStringLiteral(
"GeometryGroup" ) )
4734 <<
new QgsStaticExpressionFunction( QStringLiteral(
"relate" ), -1, fcnRelate, QStringLiteral(
"GeometryGroup" ) )
4735 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersects_bbox" ), 2, fcnBbox, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"bbox" ) )
4736 <<
new QgsStaticExpressionFunction( QStringLiteral(
"disjoint" ), 2, fcnDisjoint, QStringLiteral(
"GeometryGroup" ) )
4737 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersects" ), 2, fcnIntersects, QStringLiteral(
"GeometryGroup" ) )
4738 <<
new QgsStaticExpressionFunction( QStringLiteral(
"touches" ), 2, fcnTouches, QStringLiteral(
"GeometryGroup" ) )
4739 <<
new QgsStaticExpressionFunction( QStringLiteral(
"crosses" ), 2, fcnCrosses, QStringLiteral(
"GeometryGroup" ) )
4740 <<
new QgsStaticExpressionFunction( QStringLiteral(
"contains" ), 2, fcnContains, QStringLiteral(
"GeometryGroup" ) )
4741 <<
new QgsStaticExpressionFunction( QStringLiteral(
"overlaps" ), 2, fcnOverlaps, QStringLiteral(
"GeometryGroup" ) )
4742 <<
new QgsStaticExpressionFunction( QStringLiteral(
"within" ), 2, fcnWithin, QStringLiteral(
"GeometryGroup" ) )
4743 <<
new QgsStaticExpressionFunction( QStringLiteral(
"translate" ), 3, fcnTranslate, QStringLiteral(
"GeometryGroup" ) )
4744 <<
new QgsStaticExpressionFunction( QStringLiteral(
"buffer" ), -1, fcnBuffer, QStringLiteral(
"GeometryGroup" ) )
4754 , fcnTaperedBuffer, QStringLiteral(
"GeometryGroup" ) )
4757 , fcnBufferByM, QStringLiteral(
"GeometryGroup" ) )
4763 fcnOffsetCurve, QStringLiteral(
"GeometryGroup" ) )
4769 fcnSingleSidedBuffer, QStringLiteral(
"GeometryGroup" ) )
4773 fcnExtend, QStringLiteral(
"GeometryGroup" ) )
4774 <<
new QgsStaticExpressionFunction( QStringLiteral(
"centroid" ), 1, fcnCentroid, QStringLiteral(
"GeometryGroup" ) )
4775 <<
new QgsStaticExpressionFunction( QStringLiteral(
"point_on_surface" ), 1, fcnPointOnSurface, QStringLiteral(
"GeometryGroup" ) )
4778 <<
new QgsStaticExpressionFunction( QStringLiteral(
"reverse" ), 1, fcnReverse, QStringLiteral(
"GeometryGroup" ) )
4779 <<
new QgsStaticExpressionFunction( QStringLiteral(
"exterior_ring" ), 1, fcnExteriorRing, QStringLiteral(
"GeometryGroup" ) )
4780 <<
new QgsStaticExpressionFunction( QStringLiteral(
"interior_ring_n" ), 2, fcnInteriorRingN, QStringLiteral(
"GeometryGroup" ) )
4781 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geometry_n" ), 2, fcnGeometryN, QStringLiteral(
"GeometryGroup" ) )
4784 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds" ), 1, fcnBounds, QStringLiteral(
"GeometryGroup" ) )
4791 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_points" ), 1, fcnGeomNumPoints, QStringLiteral(
"GeometryGroup" ) )
4792 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_interior_rings" ), 1, fcnGeomNumInteriorRings, QStringLiteral(
"GeometryGroup" ) )
4793 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_rings" ), 1, fcnGeomNumRings, QStringLiteral(
"GeometryGroup" ) )
4794 <<
new QgsStaticExpressionFunction( QStringLiteral(
"num_geometries" ), 1, fcnGeomNumGeometries, QStringLiteral(
"GeometryGroup" ) )
4795 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_width" ), 1, fcnBoundsWidth, QStringLiteral(
"GeometryGroup" ) )
4796 <<
new QgsStaticExpressionFunction( QStringLiteral(
"bounds_height" ), 1, fcnBoundsHeight, QStringLiteral(
"GeometryGroup" ) )
4797 <<
new QgsStaticExpressionFunction( QStringLiteral(
"is_closed" ), 1, fcnIsClosed, QStringLiteral(
"GeometryGroup" ) )
4798 <<
new QgsStaticExpressionFunction( QStringLiteral(
"convex_hull" ), 1, fcnConvexHull, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"convexHull" ) )
4801 fcnOrientedBBox, QStringLiteral(
"GeometryGroup" ) )
4805 fcnMinimalCircle, QStringLiteral(
"GeometryGroup" ) )
4806 <<
new QgsStaticExpressionFunction( QStringLiteral(
"difference" ), 2, fcnDifference, QStringLiteral(
"GeometryGroup" ) )
4807 <<
new QgsStaticExpressionFunction( QStringLiteral(
"distance" ), 2, fcnDistance, QStringLiteral(
"GeometryGroup" ) )
4810 <<
new QgsStaticExpressionFunction( QStringLiteral(
"intersection" ), 2, fcnIntersection, QStringLiteral(
"GeometryGroup" ) )
4811 <<
new QgsStaticExpressionFunction( QStringLiteral(
"sym_difference" ), 2, fcnSymDifference, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"symDifference" ) )
4812 <<
new QgsStaticExpressionFunction( QStringLiteral(
"combine" ), 2, fcnCombine, QStringLiteral(
"GeometryGroup" ) )
4813 <<
new QgsStaticExpressionFunction( QStringLiteral(
"union" ), 2, fcnCombine, QStringLiteral(
"GeometryGroup" ) )
4814 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geom_to_wkt" ), -1, fcnGeomToWKT, QStringLiteral(
"GeometryGroup" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"geomToWKT" ) )
4815 <<
new QgsStaticExpressionFunction( QStringLiteral(
"geometry" ), 1, fcnGetGeometry, QStringLiteral(
"GeometryGroup" ), QString(),
true )
4816 <<
new QgsStaticExpressionFunction( QStringLiteral(
"transform" ), 3, fcnTransformGeometry, QStringLiteral(
"GeometryGroup" ) )
4817 <<
new QgsStaticExpressionFunction( QStringLiteral(
"extrude" ), 3, fcnExtrude, QStringLiteral(
"GeometryGroup" ), QString() );;
4819 QgsStaticExpressionFunction *orderPartsFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"order_parts" ), 3, fcnOrderParts, QStringLiteral(
"GeometryGroup" ), QString() );
4824 const QList< QgsExpressionNode *> argList = node->
args()->
list();
4827 if ( !argNode->isStatic( parent, context ) )
4835 QString expString = argNode->
eval( parent, context ).toString();
4851 QString expression = argNode->
eval( parent, context ).toString();
4859 sFunctions << orderPartsFunc;
4862 <<
new QgsStaticExpressionFunction( QStringLiteral(
"closest_point" ), 2, fcnClosestPoint, QStringLiteral(
"GeometryGroup" ) )
4863 <<
new QgsStaticExpressionFunction( QStringLiteral(
"shortest_line" ), 2, fcnShortestLine, QStringLiteral(
"GeometryGroup" ) )
4880 QgsStaticExpressionFunction *idFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$id" ), 0, fcnFeatureId, QStringLiteral(
"Record and Attributes" ) );
4882 sFunctions << idFunc;
4884 QgsStaticExpressionFunction *currentFeatureFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"$currentfeature" ), 0, fcnFeature, QStringLiteral(
"Record and Attributes" ) );
4886 sFunctions << currentFeatureFunc;
4888 QgsStaticExpressionFunction *uuidFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"uuid" ), 0, fcnUuid, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"$uuid" ) );
4890 sFunctions << uuidFunc;
4893 <<
new QgsStaticExpressionFunction( QStringLiteral(
"get_feature" ), 3, fcnGetFeature, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false, QStringList() << QStringLiteral(
"QgsExpressionUtils::getFeature" ) )
4894 <<
new QgsStaticExpressionFunction( QStringLiteral(
"get_feature_by_id" ), 2, fcnGetFeatureById, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>(),
false );
4896 QgsStaticExpressionFunction *isSelectedFunc =
new QgsStaticExpressionFunction(
4897 QStringLiteral(
"is_selected" ),
4900 QStringLiteral(
"Record and Attributes" ),
4906 sFunctions << isSelectedFunc;
4909 <<
new QgsStaticExpressionFunction(
4910 QStringLiteral(
"num_selected" ),
4913 QStringLiteral(
"Record and Attributes" ),
4934 parent->
setEvalErrorString( tr(
"If represent_value is called with 1 parameter, it must be an attribute." ) );
4944 parent->
setEvalErrorString( tr(
"represent_value must be called with exactly 1 or 2 parameters." ) );
4950 sFunctions << representValueFunc;
4954 <<
new QgsStaticExpressionFunction( QStringLiteral(
"layer_property" ), 2, fcnGetLayerProperty, QStringLiteral(
"General" ) )
4960 QgsStaticExpressionFunction *varFunction =
new QgsStaticExpressionFunction( QStringLiteral(
"var" ), 1, fcnGetVariable, QStringLiteral(
"General" ) );
4973 if ( !argNode->
isStatic( parent, context ) )
4976 QString varName = argNode->
eval( parent, context ).toString();
4979 return scope ? scope->
isStatic( varName ) :
false;
4987 QgsStaticExpressionFunction *evalFunc =
new QgsStaticExpressionFunction( QStringLiteral(
"eval" ), 1, fcnEval, QStringLiteral(
"General" ), QString(),
true, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES );
4995 if ( argNode->
isStatic( parent, context ) )
4997 QString expString = argNode->
eval( parent, context ).toString();
5009 sFunctions << evalFunc;
5012 <<
new QgsStaticExpressionFunction( QStringLiteral(
"env" ), 1, fcnEnvVar, QStringLiteral(
"General" ), QString() )
5014 <<
new QgsStaticExpressionFunction( QStringLiteral(
"attribute" ), 2, fcnAttribute, QStringLiteral(
"Record and Attributes" ), QString(),
false, QSet<QString>() <<
QgsFeatureRequest::ALL_ATTRIBUTES )
5020 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array" ), -1, fcnArray, QStringLiteral(
"Arrays" ), QString(),
false, QSet<QString>(),
false, QStringList(),
true )
5021 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_length" ), 1, fcnArrayLength, QStringLiteral(
"Arrays" ) )
5032 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_cat" ), -1, fcnArrayCat, QStringLiteral(
"Arrays" ) )
5036 <<
new QgsStaticExpressionFunction( QStringLiteral(
"array_distinct" ), 1, fcnArrayDistinct, QStringLiteral(
"Arrays" ) )
5042 <<
new QgsStaticExpressionFunction( QStringLiteral(
"json_to_map" ), 1, fcnJsonToMap, QStringLiteral(
"Maps" ) )
5043 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_to_json" ), 1, fcnMapToJson, QStringLiteral(
"Maps" ) )
5044 <<
new QgsStaticExpressionFunction( QStringLiteral(
"hstore_to_map" ), 1, fcnHstoreToMap, QStringLiteral(
"Maps" ) )
5045 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_to_hstore" ), 1, fcnMapToHstore, QStringLiteral(
"Maps" ) )
5046 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map" ), -1, fcnMap, QStringLiteral(
"Maps" ) )
5051 <<
new QgsStaticExpressionFunction( QStringLiteral(
"map_concat" ), -1, fcnMapConcat, QStringLiteral(
"Maps" ) )
5061 sOwnedFunctions <<
func;
5062 sBuiltinFunctions << func->name();
5063 sBuiltinFunctions.append( func->aliases() );
5073 QStringLiteral(
"Arrays" ) )
5084 if ( args->
count() < 2 )
5087 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
5097 QVariantList result;
5099 if ( args->
count() < 2 )
5103 QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
5106 std::unique_ptr< QgsExpressionContext > tempContext;
5109 tempContext = qgis::make_unique< QgsExpressionContext >();
5110 subContext = tempContext.get();
5116 for ( QVariantList::const_iterator it = array.constBegin(); it != array.constEnd(); ++it )
5119 result << args->
at( 1 )->
eval( parent, subContext );
5144 if ( args->
count() < 2 )
5148 args->
at( 0 )->
prepare( parent, context );
5152 subContext = *context;
5158 args->
at( 1 )->
prepare( parent, &subContext );
5167 QStringLiteral(
"Arrays" ) )
5178 if ( args->
count() < 2 )
5181 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
5191 QVariantList result;
5193 if ( args->
count() < 2 )
5197 const QVariantList array = args->
at( 0 )->
eval( parent, context ).toList();
5200 std::unique_ptr< QgsExpressionContext > tempContext;
5203 tempContext = qgis::make_unique< QgsExpressionContext >();
5204 subContext = tempContext.get();
5210 for (
const QVariant &value : array )
5213 if ( args->
at( 1 )->
eval( parent, subContext ).toBool() )
5239 if ( args->
count() < 2 )
5243 args->
at( 0 )->
prepare( parent, context );
5247 subContext = *context;
5253 args->
at( 1 )->
prepare( parent, &subContext );
5262 QStringLiteral(
"General" ) )
5273 if ( args->
count() < 3 )
5277 if ( args->
at( 0 )->
isStatic( parent, context ) && args->
at( 1 )->
isStatic( parent, context ) )
5279 QVariant
name = args->
at( 0 )->
eval( parent, context );
5280 QVariant value = args->
at( 1 )->
eval( parent, context );
5283 appendTemporaryVariable( context, name.toString(), value );
5284 if ( args->
at( 2 )->
isStatic( parent, context ) )
5286 popTemporaryVariable( context );
5297 if ( args->
count() < 3 )
5301 QVariant
name = args->
at( 0 )->
eval( parent, context );
5302 QVariant value = args->
at( 1 )->
eval( parent, context );
5305 std::unique_ptr< QgsExpressionContext > tempContext;
5306 if ( !updatedContext )
5308 tempContext = qgis::make_unique< QgsExpressionContext >();
5309 updatedContext = tempContext.get();
5312 appendTemporaryVariable( updatedContext, name.toString(), value );
5313 result = args->
at( 2 )->
eval( parent, updatedContext );
5316 popTemporaryVariable( updatedContext );
5337 if ( args->
count() < 3 )
5342 QVariant value = args->
at( 1 )->
prepare( parent, context );
5345 std::unique_ptr< QgsExpressionContext > tempContext;
5346 if ( !updatedContext )
5348 tempContext = qgis::make_unique< QgsExpressionContext >();
5349 updatedContext = tempContext.get();
5352 appendTemporaryVariable( updatedContext, name.toString(), value );
5353 args->
at( 2 )->
prepare( parent, updatedContext );
5356 popTemporaryVariable( updatedContext );
5361 void QgsWithVariableExpressionFunction::popTemporaryVariable(
const QgsExpressionContext *context )
const 5367 void QgsWithVariableExpressionFunction::appendTemporaryVariable(
const QgsExpressionContext *context,
const QString &
name,
const QVariant &value )
const 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 poleOfInaccessibility(double precision, double *distanceToBoundary=nullptr) const
Calculates the approximate pole of inaccessibility for a surface, which is the most distant internal ...
static QString longestCommonSubstring(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the longest common substring between two strings.
Class for parsing and evaluation of expressions (formerly called "search strings").
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.
double measureLength(const QgsGeometry &geometry) const
Measures the length of a geometry.
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
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.
virtual QStringList aliases() const
Returns a list of possible aliases for the function.
Base class for all map layer types.
Inter quartile range (IQR) (numeric fields only)
QgsGeometry interpolate(double distance) const
Returns an interpolated point on the geometry at the specified distance.
bool prepare(QgsExpression *parent, const QgsExpressionContext *context)
Prepare this node for evaluation.
QString group() const
Returns the first group which the function belongs to.
QgsGeometry pointOnSurface() const
Returns a point guaranteed to lie on the surface of a geometry.
virtual QString dump() const =0
Dump this node into a serialized (part) of an expression.
void setPoints(const QgsPointSequence &points)
Resets the line string to match the specified list of points.
QString getRelatedFeaturesFilter(const QgsFeature &feature) const
Returns a filter expression which returns all the features on the referencing (child) layer which hav...
QgsMapLayer::LayerType type() const
Returns the type of the layer.
static QgsFieldFormatterRegistry * fieldFormatterRegistry()
Gets the registry of available field formatters.
double months() const
Returns the interval duration in months (based on a 30 day month).
Median of values (numeric fields only)
double sum
The sum of all cells in the band. NO_DATA values are excluded.
QSet< QString > referencedVariables() const
Returns a list of all variables which are used in this expression.
QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Returns result of evaluating the function.
double angleAtVertex(int vertex) const
Returns the bisector angle for this geometry at the specified vertex.
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
QgsExpressionNode * at(int i)
Gets the node at position i in the list.
Represents a color stop within a QgsGradientColorRamp color ramp.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
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.
bool isValid() const
Returns the validity of this feature.
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example...
bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
Will be called during prepare to determine if the function is static.
QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Returns result of evaluating the function.
bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
This will be called during the prepare step() of an expression if it is not static.
Multi point geometry collection.
bool isValid() const
Returns true if the interval is valid.
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()
virtual bool handlesNull() const
Returns true if the function handles NULL values in arguments by itself, and the default NULL value h...
double distance(const QgsGeometry &geom) const
Returns the minimum distance between this geometry and another geometry, using GEOS.
QVariant func(const QVariantList &values, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Returns result of evaluating the function.
QgsArrayFilterExpressionFunction()
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...
double yMaximum() const
Returns the y maximum value (top side of rectangle).
double years() const
Returns the interval duration in years (based on an average year length)
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.
double maximumScale() const
Returns the maximum map scale (i.e.
First quartile (numeric fields only)
Number of missing (null) values.
double hausdorffDistanceDensify(const QgsGeometry &geom, double densifyFraction) const
Returns the Hausdorff distance between this geometry and geom.
QVariant cachedValue(const QString &key) const
Returns the matching cached value, if set.
A class to represent a 2D point.
Abstract base class for color ramps.
QgsVectorLayer referencingLayer
QList< QgsRelation > relationsByName(const QString &name) const
Returns a list of relations with matching names.
QVariant evaluate()
Evaluate the feature and return the result.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
bool isStatic(const QString &name) const
Tests whether the variable with the specified name is static and can be cached.
double maximumValue
The maximum cell value in the raster band.
QString title() const
Returns the title of the layer used by QGIS Server in GetCapabilities request.
Multi line string geometry collection.
double convertLengthMeasurement(double length, QgsUnitTypes::DistanceUnit toUnits) const
Takes a length measurement calculated by this QgsDistanceArea object and converts it to a different d...
int selectedFeatureCount() const
Returns the number of features that are selected in this layer.
double interpolateAngle(double distance) const
Returns the angle parallel to the linestring or polygon boundary at the specified distance along the ...
Curve polygon geometry type.
bool vertexIdFromVertexNr(int number, QgsVertexId &id) const
Calculates the vertex ID from a vertex number.
QgsGeometry intersection(const QgsGeometry &geometry) const
Returns a geometry representing the points shared by this geometry and other.
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.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
Handles the array_foreach(array, expression) expression function.
QgsLayerMetadata metadata
QVector< QgsPointXY > QgsMultiPointXY
A collection of QgsPoints that share a common collection of attributes.
QString name() const
The name of the column.
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...
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.
QString dataUrl() const
Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
QString name() const
The name of the function.
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.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QVariant aggregate(QgsAggregateCalculator::Aggregate aggregate, const QString &fieldOrExpression, const QgsAggregateCalculator::AggregateParameters ¶meters=QgsAggregateCalculator::AggregateParameters(), QgsExpressionContext *context=nullptr, bool *ok=nullptr) const
Calculates an aggregated value from the layer's features.
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...
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
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.
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...
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.
static QString soundex(const QString &string)
Returns the Soundex representation of a string.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
QList< QgsGradientStop > QgsGradientStopsList
List of gradient stops.
static QgsStyle * defaultStyle()
Returns default application-wide style.
QVariant variable(const QString &name) const
Fetches a matching variable from the context.
QgsExpressionNode::NodeList * args() const
Returns a list of arguments specified for the function.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
const QgsColorRamp * colorRampRef(const QString &name) const
Returns a const pointer to a symbol (doesn't create new instance)
void setEvalErrorString(const QString &str)
Sets evaluation error (used internally by evaluation functions)
bool contains(const QgsPointXY *p) const
Tests for containment of a point (uses GEOS)
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 variableWidthBufferByM(int segments) const
Calculates a variable width buffer for a (multi)linestring geometry, where the width at each node is ...
double days() const
Returns the interval duration in days.
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...
bool disjoint(const QgsGeometry &geometry) const
Tests for if geometry is disjoint of another (uses GEOS)
#define ENSURE_NO_EVAL_ERROR
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.
bool touches(const QgsGeometry &geometry) const
Test for if geometry touch another (uses GEOS)
CORE_EXPORT QString build(const QVariantMap &map)
Build a hstore-formatted string from a QVariantMap.
QgsRasterDataProvider * dataProvider() override
Returns the layer's data provider.
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...
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
The RasterBandStats struct is a container for statistics about a single raster band.
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.
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
QgsGeometry taperedBuffer(double startWidth, double endWidth, int segments) const
Calculates a variable width buffer ("tapered buffer") for a (multi)curve geometry.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
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...
int bandCount() const
Returns the number of bands in this layer.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
double hours() const
Returns the interval duration in hours.
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.
virtual QgsRectangle extent() const
Returns the extent of the layer.
Q_INVOKABLE QgsRelation relation(const QString &id) const
Gets access to a relation by its id.
virtual QSet< QString > referencedVariables() const =0
Returns a set of all variables which are used in this expression.
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 hasCachedValue(const QString &key) const
Returns true if the expression context contains a cached value with a matching key.
double convertAreaMeasurement(double area, QgsUnitTypes::AreaUnit toUnits) const
Takes an area measurement calculated by this QgsDistanceArea object and converts it to a different ar...
bool prepare(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const override
This will be called during the prepare step() of an expression if it is not static.
bool overlaps(const QgsGeometry &geometry) const
Test for if geometry overlaps another (uses GEOS)
Minimum length of string (string fields only)
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
static QString geometryDisplayString(GeometryType type)
Returns a display string for a geometry type.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
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).
QgsFields fields() const
Convenience function for retrieving the fields for the context, if set.
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 *)
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 difference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
QgsFeature feature() const
Convenience function for retrieving the feature for the context, if set.
An expression node which takes it value from a feature's field.
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...
double measurePerimeter(const QgsGeometry &geometry) const
Measures the perimeter of a polygon geometry.
static const QString ALL_ATTRIBUTES
A special attribute that if set matches all attributes.
double weeks() const
Returns the interval duration in weeks.
void setCachedValue(const QString &key, const QVariant &value) const
Sets a value to cache within the expression context.
long featureCount(const QString &legendKey) const
Number of features rendered with specified legend key.
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
QString attributionUrl() const
Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request.
ConstructionOption
A regular polygon can be constructed inscribed in a circle or circumscribed about a circle...
virtual bool isClosed() const
Returns true if the curve is closed.
QString abstract() const
Returns the abstract of the layer used by QGIS Server in GetCapabilities request. ...
QgsVectorLayer referencedLayer
Abstract base class for all nodes that can appear in an expression.
Abstract base class for curved geometry type.
Create a multipart geometry from aggregated geometries.
int numGeometries() const
Returns the number of geometries within the collection.
const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
QgsUnitTypes::AreaUnit areaUnits() const
Returns the desired areal units for calculations involving geomCalculator(), e.g., "$area".
bool lazyEval() const
True if this function should use lazy evaluation.
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
Single scope for storing variables and functions for use within a QgsExpressionContext.
bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
Abstract base class for all geometries.
An expression node for expression functions.
Contains information about the context in which a coordinate transform is executed.
const QString helpText() const
The help text for the function.
QgsRelationManager relationManager
static int levenshteinDistance(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the Levenshtein edit distance between two strings.
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.
double seconds() const
Returns the interval duration in seconds.
Implementation of GeometrySimplifier using the "MapToPixel" algorithm.
static const QList< QgsExpressionFunction * > & Functions()
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.
Majority of values (numeric fields only)
double minimumScale() const
Returns the minimum map scale (i.e.
QgsUnitTypes::DistanceUnit distanceUnits() const
Returns the desired distance units for calculations involving geomCalculator(), e.g., "$length" and "$perimeter".
int params() const
The number of parameters this function takes.
virtual bool isDeprecated() const
Returns true if the function is deprecated and should not be presented as a valid option to users in ...
QgsGeometry extrude(double x, double y)
Returns an extruded version of this geometry.
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.
QgsGeometry convexHull() const
Returns the smallest convex polygon that contains all the points in the 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.
uint qHash(const QVariant &variant)
Hash for QVariant.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine.
Number of distinct values.
QgsArrayForeachExpressionFunction()
double length() const
Returns the length of geometry using GEOS.
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.
QVector< QgsPoint > QgsPointSequence
QList< QgsMapLayer * > mapLayersByName(const QString &layerName) const
Retrieve a list of matching registered layers by layer name.
double minutes() const
Returns the interval duration in minutes.
QgsCurve * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
QgsGeometry simplify(double tolerance) const
Returns a simplified version of this geometry using a specified tolerance value.
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...
QgsGeometry minimalEnclosingCircle(QgsPointXY ¢er, double &radius, unsigned int segments=36) const
Returns the minimal enclosing circle for the geometry.
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.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
bool crosses(const QgsGeometry &geometry) const
Test for if geometry crosses another (uses GEOS)
static void registerContextFunctions()
Registers all known core functions provided by QgsExpressionContextScope objects. ...
Maximum length of string (string fields only)
QVariant value() const
The value of the literal.
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.
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...
QString asWkt(int precision=17) const
Exports the geometry to WKT.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QgsGeometry shortestLine(const QgsGeometry &other) const
Returns the shortest line joining this geometry to another geometry.
An expression node for literal values.
Mean of values (numeric fields only)
QgsGeometry nearestPoint(const QgsGeometry &other) const
Returns the nearest point on this geometry to another geometry.
virtual QgsPolygon * toPolygon(unsigned int segments=36) const
Returns a segmented polygon.
c++ helper class for defining QgsExpression functions.
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
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.
QgsPolygon * toPolygon() const
Returns as a polygon.
void setIsStaticFunction(const std::function< bool(const QgsExpressionNodeFunction *, QgsExpression *, const QgsExpressionContext *) > &isStatic)
Set a function that will be called in the prepare step to determine if the function is static or not...
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QgsFeatureRequest & setTimeout(int timeout)
Sets the timeout (in milliseconds) for the maximum time we should wait during feature requests before...
const QgsExpressionFunction::ParameterList & parameters() const
Returns the list of named parameters for the function, if set.
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.
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
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.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
Concatenate values with a joining string (string fields only). Specify the delimiter using setDelimit...
bool usesGeometry(const QgsExpressionNodeFunction *node) const override
Does this function use a geometry object.
This class represents a coordinate reference system (CRS).
QVariant run(QgsExpressionNode::NodeList *args, const QgsExpressionContext *context, QgsExpression *parent, const QgsExpressionNodeFunction *node) override
Evaluates the function, first evaluating all required arguments before passing them to the function's...
bool operator==(const QgsExpressionFunction &other) const
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
double hausdorffDistance(const QgsGeometry &geom) const
Returns the Hausdorff distance between this geometry and geom.
double range
The range is the distance between min & max.
QgsGeometry symDifference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...
QgsGeometry combine(const QgsGeometry &geometry) const
Returns a geometry representing all the points in this geometry and other (a union geometry operation...
QgsFeatureRequest & setLimit(long limit)
Set the maximum number of features to request.
QString authid() const
Returns the authority identifier for the CRS.
void setIsStatic(bool isStatic)
Tag this function as either static or not static.
static QString quotedString(QString text)
Returns a quoted version of a string (in single quotes)
const QgsExpressionNode * rootNode() const
Returns root node of the expression. Root node is null is parsing has failed.
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.
double minimumValue
The minimum cell value in the raster band.
static QString helpText(QString name)
Returns the help text for a specified function.
double lineLocatePoint(const QgsGeometry &point) const
Returns a distance representing the location along this linestring of the closest point on this lines...
QgsMultiPointXY asMultiPoint() const
Returns contents of the geometry as a multi point if wkbType is WKBMultiPoint, otherwise an empty lis...
OperationResult translate(double dx, double dy, double dz=0.0, double dm=0.0)
Translates this geometry by dx, dy, dz and dm.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
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.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
Represents a single parameter passed to a function.
QString description() const
Returns the descriptive name of the CRS, e.g., "WGS 84" or "GDA 94 / Vicgrid94".
bool within(const QgsGeometry &geometry) const
Test for if geometry is within another (uses GEOS)
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.
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)
QString keywordList() const
Returns the keyword list of the layer used by QGIS Server in GetCapabilities request.
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)
int count() const
Returns the number of nodes in the list.
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.
double width() const
Returns the width of the rectangle.
virtual QSet< QString > referencedColumns(const QgsExpressionNodeFunction *node) const
Returns a set of field names which are required for this function.
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 ...
Represents a vector layer which manages a vector based data sets.
QString attribution() const
Returns the attribution of the layer used by QGIS Server in GetCapabilities request.
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.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
virtual bool usesGeometry(const QgsExpressionNodeFunction *node) const
Does this function use a geometry object.
QgsWkbTypes::GeometryType type() const
Returns type of the geometry as a QgsWkbTypes::GeometryType.
double distanceToVertex(int vertex) const
Returns the distance along this geometry from its first vertex to the specified vertex.
Range of values (max - min) (numeric and datetime fields only)
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...
bool isEmpty() const override
Returns true if the geometry is empty.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
QgsGeometry mergeLines() const
Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line ...
double measureArea(const QgsGeometry &geometry) const
Measures the area of a geometry.
virtual bool isStatic(const QgsExpressionNodeFunction *node, QgsExpression *parent, const QgsExpressionContext *context) const
Will be called during prepare to determine if the function is static.
double area() const
Returns the area of the geometry using GEOS.
QgsCoordinateReferenceSystem crs
Sample standard deviation of values (numeric fields only)
Aggregate
Available aggregates to calculate.
static int hammingDistance(const QString &string1, const QString &string2, bool caseSensitive=false)
Returns the Hamming distance between two strings.
static QColor decodeColor(const QString &str)
Represents a list of OrderByClauses, with the most important first and the least important last...
virtual int partCount() const =0
Returns count of parts contained in the geometry.
virtual bool addGeometry(QgsAbstractGeometry *g)
Adds a geometry and takes ownership. Returns true in case of success.
double height() const
Returns the height of the rectangle.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
#define FEAT_FROM_CONTEXT(c, f)
QString toProj4() const
Returns a Proj4 string representation of this CRS.
A bundle of parameters controlling aggregate calculation.
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.