265 return QList< int >();
267 QList< int > resultList;
268 const QVariant val = value;
271 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
273 else if ( val.type() == QVariant::List )
275 const QVariantList list = val.toList();
276 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
277 resultList << it->toInt();
281 const QStringList parts = val.toString().split(
';' );
282 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
283 resultList << it->toInt();
287 if ( resultList.isEmpty() )
292 if ( definition->
defaultValue().type() == QVariant::List )
294 const QVariantList list = definition->
defaultValue().toList();
295 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
296 resultList << it->toInt();
300 const QStringList parts = definition->
defaultValue().toString().split(
';' );
301 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
302 resultList << it->toInt();
462 QVariantList resultList;
463 const QVariant val = value;
464 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
466 else if ( val.type() == QVariant::List )
468 const auto constToList = val.toList();
469 for (
const QVariant &var : constToList )
472 else if ( val.type() == QVariant::String )
474 const auto constSplit = val.toString().split(
',' );
475 for (
const QString &var : constSplit )
481 if ( resultList.isEmpty() )
482 return QList< int >();
484 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
488 if ( definition->
defaultValue().type() == QVariant::List )
490 const auto constToList = definition->
defaultValue().toList();
491 for (
const QVariant &var : constToList )
494 else if ( definition->
defaultValue().type() == QVariant::String )
496 const auto constSplit = definition->
defaultValue().toString().split(
',' );
497 for (
const QString &var : constSplit )
506 const auto constResultList = resultList;
507 for (
const QVariant &var : constResultList )
509 const int resInt = var.toInt();
510 if ( !enumDef || resInt < enumDef->options().size() )
550 return QStringList();
552 const QVariant val = value;
554 QStringList enumValues;
556 std::function< void(
const QVariant &var ) > processVariant;
557 processVariant = [ &enumValues, &context, &definition, &processVariant ](
const QVariant & var )
559 if ( var.type() == QVariant::List )
561 const auto constToList = var.toList();
562 for (
const QVariant &listVar : constToList )
564 processVariant( listVar );
567 else if ( var.type() == QVariant::StringList )
569 const auto constToStringList = var.toStringList();
570 for (
const QString &s : constToStringList )
575 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
579 const QStringList parts = var.toString().split(
',' );
580 for (
const QString &s : parts )
587 processVariant( val );
593 const QStringList options = enumDef->
options();
594 const QSet<QString> subtraction = QSet<QString>( enumValues.begin(), enumValues.end() ).subtract( QSet<QString>( options.begin(), options.end() ) );
596 if ( enumValues.isEmpty() || !subtraction.isEmpty() )
668QgsFeatureSink *
QgsProcessingParameters::parameterAsSink(
const QgsProcessingParameterDefinition *definition,
const QVariant &value,
const QgsFields &fields,
Qgis::WkbType geometryType,
const QgsCoordinateReferenceSystem &
crs,
QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
670 QVariantMap options = createOptions;
671 QVariant val = value;
676 bool useRemapDefinition =
false;
677 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
688 useRemapDefinition =
true;
694 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
698 else if ( !val.isValid() || val.toString().isEmpty() )
714 dest = val.toString();
719 dest = destParam->generateTemporaryDestination( &context );
722 if ( dest.isEmpty() )
725 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType,
crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition : nullptr ) );
726 destinationIdentifier = dest;
728 if ( destinationProject )
730 if ( destName.isEmpty() && definition )
736 outputName = definition->
name();
740 return sink.release();
764 QVariant val = parameters.value( definition->
name() );
766 bool selectedFeaturesOnly =
false;
767 long long featureLimit = -1;
768 QString filterExpression;
769 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
778 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
785 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
791 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
796 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
800 else if ( !val.isValid() || val.toString().isEmpty() )
806 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
812 layerRef = val.toString();
817 if ( layerRef.isEmpty() )
829 compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit, filterExpression );
832 compatibleFormats, preferredFormat, context, feedback, featureLimit, filterExpression );
1083 QVariant val = value;
1085 if ( val.userType() == QMetaType::type(
"QgsRectangle" ) )
1089 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1095 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1114 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1120 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1133 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1136 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1139 rectText = val.toString();
1141 if ( rectText.isEmpty() && !layer )
1144 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1145 const QRegularExpressionMatch match = rx.match( rectText );
1146 if ( match.hasMatch() )
1148 bool xMinOk =
false;
1149 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1150 bool xMaxOk =
false;
1151 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1152 bool yMinOk =
false;
1153 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1154 bool yMaxOk =
false;
1155 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1156 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1207 QVariant val = parameters.value( definition->
name() );
1209 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1215 g = g.densifyByCount( 20 );
1229 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1235 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1248 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1251 rectText = val.toString();
1253 if ( !rectText.isEmpty() )
1255 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1256 const QRegularExpressionMatch match = rx.match( rectText );
1257 if ( match.hasMatch() )
1259 bool xMinOk =
false;
1260 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1261 bool xMaxOk =
false;
1262 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1263 bool yMinOk =
false;
1264 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1265 bool yMaxOk =
false;
1266 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1267 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1293 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1328 QVariant val = value;
1329 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1338 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1344 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1356 QString valueAsString;
1357 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1360 valueAsString = val.toString();
1362 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1364 const QRegularExpressionMatch match = rx.match( valueAsString );
1365 if ( match.hasMatch() )
1372 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1378 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1391 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1392 return layer->crs();
1394 return layer->crs();
1396 if (
auto *lProject = context.
project() )
1397 return lProject->crs();
1770 return QList<QgsMapLayer *>();
1772 const QVariant val = value;
1773 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1775 return QList<QgsMapLayer *>() << layer;
1778 QList<QgsMapLayer *> layers;
1780 std::function< void(
const QVariant &var ) > processVariant;
1781 processVariant = [ &layers, &context, &definition, flags, &processVariant](
const QVariant & var )
1783 if ( var.type() == QVariant::List )
1785 const auto constToList = var.toList();
1786 for (
const QVariant &listVar : constToList )
1788 processVariant( listVar );
1791 else if ( var.type() == QVariant::StringList )
1793 const auto constToStringList = var.toStringList();
1794 for (
const QString &s : constToStringList )
1796 processVariant( s );
1799 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
1801 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1805 const QVariant sink = fromVar.
sink;
1806 if ( sink.userType() == QMetaType::type(
"QgsProperty" ) )
1811 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1823 processVariant( val );
1825 if ( layers.isEmpty() )
1828 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->
defaultValue() ) ) )
1832 else if ( definition->
defaultValue().type() == QVariant::List )
1834 const auto constToList = definition->
defaultValue().toList();
1835 for (
const QVariant &var : constToList )
1837 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1843 processVariant( var );
1919 return QList<double>();
1921 QStringList resultStringList;
1922 const QVariant val = value;
1924 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1926 else if ( val.type() == QVariant::List )
1928 const auto constToList = val.toList();
1929 for (
const QVariant &var : constToList )
1930 resultStringList << var.toString();
1933 resultStringList << val.toString();
1935 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1937 resultStringList.clear();
1939 if ( definition->
defaultValue().type() == QVariant::List )
1941 const auto constToList = definition->
defaultValue().toList();
1942 for (
const QVariant &var : constToList )
1943 resultStringList << var.toString();
1946 resultStringList << definition->
defaultValue().toString();
1949 if ( resultStringList.size() == 1 )
1951 resultStringList = resultStringList.at( 0 ).split(
',' );
1954 if ( resultStringList.size() < 2 )
1955 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1957 QList< double > result;
1959 double n = resultStringList.at( 0 ).toDouble( &ok );
1963 result << std::numeric_limits<double>::quiet_NaN() ;
1965 n = resultStringList.at( 1 ).toDouble( &ok );
1969 result << std::numeric_limits<double>::quiet_NaN() ;
1998 return QStringList();
2000 QStringList resultStringList;
2001 const QVariant val = value;
2002 if ( val.isValid() )
2004 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
2006 else if ( val.type() == QVariant::List )
2008 const auto constToList = val.toList();
2009 for (
const QVariant &var : constToList )
2010 resultStringList << var.toString();
2012 else if ( val.type() == QVariant::StringList )
2014 resultStringList = val.toStringList();
2017 resultStringList.append( val.toString().split(
';' ) );
2020 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
2022 resultStringList.clear();
2026 if ( definition->
defaultValue().type() == QVariant::List )
2028 const auto constToList = definition->
defaultValue().toList();
2029 for (
const QVariant &var : constToList )
2030 resultStringList << var.toString();
2032 else if ( definition->
defaultValue().type() == QVariant::StringList )
2034 resultStringList = definition->
defaultValue().toStringList();
2037 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
2041 return resultStringList;
2306 bool isOptional =
false;
2310 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2315 if ( type == QLatin1String(
"boolean" ) )
2317 else if ( type == QLatin1String(
"crs" ) )
2319 else if ( type == QLatin1String(
"layer" ) )
2321 else if ( type == QLatin1String(
"extent" ) )
2323 else if ( type == QLatin1String(
"point" ) )
2325 else if ( type == QLatin1String(
"geometry" ) )
2327 else if ( type == QLatin1String(
"file" ) )
2329 else if ( type == QLatin1String(
"folder" ) )
2331 else if ( type == QLatin1String(
"matrix" ) )
2333 else if ( type == QLatin1String(
"multiple" ) )
2335 else if ( type == QLatin1String(
"number" ) )
2337 else if ( type == QLatin1String(
"distance" ) )
2339 else if ( type == QLatin1String(
"duration" ) )
2341 else if ( type == QLatin1String(
"scale" ) )
2343 else if ( type == QLatin1String(
"range" ) )
2345 else if ( type == QLatin1String(
"raster" ) )
2347 else if ( type == QLatin1String(
"enum" ) )
2349 else if ( type == QLatin1String(
"string" ) )
2351 else if ( type == QLatin1String(
"authcfg" ) )
2353 else if ( type == QLatin1String(
"expression" ) )
2355 else if ( type == QLatin1String(
"field" ) )
2357 else if ( type == QLatin1String(
"vector" ) )
2359 else if ( type == QLatin1String(
"source" ) )
2361 else if ( type == QLatin1String(
"sink" ) )
2363 else if ( type == QLatin1String(
"vectordestination" ) )
2365 else if ( type == QLatin1String(
"rasterdestination" ) )
2367 else if ( type == QLatin1String(
"pointclouddestination" ) )
2369 else if ( type == QLatin1String(
"filedestination" ) )
2371 else if ( type == QLatin1String(
"folderdestination" ) )
2373 else if ( type == QLatin1String(
"band" ) )
2375 else if ( type == QLatin1String(
"mesh" ) )
2377 else if ( type == QLatin1String(
"layout" ) )
2379 else if ( type == QLatin1String(
"layoutitem" ) )
2381 else if ( type == QLatin1String(
"color" ) )
2383 else if ( type == QLatin1String(
"coordinateoperation" ) )
2385 else if ( type == QLatin1String(
"maptheme" ) )
2387 else if ( type == QLatin1String(
"datetime" ) )
2389 else if ( type == QLatin1String(
"providerconnection" ) )
2391 else if ( type == QLatin1String(
"databaseschema" ) )
2393 else if ( type == QLatin1String(
"databasetable" ) )
2395 else if ( type == QLatin1String(
"pointcloud" ) )
2397 else if ( type == QLatin1String(
"annotation" ) )
2399 else if ( type == QLatin1String(
"attribute" ) )
2401 else if ( type == QLatin1String(
"vectortiledestination" ) )
2519 if ( !value.isValid() )
2523 if ( value.type() == QVariant::Type::Map )
2525 const QVariantMap sourceMap = value.toMap();
2526 QVariantMap resultMap;
2527 for (
auto it = sourceMap.constBegin(); it != sourceMap.constEnd(); it++ )
2533 else if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList )
2535 const QVariantList sourceList = value.toList();
2536 QVariantList resultList;
2537 resultList.reserve( sourceList.size() );
2538 for (
const QVariant &v : sourceList )
2546 switch ( value.userType() )
2549 case QMetaType::Bool:
2550 case QMetaType::Char:
2551 case QMetaType::Int:
2552 case QMetaType::Double:
2553 case QMetaType::Float:
2554 case QMetaType::LongLong:
2555 case QMetaType::ULongLong:
2556 case QMetaType::UInt:
2557 case QMetaType::ULong:
2558 case QMetaType::UShort:
2565 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2575 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"field" ), prop.
field() }} );
2577 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"expression" ), prop.
expressionString() }} );
2582 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2592 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2600 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2609 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2621 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2636 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2642 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2649 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2656 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2661 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2663 const QColor fromVar = value.value< QColor >();
2664 if ( !fromVar.isValid() )
2667 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2669 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2671 const QDateTime fromVar = value.toDateTime();
2672 if ( !fromVar.isValid() )
2675 return fromVar.toString( Qt::ISODate );
2677 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2679 const QDate fromVar = value.toDate();
2680 if ( !fromVar.isValid() )
2683 return fromVar.toString( Qt::ISODate );
2685 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2687 const QTime fromVar = value.toTime();
2688 if ( !fromVar.isValid() )
2691 return fromVar.toString( Qt::ISODate );
2698 p.insert(
name(), value );
2702 if ( !source.isEmpty() )
2709 if ( value.userType() == QMetaType::QString )
2714 Q_ASSERT_X(
false,
"QgsProcessingParameterDefinition::valueAsJsonObject", QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ).toLocal8Bit() );
2727 if ( !value.isValid() )
2730 switch ( value.userType() )
2733 case QMetaType::Bool:
2734 case QMetaType::Char:
2735 case QMetaType::Int:
2736 case QMetaType::Double:
2737 case QMetaType::Float:
2738 case QMetaType::LongLong:
2739 case QMetaType::ULongLong:
2740 case QMetaType::UInt:
2741 case QMetaType::ULong:
2742 case QMetaType::UShort:
2743 return value.toString();
2749 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2759 return QStringLiteral(
"field:%1" ).arg( prop.
field() );
2766 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2776 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2784 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2792 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2804 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2819 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2825 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2832 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2837 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2842 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2844 const QColor fromVar = value.value< QColor >();
2845 if ( !fromVar.isValid() )
2848 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2850 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2852 const QDateTime fromVar = value.toDateTime();
2853 if ( !fromVar.isValid() )
2856 return fromVar.toString( Qt::ISODate );
2858 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2860 const QDate fromVar = value.toDate();
2861 if ( !fromVar.isValid() )
2864 return fromVar.toString( Qt::ISODate );
2866 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2868 const QTime fromVar = value.toTime();
2869 if ( !fromVar.isValid() )
2872 return fromVar.toString( Qt::ISODate );
2879 p.insert(
name(), value );
2883 if ( !source.isEmpty() )
2890 if ( value.userType() == QMetaType::QString )
2891 return value.toString();
2894 QgsDebugError( QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ) );
2896 return value.toString();
3214 for (
const QString &raster : rasters )
3216 if ( !vectors.contains( raster ) )
3220 for (
const QString &mesh : meshFilters )
3222 if ( !vectors.contains( mesh ) )
3226 for (
const QString &pointCloud : pointCloudFilters )
3228 if ( !vectors.contains( pointCloud ) )
3229 vectors << pointCloud;
3231 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
3232 std::sort( vectors.begin(), vectors.end() );
3234 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QLatin1String(
";;" ) );
3298 QString def = definition;
3301 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
3304 def = def.mid( 12 );
3307 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
3313 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
3319 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
3325 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
3331 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
3337 else if ( def.startsWith( QLatin1String(
"plugin" ), Qt::CaseInsensitive ) )
3343 else if ( def.startsWith( QLatin1String(
"pointcloud" ), Qt::CaseInsensitive ) )
3346 def = def.mid( 11 );
3349 else if ( def.startsWith( QLatin1String(
"annotation" ), Qt::CaseInsensitive ) )
3352 def = def.mid( 11 );
3432 if ( !input.isValid() )
3440 if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3444 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3449 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3454 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3459 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3463 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3470 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3473 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3482 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
3483 const QRegularExpressionMatch match = rx.match( input.toString() );
3484 if ( match.hasMatch() )
3486 bool xMinOk =
false;
3487 ( void )match.captured( 1 ).toDouble( &xMinOk );
3488 bool xMaxOk =
false;
3489 ( void )match.captured( 2 ).toDouble( &xMaxOk );
3490 bool yMinOk =
false;
3491 ( void )match.captured( 3 ).toDouble( &yMinOk );
3492 bool yMaxOk =
false;
3493 ( void )match.captured( 4 ).toDouble( &yMaxOk );
3494 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
3677 if ( !input.isValid() )
3685 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3692 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3694 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( input.value<
QgsGeometry>().
type() ) ) ) &&
3695 ( mAllowMultipart || !input.value<
QgsGeometry>().isMultipart() );
3698 if ( input.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3704 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3709 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3714 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3719 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3724 if ( input.type() == QVariant::String )
3726 if ( input.toString().isEmpty() )
3731 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3733 const QRegularExpressionMatch match = rx.match( input.toString() );
3734 if ( match.hasMatch() )
3739 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( g.
type() ) ) ) && ( mAllowMultipart || !g.
isMultipart() );
4239 if ( !input.isValid() )
4249 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
4255 if ( input.type() == QVariant::String )
4257 if ( input.toString().isEmpty() )
4260 if ( mMinimumNumberInputs > 1 )
4271 else if ( input.type() == QVariant::List )
4273 if ( input.toList().count() < mMinimumNumberInputs )
4276 if ( mMinimumNumberInputs > input.toList().count() )
4284 const auto constToList = input.toList();
4285 for (
const QVariant &v : constToList )
4287 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
4296 else if ( input.type() == QVariant::StringList )
4298 if ( input.toStringList().count() < mMinimumNumberInputs )
4301 if ( mMinimumNumberInputs > input.toStringList().count() )
4309 const auto constToStringList = input.toStringList();
4310 for (
const QString &v : constToStringList )
4906 QVariant input = value;
4907 if ( !input.isValid() )
4915 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4920 if ( mUsesStaticStrings )
4922 if ( input.type() == QVariant::List )
4924 if ( !mAllowMultiple )
4927 const QVariantList values = input.toList();
4931 for (
const QVariant &val : values )
4933 if ( !mOptions.contains( val.toString() ) )
4939 else if ( input.type() == QVariant::StringList )
4941 if ( !mAllowMultiple )
4944 const QStringList values = input.toStringList();
4949 if ( values.count() > 1 && !mAllowMultiple )
4952 for (
const QString &val : values )
4954 if ( !mOptions.contains( val ) )
4959 else if ( input.type() == QVariant::String )
4961 const QStringList parts = input.toString().split(
',' );
4962 if ( parts.count() > 1 && !mAllowMultiple )
4965 const auto constParts = parts;
4966 for (
const QString &part : constParts )
4968 if ( !mOptions.contains( part ) )
4976 if ( input.type() == QVariant::List )
4978 if ( !mAllowMultiple )
4981 const QVariantList values = input.toList();
4985 for (
const QVariant &val : values )
4988 const int res = val.toInt( &ok );
4991 else if ( res < 0 || res >= mOptions.count() )
4997 else if ( input.type() == QVariant::String )
4999 const QStringList parts = input.toString().split(
',' );
5000 if ( parts.count() > 1 && !mAllowMultiple )
5003 const auto constParts = parts;
5004 for (
const QString &part : constParts )
5007 const int res = part.toInt( &ok );
5010 else if ( res < 0 || res >= mOptions.count() )
5015 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
5018 const int res = input.toInt( &ok );
5021 else if ( res >= 0 && res < mOptions.count() )