48#include <QRegularExpression>
51using namespace Qt::StringLiterals;
56 map.insert( u
"source"_s,
source.toVariant() );
60 map.insert( u
"flags"_s,
static_cast< int >(
flags ) );
61 map.insert( u
"geometry_check"_s,
static_cast< int >(
geometryCheck ) );
67 source.loadVariant( map.value( u
"source"_s ) );
69 featureLimit = map.value( u
"feature_limit"_s, -1 ).toLongLong();
83 map.insert( u
"source"_s,
source.toVariant() );
85 map.insert( u
"dpi"_s,
dpi );
91 source.loadVariant( map.value( u
"source"_s ) );
93 dpi = map.value( u
"dpi"_s, 0 ).toInt();
104 mUseRemapping =
true;
105 mRemappingDefinition = definition;
111 map.insert( u
"sink"_s,
sink.toVariant() );
114 map.insert( u
"remapping"_s, QVariant::fromValue( mRemappingDefinition ) );
120 sink.loadVariant( map.value( u
"sink"_s ) );
122 if ( map.contains( u
"remapping"_s ) )
124 mUseRemapping =
true;
129 mUseRemapping =
false;
137 && mUseRemapping == other.mUseRemapping && mRemappingDefinition == other.mRemappingDefinition;
142 return !( *
this == other );
147 const QVariant val = parameters.value( name );
148 if ( val.userType() == qMetaTypeId<QgsProperty>() )
167 QVariant val = value;
168 if ( val.userType() == qMetaTypeId<QgsProperty>() )
171 if ( !val.isValid() )
180 return destParam->generateTemporaryDestination( &context );
183 return val.toString();
199 const QVariant val = value;
200 if ( val.userType() == qMetaTypeId<QgsProperty>() )
203 if ( val.isValid() && !val.toString().isEmpty() )
207 return val.toString();
227 QVariant val = value;
228 if ( val.userType() == qMetaTypeId<QgsProperty>() )
232 const double res = val.toDouble( &ok );
238 return val.toDouble();
254 QVariant val = value;
255 if ( val.userType() == qMetaTypeId<QgsProperty>() )
259 double dbl = val.toDouble( &ok );
264 dbl = val.toDouble( &ok );
271 const double round = std::round( dbl );
272 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
277 return static_cast< int >( std::round( dbl ) );
286 return QList< int >();
294 return QList< int >();
296 QList< int > resultList;
297 const QVariant val = value;
300 if ( val.userType() == qMetaTypeId<QgsProperty>() )
302 else if ( val.userType() == QMetaType::Type::QVariantList )
304 const QVariantList list = val.toList();
305 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
306 resultList << it->toInt();
310 const QStringList parts = val.toString().split(
';' );
311 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
312 resultList << it->toInt();
316 if ( resultList.isEmpty() )
321 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
323 const QVariantList list = definition->
defaultValue().toList();
324 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
325 resultList << it->toInt();
329 const QStringList parts = definition->
defaultValue().toString().split(
';' );
330 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
331 resultList << it->toInt();
352 QVariant val = value;
353 if ( val.userType() == qMetaTypeId<QgsProperty>() )
356 QDateTime d = val.toDateTime();
357 if ( !d.isValid() && val.userType() == QMetaType::Type::QString )
359 d = QDateTime::fromString( val.toString() );
366 d = val.toDateTime();
368 if ( !d.isValid() && val.userType() == QMetaType::Type::QString )
370 d = QDateTime::fromString( val.toString() );
389 QVariant val = value;
390 if ( val.userType() == qMetaTypeId<QgsProperty>() )
393 QDate d = val.toDate();
394 if ( !d.isValid() && val.userType() == QMetaType::Type::QString )
396 d = QDate::fromString( val.toString() );
405 if ( !d.isValid() && val.userType() == QMetaType::Type::QString )
407 d = QDate::fromString( val.toString() );
426 QVariant val = value;
427 if ( val.userType() == qMetaTypeId<QgsProperty>() )
432 if ( val.userType() == QMetaType::Type::QDateTime )
433 d = val.toDateTime().time();
437 if ( !d.isValid() && val.userType() == QMetaType::Type::QString )
439 d = QTime::fromString( val.toString() );
448 if ( !d.isValid() && val.userType() == QMetaType::Type::QString )
450 d = QTime::fromString( val.toString() );
471 if ( enumDef && val >= enumDef->
options().size() )
491 QVariantList resultList;
492 const QVariant val = value;
493 if ( val.userType() == qMetaTypeId<QgsProperty>() )
495 else if ( val.userType() == QMetaType::Type::QVariantList )
497 const auto constToList = val.toList();
498 for (
const QVariant &var : constToList )
501 else if ( val.userType() == QMetaType::Type::QString )
503 const auto constSplit = val.toString().split(
',' );
504 for (
const QString &var : constSplit )
510 if ( resultList.isEmpty() )
511 return QList< int >();
513 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
517 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
519 const auto constToList = definition->
defaultValue().toList();
520 for (
const QVariant &var : constToList )
523 else if ( definition->
defaultValue().userType() == QMetaType::Type::QString )
525 const auto constSplit = definition->
defaultValue().toString().split(
',' );
526 for (
const QString &var : constSplit )
535 const auto constResultList = resultList;
536 for (
const QVariant &var : constResultList )
538 const int resInt = var.toInt();
539 if ( !enumDef || resInt < enumDef->options().size() )
563 enumText.isEmpty() || !enumDef->options().contains( enumText )
576 return QStringList();
584 return QStringList();
586 const QVariant val = value;
588 QStringList enumValues;
590 std::function< void(
const QVariant &var ) > processVariant;
591 processVariant = [ &enumValues, &context, &definition, &processVariant ](
const QVariant & var )
593 if ( var.userType() == QMetaType::Type::QVariantList )
595 const auto constToList = var.toList();
596 for (
const QVariant &listVar : constToList )
598 processVariant( listVar );
601 else if ( var.userType() == QMetaType::Type::QStringList )
603 const auto constToStringList = var.toStringList();
604 for (
const QString &s : constToStringList )
609 else if ( var.userType() == qMetaTypeId<QgsProperty>() )
613 const QStringList parts = var.toString().split(
',' );
614 for (
const QString &s : parts )
621 processVariant( val );
628 const QStringList options = enumDef->options();
629 const QSet<QString> subtraction = QSet<QString>( enumValues.begin(), enumValues.end() ).subtract( QSet<QString>( options.begin(), options.end() ) );
631 if ( enumValues.isEmpty() || !subtraction.isEmpty() )
665 const QVariant val = value;
666 if ( val.userType() == qMetaTypeId<QgsProperty>() )
668 else if ( val.isValid() )
681 const QVariant val = value;
682 if ( val.userType() == qMetaTypeId<QgsProperty>() )
684 else if ( val.isValid() )
693 const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
698 val = parameters.value( definition->
name() );
701 return parameterAsSink( definition, val, fields, geometryType, crs, context, destinationIdentifier, sinkFlags, createOptions, datasourceOptions, layerOptions );
704QgsFeatureSink *
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 )
706 QVariantMap options = createOptions;
707 QVariant val = value;
712 bool useRemapDefinition =
false;
713 if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
724 useRemapDefinition =
true;
730 if ( definition && val.userType() == qMetaTypeId<QgsProperty>() )
734 else if ( !val.isValid() || val.toString().isEmpty() )
750 dest = val.toString();
755 dest = destParam->generateTemporaryDestination( &context );
758 if ( dest.isEmpty() )
761 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType, crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition :
nullptr ) );
762 destinationIdentifier = dest;
764 if ( destinationProject )
766 if ( destName.isEmpty() && definition )
772 outputName = definition->
name();
776 return sink.release();
800 QVariant val = parameters.value( definition->
name() );
802 bool selectedFeaturesOnly =
false;
803 long long featureLimit = -1;
804 QString filterExpression;
805 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
814 else if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
821 if ( val.userType() == qMetaTypeId<QgsProperty>() )
827 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
832 if ( val.userType() == qMetaTypeId<QgsProperty>() )
836 else if ( !val.isValid() || val.toString().isEmpty() )
842 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
848 layerRef = val.toString();
853 if ( layerRef.isEmpty() )
865 compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit, filterExpression );
868 compatibleFormats, preferredFormat, context, feedback, featureLimit, filterExpression );
878 QString *destLayer = layerName;
893 return parameterAsLayer( definition, parameters.value( definition->
name() ), context, layerHint, flags );
901 QVariant val = value;
902 if ( val.userType() == qMetaTypeId<QgsProperty>() )
907 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
912 if ( val.userType() == qMetaTypeId<QgsProcessingRasterLayerDefinition>() )
918 if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
930 if ( !val.isValid() || val.toString().isEmpty() )
936 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
941 QString layerRef = val.toString();
942 if ( layerRef.isEmpty() )
945 if ( layerRef.isEmpty() )
976 val = parameters.value( definition->
name() );
987 val = parameters.value( definition->
name() );
988 if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
992 format = fromVar.
format();
1000 QVariant val = value;
1004 if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1014 if ( definition && val.userType() == qMetaTypeId<QgsProperty>() )
1018 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
1025 dest = val.toString();
1030 dest = destParam->generateTemporaryDestination( &context );
1033 if ( destinationProject )
1036 if ( destName.isEmpty() && definition )
1041 outputName = definition->
name();
1065 val = parameters.value( definition->
name() );
1072 QVariant val = value;
1074 if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1082 if ( definition && val.userType() == qMetaTypeId<QgsProperty>() )
1086 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
1093 dest = val.toString();
1098 dest = destParam->generateTemporaryDestination( &context );
1118 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
1143 QVariant val = value;
1145 if ( val.userType() == qMetaTypeId<QgsRectangle>() )
1149 if ( val.userType() == qMetaTypeId< QgsGeometry>() )
1155 if ( val.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1174 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
1180 else if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1193 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1196 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1199 rectText = val.toString();
1201 if ( rectText.isEmpty() && !layer )
1204 const thread_local QRegularExpression rx( u
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$"_s );
1205 const QRegularExpressionMatch match = rx.match( rectText );
1206 if ( match.hasMatch() )
1208 bool xMinOk =
false;
1209 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1210 bool xMaxOk =
false;
1211 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1212 bool yMinOk =
false;
1213 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1214 bool yMaxOk =
false;
1215 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1216 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1267 QVariant val = parameters.value( definition->
name() );
1269 if ( val.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1275 g = g.densifyByCount( 20 );
1289 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
1295 else if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1308 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1311 rectText = val.toString();
1313 if ( !rectText.isEmpty() )
1315 const thread_local QRegularExpression rx( u
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$"_s );
1316 const QRegularExpressionMatch match = rx.match( rectText );
1317 if ( match.hasMatch() )
1319 bool xMinOk =
false;
1320 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1321 bool xMaxOk =
false;
1322 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1323 bool yMinOk =
false;
1324 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1325 bool yMaxOk =
false;
1326 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1327 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1357 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1386 const QVariant val = parameters.value( definition->
name() );
1392 QVariant val = value;
1393 if ( val.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1402 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
1408 else if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1420 QString valueAsString;
1421 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1424 valueAsString = val.toString();
1426 const thread_local QRegularExpression rx( u
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$"_s );
1428 const QRegularExpressionMatch match = rx.match( valueAsString );
1429 if ( match.hasMatch() )
1436 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
1442 else if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1455 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1456 return layer->crs();
1458 return layer->crs();
1460 if (
auto *lProject = context.
project() )
1461 return lProject->crs();
1479 const QVariant val = value;
1480 if ( val.userType() == qMetaTypeId<QgsPointXY>() )
1484 if ( val.userType() == qMetaTypeId< QgsGeometry>() )
1490 if ( val.userType() == qMetaTypeId<QgsReferencedPointXY>() )
1509 if ( pointText.isEmpty() )
1512 if ( pointText.isEmpty() )
1515 const thread_local QRegularExpression rx( u
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$"_s );
1518 const QRegularExpressionMatch match = rx.match( valueAsString );
1519 if ( match.hasMatch() )
1522 const double x = match.captured( 1 ).toDouble( &xOk );
1524 const double y = match.captured( 2 ).toDouble( &yOk );
1552 const QVariant val = parameters.value( definition->
name() );
1558 if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
1567 const thread_local QRegularExpression rx( u
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$"_s );
1570 const QRegularExpressionMatch match = rx.match( valueAsString );
1571 if ( match.hasMatch() )
1578 if (
auto *lProject = context.
project() )
1579 return lProject->crs();
1597 const QVariant val = value;
1598 if ( val.userType() == qMetaTypeId< QgsGeometry>() )
1603 if ( val.userType() == qMetaTypeId<QgsPointXY>() )
1608 if ( val.userType() == qMetaTypeId<QgsRectangle>() )
1613 if ( val.userType() == qMetaTypeId<QgsReferencedPointXY>() )
1631 if ( val.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1637 g = g.densifyByCount( 20 );
1651 if ( val.userType() == qMetaTypeId<QgsReferencedGeometry>() )
1670 if ( valueAsString.isEmpty() )
1673 if ( valueAsString.isEmpty() )
1676 const thread_local QRegularExpression rx( u
"^\\s*(?:CRS=(.*);)?(.*?)$"_s );
1678 const QRegularExpressionMatch match = rx.match( valueAsString );
1679 if ( match.hasMatch() )
1706 const QVariant val = parameters.value( definition->
name() );
1712 if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
1721 if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
1730 if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1740 const QRegularExpression rx( u
"^\\s*(?:CRS=(.*);)?(.*?)$"_s );
1743 const QRegularExpressionMatch match = rx.match( valueAsString );
1744 if ( match.hasMatch() )
1751 if (
auto *lProject = context.
project() )
1752 return lProject->crs();
1763 if ( fileText.isEmpty() )
1774 if ( fileText.isEmpty() )
1782 return QVariantList();
1790 return QVariantList();
1792 QString resultString;
1793 const QVariant val = value;
1794 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1796 else if ( val.userType() == QMetaType::Type::QVariantList )
1797 return val.toList();
1799 resultString = val.toString();
1801 if ( resultString.isEmpty() )
1804 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
1810 QVariantList result;
1811 const auto constSplit = resultString.split(
',' );
1814 for (
const QString &s : constSplit )
1816 number = s.toDouble( &ok );
1817 result << ( ok ? QVariant( number ) : s );
1826 return QList<QgsMapLayer *>();
1834 return QList<QgsMapLayer *>();
1836 const QVariant val = value;
1837 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1839 return QList<QgsMapLayer *>() << layer;
1842 QList<QgsMapLayer *> layers;
1844 std::function< void(
const QVariant &var ) > processVariant;
1845 processVariant = [ &layers, &context, &definition, flags, &processVariant](
const QVariant & var )
1847 if ( var.userType() == QMetaType::Type::QVariantList )
1849 const auto constToList = var.toList();
1850 for (
const QVariant &listVar : constToList )
1852 processVariant( listVar );
1855 else if ( var.userType() == QMetaType::Type::QStringList )
1857 const auto constToStringList = var.toStringList();
1858 for (
const QString &s : constToStringList )
1860 processVariant( s );
1863 else if ( var.userType() == qMetaTypeId<QgsProperty>() )
1865 else if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1869 const QVariant sink = fromVar.
sink;
1870 if ( sink.userType() == qMetaTypeId<QgsProperty>() )
1875 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1887 processVariant( val );
1889 if ( layers.isEmpty() )
1892 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->
defaultValue() ) ) )
1896 else if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
1898 const auto constToList = definition->
defaultValue().toList();
1899 for (
const QVariant &var : constToList )
1901 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1907 processVariant( var );
1921 return QStringList();
1923 const QVariant val = value;
1927 std::function< void(
const QVariant &var ) > processVariant;
1928 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1930 if ( var.userType() == QMetaType::Type::QVariantList )
1932 const auto constToList = var.toList();
1933 for (
const QVariant &listVar : constToList )
1935 processVariant( listVar );
1938 else if ( var.userType() == QMetaType::Type::QStringList )
1940 const auto constToStringList = var.toStringList();
1941 for (
const QString &s : constToStringList )
1943 processVariant( s );
1946 else if ( var.userType() == qMetaTypeId<QgsProperty>() )
1950 files << var.toString();
1954 processVariant( val );
1956 if ( files.isEmpty() )
1967 return QStringList();
1975 return QList<double>();
1983 return QList<double>();
1985 QStringList resultStringList;
1986 const QVariant val = value;
1988 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1990 else if ( val.userType() == QMetaType::Type::QVariantList )
1992 const auto constToList = val.toList();
1993 for (
const QVariant &var : constToList )
1994 resultStringList << var.toString();
1997 resultStringList << val.toString();
1999 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
2001 resultStringList.clear();
2003 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
2005 const auto constToList = definition->
defaultValue().toList();
2006 for (
const QVariant &var : constToList )
2007 resultStringList << var.toString();
2010 resultStringList << definition->
defaultValue().toString();
2013 if ( resultStringList.size() == 1 )
2015 resultStringList = resultStringList.at( 0 ).split(
',' );
2018 if ( resultStringList.size() < 2 )
2019 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
2021 QList< double > result;
2023 double n = resultStringList.at( 0 ).toDouble( &ok );
2027 result << std::numeric_limits<double>::quiet_NaN() ;
2029 n = resultStringList.at( 1 ).toDouble( &ok );
2033 result << std::numeric_limits<double>::quiet_NaN() ;
2041 return QStringList();
2054 return QStringList();
2062 return QStringList();
2064 QStringList resultStringList;
2065 const QVariant val = value;
2066 if ( val.isValid() )
2068 if ( val.userType() == qMetaTypeId<QgsProperty>() )
2070 else if ( val.userType() == QMetaType::Type::QVariantList )
2072 const auto constToList = val.toList();
2073 for (
const QVariant &var : constToList )
2074 resultStringList << var.toString();
2076 else if ( val.userType() == QMetaType::Type::QStringList )
2078 resultStringList = val.toStringList();
2081 resultStringList.append( val.toString().split(
';' ) );
2084 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
2086 resultStringList.clear();
2090 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
2092 const auto constToList = definition->
defaultValue().toList();
2093 for (
const QVariant &var : constToList )
2094 resultStringList << var.toString();
2096 else if ( definition->
defaultValue().userType() == QMetaType::Type::QStringList )
2098 resultStringList = definition->
defaultValue().toStringList();
2101 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
2105 return resultStringList;
2119 if ( layoutName.isEmpty() )
2171 QVariant val = value;
2172 if ( val.userType() == qMetaTypeId<QgsProperty>() )
2176 if ( val.userType() == QMetaType::Type::QColor )
2178 QColor
c = val.value< QColor >();
2180 if ( !colorParam->opacityEnabled() )
2188 if ( definition->
defaultValue().userType() == QMetaType::Type::QColor )
2194 if ( colorText.isEmpty() )
2197 bool containsAlpha =
false;
2200 if (
c.isValid() && !colorParam->opacityEnabled() )
2272 const QString type = map.value( u
"parameter_type"_s ).toString();
2273 const QString name = map.value( u
"name"_s ).toString();
2274 std::unique_ptr< QgsProcessingParameterDefinition > def;
2280 def = std::make_unique<QgsProcessingParameterBoolean>( name );
2282 def = std::make_unique<QgsProcessingParameterCrs>( name );
2284 def = std::make_unique<QgsProcessingParameterMapLayer>( name );
2286 def = std::make_unique<QgsProcessingParameterExtent>( name );
2288 def = std::make_unique<QgsProcessingParameterPoint>( name );
2290 def = std::make_unique<QgsProcessingParameterFile>( name );
2292 def = std::make_unique<QgsProcessingParameterMatrix>( name );
2294 def = std::make_unique<QgsProcessingParameterMultipleLayers>( name );
2296 def = std::make_unique<QgsProcessingParameterNumber>( name );
2298 def = std::make_unique<QgsProcessingParameterRange>( name );
2300 def = std::make_unique<QgsProcessingParameterRasterLayer>( name );
2302 def = std::make_unique<QgsProcessingParameterEnum>( name );
2304 def = std::make_unique<QgsProcessingParameterString>( name );
2306 def = std::make_unique<QgsProcessingParameterAuthConfig>( name );
2308 def = std::make_unique<QgsProcessingParameterExpression>( name );
2310 def = std::make_unique<QgsProcessingParameterVectorLayer>( name );
2312 def = std::make_unique<QgsProcessingParameterField>( name );
2314 def = std::make_unique<QgsProcessingParameterFeatureSource>( name );
2316 def = std::make_unique<QgsProcessingParameterFeatureSink>( name );
2318 def = std::make_unique<QgsProcessingParameterVectorDestination>( name );
2320 def = std::make_unique<QgsProcessingParameterRasterDestination>( name );
2322 def = std::make_unique<QgsProcessingParameterPointCloudDestination>( name );
2324 def = std::make_unique<QgsProcessingParameterFileDestination>( name );
2326 def = std::make_unique<QgsProcessingParameterFolderDestination>( name );
2328 def = std::make_unique<QgsProcessingParameterBand>( name );
2330 def = std::make_unique<QgsProcessingParameterMeshLayer>( name );
2332 def = std::make_unique<QgsProcessingParameterLayout>( name );
2334 def = std::make_unique<QgsProcessingParameterLayoutItem>( name );
2336 def = std::make_unique<QgsProcessingParameterColor>( name );
2338 def = std::make_unique<QgsProcessingParameterCoordinateOperation>( name );
2340 def = std::make_unique<QgsProcessingParameterPointCloudLayer>( name );
2342 def = std::make_unique<QgsProcessingParameterAnnotationLayer>( name );
2344 def = std::make_unique<QgsProcessingParameterPointCloudAttribute>( name );
2346 def = std::make_unique<QgsProcessingParameterVectorTileDestination>( name );
2351 def.reset( paramType->
create( name ) );
2357 def->fromVariantMap( map );
2358 return def.release();
2363 QString desc = name;
2364 desc.replace(
'_',
' ' );
2370 bool isOptional =
false;
2374 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2379 if ( type ==
"boolean"_L1 )
2381 else if ( type ==
"crs"_L1 )
2383 else if ( type ==
"layer"_L1 )
2385 else if ( type ==
"extent"_L1 )
2387 else if ( type ==
"point"_L1 )
2389 else if ( type ==
"geometry"_L1 )
2391 else if ( type ==
"file"_L1 )
2393 else if ( type ==
"folder"_L1 )
2395 else if ( type ==
"matrix"_L1 )
2397 else if ( type ==
"multiple"_L1 )
2399 else if ( type ==
"number"_L1 )
2401 else if ( type ==
"distance"_L1 )
2403 else if ( type ==
"area"_L1 )
2405 else if ( type ==
"volume"_L1 )
2407 else if ( type ==
"duration"_L1 )
2409 else if ( type ==
"scale"_L1 )
2411 else if ( type ==
"range"_L1 )
2413 else if ( type ==
"raster"_L1 )
2415 else if ( type ==
"enum"_L1 )
2417 else if ( type ==
"string"_L1 )
2419 else if ( type ==
"authcfg"_L1 )
2421 else if ( type ==
"expression"_L1 )
2423 else if ( type ==
"field"_L1 )
2425 else if ( type ==
"vector"_L1 )
2427 else if ( type ==
"source"_L1 )
2429 else if ( type ==
"sink"_L1 )
2431 else if ( type ==
"vectordestination"_L1 )
2433 else if ( type ==
"rasterdestination"_L1 )
2435 else if ( type ==
"pointclouddestination"_L1 )
2437 else if ( type ==
"filedestination"_L1 )
2439 else if ( type ==
"folderdestination"_L1 )
2441 else if ( type ==
"band"_L1 )
2443 else if ( type ==
"mesh"_L1 )
2445 else if ( type ==
"layout"_L1 )
2447 else if ( type ==
"layoutitem"_L1 )
2449 else if ( type ==
"color"_L1 )
2451 else if ( type ==
"coordinateoperation"_L1 )
2453 else if ( type ==
"maptheme"_L1 )
2455 else if ( type ==
"datetime"_L1 )
2457 else if ( type ==
"providerconnection"_L1 )
2459 else if ( type ==
"databaseschema"_L1 )
2461 else if ( type ==
"databasetable"_L1 )
2463 else if ( type ==
"pointcloud"_L1 )
2465 else if ( type ==
"annotation"_L1 )
2467 else if ( type ==
"attribute"_L1 )
2469 else if ( type ==
"vectortiledestination"_L1 )
2475bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2477 const thread_local QRegularExpression re( u
"(?:#*)(.*?)=\\s*(.*)"_s );
2478 QRegularExpressionMatch m = re.match( code );
2479 if ( !m.hasMatch() )
2482 name = m.captured( 1 );
2483 QString tokens = m.captured( 2 );
2484 if ( tokens.startsWith(
"optional"_L1, Qt::CaseInsensitive ) )
2487 tokens.remove( 0, 8 );
2494 tokens = tokens.trimmed();
2496 const thread_local QRegularExpression re2( u
"(.*?)\\s+(.*)"_s );
2497 m = re2.match( tokens );
2498 if ( !m.hasMatch() )
2500 type = tokens.toLower().trimmed();
2505 type = m.captured( 1 ).toLower().trimmed();
2506 definition = m.captured( 2 );
2520 ,
mFlags( optional ?
Qgis::ProcessingParameterFlag::Optional :
Qgis::ProcessingParameterFlag() )
2526 if ( defaultSettingsValue.isValid() )
2528 return defaultSettingsValue;
2536 if ( defaultSettingsValue.isValid() )
2538 return defaultSettingsValue;
2548 QVariant settingValue = s.
value( u
"/Processing/DefaultGuiParam/%1/%2"_s.arg(
mAlgorithm->id() ).arg(
mName ) );
2549 if ( settingValue.isValid() )
2551 return settingValue;
2559 if ( !input.isValid() && !
mDefault.isValid() )
2562 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
2563 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
2571 if ( !value.isValid() )
2574 if ( value.userType() == qMetaTypeId<QgsProperty>() )
2587 if ( !value.isValid() )
2591 if ( value.userType() == QMetaType::Type::QVariantMap )
2593 const QVariantMap sourceMap = value.toMap();
2594 QVariantMap resultMap;
2595 for (
auto it = sourceMap.constBegin(); it != sourceMap.constEnd(); it++ )
2601 else if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
2603 const QVariantList sourceList = value.toList();
2604 QVariantList resultList;
2605 resultList.reserve( sourceList.size() );
2606 for (
const QVariant &v : sourceList )
2614 switch ( value.userType() )
2617 case QMetaType::Bool:
2618 case QMetaType::Char:
2619 case QMetaType::Int:
2620 case QMetaType::Double:
2621 case QMetaType::Float:
2622 case QMetaType::LongLong:
2623 case QMetaType::ULongLong:
2624 case QMetaType::UInt:
2625 case QMetaType::ULong:
2626 case QMetaType::UShort:
2633 if ( value.userType() == qMetaTypeId<QgsProperty>() )
2643 return QVariantMap( {{u
"type"_s, u
"data_defined"_s}, {u
"field"_s, prop.
field() }} );
2645 return QVariantMap( {{u
"type"_s, u
"data_defined"_s}, {u
"expression"_s, prop.
expressionString() }} );
2650 if ( value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
2655 else if ( !crs.
authid().isEmpty() )
2660 else if ( value.userType() == qMetaTypeId<QgsRectangle>() )
2668 else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
2677 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
2689 else if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
2704 else if ( value.userType() == qMetaTypeId<QgsPointXY>() )
2710 else if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
2717 else if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
2724 else if ( value.userType() == qMetaTypeId<QgsProcessingRasterLayerDefinition>() )
2731 else if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
2736 else if ( value.userType() == qMetaTypeId<QColor>() )
2738 const QColor fromVar = value.value< QColor >();
2739 if ( !fromVar.isValid() )
2742 return u
"rgba( %1, %2, %3, %4 )"_s.arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2744 else if ( value.userType() == qMetaTypeId<QDateTime>() )
2746 const QDateTime fromVar = value.toDateTime();
2747 if ( !fromVar.isValid() )
2750 return fromVar.toString( Qt::ISODate );
2752 else if ( value.userType() == qMetaTypeId<QDate>() )
2754 const QDate fromVar = value.toDate();
2755 if ( !fromVar.isValid() )
2758 return fromVar.toString( Qt::ISODate );
2760 else if ( value.userType() == qMetaTypeId<QTime>() )
2762 const QTime fromVar = value.toTime();
2763 if ( !fromVar.isValid() )
2766 return fromVar.toString( Qt::ISODate );
2773 p.insert(
name(), value );
2781 if ( value.userType() == QMetaType::QString )
2786 Q_ASSERT_X(
false,
"QgsProcessingParameterDefinition::valueAsJsonObject", u
"unsupported variant type %1"_s.arg( QMetaType::typeName( value.userType() ) ).toLocal8Bit() );
2799 if ( !value.isValid() )
2802 switch ( value.userType() )
2805 case QMetaType::Bool:
2806 case QMetaType::Char:
2807 case QMetaType::Int:
2808 case QMetaType::Double:
2809 case QMetaType::Float:
2810 case QMetaType::LongLong:
2811 case QMetaType::ULongLong:
2812 case QMetaType::UInt:
2813 case QMetaType::ULong:
2814 case QMetaType::UShort:
2815 return value.toString();
2821 if ( value.userType() == qMetaTypeId<QgsProperty>() )
2831 return u
"field:%1"_s.arg( prop.
field() );
2838 if ( value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
2843 else if ( !crs.
authid().isEmpty() )
2848 else if ( value.userType() == qMetaTypeId<QgsRectangle>() )
2856 else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
2864 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
2876 else if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
2891 else if ( value.userType() == qMetaTypeId<QgsPointXY>() )
2897 else if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
2904 else if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
2909 else if ( value.userType() == qMetaTypeId<QgsProcessingRasterLayerDefinition>() )
2914 else if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
2919 else if ( value.userType() == qMetaTypeId<QColor>() )
2921 const QColor fromVar = value.value< QColor >();
2922 if ( !fromVar.isValid() )
2925 return u
"rgba( %1, %2, %3, %4 )"_s.arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2927 else if ( value.userType() == qMetaTypeId<QDateTime>() )
2929 const QDateTime fromVar = value.toDateTime();
2930 if ( !fromVar.isValid() )
2933 return fromVar.toString( Qt::ISODate );
2935 else if ( value.userType() == qMetaTypeId<QDate>() )
2937 const QDate fromVar = value.toDate();
2938 if ( !fromVar.isValid() )
2941 return fromVar.toString( Qt::ISODate );
2943 else if ( value.userType() == qMetaTypeId<QTime>() )
2945 const QTime fromVar = value.toTime();
2946 if ( !fromVar.isValid() )
2949 return fromVar.toString( Qt::ISODate );
2956 p.insert(
name(), value );
2964 if ( value.userType() == QMetaType::QString )
2965 return value.toString();
2968 QgsDebugError( u
"unsupported variant type %1"_s.arg( QMetaType::typeName( value.userType() ) ) );
2970 return value.toString();
2976 if ( !value.isValid( ) )
2977 return QStringList();
2979 if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
2981 const QVariantList sourceList = value.toList();
2982 QStringList resultList;
2983 resultList.reserve( sourceList.size() );
2984 for (
const QVariant &v : sourceList )
2993 return QStringList();
3005 QString code = u
"##%1="_s.arg(
mName );
3007 code +=
"optional "_L1;
3008 code +=
type() +
' ';
3010 return code.trimmed();
3018 switch ( outputType )
3022 QString code = t->className() + u
"('%1', %2"_s
3025 code +=
", optional=True"_L1;
3041 map.insert( u
"parameter_type"_s,
type() );
3042 map.insert( u
"name"_s,
mName );
3044 map.insert( u
"help"_s,
mHelp );
3045 map.insert( u
"default"_s,
mDefault );
3047 map.insert( u
"flags"_s,
static_cast< int >(
mFlags ) );
3054 mName = map.value( u
"name"_s ).toString();
3055 mDescription = map.value( u
"description"_s ).toString();
3056 mHelp = map.value( u
"help"_s ).toString();
3057 mDefault = map.value( u
"default"_s );
3060 mMetadata = map.value( u
"metadata"_s ).toMap();
3076 QString text = u
"<p><b>%1</b></p>"_s.arg(
description() );
3077 if ( !
help().isEmpty() )
3079 text += u
"<p>%1</p>"_s.arg(
help() );
3081 text += u
"<p>%1</p>"_s.arg( QObject::tr(
"Python identifier: ‘%1’" ).arg( u
"<i>%1</i>"_s.arg(
name() ) ) );
3110 if ( value.userType() == qMetaTypeId<QgsPointXY>() )
3117 else if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3120 return u
"%1, %2 [%3]"_s.arg(
3127 else if ( value.userType() == qMetaTypeId<QgsRectangle>() )
3133 else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3144 else if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
3157 return value.toString();
3163 if ( !val.isValid() )
3166 if ( val.userType() == qMetaTypeId<QgsProperty>() )
3168 return val.toBool() ? u
"True"_s : u
"False"_s;
3173 QString code = u
"##%1="_s.arg(
mName );
3175 code +=
"optional "_L1;
3176 code +=
type() +
' ';
3177 code +=
mDefault.toBool() ? u
"true"_s : u
"false"_s;
3178 return code.trimmed();
3200 if ( !input.isValid() )
3208 if ( input.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
3212 else if ( input.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
3216 else if ( input.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
3221 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3226 if ( input.type() == QVariant::String )
3228 const QString
string = input.toString();
3229 if (
string.compare(
"ProjectCrs"_L1, Qt::CaseInsensitive ) == 0 )
3238 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3241 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3249 if ( !value.isValid() )
3252 if ( value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
3255 return u
"QgsCoordinateReferenceSystem()"_s;
3260 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3263 if ( value.type() == QVariant::String )
3265 const QString
string = value.toString();
3266 if (
string.compare(
"ProjectCrs"_L1, Qt::CaseInsensitive ) == 0 )
3275 p.insert(
name(), value );
3285 if ( value.type() == QVariant::String )
3287 const QString
string = value.toString();
3288 if (
string.compare(
"ProjectCrs"_L1, Qt::CaseInsensitive ) == 0 )
3301 if ( value.type() == QVariant::String )
3303 const QString
string = value.toString();
3304 if (
string.compare(
"ProjectCrs"_L1, Qt::CaseInsensitive ) == 0 )
3330 return QObject::tr(
"Invalid CRS" );
3351 if ( !input.isValid() )
3359 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3364 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3369 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3387 if ( !val.isValid() )
3390 if ( val.userType() == qMetaTypeId<QgsProperty>() )
3394 p.insert(
name(), val );
3414 for (
const QString &raster : rasters )
3416 if ( !vectors.contains( raster ) )
3420 for (
const QString &mesh : meshFilters )
3422 if ( !vectors.contains( mesh ) )
3426 for (
const QString &pointCloud : pointCloudFilters )
3428 if ( !vectors.contains( pointCloud ) )
3429 vectors << pointCloud;
3431 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
3432 std::sort( vectors.begin(), vectors.end() );
3434 return QObject::tr(
"All files (*.*)" ) + u
";;"_s + vectors.join(
";;"_L1 );
3444 QString code = u
"##%1="_s.arg(
mName );
3446 code +=
"optional "_L1;
3447 code +=
"layer "_L1;
3454 code +=
"table "_L1;
3458 code +=
"hasgeometry "_L1;
3462 code +=
"point "_L1;
3470 code +=
"polygon "_L1;
3474 code +=
"raster "_L1;
3482 code +=
"plugin "_L1;
3486 code +=
"pointcloud "_L1;
3490 code +=
"annotation "_L1;
3494 code +=
"vectortile "_L1;
3498 code +=
"tiledscene "_L1;
3507 return code.trimmed();
3513 QString def = definition;
3516 if ( def.startsWith(
"table"_L1, Qt::CaseInsensitive ) )
3522 if ( def.startsWith(
"hasgeometry"_L1, Qt::CaseInsensitive ) )
3525 def = def.mid( 12 );
3528 else if ( def.startsWith(
"point"_L1, Qt::CaseInsensitive ) )
3534 else if ( def.startsWith(
"line"_L1, Qt::CaseInsensitive ) )
3540 else if ( def.startsWith(
"polygon"_L1, Qt::CaseInsensitive ) )
3546 else if ( def.startsWith(
"raster"_L1, Qt::CaseInsensitive ) )
3552 else if ( def.startsWith(
"mesh"_L1, Qt::CaseInsensitive ) )
3558 else if ( def.startsWith(
"plugin"_L1, Qt::CaseInsensitive ) )
3564 else if ( def.startsWith(
"pointcloud"_L1, Qt::CaseInsensitive ) )
3567 def = def.mid( 11 );
3570 else if ( def.startsWith(
"annotation"_L1, Qt::CaseInsensitive ) )
3573 def = def.mid( 11 );
3576 else if ( def.startsWith(
"vectortile"_L1, Qt::CaseInsensitive ) )
3579 def = def.mid( 11 );
3582 else if ( def.startsWith(
"tiledscene"_L1, Qt::CaseInsensitive ) )
3585 def = def.mid( 11 );
3596 switch ( outputType )
3600 QString code = u
"QgsProcessingParameterMapLayer('%1', %2"_s
3603 code +=
", optional=True"_L1;
3610 QStringList options;
3614 code += u
", types=[%1])"_s.arg( options.join(
',' ) );
3635 map.insert( u
"data_types"_s, types );
3643 const QVariantList values = map.value( u
"data_types"_s ).toList();
3644 for (
const QVariant &val : values )
3665 if ( !input.isValid() )
3673 if ( input.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
3677 else if ( input.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
3682 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3687 if ( input.userType() == qMetaTypeId<QgsRectangle>() )
3692 if ( input.userType() == qMetaTypeId< QgsGeometry>() )
3696 if ( input.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3703 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3706 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3709 if ( variantIsValidStringForExtent( input ) )
3722bool QgsProcessingParameterExtent::variantIsValidStringForExtent(
const QVariant &value )
3724 if ( value.userType() == QMetaType::Type::QString )
3726 const thread_local QRegularExpression rx( u
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$"_s );
3727 const QRegularExpressionMatch match = rx.match( value.toString() );
3728 if ( match.hasMatch() )
3730 bool xMinOk =
false;
3731 ( void )match.captured( 1 ).toDouble( &xMinOk );
3732 bool xMaxOk =
false;
3733 ( void )match.captured( 2 ).toDouble( &xMaxOk );
3734 bool yMinOk =
false;
3735 ( void )match.captured( 3 ).toDouble( &yMinOk );
3736 bool yMaxOk =
false;
3737 ( void )match.captured( 4 ).toDouble( &yMaxOk );
3738 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
3747 if ( !value.isValid() )
3750 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3753 if ( value.userType() == qMetaTypeId<QgsRectangle>() )
3761 else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3770 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
3775 const QString wkt = g.
asWkt();
3776 return u
"QgsGeometry.fromWkt('%1')"_s.arg( wkt );
3779 else if ( variantIsValidStringForExtent( value ) )
3785 p.insert(
name(), value );
3795 if ( variantIsValidStringForExtent( value ) )
3797 return value.toString();
3805 if ( variantIsValidStringForExtent( value ) )
3832 if ( !input.isValid() )
3840 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3845 if ( input.userType() == qMetaTypeId<QgsPointXY>() )
3849 if ( input.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3853 if ( input.userType() == qMetaTypeId< QgsGeometry>() )
3858 if ( input.userType() == QMetaType::Type::QString )
3860 if ( input.toString().isEmpty() )
3864 const thread_local QRegularExpression rx( u
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$"_s );
3866 const QRegularExpressionMatch match = rx.match( input.toString() );
3867 if ( match.hasMatch() )
3870 ( void )match.captured( 1 ).toDouble( &xOk );
3872 ( void )match.captured( 2 ).toDouble( &yOk );
3881 if ( !value.isValid() )
3884 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3887 if ( value.userType() == qMetaTypeId<QgsPointXY>() )
3893 else if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3900 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
3905 const QString wkt = g.
asWkt();
3906 return u
"QgsGeometry.fromWkt('%1')"_s.arg( wkt );
3936 if ( !input.isValid() )
3944 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3951 if ( input.userType() == qMetaTypeId< QgsGeometry>() )
3953 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( input.value<
QgsGeometry>().
type() ) ) ) &&
3957 if ( input.userType() == qMetaTypeId<QgsReferencedGeometry>() )
3963 if ( input.userType() == qMetaTypeId<QgsPointXY>() )
3968 if ( input.userType() == qMetaTypeId<QgsRectangle>() )
3973 if ( input.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3978 if ( input.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3983 if ( input.userType() == QMetaType::Type::QString )
3985 if ( input.toString().isEmpty() )
3990 const thread_local QRegularExpression rx( u
"^\\s*(?:CRS=(.*);)?(.*?)$"_s );
3992 const QRegularExpressionMatch match = rx.match( input.toString() );
3993 if ( match.hasMatch() )
3998 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( g.
type() ) ) ) && ( mAllowMultipart || !g.
isMultipart() );
4012 if ( !crs.isValid() )
4018 if ( !value.isValid() )
4021 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4024 if ( value.userType() == qMetaTypeId< QgsGeometry>() )
4031 if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
4038 if ( value.userType() == qMetaTypeId<QgsPointXY>() )
4045 if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
4052 if ( value.userType() == qMetaTypeId<QgsRectangle>() )
4059 if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
4071 QString code = u
"##%1="_s.arg(
mName );
4073 code +=
"optional "_L1;
4074 code +=
type() +
' ';
4076 for (
const int type : mGeomTypes )
4081 code +=
"point "_L1;
4089 code +=
"polygon "_L1;
4093 code +=
"unknown "_L1;
4099 return code.trimmed();
4104 switch ( outputType )
4108 QString code = u
"QgsProcessingParameterGeometry('%1', %2"_s
4111 code +=
", optional=True"_L1;
4113 if ( !mGeomTypes.empty() )
4120 return u
"PointGeometry"_s;
4123 return u
"LineGeometry"_s;
4126 return u
"PolygonGeometry"_s;
4129 return u
"UnknownGeometry"_s;
4132 return u
"NullGeometry"_s;
4137 QStringList options;
4138 options.reserve( mGeomTypes.size() );
4139 for (
const int type : mGeomTypes )
4143 code += u
", geometryTypes=[%1 ]"_s.arg( options.join(
',' ) );
4146 if ( ! mAllowMultipart )
4148 code +=
", allowMultipart=False"_L1;
4163 for (
const int type : mGeomTypes )
4167 map.insert( u
"geometrytypes"_s, types );
4168 map.insert( u
"multipart"_s, mAllowMultipart );
4176 const QVariantList values = map.value( u
"geometrytypes"_s ).toList();
4177 for (
const QVariant &val : values )
4179 mGeomTypes << val.toInt();
4181 mAllowMultipart = map.value( u
"multipart"_s ).toBool();
4195 if ( value.isValid() )
4198 if ( value.userType() == qMetaTypeId< QgsGeometry>() )
4204 else if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
4214 else if ( value.userType() == QMetaType::QString )
4226 return QObject::tr(
"Invalid geometry" );
4246 if ( !input.isValid() )
4254 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4259 const QString
string = input.toString().trimmed();
4261 if ( input.userType() != QMetaType::Type::QString ||
string.isEmpty() )
4264 switch ( mBehavior )
4268 if ( !mExtension.isEmpty() )
4270 return string.endsWith( mExtension, Qt::CaseInsensitive );
4272 else if ( !mFileFilter.isEmpty() )
4290 QString code = u
"##%1="_s.arg(
mName );
4292 code +=
"optional "_L1;
4295 return code.trimmed();
4300 switch ( outputType )
4305 QString code = u
"QgsProcessingParameterFile('%1', %2"_s
4308 code +=
", optional=True"_L1;
4310 if ( !mExtension.isEmpty() )
4311 code += u
", extension='%1'"_s.arg( mExtension );
4312 if ( !mFileFilter.isEmpty() )
4313 code += u
", fileFilter='%1'"_s.arg( mFileFilter );
4324 switch ( mBehavior )
4328 if ( !mFileFilter.isEmpty() )
4329 return mFileFilter != QObject::tr(
"All files (*.*)" ) ? mFileFilter + u
";;"_s + QObject::tr(
"All files (*.*)" ) : mFileFilter;
4330 else if ( !mExtension.isEmpty() )
4331 return QObject::tr(
"%1 files" ).arg( mExtension.toUpper() ) + u
" (*."_s + mExtension.toLower() + u
");;"_s + QObject::tr(
"All files (*.*)" );
4333 return QObject::tr(
"All files (*.*)" );
4345 mFileFilter.clear();
4355 mFileFilter = filter;
4362 map.insert( u
"behavior"_s,
static_cast< int >( mBehavior ) );
4363 map.insert( u
"extension"_s, mExtension );
4364 map.insert( u
"filefilter"_s, mFileFilter );
4372 mExtension = map.value( u
"extension"_s ).toString();
4373 mFileFilter = map.value( u
"filefilter"_s ).toString();
4386 , mFixedNumberRows( fixedNumberRows )
4399 if ( !input.isValid() )
4407 if ( input.userType() == QMetaType::Type::QString )
4409 if ( input.toString().isEmpty() )
4413 else if ( input.userType() == QMetaType::Type::QVariantList )
4415 if ( input.toList().isEmpty() )
4419 else if ( input.userType() == QMetaType::Type::Double || input.userType() == QMetaType::Type::Int )
4429 if ( !value.isValid() )
4432 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4436 p.insert(
name(), value );
4444 switch ( outputType )
4448 QString code = u
"QgsProcessingParameterMatrix('%1', %2"_s
4451 code +=
", optional=True"_L1;
4452 code += u
", numberRows=%1"_s.arg( mNumberRows );
4453 code += u
", hasFixedNumberRows=%1"_s.arg( mFixedNumberRows ? u
"True"_s : u
"False"_s );
4456 headers.reserve( mHeaders.size() );
4457 for (
const QString &h : mHeaders )
4459 code += u
", headers=[%1]"_s.arg(
headers.join(
',' ) );
4491 return mFixedNumberRows;
4496 mFixedNumberRows = fixedNumberRows;
4502 map.insert( u
"headers"_s, mHeaders );
4503 map.insert( u
"rows"_s, mNumberRows );
4504 map.insert( u
"fixed_number_rows"_s, mFixedNumberRows );
4511 mHeaders = map.value( u
"headers"_s ).toStringList();
4512 mNumberRows = map.value( u
"rows"_s ).toInt();
4513 mFixedNumberRows = map.value( u
"fixed_number_rows"_s ).toBool();
4537 if ( !input.isValid() )
4547 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
4553 if ( input.userType() == QMetaType::Type::QString )
4555 if ( input.toString().isEmpty() )
4558 if ( mMinimumNumberInputs > 1 )
4569 else if ( input.userType() == QMetaType::Type::QVariantList )
4571 if ( input.toList().count() < mMinimumNumberInputs )
4574 if ( mMinimumNumberInputs > input.toList().count() )
4582 const auto constToList = input.toList();
4583 for (
const QVariant &v : constToList )
4585 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
4594 else if ( input.userType() == QMetaType::Type::QStringList )
4596 if ( input.toStringList().count() < mMinimumNumberInputs )
4599 if ( mMinimumNumberInputs > input.toStringList().count() )
4607 const auto constToStringList = input.toStringList();
4608 for (
const QString &v : constToStringList )
4621 if ( !value.isValid() )
4624 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4630 if ( value.userType() == QMetaType::Type::QStringList )
4632 const QStringList list = value.toStringList();
4633 parts.reserve( list.count() );
4634 for (
const QString &v : list )
4637 else if ( value.userType() == QMetaType::Type::QVariantList )
4639 const QVariantList list = value.toList();
4640 parts.reserve( list.count() );
4641 for (
const QVariant &v : list )
4644 if ( !parts.isEmpty() )
4645 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4650 p.insert(
name(), value );
4652 if ( !list.isEmpty() )
4655 parts.reserve( list.count() );
4660 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4679 QString code = u
"##%1="_s.arg(
mName );
4681 code +=
"optional "_L1;
4682 switch ( mLayerType )
4685 code +=
"multiple raster"_L1;
4689 code +=
"multiple file"_L1;
4693 code +=
"multiple vector"_L1;
4697 if (
mDefault.userType() == QMetaType::Type::QVariantList )
4700 const auto constToList =
mDefault.toList();
4701 for (
const QVariant &var : constToList )
4703 parts << var.toString();
4705 code += parts.join(
',' );
4707 else if (
mDefault.userType() == QMetaType::Type::QStringList )
4709 code +=
mDefault.toStringList().join(
',' );
4715 return code.trimmed();
4720 switch ( outputType )
4724 QString code = u
"QgsProcessingParameterMultipleLayers('%1', %2"_s
4727 code +=
", optional=True"_L1;
4731 code += u
", layerType=%1"_s.arg(
layerType );
4742 switch ( mLayerType )
4745 return QObject::tr(
"All files (*.*)" );
4785 return mMinimumNumberInputs;
4797 map.insert( u
"layer_type"_s,
static_cast< int >( mLayerType ) );
4798 map.insert( u
"min_inputs"_s, mMinimumNumberInputs );
4806 mMinimumNumberInputs = map.value( u
"min_inputs"_s ).toInt();
4812 QString
type = definition;
4814 const thread_local QRegularExpression re( u
"(.*?)\\s+(.*)"_s );
4815 const QRegularExpressionMatch m = re.match( definition );
4818 type = m.captured( 1 ).toLower().trimmed();
4819 defaultVal = m.captured( 2 );
4822 if (
type ==
"vector"_L1 )
4824 else if (
type ==
"raster"_L1 )
4826 else if (
type ==
"file"_L1 )
4839 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
4850 QVariant input = value;
4851 if ( !input.isValid() )
4859 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4865 const double res = input.toDouble( &ok );
4869 return !( res < mMin || res > mMax );
4874 if ( !value.isValid() )
4877 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4880 return value.toString();
4887 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
4888 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
4889 if ( mMax < std::numeric_limits<double>::max() )
4890 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
4893 const QString extra = parts.join(
"<br />"_L1 );
4894 if ( !extra.isEmpty() )
4895 text += u
"<p>%1</p>"_s.arg( extra );
4901 switch ( outputType )
4905 QString code = u
"QgsProcessingParameterNumber('%1', %2"_s
4908 code +=
", optional=True"_L1;
4912 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
4913 code += u
", minValue=%1"_s.arg( mMin );
4914 if ( mMax != std::numeric_limits<double>::max() )
4915 code += u
", maxValue=%1"_s.arg( mMax );
4957 map.insert( u
"min"_s, mMin );
4958 map.insert( u
"max"_s, mMax );
4959 map.insert( u
"data_type"_s,
static_cast< int >( mDataType ) );
4966 mMin = map.value( u
"min"_s ).toDouble();
4967 mMax = map.value( u
"max"_s ).toDouble();
4975 : ( definition.toLower().trimmed() ==
"none"_L1 ? QVariant() : definition ), isOptional );
4993 if ( !input.isValid() )
5001 if ( input.userType() == qMetaTypeId<QgsProperty>() )
5006 if ( input.userType() == QMetaType::Type::QString )
5008 const QStringList list = input.toString().split(
',' );
5009 if ( list.count() != 2 )
5012 list.at( 0 ).toDouble( &ok );
5014 list.at( 1 ).toDouble( &ok2 );
5019 else if ( input.userType() == QMetaType::Type::QVariantList )
5021 if ( input.toList().count() != 2 )
5025 input.toList().at( 0 ).toDouble( &ok );
5027 input.toList().at( 1 ).toDouble( &ok2 );
5038 if ( !value.isValid() )
5041 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5045 p.insert(
name(), value );
5048 QStringList stringParts;
5049 const auto constParts = parts;
5050 for (
const double v : constParts )
5052 stringParts << QString::number( v );
5054 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
5059 switch ( outputType )
5063 QString code = u
"QgsProcessingParameterRange('%1', %2"_s
5066 code +=
", optional=True"_L1;
5091 map.insert( u
"data_type"_s,
static_cast< int >( mDataType ) );
5105 : ( definition.toLower().trimmed() ==
"none"_L1 ? QVariant() : definition ), isOptional );
5122 if ( !input.isValid() )
5130 if ( input.userType() == qMetaTypeId<QgsProcessingRasterLayerDefinition>() )
5136 if ( input.userType() == qMetaTypeId<QgsProperty>() )
5149 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
5152 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
5170 if ( !val.isValid() )
5173 if ( val.userType() == qMetaTypeId<QgsProperty>() )
5176 if ( val.userType() == qMetaTypeId<QgsProcessingRasterLayerDefinition>() )
5185 layerString = layer->source();
5189 return u
"QgsProcessingRasterLayerDefinition(%1, referenceScale=%2, dpi=%3)"_s
5192 QString::number( fromVar.
dpi ) );
5203 return u
"QgsProcessingRasterLayerDefinition(QgsProperty.fromExpression(%1), referenceScale=%2, dpi=%3)"_s
5206 QString::number( fromVar.
dpi ) );
5216 p.insert(
name(), val );
5244 mCapabilities = capabilities;
5249 return mCapabilities;
5268 QVariant input = value;
5269 if ( !input.isValid() )
5277 if ( input.userType() == qMetaTypeId<QgsProperty>() )
5282 if ( mUsesStaticStrings )
5284 if ( input.userType() == QMetaType::Type::QVariantList )
5286 if ( !mAllowMultiple )
5289 const QVariantList values = input.toList();
5293 for (
const QVariant &val : values )
5295 if ( !mOptions.contains( val.toString() ) )
5301 else if ( input.userType() == QMetaType::Type::QStringList )
5303 if ( !mAllowMultiple )
5306 const QStringList values = input.toStringList();
5311 if ( values.count() > 1 && !mAllowMultiple )
5314 for (
const QString &val : values )
5316 if ( !mOptions.contains( val ) )
5321 else if ( input.userType() == QMetaType::Type::QString )
5323 const QStringList parts = input.toString().split(
',' );
5324 if ( parts.count() > 1 && !mAllowMultiple )
5327 const auto constParts = parts;
5328 for (
const QString &part : constParts )
5330 if ( !mOptions.contains( part ) )
5338 if ( input.userType() == QMetaType::Type::QVariantList )
5340 if ( !mAllowMultiple )
5343 const QVariantList values = input.toList();
5347 for (
const QVariant &val : values )
5350 const int res = val.toInt( &ok );
5353 else if ( res < 0 || res >= mOptions.count() )
5359 else if ( input.userType() == QMetaType::Type::QString )
5361 const QStringList parts = input.toString().split(
',' );
5362 if ( parts.count() > 1 && !mAllowMultiple )
5365 const auto constParts = parts;
5366 for (
const QString &part : constParts )
5369 const int res = part.toInt( &ok );
5372 else if ( res < 0 || res >= mOptions.count() )
5377 else if ( input.userType() == QMetaType::Type::Int || input.userType() == QMetaType::Type::Double )
5380 const int res = input.toInt( &ok );
5383 else if ( res >= 0 && res < mOptions.count() )
5393 if ( !value.isValid() )
5396 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5399 if ( mUsesStaticStrings )
5401 if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
5404 const QStringList constList = value.toStringList();
5405 for (
const QString &val : constList )
5409 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5411 else if ( value.userType() == QMetaType::Type::QString )
5414 const QStringList constList = value.toString().split(
',' );
5415 if ( constList.count() > 1 )
5417 for (
const QString &val : constList )
5421 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5429 if ( value.userType() == QMetaType::Type::QVariantList )
5432 const auto constToList = value.toList();
5433 for (
const QVariant &val : constToList )
5435 parts << QString::number( static_cast< int >( val.toDouble() ) );
5437 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5439 else if ( value.userType() == QMetaType::Type::QString )
5441 const QStringList parts = value.toString().split(
',' );
5442 if ( parts.count() > 1 )
5444 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5448 return QString::number(
static_cast< int >( value.toDouble() ) );
5454 if ( !value.isValid() )
5457 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5460 if ( mUsesStaticStrings )
5466 if ( value.userType() == QMetaType::Type::QVariantList )
5469 const QVariantList toList = value.toList();
5470 parts.reserve( toList.size() );
5471 for (
const QVariant &val : toList )
5473 parts << mOptions.value(
static_cast< int >( val.toDouble() ) );
5475 return parts.join(
',' );
5477 else if ( value.userType() == QMetaType::Type::QString )
5479 const QStringList parts = value.toString().split(
',' );
5480 QStringList comments;
5481 if ( parts.count() > 1 )
5483 for (
const QString &part : parts )
5486 const int val = part.toInt( &ok );
5488 comments << mOptions.value( val );
5490 return comments.join(
',' );
5494 return mOptions.value(
static_cast< int >( value.toDouble() ) );
5500 QString code = u
"##%1="_s.arg(
mName );
5502 code +=
"optional "_L1;
5505 if ( mAllowMultiple )
5506 code +=
"multiple "_L1;
5508 if ( mUsesStaticStrings )
5509 code +=
"static "_L1;
5511 code += mOptions.join(
';' ) +
' ';
5514 return code.trimmed();
5519 switch ( outputType )
5523 QString code = u
"QgsProcessingParameterEnum('%1', %2"_s
5526 code +=
", optional=True"_L1;
5529 options.reserve( mOptions.size() );
5530 for (
const QString &o : mOptions )
5532 code += u
", options=[%1]"_s.arg(
options.join(
',' ) );
5534 code += u
", allowMultiple=%1"_s.arg( mAllowMultiple ? u
"True"_s : u
"False"_s );
5536 code += u
", usesStaticStrings=%1"_s.arg( mUsesStaticStrings ? u
"True"_s : u
"False"_s );
5552 return options().value( value.toInt() );
5567 return mAllowMultiple;
5577 return mUsesStaticStrings;
5588 map.insert( u
"options"_s, mOptions );
5589 map.insert( u
"allow_multiple"_s, mAllowMultiple );
5590 map.insert( u
"uses_static_strings"_s, mUsesStaticStrings );
5597 mOptions = map.value( u
"options"_s ).toStringList();
5598 mAllowMultiple = map.value( u
"allow_multiple"_s ).toBool();
5599 mUsesStaticStrings = map.value( u
"uses_static_strings"_s ).toBool();
5606 QString def = definition;
5608 bool multiple =
false;
5609 if ( def.startsWith(
"multiple"_L1, Qt::CaseInsensitive ) )
5615 bool staticStrings =
false;
5616 if ( def.startsWith(
"static"_L1, Qt::CaseInsensitive ) )
5618 staticStrings =
true;
5622 const thread_local QRegularExpression re( u
"(.*)\\s+(.*?)$"_s );
5623 const QRegularExpressionMatch m = re.match( def );
5624 QString values = def;
5627 values = m.captured( 1 ).trimmed();
5628 defaultVal = m.captured( 2 );
5651 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5654 const QString s = value.toString();
5660 QString code = u
"##%1="_s.arg(
mName );
5662 code +=
"optional "_L1;
5663 code +=
"string "_L1;
5669 return code.trimmed();
5674 switch ( outputType )
5678 QString code = u
"QgsProcessingParameterString('%1', %2"_s
5681 code +=
", optional=True"_L1;
5682 code += u
", multiLine=%1"_s.arg( mMultiLine ? u
"True"_s : u
"False"_s );
5705 map.insert( u
"multiline"_s, mMultiLine );
5712 mMultiLine = map.value( u
"multiline"_s ).toBool();
5718 QString def = definition;
5720 if ( def.startsWith(
"long"_L1, Qt::CaseInsensitive ) )
5726 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5728 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5732 if ( def ==
"None"_L1 )
5755 if ( !value.isValid() )
5758 const QString s = value.toString();
5764 QString code = u
"##%1="_s.arg(
mName );
5766 code +=
"optional "_L1;
5767 code +=
"authcfg "_L1;
5770 return code.trimmed();
5775 QString def = definition;
5777 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5779 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5783 if ( def ==
"None"_L1 )
5797 , mExpressionType(
type )
5809 if ( !value.isValid() )
5812 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5815 const QString s = value.toString();
5821 QStringList depends;
5822 if ( !mParentLayerParameterName.isEmpty() )
5823 depends << mParentLayerParameterName;
5829 switch ( outputType )
5833 QString code = u
"QgsProcessingParameterExpression('%1', %2"_s
5836 code +=
", optional=True"_L1;
5838 code += u
", parentLayerParameterName='%1'"_s.arg( mParentLayerParameterName );
5844 switch ( mExpressionType )
5847 code +=
", type=Qgis.ExpressionType.PointCloud)"_L1;
5850 code +=
", type=Qgis.ExpressionType.RasterCalculator)"_L1;
5864 return mParentLayerParameterName;
5874 return mExpressionType;
5885 map.insert( u
"parent_layer"_s, mParentLayerParameterName );
5886 map.insert( u
"expression_type"_s,
static_cast< int >( mExpressionType ) );
5893 mParentLayerParameterName = map.value( u
"parent_layer"_s ).toString();
5894 mExpressionType =
static_cast< Qgis::ExpressionType >( map.value( u
"expression_type"_s ).toInt() );
5919 if ( !var.isValid() )
5927 if ( var.userType() == qMetaTypeId<QgsProperty>() )
5940 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
5943 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
5961 if ( !val.isValid() )
5964 if ( val.userType() == qMetaTypeId<QgsProperty>() )
5968 p.insert(
name(), val );
5986 switch ( outputType )
5990 QString code = u
"QgsProcessingParameterVectorLayer('%1', %2"_s
5993 code +=
", optional=True"_L1;
5997 QStringList options;
6000 code += u
", types=[%1]"_s.arg( options.join(
',' ) );
6034 map.insert( u
"data_types"_s, types );
6042 const QVariantList values = map.value( u
"data_types"_s ).toList();
6043 for (
const QVariant &val : values )
6071 if ( !var.isValid() )
6079 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6092 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
6095 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
6113 if ( !val.isValid() )
6116 if ( val.userType() == qMetaTypeId<QgsProperty>() )
6120 p.insert(
name(), val );
6165 if ( !input.isValid() )
6173 if ( input.userType() == qMetaTypeId<QgsProperty>() )
6178 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
6180 if ( !mAllowMultiple )
6186 else if ( input.userType() == QMetaType::Type::QString )
6188 if ( input.toString().isEmpty() )
6191 const QStringList parts = input.toString().split(
';' );
6192 if ( parts.count() > 1 && !mAllowMultiple )
6197 if ( input.toString().isEmpty() )
6205 if ( !value.isValid() )
6208 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6211 if ( value.userType() == QMetaType::Type::QVariantList )
6214 const auto constToList = value.toList();
6215 for (
const QVariant &val : constToList )
6219 return parts.join(
',' ).prepend(
'[' ).append(
']' );
6221 else if ( value.userType() == QMetaType::Type::QStringList )
6224 const auto constToStringList = value.toStringList();
6225 for (
const QString &s : constToStringList )
6229 return parts.join(
',' ).prepend(
'[' ).append(
']' );
6237 QString code = u
"##%1="_s.arg(
mName );
6239 code +=
"optional "_L1;
6240 code +=
"field "_L1;
6242 switch ( mDataType )
6245 code +=
"numeric "_L1;
6249 code +=
"string "_L1;
6253 code +=
"datetime "_L1;
6257 code +=
"binary "_L1;
6261 code +=
"boolean "_L1;
6268 if ( mAllowMultiple )
6269 code +=
"multiple "_L1;
6271 if ( mDefaultToAllFields )
6272 code +=
"default_to_all_fields "_L1;
6274 code += mParentLayerParameterName +
' ';
6277 return code.trimmed();
6282 switch ( outputType )
6286 QString code = u
"QgsProcessingParameterField('%1', %2"_s
6289 code +=
", optional=True"_L1;
6292 switch ( mDataType )
6295 dataType = u
"QgsProcessingParameterField.Any"_s;
6299 dataType = u
"QgsProcessingParameterField.Numeric"_s;
6303 dataType = u
"QgsProcessingParameterField.String"_s;
6307 dataType = u
"QgsProcessingParameterField.DateTime"_s;
6311 dataType = u
"QgsProcessingParameterField.Binary"_s;
6315 dataType = u
"QgsProcessingParameterField.Boolean"_s;
6318 code += u
", type=%1"_s.arg(
dataType );
6320 code += u
", parentLayerParameterName='%1'"_s.arg( mParentLayerParameterName );
6321 code += u
", allowMultiple=%1"_s.arg( mAllowMultiple ? u
"True"_s : u
"False"_s );
6325 if ( mDefaultToAllFields )
6326 code +=
", defaultToAllFields=True"_L1;
6338 QStringList depends;
6339 if ( !mParentLayerParameterName.isEmpty() )
6340 depends << mParentLayerParameterName;
6346 return mParentLayerParameterName;
6366 return mAllowMultiple;
6376 return mDefaultToAllFields;
6381 mDefaultToAllFields = enabled;
6387 map.insert( u
"parent_layer"_s, mParentLayerParameterName );
6388 map.insert( u
"data_type"_s,
static_cast< int >( mDataType ) );
6389 map.insert( u
"allow_multiple"_s, mAllowMultiple );
6390 map.insert( u
"default_to_all_fields"_s, mDefaultToAllFields );
6397 mParentLayerParameterName = map.value( u
"parent_layer"_s ).toString();
6399 mAllowMultiple = map.value( u
"allow_multiple"_s ).toBool();
6400 mDefaultToAllFields = map.value( u
"default_to_all_fields"_s ).toBool();
6410 QString def = definition;
6412 if ( def.startsWith(
"numeric "_L1, Qt::CaseInsensitive ) )
6417 else if ( def.startsWith(
"string "_L1, Qt::CaseInsensitive ) )
6422 else if ( def.startsWith(
"datetime "_L1, Qt::CaseInsensitive ) )
6427 else if ( def.startsWith(
"binary "_L1, Qt::CaseInsensitive ) )
6432 else if ( def.startsWith(
"boolean "_L1, Qt::CaseInsensitive ) )
6438 if ( def.startsWith(
"multiple"_L1, Qt::CaseInsensitive ) )
6441 def = def.mid( 8 ).trimmed();
6444 if ( def.startsWith(
"default_to_all_fields"_L1, Qt::CaseInsensitive ) )
6447 def = def.mid( 21 ).trimmed();
6450 const thread_local QRegularExpression re( u
"(.*?)\\s+(.*)$"_s );
6451 const QRegularExpressionMatch m = re.match( def );
6454 parent = m.captured( 1 ).trimmed();
6455 def = m.captured( 2 );
6480 QVariant var = input;
6481 if ( !var.isValid() )
6489 if ( var.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
6494 else if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6501 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6513 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
6518 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
6536 if ( !value.isValid() )
6539 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6542 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
6545 QString geometryCheckString;
6549 geometryCheckString = u
"QgsFeatureRequest.GeometryNoCheck"_s;
6553 geometryCheckString = u
"QgsFeatureRequest.GeometrySkipInvalid"_s;
6557 geometryCheckString = u
"QgsFeatureRequest.GeometryAbortOnInvalid"_s;
6564 flags << u
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck"_s;
6566 flags << u
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature"_s;
6567 if ( !
flags.empty() )
6568 flagString =
flags.join(
" | "_L1 );
6575 layerString = layer->source();
6582 flagString.isEmpty() ? QString() : ( u
", flags=%1"_s.arg( flagString ) ),
6583 geometryCheckString,
6595 return u
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression(%1), selectedFeaturesOnly=%2, featureLimit=%3%4%6, geometryCheck=%5)"_s
6599 flagString.isEmpty() ? QString() : ( u
", flags=%1"_s.arg( flagString ) ),
6600 geometryCheckString,
6609 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
6614 QString layerString = value.toString();
6618 layerString = layer->providerType() !=
"ogr"_L1 && layer->providerType() !=
"gdal"_L1 && layer->providerType() !=
"mdal"_L1 ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
6635 QString code = u
"##%1="_s.arg(
mName );
6637 code +=
"optional "_L1;
6638 code +=
"source "_L1;
6645 code +=
"point "_L1;
6653 code +=
"polygon "_L1;
6662 return code.trimmed();
6667 switch ( outputType )
6671 QString code = u
"QgsProcessingParameterFeatureSource('%1', %2"_s
6674 code +=
", optional=True"_L1;
6678 QStringList options;
6682 code += u
", types=[%1]"_s.arg( options.join(
',' ) );
6712 map.insert( u
"data_types"_s, types );
6720 const QVariantList values = map.value( u
"data_types"_s ).toList();
6721 for (
const QVariant &val : values )
6731 QString def = definition;
6734 if ( def.startsWith(
"point"_L1, Qt::CaseInsensitive ) )
6740 else if ( def.startsWith(
"line"_L1, Qt::CaseInsensitive ) )
6746 else if ( def.startsWith(
"polygon"_L1, Qt::CaseInsensitive ) )
6772 QVariant var = input;
6773 if ( !var.isValid() )
6781 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6787 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6800 if ( var.userType() != QMetaType::Type::QString )
6803 if ( var.toString().isEmpty() )
6811 if ( !value.isValid() )
6814 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6817 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6826 return u
"QgsProperty.fromExpression('%1')"_s.arg( fromVar.
sink.
asExpression() );
6835 QString code = u
"##%1="_s.arg(
mName );
6837 code +=
"optional "_L1;
6840 switch ( mDataType )
6843 code +=
"point "_L1;
6851 code +=
"polygon "_L1;
6855 code +=
"table "_L1;
6863 return code.trimmed();
6875 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6879 return p->defaultVectorFileExtension(
hasGeometry() );
6896 switch ( outputType )
6900 QString code = u
"QgsProcessingParameterFeatureSink('%1', %2"_s
6903 code +=
", optional=True"_L1;
6907 code += u
", createByDefault=%1"_s.arg(
createByDefault() ? u
"True"_s : u
"False"_s );
6908 if ( mSupportsAppend )
6909 code +=
", supportsAppend=True"_L1;
6922 QStringList filters;
6923 for (
const QString &ext : exts )
6925 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6927 return filters.join(
";;"_L1 ) + u
";;"_s + QObject::tr(
"All files (*.*)" );
6936 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6938 return lOriginalProvider->supportedOutputTableExtensions();
6943 return p->supportedOutputVectorLayerExtensions();
6945 return p->supportedOutputTableExtensions();
6960 switch ( mDataType )
6991 map.insert( u
"data_type"_s,
static_cast< int >( mDataType ) );
6992 map.insert( u
"supports_append"_s, mSupportsAppend );
7000 mSupportsAppend = map.value( u
"supports_append"_s,
false ).toBool();
7015 QString def = definition;
7016 if ( def.startsWith(
"point"_L1, Qt::CaseInsensitive ) )
7021 else if ( def.startsWith(
"line"_L1, Qt::CaseInsensitive ) )
7026 else if ( def.startsWith(
"polygon"_L1, Qt::CaseInsensitive ) )
7031 else if ( def.startsWith(
"table"_L1, Qt::CaseInsensitive ) )
7042 return mSupportsAppend;
7062 QVariant var = input;
7063 if ( !var.isValid() )
7071 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
7077 if ( var.userType() == qMetaTypeId<QgsProperty>() )
7090 if ( var.userType() != QMetaType::Type::QString )
7093 if ( var.toString().isEmpty() )
7101 if ( !value.isValid() )
7104 if ( value.userType() == qMetaTypeId<QgsProperty>() )
7107 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
7116 return u
"QgsProperty.fromExpression('%1')"_s.arg( fromVar.
sink.
asExpression() );
7132 return lOriginalProvider->defaultRasterFileFormat();
7136 return p->defaultRasterFileFormat();
7148 if ( !extensions.isEmpty() )
7149 return extensions[0];
7156 QStringList filters;
7158 for (
const QPair<QString, QString> &formatAndExt : std::as_const( formatAndExtensions ) )
7160 QString format = formatAndExt.first;
7161 const QString &extension = formatAndExt.second;
7162 if ( format.isEmpty() )
7164 filters << QObject::tr(
"%1 files (*.%2)" ).arg( format.toUpper(), extension.toLower() );
7167 return filters.join(
";;"_L1 ) + u
";;"_s + QObject::tr(
"All files (*.*)" );
7173 QSet< QString > extensions;
7174 for (
const QPair<QString, QString> &formatAndExt : std::as_const( formatAndExtensions ) )
7176 extensions.insert( formatAndExt.second );
7178 return QStringList( extensions.constBegin(), extensions.constEnd() );
7185 return lOriginalProvider->supportedOutputRasterLayerFormatAndExtensions();
7189 return p->supportedOutputRasterLayerFormatAndExtensions();
7217 QVariant var = input;
7218 if ( !var.isValid() )
7226 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
7232 if ( var.userType() == qMetaTypeId<QgsProperty>() )
7245 if ( var.userType() != QMetaType::Type::QString )
7248 if ( var.toString().isEmpty() )
7258 if ( !value.isValid() )
7261 if ( value.userType() == qMetaTypeId<QgsProperty>() )
7264 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
7273 return u
"QgsProperty.fromExpression('%1')"_s.arg( fromVar.
sink.
asExpression() );
7282 if ( !mFileFilter.isEmpty() && mFileFilter.contains( u
"htm"_s, Qt::CaseInsensitive ) )
7294 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
7298 const thread_local QRegularExpression rx( u
".*?\\(\\*\\.([a-zA-Z0-9._]+).*"_s );
7299 const QRegularExpressionMatch match = rx.match( mFileFilter );
7300 if ( !match.hasMatch() )
7303 return match.captured( 1 );
7308 switch ( outputType )
7312 QString code = u
"QgsProcessingParameterFileDestination('%1', %2"_s
7315 code +=
", optional=True"_L1;
7319 code += u
", createByDefault=%1"_s.arg(
createByDefault() ? u
"True"_s : u
"False"_s );
7331 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + u
";;"_s ) + QObject::tr(
"All files (*.*)" );
7347 map.insert( u
"file_filter"_s, mFileFilter );
7354 mFileFilter = map.value( u
"file_filter"_s ).toString();
7375 QVariant var = input;
7376 if ( !var.isValid() )
7384 if ( var.userType() == qMetaTypeId<QgsProperty>() )
7397 if ( var.userType() != QMetaType::Type::QString )
7400 if ( var.toString().isEmpty() )
7431 map.insert( u
"supports_non_file_outputs"_s, mSupportsNonFileBasedOutputs );
7432 map.insert( u
"create_by_default"_s, mCreateByDefault );
7439 mSupportsNonFileBasedOutputs = map.value( u
"supports_non_file_outputs"_s ).toBool();
7440 mCreateByDefault = map.value( u
"create_by_default"_s, u
"1"_s ).toBool();
7446 switch ( outputType )
7453 QString code = t->className() + u
"('%1', %2"_s
7456 code +=
", optional=True"_L1;
7458 code += u
", createByDefault=%1"_s.arg( mCreateByDefault ? u
"True"_s : u
"False"_s );
7480 const thread_local QRegularExpression rx( u
"[.]"_s );
7481 QString sanitizedName =
name();
7482 sanitizedName.replace( rx, u
"_"_s );
7497 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
7506 return mCreateByDefault;
7528 QVariant var = input;
7529 if ( !var.isValid() )
7537 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
7543 if ( var.userType() == qMetaTypeId<QgsProperty>() )
7556 if ( var.userType() != QMetaType::Type::QString )
7559 if ( var.toString().isEmpty() )
7567 if ( !value.isValid() )
7570 if ( value.userType() == qMetaTypeId<QgsProperty>() )
7573 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
7582 return u
"QgsProperty.fromExpression('%1')"_s.arg( fromVar.
sink.
asExpression() );
7591 QString code = u
"##%1="_s.arg(
mName );
7593 code +=
"optional "_L1;
7594 code +=
"vectorDestination "_L1;
7596 switch ( mDataType )
7599 code +=
"point "_L1;
7607 code +=
"polygon "_L1;
7615 return code.trimmed();
7627 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
7631 return p->defaultVectorFileExtension(
hasGeometry() );
7648 switch ( outputType )
7652 QString code = u
"QgsProcessingParameterVectorDestination('%1', %2"_s
7655 code +=
", optional=True"_L1;
7659 code += u
", createByDefault=%1"_s.arg(
createByDefault() ? u
"True"_s : u
"False"_s );
7672 QStringList filters;
7673 for (
const QString &ext : exts )
7675 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
7677 return filters.join(
";;"_L1 ) + u
";;"_s + QObject::tr(
"All files (*.*)" );
7685 return lOriginalProvider->supportedOutputVectorLayerExtensions();
7687 return lOriginalProvider->supportedOutputTableExtensions();
7692 return p->supportedOutputVectorLayerExtensions();
7694 return p->supportedOutputTableExtensions();
7709 switch ( mDataType )
7740 map.insert( u
"data_type"_s,
static_cast< int >( mDataType ) );
7754 QString def = definition;
7755 if ( def.startsWith(
"point"_L1, Qt::CaseInsensitive ) )
7760 else if ( def.startsWith(
"line"_L1, Qt::CaseInsensitive ) )
7765 else if ( def.startsWith(
"polygon"_L1, Qt::CaseInsensitive ) )
7789 QVariant input = value;
7790 if ( !input.isValid() )
7798 if ( input.userType() == qMetaTypeId<QgsProperty>() )
7803 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
7805 if ( !mAllowMultiple )
7814 const double res = input.toInt( &ok );
7824 return mAllowMultiple;
7834 if ( !value.isValid() )
7837 if ( value.userType() == qMetaTypeId<QgsProperty>() )
7840 if ( value.userType() == QMetaType::Type::QVariantList )
7843 const QVariantList values = value.toList();
7844 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7846 parts << QString::number( static_cast< int >( it->toDouble() ) );
7848 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7850 else if ( value.userType() == QMetaType::Type::QStringList )
7853 const QStringList values = value.toStringList();
7854 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7856 parts << QString::number( static_cast< int >( it->toDouble() ) );
7858 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7861 return value.toString();
7866 QString code = u
"##%1="_s.arg(
mName );
7868 code +=
"optional "_L1;
7871 if ( mAllowMultiple )
7872 code +=
"multiple "_L1;
7874 code += mParentLayerParameterName +
' ';
7877 return code.trimmed();
7882 QStringList depends;
7883 if ( !mParentLayerParameterName.isEmpty() )
7884 depends << mParentLayerParameterName;
7890 switch ( outputType )
7894 QString code = u
"QgsProcessingParameterBand('%1', %2"_s
7897 code +=
", optional=True"_L1;
7899 code += u
", parentLayerParameterName='%1'"_s.arg( mParentLayerParameterName );
7900 code += u
", allowMultiple=%1"_s.arg( mAllowMultiple ? u
"True"_s : u
"False"_s );
7912 return mParentLayerParameterName;
7923 map.insert( u
"parent_layer"_s, mParentLayerParameterName );
7924 map.insert( u
"allow_multiple"_s, mAllowMultiple );
7931 mParentLayerParameterName = map.value( u
"parent_layer"_s ).toString();
7932 mAllowMultiple = map.value( u
"allow_multiple"_s ).toBool();
7939 QString def = definition;
7942 if ( def.startsWith(
"multiple"_L1, Qt::CaseInsensitive ) )
7945 def = def.mid( 8 ).trimmed();
7948 const thread_local QRegularExpression re( u
"(.*?)\\s+(.*)$"_s );
7949 const QRegularExpressionMatch m = re.match( def );
7952 parent = m.captured( 1 ).trimmed();
7953 def = m.captured( 2 );
7987 QStringList depends;
7988 if ( !mParentParameterName.isEmpty() )
7989 depends << mParentParameterName;
7995 switch ( outputType )
7999 QString code = u
"QgsProcessingParameterDistance('%1', %2"_s
8002 code +=
", optional=True"_L1;
8004 code += u
", parentParameterName='%1'"_s.arg( mParentParameterName );
8006 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
8007 code += u
", minValue=%1"_s.arg(
minimum() );
8008 if (
maximum() != std::numeric_limits<double>::max() )
8009 code += u
", maxValue=%1"_s.arg(
maximum() );
8020 return mParentParameterName;
8031 map.insert( u
"parent"_s, mParentParameterName );
8032 map.insert( u
"default_unit"_s,
static_cast< int >( mDefaultUnit ) );
8039 mParentParameterName = map.value( u
"parent"_s ).toString();
8077 QStringList depends;
8078 if ( !mParentParameterName.isEmpty() )
8079 depends << mParentParameterName;
8085 switch ( outputType )
8089 QString code = u
"QgsProcessingParameterArea('%1', %2"_s
8092 code +=
", optional=True"_L1;
8094 code += u
", parentParameterName='%1'"_s.arg( mParentParameterName );
8097 code += u
", minValue=%1"_s.arg(
minimum() );
8098 if (
maximum() != std::numeric_limits<double>::max() )
8099 code += u
", maxValue=%1"_s.arg(
maximum() );
8110 return mParentParameterName;
8121 map.insert( u
"parent"_s, mParentParameterName );
8129 mParentParameterName = map.value( u
"parent"_s ).toString();
8167 QStringList depends;
8168 if ( !mParentParameterName.isEmpty() )
8169 depends << mParentParameterName;
8175 switch ( outputType )
8179 QString code = u
"QgsProcessingParameterVolume('%1', %2"_s
8182 code +=
", optional=True"_L1;
8184 code += u
", parentParameterName='%1'"_s.arg( mParentParameterName );
8187 code += u
", minValue=%1"_s.arg(
minimum() );
8188 if (
maximum() != std::numeric_limits<double>::max() )
8189 code += u
", maxValue=%1"_s.arg(
maximum() );
8200 return mParentParameterName;
8211 map.insert( u
"parent"_s, mParentParameterName );
8219 mParentParameterName = map.value( u
"parent"_s ).toString();
8253 switch ( outputType )
8257 QString code = u
"QgsProcessingParameterDuration('%1', %2"_s
8260 code +=
", optional=True"_L1;
8262 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
8263 code += u
", minValue=%1"_s.arg(
minimum() );
8264 if (
maximum() != std::numeric_limits<double>::max() )
8265 code += u
", maxValue=%1"_s.arg(
maximum() );
8277 map.insert( u
"default_unit"_s,
static_cast< int >( mDefaultUnit ) );
8319 switch ( outputType )
8323 QString code = u
"QgsProcessingParameterScale('%1', %2"_s
8326 code +=
", optional=True"_L1;
8338 : ( definition.toLower().trimmed() ==
"none"_L1 ? QVariant() : definition ), isOptional );
8360 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8363 const QString s = value.toString();
8369 QString code = u
"##%1="_s.arg(
mName );
8371 code +=
"optional "_L1;
8372 code +=
"layout "_L1;
8375 return code.trimmed();
8380 switch ( outputType )
8384 QString code = u
"QgsProcessingParameterLayout('%1', %2"_s
8387 code +=
", optional=True"_L1;
8398 QString def = definition;
8400 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8402 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8406 if ( def ==
"None"_L1 )
8435 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8438 const QString s = value.toString();
8444 QString code = u
"##%1="_s.arg(
mName );
8446 code +=
"optional "_L1;
8447 code +=
"layoutitem "_L1;
8448 if ( mItemType >= 0 )
8449 code += QString::number( mItemType ) +
' ';
8451 code += mParentLayoutParameterName +
' ';
8454 return code.trimmed();
8459 switch ( outputType )
8463 QString code = u
"QgsProcessingParameterLayoutItem('%1', %2"_s
8466 code +=
", optional=True"_L1;
8468 if ( mItemType >= 0 )
8469 code += u
", itemType=%1"_s.arg( mItemType );
8471 code += u
", parentLayoutParameterName='%1'"_s.arg( mParentLayoutParameterName );
8484 map.insert( u
"parent_layout"_s, mParentLayoutParameterName );
8485 map.insert( u
"item_type"_s, mItemType );
8492 mParentLayoutParameterName = map.value( u
"parent_layout"_s ).toString();
8493 mItemType = map.value( u
"item_type"_s ).toInt();
8499 QStringList depends;
8500 if ( !mParentLayoutParameterName.isEmpty() )
8501 depends << mParentLayoutParameterName;
8508 QString def = definition;
8510 const thread_local QRegularExpression re( u
"(\\d+)?\\s*(.*?)\\s+(.*)$"_s );
8511 const QRegularExpressionMatch m = re.match( def );
8514 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
8515 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
8516 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
8529 return mParentLayoutParameterName;
8534 mParentLayoutParameterName =
name;
8568 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8571 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
8572 return u
"QColor()"_s;
8574 if ( value.canConvert< QColor >() )
8576 const QColor
c = value.value< QColor >();
8577 if ( !mAllowOpacity ||
c.alpha() == 255 )
8578 return u
"QColor(%1, %2, %3)"_s.arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
8580 return u
"QColor(%1, %2, %3, %4)"_s.arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
8583 const QString s = value.toString();
8589 QString code = u
"##%1="_s.arg(
mName );
8591 code +=
"optional "_L1;
8592 code +=
"color "_L1;
8594 if ( mAllowOpacity )
8595 code +=
"withopacity "_L1;
8598 return code.trimmed();
8603 switch ( outputType )
8607 QString code = u
"QgsProcessingParameterColor('%1', %2"_s
8610 code +=
", optional=True"_L1;
8612 code += u
", opacityEnabled=%1"_s.arg( mAllowOpacity ? u
"True"_s : u
"False"_s );
8624 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
8627 if ( !input.isValid() )
8630 if ( input.userType() == QMetaType::Type::QColor )
8634 else if ( input.userType() == qMetaTypeId<QgsProperty>() )
8639 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
8642 bool containsAlpha =
false;
8649 map.insert( u
"opacityEnabled"_s, mAllowOpacity );
8656 mAllowOpacity = map.value( u
"opacityEnabled"_s ).toBool();
8662 return mAllowOpacity;
8667 mAllowOpacity = enabled;
8672 QString def = definition;
8674 bool allowOpacity =
false;
8675 if ( def.startsWith(
"withopacity"_L1, Qt::CaseInsensitive ) )
8677 allowOpacity =
true;
8678 def = def.mid( 12 );
8681 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8683 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8687 if ( def ==
"None"_L1 || def.isEmpty() )
8700 , mSourceCrs( staticSourceCrs )
8701 , mDestCrs( staticDestinationCrs )
8713 return valueAsPythonStringPrivate( value, context,
false );
8716QString QgsProcessingParameterCoordinateOperation::valueAsPythonStringPrivate(
const QVariant &value,
QgsProcessingContext &context,
bool allowNonStringValues )
const
8721 if ( allowNonStringValues && value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
8724 return u
"QgsCoordinateReferenceSystem()"_s;
8729 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8730 return u
"QgsProperty.fromExpression('%1')"_s.arg( value.value< QgsProperty >().asExpression() );
8732 if ( allowNonStringValues )
8735 p.insert(
name(), value );
8741 const QString s = value.toString();
8747 QString code = u
"##%1="_s.arg(
mName );
8749 code +=
"optional "_L1;
8750 code +=
"coordinateoperation "_L1;
8753 return code.trimmed();
8758 switch ( outputType )
8763 QString code = u
"QgsProcessingParameterCoordinateOperation('%1', %2"_s
8766 code +=
", optional=True"_L1;
8767 if ( !mSourceParameterName.isEmpty() )
8768 code += u
", sourceCrsParameterName=%1"_s.arg( valueAsPythonStringPrivate( mSourceParameterName,
c,
false ) );
8769 if ( !mDestParameterName.isEmpty() )
8770 code += u
", destinationCrsParameterName=%1"_s.arg( valueAsPythonStringPrivate( mDestParameterName,
c,
false ) );
8772 if ( mSourceCrs.isValid() )
8773 code += u
", staticSourceCrs=%1"_s.arg( valueAsPythonStringPrivate( mSourceCrs,
c,
true ) );
8774 if ( mDestCrs.isValid() )
8775 code += u
", staticDestinationCrs=%1"_s.arg( valueAsPythonStringPrivate( mDestCrs,
c,
true ) );
8777 code += u
", defaultValue=%1)"_s.arg( valueAsPythonStringPrivate(
mDefault,
c,
false ) );
8787 if ( !mSourceParameterName.isEmpty() )
8788 res << mSourceParameterName;
8789 if ( !mDestParameterName.isEmpty() )
8790 res << mDestParameterName;
8797 map.insert( u
"source_crs_parameter_name"_s, mSourceParameterName );
8798 map.insert( u
"dest_crs_parameter_name"_s, mDestParameterName );
8799 map.insert( u
"static_source_crs"_s, mSourceCrs );
8800 map.insert( u
"static_dest_crs"_s, mDestCrs );
8807 mSourceParameterName = map.value( u
"source_crs_parameter_name"_s ).toString();
8808 mDestParameterName = map.value( u
"dest_crs_parameter_name"_s ).toString();
8809 mSourceCrs = map.value( u
"static_source_crs"_s );
8810 mDestCrs = map.value( u
"static_dest_crs"_s );
8816 QString def = definition;
8818 if ( def.startsWith(
'"' ) )
8821 if ( def.endsWith(
'"' ) )
8824 else if ( def.startsWith(
'\'' ) )
8827 if ( def.endsWith(
'\'' ) )
8832 if ( def ==
"None"_L1 )
8857 if ( !input.isValid() && !
mDefault.isValid() )
8860 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8861 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8869 if ( !value.isValid() )
8872 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8880 QString code = u
"##%1="_s.arg(
mName );
8882 code +=
"optional "_L1;
8883 code +=
"maptheme "_L1;
8886 return code.trimmed();
8891 switch ( outputType )
8895 QString code = u
"QgsProcessingParameterMapTheme('%1', %2"_s
8898 code +=
", optional=True"_L1;
8923 QString def = definition;
8924 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8926 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8948 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
8950 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg( name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
8961 QVariant input = value;
8962 if ( !input.isValid() )
8970 if ( input.userType() == qMetaTypeId<QgsProperty>() )
8975 if ( input.userType() != QMetaType::Type::QDateTime && input.userType() != QMetaType::Type::QDate && input.userType() != QMetaType::Type::QTime && input.userType() != QMetaType::Type::QString )
8981 if ( input.userType() == QMetaType::Type::QString )
8983 const QString s = input.toString();
8987 input = QDateTime::fromString( s, Qt::ISODate );
8990 if ( !input.toDateTime().isValid() )
8991 input = QTime::fromString( s );
8993 input = input.toDateTime().time();
8999 const QDateTime res = input.toDateTime();
9000 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
9004 const QTime res = input.toTime();
9005 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
9011 if ( !value.isValid() )
9014 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9017 if ( value.userType() == QMetaType::Type::QDateTime )
9019 const QDateTime dt = value.toDateTime();
9020 if ( !dt.isValid() )
9021 return u
"QDateTime()"_s;
9023 return u
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))"_s.arg( dt.date().year() )
9024 .arg( dt.date().month() )
9025 .arg( dt.date().day() )
9026 .arg( dt.time().hour() )
9027 .arg( dt.time().minute() )
9028 .arg( dt.time().second() );
9030 else if ( value.userType() == QMetaType::Type::QDate )
9032 const QDate dt = value.toDate();
9033 if ( !dt.isValid() )
9034 return u
"QDate()"_s;
9036 return u
"QDate(%1, %2, %3)"_s.arg( dt.year() )
9040 else if ( value.userType() == QMetaType::Type::QTime )
9042 const QTime dt = value.toTime();
9043 if ( !dt.isValid() )
9044 return u
"QTime()"_s;
9046 return u
"QTime(%4, %5, %6)"_s
9049 .arg( dt.second() );
9051 return value.toString();
9058 if ( mMin.isValid() )
9059 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
9060 if ( mMax.isValid() )
9061 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
9065 const QString extra = parts.join(
"<br />"_L1 );
9066 if ( !extra.isEmpty() )
9067 text += u
"<p>%1</p>"_s.arg( extra );
9073 switch ( outputType )
9077 QString code = u
"QgsProcessingParameterDateTime('%1', %2"_s
9080 code +=
", optional=True"_L1;
9084 : u
"QgsProcessingParameterDateTime.Time"_s );
9087 if ( mMin.isValid() )
9089 if ( mMax.isValid() )
9131 map.insert( u
"min"_s, mMin );
9132 map.insert( u
"max"_s, mMax );
9133 map.insert( u
"data_type"_s,
static_cast< int >( mDataType ) );
9140 mMin = map.value( u
"min"_s ).toDateTime();
9141 mMax = map.value( u
"max"_s ).toDateTime();
9149 : ( definition.toLower().trimmed() ==
"none"_L1 ? QVariant() : definition ), isOptional );
9158 if ( value.userType() == QMetaType::Type::QDateTime )
9160 const QDateTime dt = value.toDateTime();
9161 if ( !dt.isValid() )
9162 return QObject::tr(
"Invalid datetime" );
9164 return dt.toString( Qt::ISODate );
9167 else if ( value.userType() == QMetaType::Type::QDate )
9169 const QDate dt = value.toDate();
9170 if ( !dt.isValid() )
9171 return QObject::tr(
"Invalid date" );
9173 return dt.toString( Qt::ISODate );
9176 else if ( value.userType() == QMetaType::Type::QTime )
9178 const QTime dt = value.toTime();
9179 if ( !dt.isValid() )
9180 return QObject::tr(
"Invalid time" );
9182 return dt.toString( Qt::ISODate );
9185 return value.toString();
9207 if ( !input.isValid() && !
mDefault.isValid() )
9210 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
9211 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
9219 if ( !value.isValid() )
9222 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9230 QString code = u
"##%1="_s.arg(
mName );
9232 code +=
"optional "_L1;
9233 code +=
"providerconnection "_L1;
9234 code += mProviderId +
' ';
9237 return code.trimmed();
9242 switch ( outputType )
9246 QString code = u
"QgsProcessingParameterProviderConnection('%1', %2, '%3'"_s
9249 code +=
", optional=True"_L1;
9263 map.insert( u
"provider"_s, mProviderId );
9270 mProviderId = map.value( u
"provider"_s ).toString();
9276 QString def = definition;
9278 if ( def.contains(
' ' ) )
9280 provider = def.left( def.indexOf(
' ' ) );
9281 def = def.mid( def.indexOf(
' ' ) + 1 );
9289 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
9291 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
9309 , mParentConnectionParameterName( parentLayerParameterName )
9322 if ( !input.isValid() && !
mDefault.isValid() )
9325 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
9326 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
9334 if ( !value.isValid() )
9337 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9345 QString code = u
"##%1="_s.arg(
mName );
9347 code +=
"optional "_L1;
9348 code +=
"databaseschema "_L1;
9350 code += mParentConnectionParameterName +
' ';
9353 return code.trimmed();
9358 switch ( outputType )
9362 QString code = u
"QgsProcessingParameterDatabaseSchema('%1', %2"_s
9365 code +=
", optional=True"_L1;
9367 code += u
", connectionParameterName='%1'"_s.arg( mParentConnectionParameterName );
9381 QStringList depends;
9382 if ( !mParentConnectionParameterName.isEmpty() )
9383 depends << mParentConnectionParameterName;
9389 return mParentConnectionParameterName;
9394 mParentConnectionParameterName =
name;
9400 map.insert( u
"mParentConnectionParameterName"_s, mParentConnectionParameterName );
9407 mParentConnectionParameterName = map.value( u
"mParentConnectionParameterName"_s ).toString();
9414 QString def = definition;
9416 const thread_local QRegularExpression re( u
"(.*?)\\s+(.*)$"_s );
9417 const QRegularExpressionMatch m = re.match( def );
9420 parent = m.captured( 1 ).trimmed();
9421 def = m.captured( 2 );
9437 const QString &connectionParameterName,
9438 const QString &schemaParameterName,
9441 , mParentConnectionParameterName( connectionParameterName )
9442 , mParentSchemaParameterName( schemaParameterName )
9456 if ( !input.isValid() && !
mDefault.isValid() )
9459 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
9460 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
9468 if ( !value.isValid() )
9471 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9479 QString code = u
"##%1="_s.arg(
mName );
9481 code +=
"optional "_L1;
9482 code +=
"databasetable "_L1;
9484 code += ( mParentConnectionParameterName.isEmpty() ? u
"none"_s : mParentConnectionParameterName ) +
' ';
9485 code += ( mParentSchemaParameterName.isEmpty() ? u
"none"_s : mParentSchemaParameterName ) +
' ';
9488 return code.trimmed();
9493 switch ( outputType )
9497 QString code = u
"QgsProcessingParameterDatabaseTable('%1', %2"_s
9500 code +=
", optional=True"_L1;
9502 if ( mAllowNewTableNames )
9503 code +=
", allowNewTableNames=True"_L1;
9505 code += u
", connectionParameterName='%1'"_s.arg( mParentConnectionParameterName );
9506 code += u
", schemaParameterName='%1'"_s.arg( mParentSchemaParameterName );
9520 QStringList depends;
9521 if ( !mParentConnectionParameterName.isEmpty() )
9522 depends << mParentConnectionParameterName;
9523 if ( !mParentSchemaParameterName.isEmpty() )
9524 depends << mParentSchemaParameterName;
9530 return mParentConnectionParameterName;
9535 mParentConnectionParameterName =
name;
9540 return mParentSchemaParameterName;
9545 mParentSchemaParameterName =
name;
9551 map.insert( u
"mParentConnectionParameterName"_s, mParentConnectionParameterName );
9552 map.insert( u
"mParentSchemaParameterName"_s, mParentSchemaParameterName );
9553 map.insert( u
"mAllowNewTableNames"_s, mAllowNewTableNames );
9560 mParentConnectionParameterName = map.value( u
"mParentConnectionParameterName"_s ).toString();
9561 mParentSchemaParameterName = map.value( u
"mParentSchemaParameterName"_s ).toString();
9562 mAllowNewTableNames = map.value( u
"mAllowNewTableNames"_s,
false ).toBool();
9570 QString def = definition;
9572 const thread_local QRegularExpression re( u
"(.*?)\\s+(.*+)\\b\\s*(.*)$"_s );
9573 const QRegularExpressionMatch m = re.match( def );
9576 connection = m.captured( 1 ).trimmed();
9577 if ( connection ==
"none"_L1 )
9579 schema = m.captured( 2 ).trimmed();
9580 if ( schema ==
"none"_L1 )
9582 def = m.captured( 3 );
9590 return mAllowNewTableNames;
9617 if ( !var.isValid() )
9625 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9638 if ( qobject_cast< QgsPointCloudLayer * >( qvariant_cast<QObject *>( var ) ) )
9641 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
9659 if ( !val.isValid() )
9662 if ( val.userType() == qMetaTypeId<QgsProperty>() )
9666 p.insert(
name(), val );
9710 if ( !var.isValid() )
9718 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9731 if ( qobject_cast< QgsAnnotationLayer * >( qvariant_cast<QObject *>( var ) ) )
9734 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
9752 if ( !val.isValid() )
9755 if ( val.userType() == qMetaTypeId<QgsProperty>() )
9759 p.insert(
name(), val );
9792 QVariant var = input;
9793 if ( !var.isValid() )
9801 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9807 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9820 if ( var.userType() != QMetaType::Type::QString )
9823 if ( var.toString().isEmpty() )
9831 if ( !value.isValid() )
9834 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9837 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9846 return u
"QgsProperty.fromExpression('%1')"_s.arg( fromVar.
sink.
asExpression() );
9862 return lOriginalProvider->defaultPointCloudFileExtension();
9866 return p->defaultPointCloudFileExtension();
9877 QStringList filters;
9878 for (
const QString &ext : exts )
9880 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9882 return filters.join(
";;"_L1 ) + u
";;"_s + QObject::tr(
"All files (*.*)" );
9889 return lOriginalProvider->supportedOutputPointCloudLayerExtensions();
9893 return p->supportedOutputPointCloudLayerExtensions();
9898 return QStringList() << ext;
9935 if ( input.userType() == qMetaTypeId<QgsProperty>() )
9940 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
9942 if ( !mAllowMultiple )
9948 else if ( input.userType() == QMetaType::Type::QString )
9950 if ( input.toString().isEmpty() )
9953 const QStringList parts = input.toString().split(
';' );
9954 if ( parts.count() > 1 && !mAllowMultiple )
9959 if ( input.toString().isEmpty() )
9967 if ( !value.isValid() )
9970 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9973 if ( value.userType() == QMetaType::Type::QVariantList )
9976 const auto constToList = value.toList();
9977 for (
const QVariant &val : constToList )
9981 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9983 else if ( value.userType() == QMetaType::Type::QStringList )
9986 const auto constToStringList = value.toStringList();
9987 for (
const QString &s : constToStringList )
9991 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9999 QString code = u
"##%1="_s.arg(
mName );
10001 code +=
"optional "_L1;
10002 code +=
"attribute "_L1;
10004 if ( mAllowMultiple )
10005 code +=
"multiple "_L1;
10007 if ( mDefaultToAllAttributes )
10008 code +=
"default_to_all_attributes "_L1;
10010 code += mParentLayerParameterName +
' ';
10013 return code.trimmed();
10018 switch ( outputType )
10022 QString code = u
"QgsProcessingParameterPointCloudAttribute('%1', %2"_s
10025 code +=
", optional=True"_L1;
10027 code += u
", parentLayerParameterName='%1'"_s.arg( mParentLayerParameterName );
10028 code += u
", allowMultiple=%1"_s.arg( mAllowMultiple ? u
"True"_s : u
"False"_s );
10032 if ( mDefaultToAllAttributes )
10033 code +=
", defaultToAllAttributes=True"_L1;
10045 QStringList depends;
10046 if ( !mParentLayerParameterName.isEmpty() )
10047 depends << mParentLayerParameterName;
10053 return mParentLayerParameterName;
10063 return mAllowMultiple;
10073 return mDefaultToAllAttributes;
10078 mDefaultToAllAttributes = enabled;
10084 map.insert( u
"parent_layer"_s, mParentLayerParameterName );
10085 map.insert( u
"allow_multiple"_s, mAllowMultiple );
10086 map.insert( u
"default_to_all_attributes"_s, mDefaultToAllAttributes );
10093 mParentLayerParameterName = map.value( u
"parent_layer"_s ).toString();
10094 mAllowMultiple = map.value( u
"allow_multiple"_s ).toBool();
10095 mDefaultToAllAttributes = map.value( u
"default_to_all_attributes"_s ).toBool();
10104 QString def = definition;
10106 if ( def.startsWith(
"multiple"_L1, Qt::CaseInsensitive ) )
10109 def = def.mid( 8 ).trimmed();
10112 if ( def.startsWith(
"default_to_all_attributes"_L1, Qt::CaseInsensitive ) )
10115 def = def.mid( 25 ).trimmed();
10118 const thread_local QRegularExpression re( u
"(.*?)\\s+(.*)$"_s );
10119 const QRegularExpressionMatch m = re.match( def );
10120 if ( m.hasMatch() )
10122 parent = m.captured( 1 ).trimmed();
10123 def = m.captured( 2 );
10150 QVariant var = input;
10151 if ( !var.isValid() )
10159 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
10162 var = fromVar.
sink;
10165 if ( var.userType() == qMetaTypeId<QgsProperty>() )
10178 if ( var.userType() != QMetaType::Type::QString )
10181 if ( var.toString().isEmpty() )
10189 if ( !value.isValid() )
10192 if ( value.userType() == qMetaTypeId<QgsProperty>() )
10195 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
10204 return u
"QgsProperty.fromExpression('%1')"_s.arg( fromVar.
sink.
asExpression() );
10224 QStringList filters;
10225 for (
const QString &ext : exts )
10227 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
10229 return filters.join(
";;"_L1 ) + u
";;"_s + QObject::tr(
"All files (*.*)" );
10235 return QStringList() << ext;
Provides global constants and enumerations for use throughout the application.
ProcessingSourceType
Processing data source types.
@ File
Files (i.e. non map layer sources, such as text files).
@ TiledScene
Tiled scene layers.
@ Annotation
Annotation layers.
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ VectorTile
Vector tile layers.
@ MapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer).
@ VectorAnyGeometry
Any vector layer with geometry.
@ VectorPoint
Vector point layers.
@ VectorPolygon
Vector polygon layers.
@ VectorLine
Vector line layers.
@ PointCloud
Point cloud layers.
ProcessingFileParameterBehavior
Flags which dictate the behavior of QgsProcessingParameterFile.
@ File
Parameter is a single file.
@ Folder
Parameter is a folder.
ExpressionType
Expression types.
@ RasterCalculator
Raster calculator expression.
@ Qgis
Native QGIS expression.
@ PointCloud
Point cloud expression.
@ ShortString
A heavily abbreviated string, for use when a compact representation is required.
DistanceUnit
Units of distance.
@ Unknown
Unknown distance unit.
QFlags< RasterProcessingParameterCapability > RasterProcessingParameterCapabilities
Raster layer processing parameter capabilities.
ProcessingFieldParameterDataType
Processing field parameter data types.
@ String
Accepts string fields.
@ Boolean
Accepts boolean fields, since QGIS 3.34.
@ Binary
Accepts binary fields, since QGIS 3.34.
@ Numeric
Accepts numeric fields.
@ DateTime
Accepts datetime fields.
@ Unknown
Unknown areal unit.
@ Invalid
Invalid (not set) property.
@ Field
Field based property.
@ Expression
Expression based property.
TemporalUnit
Temporal units.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
QFlags< ProcessingParameterFlag > ProcessingParameterFlags
Flags which dictate the behavior of Processing parameters.
@ Unknown
Unknown volume unit.
InvalidGeometryCheck
Methods for handling of features with invalid geometries.
@ NoCheck
No invalid geometry checking.
@ AbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
@ SkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
QFlags< ProcessingFeatureSourceDefinitionFlag > ProcessingFeatureSourceDefinitionFlags
Flags which control behavior for a Processing feature source.
@ CreateIndividualOutputPerInputFeature
If set, every feature processed from this source will be placed into its own individually created out...
@ OverrideDefaultGeometryCheck
If set, the default geometry check method (as dictated by QgsProcessingContext) will be overridden fo...
WkbType
The WKB type describes the number of dimensions a geometry has.
@ Preferred
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
@ Optional
Parameter is optional.
ProcessingDateTimeParameterDataType
Processing date time parameter data types.
@ DateTime
Datetime values.
ProcessingNumberParameterType
Processing numeric parameter data types.
@ Double
Double/float values.
Represents a map layer containing a set of georeferenced annotations, e.g.
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
Represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString userFriendlyIdentifier(Qgis::CrsIdentifierType type=Qgis::CrsIdentifierType::MediumString) const
Returns a user friendly identifier for the CRS.
QString toWkt(Qgis::CrsWktVariant variant=Qgis::CrsWktVariant::Wkt1Gdal, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
Custom exception class for Coordinate Reference System related exceptions.
Handles parsing and evaluation of expressions (formerly called "search strings").
bool isValid() const
Checks if this expression is valid.
An interface for objects which accept features via addFeature(s) methods.
QFlags< SinkFlag > SinkFlags
Container of fields for a vector layer.
static bool fileMatchesFilter(const QString &fileName, const QString &filter)
Returns true if the given fileName matches a file filter string.
A geometry is the spatial representation of a feature.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
QString lastError() const
Returns an error string referring to the last error encountered either when this geometry was created...
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
static Q_INVOKABLE QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
Q_INVOKABLE QString asWkt(int precision=17) const
Exports the geometry to WKT.
Base class for graphical items within a QgsLayout.
QgsMasterLayoutInterface * layoutByName(const QString &name) const
Returns the layout with a matching name, or nullptr if no matching layouts were found.
QgsLayoutItem * itemById(const QString &id) const
Returns a layout item given its id.
QgsLayoutItem * itemByUuid(const QString &uuid, bool includeTemplateUuids=false) const
Returns the layout item with matching uuid unique identifier, or nullptr if a matching item could not...
Base class for all map layer types.
virtual QgsRectangle extent() const
Returns the extent of the layer.
QgsCoordinateReferenceSystem crs
Interface for master layout type objects, such as print layouts and reports.
virtual QgsMasterLayoutInterface::Type layoutType() const =0
Returns the master layout type.
@ PrintLayout
Individual print layout (QgsPrintLayout).
Represents a mesh layer supporting display of data on structured or unstructured meshes.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
Represents a map layer supporting display of point clouds.
Print layout, a QgsLayout subclass for static or atlas-based layouts.
Details for layers to load into projects.
Contains information about the context in which a processing algorithm is executed.
QgsExpressionContext & expressionContext()
Returns the expression context.
void addLayerToLoadOnCompletion(const QString &layer, const QgsProcessingContext::LayerDetails &details)
Adds a layer to load (by ID or datasource) into the canvas upon completion of the algorithm or model.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
Base class for all parameter definitions which represent file or layer destinations,...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
virtual QString defaultFileExtension() const =0
Returns the default file extension for destination file paths associated with this parameter.
void setCreateByDefault(bool createByDefault)
Sets whether the destination should be created by default.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool supportsNonFileBasedOutput() const
Returns true if the destination parameter supports non filed-based outputs, such as memory layers or ...
bool createByDefault() const
Returns true if the destination should be created by default.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
virtual bool isSupportedOutputValue(const QVariant &value, QgsProcessingContext &context, QString &error) const
Tests whether a value is a supported value for this parameter.
virtual QString generateTemporaryDestination(const QgsProcessingContext *context=nullptr) const
Generates a temporary destination value for this parameter.
QgsProcessingProvider * originalProvider() const
Original (source) provider which this parameter has been derived from.
QgsProcessingDestinationParameter(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingDestinationParameter.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Custom exception class for processing related exceptions.
Encapsulates settings relating to a feature source input to a processing algorithm.
bool loadVariant(const QVariantMap &map)
Loads this source definition from a QVariantMap, wrapped in a QVariant.
bool selectedFeaturesOnly
true if only selected features in the source should be used by algorithms.
QgsProperty source
Source definition.
Qgis::InvalidGeometryCheck geometryCheck
Geometry check method to apply to this source.
Qgis::ProcessingFeatureSourceDefinitionFlags flags
Flags which dictate source behavior.
long long featureLimit
If set to a value > 0, places a limit on the maximum number of features which will be read from the s...
QVariant toVariant() const
Saves this source definition to a QVariantMap, wrapped in a QVariant.
QString filterExpression
Optional expression filter to use for filtering features which will be read from the source.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource,...
Base class for providing feedback from a processing algorithm.
Base class for the definition of processing outputs.
A file output for processing algorithms.
A folder output for processing algorithms.
A HTML file output for processing algorithms.
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm.
QString format() const
Returns the format (if set).
bool loadVariant(const QVariantMap &map)
Loads this output layer definition from a QVariantMap, wrapped in a QVariant.
bool operator!=(const QgsProcessingOutputLayerDefinition &other) const
QgsProject * destinationProject
Destination project.
bool operator==(const QgsProcessingOutputLayerDefinition &other) const
QgsProperty sink
Sink/layer definition.
bool useRemapping() const
Returns true if the output uses a remapping definition.
QgsProcessingOutputLayerDefinition(const QString &sink=QString(), QgsProject *destinationProject=nullptr)
Constructor for QgsProcessingOutputLayerDefinition, accepting a static sink/layer string.
QgsRemappingSinkDefinition remappingDefinition() const
Returns the output remapping definition, if useRemapping() is true.
QVariant toVariant() const
Saves this output layer definition to a QVariantMap, wrapped in a QVariant.
QString destinationName
Name to use for sink if it's to be loaded into a destination project.
QVariantMap createOptions
Map of optional sink/layer creation options, which are passed to the underlying provider when creatin...
void setRemappingDefinition(const QgsRemappingSinkDefinition &definition)
Sets the remapping definition to use when adding features to the output layer.
A pointcloud layer output for processing algorithms.
A raster layer output for processing algorithms.
A vector layer output for processing algorithms.
A vector tile layer output for processing algorithms.
QgsProcessingParameterAnnotationLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterAnnotationLayer.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterAnnotationLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterArea * clone() const override
Creates a clone of the parameter definition.
QString type() const override
Unique parameter type name.
QString parentParameterName() const
Returns the name of the parent parameter, or an empty string if this is not set.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
void setParentParameterName(const QString &parentParameterName)
Sets the name of the parent layer parameter.
Qgis::AreaUnit defaultUnit() const
Returns the default area unit for the parameter.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterArea(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentParameterName=QString(), bool optional=false, double minValue=0, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterArea.
static QString typeName()
Returns the type name for the parameter class.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QString userFriendlyString(const QVariant &value) const override
Returns a user-friendly string representation of the provided parameter value.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterAuthConfig(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterAuthConfig.
static QString typeName()
Returns the type name for the parameter class.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterAuthConfig * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple band selections are permitted.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
QgsProcessingParameterBand(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false, bool allowMultiple=false)
Constructor for QgsProcessingParameterBand.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsProcessingParameterBand * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple band selections are permitted.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString type() const override
Unique parameter type name.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterBoolean * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterBoolean(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterBoolean.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
A color parameter for processing algorithms.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterColor * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool opacityEnabled() const
Returns true if the parameter allows opacity control.
void setOpacityEnabled(bool enabled)
Sets whether the parameter allows opacity control.
QgsProcessingParameterColor(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool opacityEnabled=true, bool optional=false)
Constructor for QgsProcessingParameterColor.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString destinationCrsParameterName() const
Returns the name of the destination CRS parameter, or an empty string if this is not set.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QgsProcessingParameterCoordinateOperation * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterCoordinateOperation(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &sourceCrsParameterName=QString(), const QString &destinationCrsParameterName=QString(), const QVariant &staticSourceCrs=QVariant(), const QVariant &staticDestinationCrs=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCoordinateOperation.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QString sourceCrsParameterName() const
Returns the name of the source CRS parameter, or an empty string if this is not set.
QgsProcessingParameterCrs(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCrs.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QString userFriendlyString(const QVariant &value) const override
Returns a user-friendly string representation of the provided parameter value.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterCrs * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
void setParentConnectionParameterName(const QString &name)
Sets the name of the parent connection parameter.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterDatabaseSchema(const QString &name, const QString &description, const QString &connectionParameterName=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterDatabaseSchema.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingParameterDatabaseSchema * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDatabaseTable(const QString &name, const QString &description, const QString &connectionParameterName=QString(), const QString &schemaParameterName=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool allowNewTableNames=false)
Constructor for QgsProcessingParameterDatabaseTable.
void setParentSchemaParameterName(const QString &name)
Sets the name of the parent schema parameter.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
QString parentSchemaParameterName() const
Returns the name of the parent schema parameter, or an empty string if this is not set.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QgsProcessingParameterDatabaseTable * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool allowNewTableNames() const
Returns true if the parameter allows users to enter names for a new (non-existing) tables.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
void setAllowNewTableNames(bool allowed)
Sets whether the parameter allows users to enter names for a new (non-existing) tables.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
void setParentConnectionParameterName(const QString &name)
Sets the name of the parent connection parameter.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString type() const override
Unique parameter type name.
void setMaximum(const QDateTime &maximum)
Sets the maximum value acceptable by the parameter.
static QgsProcessingParameterDateTime * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QDateTime minimum() const
Returns the minimum value acceptable by the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
void setDataType(Qgis::ProcessingDateTimeParameterDataType type)
Sets the acceptable data type for the parameter.
Qgis::ProcessingDateTimeParameterDataType dataType() const
Returns the acceptable data type for the parameter.
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
void setMinimum(const QDateTime &minimum)
Sets the minimum value acceptable by the parameter.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QDateTime maximum() const
Returns the maximum value acceptable by the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString userFriendlyString(const QVariant &value) const override
Returns a user-friendly string representation of the provided parameter value.
QgsProcessingParameterDateTime(const QString &name, const QString &description=QString(), Qgis::ProcessingDateTimeParameterDataType type=Qgis::ProcessingDateTimeParameterDataType::DateTime, const QVariant &defaultValue=QVariant(), bool optional=false, const QDateTime &minValue=QDateTime(), const QDateTime &maxValue=QDateTime())
Constructor for QgsProcessingParameterDateTime.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Base class for the definition of processing parameters.
QgsProcessingAlgorithm * mAlgorithm
Pointer to algorithm which owns this parameter.
QString mHelp
Parameter help.
virtual QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QVariant defaultValue() const
Returns the default value for the parameter.
QVariant guiDefaultValueOverride() const
Returns the default value to use in the GUI for the parameter.
QString valueAsStringPrivate(const QVariant &value, QgsProcessingContext &context, bool &ok, ValueAsStringFlags flags) const
Internal method for evaluating values as string.
QString help() const
Returns the help for the parameter.
virtual QString asScriptCode() const
Returns the parameter definition encoded in a string which can be used within a Processing script.
virtual QString toolTip() const
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
Qgis::ProcessingParameterFlags mFlags
Parameter flags.
virtual QString userFriendlyString(const QVariant &value) const
Returns a user-friendly string representation of the provided parameter value.
QFlags< ValueAsStringFlag > ValueAsStringFlags
virtual QStringList valueAsStringList(const QVariant &value, QgsProcessingContext &context, bool &ok) const
Returns a string list version of the parameter input value (if possible).
QgsProcessingAlgorithm * algorithm() const
Returns a pointer to the algorithm which owns this parameter.
QgsProcessingProvider * provider() const
Returns a pointer to the provider for the algorithm which owns this parameter.
@ AllowMapLayerValues
Enable map layer value handling.
QString mName
Parameter name.
virtual QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString description() const
Returns the description for the parameter.
QgsProcessingParameterDefinition(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &help=QString())
Constructor for QgsProcessingParameterDefinition.
QVariant defaultValueForGui() const
Returns the default value to use for the parameter in a GUI.
friend class QgsProcessingAlgorithm
virtual QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const
Returns a string version of the parameter input value (if possible).
QVariantMap mMetadata
Freeform metadata for parameter. Mostly used by widget wrappers to customize their appearance and beh...
QString mDescription
Parameter description.
virtual QString type() const =0
Unique parameter type name.
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
QString name() const
Returns the name of the parameter.
QVariant mDefault
Default value for parameter.
Qgis::ProcessingParameterFlags flags() const
Returns any flags associated with the parameter.
QVariant mGuiDefault
Default value for parameter in GUI.
virtual QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
QVariant defaultGuiValueFromSetting() const
Default gui value for an algorithm parameter from settings.
virtual bool fromVariantMap(const QVariantMap &map)
Restores this parameter to a QVariantMap.
virtual QString valueAsPythonComment(const QVariant &value, QgsProcessingContext &context) const
Returns a Python comment explaining a parameter value, or an empty string if no comment is required.
QVariant valueAsJsonObjectPrivate(const QVariant &value, QgsProcessingContext &context, ValueAsStringFlags flags) const
Internal method for evaluating values as JSON objects.
virtual QColor modelColor() const
Returns the color to use for the parameter in model designer windows.
void setParentParameterName(const QString &parentParameterName)
Sets the name of the parent layer parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString typeName()
Returns the type name for the parameter class.
QString parentParameterName() const
Returns the name of the parent parameter, or an empty string if this is not set.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Qgis::DistanceUnit defaultUnit() const
Returns the default distance unit for the parameter.
QgsProcessingParameterDistance * clone() const override
Creates a clone of the parameter definition.
QString userFriendlyString(const QVariant &value) const override
Returns a user-friendly string representation of the provided parameter value.
QString type() const override
Unique parameter type name.
QgsProcessingParameterDistance(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentParameterName=QString(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterDistance.
Qgis::TemporalUnit defaultUnit() const
Returns the default duration unit for the parameter.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString userFriendlyString(const QVariant &value) const override
Returns a user-friendly string representation of the provided parameter value.
QgsProcessingParameterDuration * clone() const override
Creates a clone of the parameter definition.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString typeName()
Returns the type name for the parameter class.
QString type() const override
Unique parameter type name.
QgsProcessingParameterDuration(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterDuration.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
void setUsesStaticStrings(bool usesStaticStrings)
Sets whether the parameter uses static (non-translated) string values for its enumeration choice list...
QString userFriendlyString(const QVariant &value) const override
Returns a user-friendly string representation of the provided parameter value.
static QgsProcessingParameterEnum * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QStringList options() const
Returns the list of acceptable options for the parameter.
QgsProcessingParameterEnum(const QString &name, const QString &description=QString(), const QStringList &options=QStringList(), bool allowMultiple=false, const QVariant &defaultValue=QVariant(), bool optional=false, bool usesStaticStrings=false)
Constructor for QgsProcessingParameterEnum.
void setOptions(const QStringList &options)
Sets the list of acceptable options for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool usesStaticStrings() const
Returns true if the parameter uses static (non-translated) string values for its enumeration choice l...
QString valueAsPythonComment(const QVariant &value, QgsProcessingContext &context) const override
Returns a Python comment explaining a parameter value, or an empty string if no comment is required.
void setAllowMultiple(bool allowMultiple)
Sets whether the parameter allows multiple selected values.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingParameterExpression * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterExpression(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false, Qgis::ExpressionType type=Qgis::ExpressionType::Qgis)
Constructor for QgsProcessingParameterExpression.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
QString type() const override
Unique parameter type name.
static QString typeName()
Returns the type name for the parameter class.
Qgis::ExpressionType expressionType() const
Returns the parameter's expression type.
void setExpressionType(Qgis::ExpressionType type)
Sets the parameter's expression type.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterExtent(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterExtent.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterExtent * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QgsProcessingParameterFeatureSink(const QString &name, const QString &description=QString(), Qgis::ProcessingSourceType type=Qgis::ProcessingSourceType::VectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true, bool supportsAppend=false)
Constructor for QgsProcessingParameterFeatureSink.
QString generateTemporaryDestination(const QgsProcessingContext *context=nullptr) const override
Generates a temporary destination value for this parameter.
static QgsProcessingParameterFeatureSink * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
bool hasGeometry() const
Returns true if sink is likely to include geometries.
QString type() const override
Unique parameter type name.
void setDataType(Qgis::ProcessingSourceType type)
Sets the layer type for the sinks associated with the parameter.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
void setSupportsAppend(bool supportsAppend)
Sets whether the sink supports appending features to an existing table.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
bool supportsAppend() const
Returns true if the sink supports appending features to an existing table.
Qgis::ProcessingSourceType dataType() const
Returns the layer type for sinks associated with the parameter.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterFeatureSource(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFeatureSource.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
static QString typeName()
Returns the type name for the parameter class.
QString type() const override
Unique parameter type name.
static QgsProcessingParameterFeatureSource * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
Qgis::ProcessingFieldParameterDataType dataType() const
Returns the acceptable data type for the field.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString type() const override
Unique parameter type name.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
void setDataType(Qgis::ProcessingFieldParameterDataType type)
Sets the acceptable data type for the field.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
QgsProcessingParameterField(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), Qgis::ProcessingFieldParameterDataType type=Qgis::ProcessingFieldParameterDataType::Any, bool allowMultiple=false, bool optional=false, bool defaultToAllFields=false)
Constructor for QgsProcessingParameterField.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
void setDefaultToAllFields(bool enabled)
Sets whether a parameter which allows multiple selections (see allowMultiple()) should automatically ...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingParameterField * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QgsProcessingParameterFileDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterFileDestination(const QString &name, const QString &description=QString(), const QString &fileFilter=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFileDestination.
static QString typeName()
Returns the type name for the parameter class.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString extension() const
Returns any specified file extension for the parameter.
void setExtension(const QString &extension)
Sets a file extension for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterFile(const QString &name, const QString &description=QString(), Qgis::ProcessingFileParameterBehavior behavior=Qgis::ProcessingFileParameterBehavior::File, const QString &extension=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &fileFilter=QString())
Constructor for QgsProcessingParameterFile.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
static QgsProcessingParameterFile * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition, Qgis::ProcessingFileParameterBehavior behavior=Qgis::ProcessingFileParameterBehavior::File)
Creates a new parameter using the definition from a script code.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Qgis::ProcessingFileParameterBehavior behavior() const
Returns the parameter behavior (e.g.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
static QgsProcessingParameterFolderDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterFolderDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFolderDestination.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString type() const override
Unique parameter type name.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool allowMultipart() const
Returns the parameter allow multipart geometries.
QgsProcessingParameterGeometry(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QList< int > &geometryTypes=QList< int >(), bool allowMultipart=true)
Constructor for QgsProcessingParameterGeometry.
QList< int > geometryTypes() const
Returns the parameter allowed geometries, as a list of Qgis::GeometryType values.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString userFriendlyString(const QVariant &value) const override
Returns a user-friendly string representation of the provided parameter value.
static QgsProcessingParameterGeometry * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString type() const override
Unique parameter type name.
static QgsProcessingParameterLayoutItem * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterLayoutItem(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayoutParameterName=QString(), int itemType=-1, bool optional=false)
Constructor for QgsProcessingParameterLayoutItem.
void setParentLayoutParameterName(const QString &name)
Sets the name of the parent layout parameter.
QString parentLayoutParameterName() const
Returns the name of the parent layout parameter, or an empty string if this is not set.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
int itemType() const
Returns the acceptable item type, or -1 if any item type is allowed.
void setItemType(int type)
Sets the acceptable item type, or -1 if any item type is allowed.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterLayout * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterLayout(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterLayout.
static QString typeName()
Returns the type name for the parameter class.
void setDataTypes(const QList< int > &types)
Sets the geometry types for sources acceptable by the parameter.
QgsProcessingParameterLimitedDataTypes(const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterLimitedDataTypes, with a list of acceptable data types.
QList< int > mDataTypes
List of acceptable data types for the parameter.
QList< int > dataTypes() const
Returns the geometry types for sources acceptable by the parameter.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QgsProcessingParameterMapLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString type() const override
Unique parameter type name.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterMapLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterMapLayer.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsProcessingParameterMapTheme * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterMapTheme(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMapTheme.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QStringList headers() const
Returns a list of column headers (if set).
void setHeaders(const QStringList &headers)
Sets the list of column headers.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
void setHasFixedNumberRows(bool hasFixedNumberRows)
Sets whether the table has a fixed number of rows.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
void setNumberRows(int rows)
Sets the fixed number of rows in the table.
int numberRows() const
Returns the fixed number of rows in the table.
static QgsProcessingParameterMatrix * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterMatrix(const QString &name, const QString &description=QString(), int numberRows=3, bool hasFixedNumberRows=false, const QStringList &headers=QStringList(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMatrix.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool hasFixedNumberRows() const
Returns whether the table has a fixed number of rows.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QgsProcessingParameterMeshLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMeshLayer.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterMeshLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
void setMinimumNumberInputs(int minimum)
Sets the minimum number of layers required for the parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Qgis::ProcessingSourceType layerType() const
Returns the layer type for layers acceptable by the parameter.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QString typeName()
Returns the type name for the parameter class.
void setLayerType(Qgis::ProcessingSourceType type)
Sets the layer type for layers acceptable by the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QgsProcessingParameterMultipleLayers(const QString &name, const QString &description=QString(), Qgis::ProcessingSourceType layerType=Qgis::ProcessingSourceType::VectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMultipleLayers.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QgsProcessingParameterMultipleLayers * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString type() const override
Unique parameter type name.
int minimumNumberInputs() const
Returns the minimum number of layers required for the parameter.
double minimum() const
Returns the minimum value acceptable by the parameter.
static QgsProcessingParameterNumber * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
void setMinimum(double minimum)
Sets the minimum value acceptable by the parameter.
void setMaximum(double maximum)
Sets the maximum value acceptable by the parameter.
double maximum() const
Returns the maximum value acceptable by the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString type() const override
Unique parameter type name.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterNumber(const QString &name, const QString &description=QString(), Qgis::ProcessingNumberParameterType type=Qgis::ProcessingNumberParameterType::Integer, const QVariant &defaultValue=QVariant(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterNumber.
void setDataType(Qgis::ProcessingNumberParameterType type)
Sets the acceptable data type for the parameter.
QgsProcessingParameterPointCloudAttribute(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool allowMultiple=false, bool optional=false, bool defaultToAllAttributes=false)
Constructor for QgsProcessingParameterField.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setDefaultToAllAttributes(bool enabled)
Sets whether a parameter which allows multiple selections (see allowMultiple()) should automatically ...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
static QgsProcessingParameterPointCloudAttribute * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString typeName()
Returns the type name for the parameter class.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool defaultToAllAttributes() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterPointCloudDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
virtual QStringList supportedOutputPointCloudLayerExtensions() const
Returns a list of the point cloud format file extensions supported for this parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterPointCloudDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterPointCloudDestination.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
static QgsProcessingParameterPointCloudLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterPointCloudLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterPointCloudLayer.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsProcessingParameterPoint * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterPoint(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterPoint.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterProviderConnection(const QString &name, const QString &description, const QString &provider, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterProviderConnection, for the specified provider type.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QgsProcessingParameterProviderConnection * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Qgis::ProcessingNumberParameterType dataType() const
Returns the acceptable data type for the range.
QgsProcessingParameterRange(const QString &name, const QString &description=QString(), Qgis::ProcessingNumberParameterType type=Qgis::ProcessingNumberParameterType::Integer, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRange.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
void setDataType(Qgis::ProcessingNumberParameterType dataType)
Sets the acceptable data type for the range.
QString type() const override
Unique parameter type name.
static QgsProcessingParameterRange * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QgsProcessingParameterRasterDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterRasterDestination.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterRasterDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QString defaultFileFormat() const
Returns the default file format for destination file paths associated with this parameter.
virtual Q_DECL_DEPRECATED QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported for this parameter.
static QString typeName()
Returns the type name for the parameter class.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
virtual QList< QPair< QString, QString > > supportedOutputRasterLayerFormatAndExtensions() const
Returns a list of (format, file extension) supported by this provider.
Qgis::RasterProcessingParameterCapabilities parameterCapabilities() const
Returns flags containing the supported capabilities of the raster layer parameter.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterRasterLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterRasterLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRasterLayer.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
void setParameterCapabilities(Qgis::RasterProcessingParameterCapabilities capabilities)
Sets the supported capabilities of the raster layer parameter.
QString type() const override
Unique parameter type name.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterScale * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QgsProcessingParameterScale * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterScale(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterScale.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setMultiLine(bool multiLine)
Sets whether the parameter allows multiline strings.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QgsProcessingParameterString * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool multiLine() const
Returns true if the parameter allows multiline strings.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterString(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool multiLine=false, bool optional=false)
Constructor for QgsProcessingParameterString.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Makes metadata of processing parameters available.
virtual QgsProcessingParameterDefinition * create(const QString &name) const =0
Creates a new parameter of this type.
virtual QColor modelColor() const
Returns the color to use for the parameter in model designer windows.
static QColor defaultModelColor()
Returns the default color for a processing parameter.
QgsProcessingParameterVectorDestination(const QString &name, const QString &description=QString(), Qgis::ProcessingSourceType type=Qgis::ProcessingSourceType::VectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterVectorDestination.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString type() const override
Unique parameter type name.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Qgis::ProcessingSourceType dataType() const
Returns the layer type for this created vector layer.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
bool hasGeometry() const
Returns true if the created layer is likely to include geometries.
void setDataType(Qgis::ProcessingSourceType type)
Sets the layer type for the created vector layer.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterVectorDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QgsProcessingParameterVectorLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString valueAsString(const QVariant &value, QgsProcessingContext &context, bool &ok) const override
Returns a string version of the parameter input value (if possible).
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString type() const override
Unique parameter type name.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QgsProcessingParameterVectorLayer(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterVectorLayer.
static QString typeName()
Returns the type name for the parameter class.
QVariant valueAsJsonObject(const QVariant &value, QgsProcessingContext &context) const override
Returns a version of the parameter input value, which is suitable for use in a JSON object.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterVectorTileDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterVectorTileDestination.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
virtual QStringList supportedOutputVectorTileLayerExtensions() const
Returns a list of the point cloud format file extensions supported for this parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterVectorTileDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString typeName()
Returns the type name for the parameter class.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString userFriendlyString(const QVariant &value) const override
Returns a user-friendly string representation of the provided parameter value.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterVolume(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentParameterName=QString(), bool optional=false, double minValue=0, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterVolume.
Qgis::VolumeUnit defaultUnit() const
Returns the default volume unit for the parameter.
void setParentParameterName(const QString &parentParameterName)
Sets the name of the parent layer parameter.
QgsProcessingParameterVolume * clone() const override
Creates a clone of the parameter definition.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QString parentParameterName() const
Returns the name of the parent parameter, or an empty string if this is not set.
QString type() const override
Unique parameter type name.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString descriptionFromName(const QString &name)
Creates an autogenerated parameter description from a parameter name.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
static QString parameterAsOutputLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output layer destination.
static QgsFeatureSink * parameterAsSink(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsFields &fields, Qgis::WkbType geometryType, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList())
Evaluates the parameter with matching definition to a feature sink.
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a list of map layers.
static QTime parameterAsTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static time value.
static QgsProcessingParameterDefinition * parameterFromVariantMap(const QVariantMap &map)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied variant map.
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
static QgsCoordinateReferenceSystem parameterAsGeometryCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with a geometry parameter value.
static QgsAnnotationLayer * parameterAsAnnotationLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to an annotation layer.
static QString parameterAsEnumString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static enum string.
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
static QStringList parameterAsStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of strings (e.g.
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
static QString parameterAsConnectionName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a connection name string.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
static QString parameterAsFileOutput(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file based output destination.
static bool parameterAsBoolean(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
static QgsPointCloudLayer * parameterAsPointCloudLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a point cloud layer.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value.
static QgsLayoutItem * parameterAsLayoutItem(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsPrintLayout *layout)
Evaluates the parameter with matching definition to a print layout item, taken from the specified lay...
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
static QString parameterAsCompatibleSourceLayerPathAndLayerName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr, QString *layerName=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path and layer name of...
static QgsMeshLayer * parameterAsMeshLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition and value to a mesh layer.
static QString parameterAsCompatibleSourceLayerPath(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path of compatible for...
static QgsProcessingParameterDefinition * parameterFromScriptCode(const QString &code)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied script code st...
static QColor parameterAsColor(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the color associated with an point parameter value, or an invalid color if the parameter was ...
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
static QString parameterAsOutputFormat(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output format.
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
static QString parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
static QgsMapLayer * parameterAsLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingUtils::LayerHint layerHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Evaluates the parameter with matching definition to a map layer.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QStringList parameterAsEnumStrings(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of static enum strings.
static QgsGeometry parameterAsExtentGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent, and returns a geometry cove...
static QStringList parameterAsFileList(const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of files (for QgsProcessingParameterMultip...
static bool isDynamic(const QVariantMap ¶meters, const QString &name)
Returns true if the parameter with matching name is a dynamic parameter, and must be evaluated once f...
static Q_DECL_DEPRECATED QStringList parameterAsFields(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of fields.
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
static QDateTime parameterAsDateTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static datetime value.
static QString parameterAsFile(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file/folder name.
static QDate parameterAsDate(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static date value.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
Abstract base class for processing providers.
virtual bool isSupportedOutputValue(const QVariant &outputValue, const QgsProcessingDestinationParameter *parameter, QgsProcessingContext &context, QString &error) const
Returns true if the specified outputValue is of a supported file format for the given destination par...
static QList< QPair< QString, QString > > supportedOutputRasterLayerFormatAndExtensionsDefault()
Returns a list of (format, file extension) supported by GDAL.
Encapsulates settings relating to a raster layer input to a processing algorithm.
double referenceScale
If set to a value > 0, sets a scale at which a raster (e.g., a WMS) should be requested or rendered.
int dpi
Indicates the resolution of the raster source (e.g., a WMS server).
QgsProperty source
Source definition.
bool loadVariant(const QVariantMap &map)
Loads this raster layer definition from a QVariantMap, wrapped in a QVariant.
QVariant toVariant() const
Saves this raster layer definition to a QVariantMap, wrapped in a QVariant.
QgsProcessingParameterType * parameterType(const QString &id) const
Returns the parameter type registered for id.
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
static QString defaultVectorExtension()
Returns the default vector extension to use, in the absence of all other constraints (e....
static QString layerToStringIdentifier(const QgsMapLayer *layer, const QString &layerName=QString())
Returns a string representation of the source for a layer.
static QString generateTempFilename(const QString &basename, const QgsProcessingContext *context=nullptr)
Returns a temporary filename for a given file, putting it into a temporary folder (creating that fold...
static QString encodeProviderKeyAndUri(const QString &providerKey, const QString &uri)
Encodes a provider key and layer uri to a single string, for use with decodeProviderKeyAndUri().
LayerHint
Layer type hints.
@ Annotation
Annotation layer type, since QGIS 3.22.
@ Vector
Vector layer type.
@ VectorTile
Vector tile layer type, since QGIS 3.32.
@ Mesh
Mesh layer type, since QGIS 3.6.
@ Raster
Raster layer type.
@ UnknownType
Unknown layer type.
@ PointCloud
Point cloud layer type, since QGIS 3.22.
static QString defaultRasterFormat()
Returns the default raster format to use, in the absence of all other constraints (e....
static QgsProcessingFeatureSource * variantToSource(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a new feature source.
static QString variantToPythonLiteral(const QVariant &value)
Converts a variant to a Python literal.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
static QString convertToCompatibleFormatAndLayerName(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, QString &layerName, long long featureLimit=-1, const QString &filterExpression=QString())
Converts a source vector layer to a file path and layer name of a vector layer of compatible format.
static QString convertToCompatibleFormat(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, long long featureLimit=-1, const QString &filterExpression=QString())
Converts a source vector layer to a file path of a vector layer of compatible format.
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, Qgis::WkbType geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), QgsRemappingSinkDefinition *remappingDefinition=nullptr)
Creates a feature sink ready for adding features.
static QString defaultVectorTileExtension()
Returns the default vector tile extension to use, in the absence of all other constraints (e....
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Interprets a string as a map layer within the supplied context.
static QString defaultPointCloudExtension()
Returns the default point cloud extension to use, in the absence of all other constraints (e....
QFlags< LayerOptionsFlag > LayerOptionsFlags
static const QString TEMPORARY_OUTPUT
Constant used to indicate that a Processing algorithm output should be a temporary layer/file.
PythonOutputType
Available Python output types.
@ PythonQgsProcessingAlgorithmSubclass
Full Python QgsProcessingAlgorithm subclass.
static QString sourceTypeToString(Qgis::ProcessingSourceType type)
Converts a source type to a string representation.
@ SkipIndexGeneration
Do not generate index when creating a layer. Makes sense only for point cloud layers.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QgsAnnotationLayer * mainAnnotationLayer()
Returns the main annotation layer associated with the project.
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
A store for object properties.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
QString expressionString() const
Returns the expression used for the property value.
Qgis::PropertyType propertyType() const
Returns the property type.
QString valueAsString(const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a string.
QString field() const
Returns the current field name the property references.
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
QVariant staticValue() const
Returns the current static value for the property.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QString fileVectorFilters() const
Returns a file filter string for supported vector files.
QString fileRasterFilters() const
Returns a file filter string for supported raster files.
QString fileMeshFilters() const
Returns a file filter string for supported mesh files.
QString filePointCloudFilters() const
Returns a file filter string for supported point clouds.
static QStringList extensionsForFormat(const QString &format)
Returns a list of known file extensions for the given GDAL driver format.
Represents a raster layer.
A rectangle specified with double values.
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
A QgsGeometry with associated coordinate reference system.
static QgsReferencedGeometry fromReferencedPointXY(const QgsReferencedPointXY &point)
Construct a new QgsReferencedGeometry from referenced point.
static QgsReferencedGeometry fromReferencedRect(const QgsReferencedRectangle &rectangle)
Construct a new QgsReferencedGeometry from referenced rectangle.
A QgsPointXY with associated coordinate reference system.
A QgsRectangle with associated coordinate reference system.
Defines the parameters used to remap features when creating a QgsRemappingProxyFeatureSink.
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
static QColor parseColorWithAlpha(const QString &colorStr, bool &containsAlpha, bool strictEval=false)
Attempts to parse a string as a color using a variety of common formats, including hex codes,...
static Q_INVOKABLE QString toAbbreviatedString(Qgis::DistanceUnit unit)
Returns a translated abbreviation representing a distance unit.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
static QStringList supportedFormatExtensions(VectorFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats, e.g "shp", "gpkg".
Represents a vector layer which manages a vector based dataset.
static Q_INVOKABLE QString geometryDisplayString(Qgis::GeometryType type)
Returns a display string for a geometry type.
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
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
#define QgsDebugError(str)
QString parameterAsCompatibleSourceLayerPathInternal(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingFeedback *feedback, QString *layerName)
QString createAllMapLayerFileFilter()