43#include <QRegularExpression>
51 map.insert( QStringLiteral(
"feature_limit" ),
featureLimit );
53 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
flags ) );
54 map.insert( QStringLiteral(
"geometry_check" ),
static_cast< int >(
geometryCheck ) );
62 featureLimit = map.value( QStringLiteral(
"feature_limit" ), -1 ).toLongLong();
77 mRemappingDefinition = definition;
84 map.insert( QStringLiteral(
"create_options" ),
createOptions );
86 map.insert( QStringLiteral(
"remapping" ), QVariant::fromValue( mRemappingDefinition ) );
93 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
94 if ( map.contains( QStringLiteral(
"remapping" ) ) )
101 mUseRemapping =
false;
109 && mUseRemapping == other.mUseRemapping && mRemappingDefinition == other.mRemappingDefinition;
114 return !( *
this == other );
119 const QVariant val = parameters.value( name );
120 if ( val.userType() == qMetaTypeId<QgsProperty>() )
139 QVariant val = value;
140 if ( val.userType() == qMetaTypeId<QgsProperty>() )
143 if ( !val.isValid() )
152 return destParam->generateTemporaryDestination( &context );
155 return val.toString();
171 const QVariant val = value;
172 if ( val.userType() == qMetaTypeId<QgsProperty>() )
175 if ( val.isValid() && !val.toString().isEmpty() )
179 return val.toString();
199 QVariant val = value;
200 if ( val.userType() == qMetaTypeId<QgsProperty>() )
204 const double res = val.toDouble( &ok );
210 return val.toDouble();
226 QVariant val = value;
227 if ( val.userType() == qMetaTypeId<QgsProperty>() )
231 double dbl = val.toDouble( &ok );
236 dbl = val.toDouble( &ok );
243 const double round = std::round( dbl );
244 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
249 return static_cast< int >( std::round( dbl ) );
258 return QList< int >();
266 return QList< int >();
268 QList< int > resultList;
269 const QVariant val = value;
272 if ( val.userType() == qMetaTypeId<QgsProperty>() )
274 else if ( val.userType() == QMetaType::Type::QVariantList )
276 const QVariantList list = val.toList();
277 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
278 resultList << it->toInt();
282 const QStringList parts = val.toString().split(
';' );
283 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
284 resultList << it->toInt();
288 if ( resultList.isEmpty() )
293 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
295 const QVariantList list = definition->
defaultValue().toList();
296 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
297 resultList << it->toInt();
301 const QStringList parts = definition->
defaultValue().toString().split(
';' );
302 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
303 resultList << it->toInt();
324 QVariant val = value;
325 if ( val.userType() == qMetaTypeId<QgsProperty>() )
328 QDateTime d = val.toDateTime();
329 if ( !d.isValid() && val.userType() == QMetaType::Type::QString )
331 d = QDateTime::fromString( val.toString() );
338 d = val.toDateTime();
340 if ( !d.isValid() && val.userType() == QMetaType::Type::QString )
342 d = QDateTime::fromString( val.toString() );
361 QVariant val = value;
362 if ( val.userType() == qMetaTypeId<QgsProperty>() )
365 QDate d = val.toDate();
366 if ( !d.isValid() && val.userType() == QMetaType::Type::QString )
368 d = QDate::fromString( val.toString() );
377 if ( !d.isValid() && val.userType() == QMetaType::Type::QString )
379 d = QDate::fromString( val.toString() );
398 QVariant val = value;
399 if ( val.userType() == qMetaTypeId<QgsProperty>() )
404 if ( val.userType() == QMetaType::Type::QDateTime )
405 d = val.toDateTime().time();
409 if ( !d.isValid() && val.userType() == QMetaType::Type::QString )
411 d = QTime::fromString( val.toString() );
420 if ( !d.isValid() && val.userType() == QMetaType::Type::QString )
422 d = QTime::fromString( val.toString() );
443 if ( enumDef && val >= enumDef->
options().size() )
463 QVariantList resultList;
464 const QVariant val = value;
465 if ( val.userType() == qMetaTypeId<QgsProperty>() )
467 else if ( val.userType() == QMetaType::Type::QVariantList )
469 const auto constToList = val.toList();
470 for (
const QVariant &var : constToList )
473 else if ( val.userType() == QMetaType::Type::QString )
475 const auto constSplit = val.toString().split(
',' );
476 for (
const QString &var : constSplit )
482 if ( resultList.isEmpty() )
483 return QList< int >();
485 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
489 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
491 const auto constToList = definition->
defaultValue().toList();
492 for (
const QVariant &var : constToList )
495 else if ( definition->
defaultValue().userType() == QMetaType::Type::QString )
497 const auto constSplit = definition->
defaultValue().toString().split(
',' );
498 for (
const QString &var : constSplit )
507 const auto constResultList = resultList;
508 for (
const QVariant &var : constResultList )
510 const int resInt = var.toInt();
511 if ( !enumDef || resInt < enumDef->options().size() )
534 if ( enumText.isEmpty() || !enumDef->
options().contains( enumText ) )
543 return QStringList();
551 return QStringList();
553 const QVariant val = value;
555 QStringList enumValues;
557 std::function< void(
const QVariant &var ) > processVariant;
558 processVariant = [ &enumValues, &context, &definition, &processVariant ](
const QVariant & var )
560 if ( var.userType() == QMetaType::Type::QVariantList )
562 const auto constToList = var.toList();
563 for (
const QVariant &listVar : constToList )
565 processVariant( listVar );
568 else if ( var.userType() == QMetaType::Type::QStringList )
570 const auto constToStringList = var.toStringList();
571 for (
const QString &s : constToStringList )
576 else if ( var.userType() == qMetaTypeId<QgsProperty>() )
580 const QStringList parts = var.toString().split(
',' );
581 for (
const QString &s : parts )
588 processVariant( val );
594 const QStringList options = enumDef->
options();
595 const QSet<QString> subtraction = QSet<QString>( enumValues.begin(), enumValues.end() ).subtract( QSet<QString>( options.begin(), options.end() ) );
597 if ( enumValues.isEmpty() || !subtraction.isEmpty() )
630 const QVariant val = value;
631 if ( val.userType() == qMetaTypeId<QgsProperty>() )
633 else if ( val.isValid() )
646 const QVariant val = value;
647 if ( val.userType() == qMetaTypeId<QgsProperty>() )
649 else if ( val.isValid() )
658 const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
663 val = parameters.value( definition->
name() );
666 return parameterAsSink( definition, val, fields, geometryType,
crs, context, destinationIdentifier, sinkFlags, createOptions, datasourceOptions, layerOptions );
669QgsFeatureSink *
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 )
671 QVariantMap options = createOptions;
672 QVariant val = value;
677 bool useRemapDefinition =
false;
678 if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
689 useRemapDefinition =
true;
695 if ( definition && val.userType() == qMetaTypeId<QgsProperty>() )
699 else if ( !val.isValid() || val.toString().isEmpty() )
715 dest = val.toString();
720 dest = destParam->generateTemporaryDestination( &context );
723 if ( dest.isEmpty() )
726 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType,
crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition : nullptr ) );
727 destinationIdentifier = dest;
729 if ( destinationProject )
731 if ( destName.isEmpty() && definition )
737 outputName = definition->
name();
741 return sink.release();
669QgsFeatureSink *
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 ) {
…}
765 QVariant val = parameters.value( definition->
name() );
767 bool selectedFeaturesOnly =
false;
768 long long featureLimit = -1;
769 QString filterExpression;
770 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
779 else if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
786 if ( val.userType() == qMetaTypeId<QgsProperty>() )
792 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
797 if ( val.userType() == qMetaTypeId<QgsProperty>() )
801 else if ( !val.isValid() || val.toString().isEmpty() )
807 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
813 layerRef = val.toString();
818 if ( layerRef.isEmpty() )
830 compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit, filterExpression );
833 compatibleFormats, preferredFormat, context, feedback, featureLimit, filterExpression );
843 QString *destLayer = layerName;
858 return parameterAsLayer( definition, parameters.value( definition->
name() ), context, layerHint, flags );
866 QVariant val = value;
867 if ( val.userType() == qMetaTypeId<QgsProperty>() )
872 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
877 if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
889 if ( !val.isValid() || val.toString().isEmpty() )
895 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
900 QString layerRef = val.toString();
901 if ( layerRef.isEmpty() )
904 if ( layerRef.isEmpty() )
935 val = parameters.value( definition->
name() );
942 QVariant val = value;
946 if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
956 if ( definition && val.userType() == qMetaTypeId<QgsProperty>() )
960 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
967 dest = val.toString();
972 dest = destParam->generateTemporaryDestination( &context );
975 if ( destinationProject )
978 if ( destName.isEmpty() && definition )
983 outputName = definition->
name();
1007 val = parameters.value( definition->
name() );
1014 QVariant val = value;
1016 if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1024 if ( definition && val.userType() == qMetaTypeId<QgsProperty>() )
1028 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
1035 dest = val.toString();
1040 dest = destParam->generateTemporaryDestination( &context );
1060 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
1085 QVariant val = value;
1087 if ( val.userType() == qMetaTypeId<QgsRectangle>() )
1091 if ( val.userType() == qMetaTypeId< QgsGeometry>() )
1097 if ( val.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1116 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
1122 else if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1135 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1138 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1141 rectText = val.toString();
1143 if ( rectText.isEmpty() && !layer )
1146 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1147 const QRegularExpressionMatch match = rx.match( rectText );
1148 if ( match.hasMatch() )
1150 bool xMinOk =
false;
1151 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1152 bool xMaxOk =
false;
1153 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1154 bool yMinOk =
false;
1155 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1156 bool yMaxOk =
false;
1157 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1158 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1209 QVariant val = parameters.value( definition->
name() );
1211 if ( val.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1217 g = g.densifyByCount( 20 );
1231 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
1237 else if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1250 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1253 rectText = val.toString();
1255 if ( !rectText.isEmpty() )
1257 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1258 const QRegularExpressionMatch match = rx.match( rectText );
1259 if ( match.hasMatch() )
1261 bool xMinOk =
false;
1262 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1263 bool xMaxOk =
false;
1264 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1265 bool yMinOk =
false;
1266 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1267 bool yMaxOk =
false;
1268 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1269 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1299 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1328 const QVariant val = parameters.value( definition->
name() );
1334 QVariant val = value;
1335 if ( val.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1344 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
1350 else if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1362 QString valueAsString;
1363 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1366 valueAsString = val.toString();
1368 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1370 const QRegularExpressionMatch match = rx.match( valueAsString );
1371 if ( match.hasMatch() )
1378 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
1384 else if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1397 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1398 return layer->crs();
1400 return layer->crs();
1402 if (
auto *lProject = context.
project() )
1403 return lProject->crs();
1421 const QVariant val = value;
1422 if ( val.userType() == qMetaTypeId<QgsPointXY>() )
1426 if ( val.userType() == qMetaTypeId< QgsGeometry>() )
1432 if ( val.userType() == qMetaTypeId<QgsReferencedPointXY>() )
1451 if ( pointText.isEmpty() )
1454 if ( pointText.isEmpty() )
1457 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1460 const QRegularExpressionMatch match = rx.match( valueAsString );
1461 if ( match.hasMatch() )
1464 const double x = match.captured( 1 ).toDouble( &xOk );
1466 const double y = match.captured( 2 ).toDouble( &yOk );
1494 const QVariant val = parameters.value( definition->
name() );
1500 if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
1509 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1512 const QRegularExpressionMatch match = rx.match( valueAsString );
1513 if ( match.hasMatch() )
1520 if (
auto *lProject = context.
project() )
1521 return lProject->crs();
1539 const QVariant val = value;
1540 if ( val.userType() == qMetaTypeId< QgsGeometry>() )
1545 if ( val.userType() == qMetaTypeId<QgsPointXY>() )
1550 if ( val.userType() == qMetaTypeId<QgsRectangle>() )
1555 if ( val.userType() == qMetaTypeId<QgsReferencedPointXY>() )
1573 if ( val.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1579 g = g.densifyByCount( 20 );
1593 if ( val.userType() == qMetaTypeId<QgsReferencedGeometry>() )
1612 if ( valueAsString.isEmpty() )
1615 if ( valueAsString.isEmpty() )
1618 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1620 const QRegularExpressionMatch match = rx.match( valueAsString );
1621 if ( match.hasMatch() )
1648 const QVariant val = parameters.value( definition->
name() );
1654 if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
1663 if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
1672 if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1682 const QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1685 const QRegularExpressionMatch match = rx.match( valueAsString );
1686 if ( match.hasMatch() )
1693 if (
auto *lProject = context.
project() )
1694 return lProject->crs();
1705 if ( fileText.isEmpty() )
1716 if ( fileText.isEmpty() )
1724 return QVariantList();
1732 return QVariantList();
1734 QString resultString;
1735 const QVariant val = value;
1736 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1738 else if ( val.userType() == QMetaType::Type::QVariantList )
1739 return val.toList();
1741 resultString = val.toString();
1743 if ( resultString.isEmpty() )
1746 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
1752 QVariantList result;
1753 const auto constSplit = resultString.split(
',' );
1756 for (
const QString &s : constSplit )
1758 number = s.toDouble( &ok );
1759 result << ( ok ? QVariant( number ) : s );
1768 return QList<QgsMapLayer *>();
1776 return QList<QgsMapLayer *>();
1778 const QVariant val = value;
1779 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1781 return QList<QgsMapLayer *>() << layer;
1784 QList<QgsMapLayer *> layers;
1786 std::function< void(
const QVariant &var ) > processVariant;
1787 processVariant = [ &layers, &context, &definition, flags, &processVariant](
const QVariant & var )
1789 if ( var.userType() == QMetaType::Type::QVariantList )
1791 const auto constToList = var.toList();
1792 for (
const QVariant &listVar : constToList )
1794 processVariant( listVar );
1797 else if ( var.userType() == QMetaType::Type::QStringList )
1799 const auto constToStringList = var.toStringList();
1800 for (
const QString &s : constToStringList )
1802 processVariant( s );
1805 else if ( var.userType() == qMetaTypeId<QgsProperty>() )
1807 else if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1811 const QVariant sink = fromVar.
sink;
1812 if ( sink.userType() == qMetaTypeId<QgsProperty>() )
1817 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1829 processVariant( val );
1831 if ( layers.isEmpty() )
1834 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->
defaultValue() ) ) )
1838 else if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
1840 const auto constToList = definition->
defaultValue().toList();
1841 for (
const QVariant &var : constToList )
1843 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1849 processVariant( var );
1863 return QStringList();
1865 const QVariant val = value;
1869 std::function< void(
const QVariant &var ) > processVariant;
1870 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1872 if ( var.userType() == QMetaType::Type::QVariantList )
1874 const auto constToList = var.toList();
1875 for (
const QVariant &listVar : constToList )
1877 processVariant( listVar );
1880 else if ( var.userType() == QMetaType::Type::QStringList )
1882 const auto constToStringList = var.toStringList();
1883 for (
const QString &s : constToStringList )
1885 processVariant( s );
1888 else if ( var.userType() == qMetaTypeId<QgsProperty>() )
1892 files << var.toString();
1896 processVariant( val );
1898 if ( files.isEmpty() )
1909 return QStringList();
1917 return QList<double>();
1925 return QList<double>();
1927 QStringList resultStringList;
1928 const QVariant val = value;
1930 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1932 else if ( val.userType() == QMetaType::Type::QVariantList )
1934 const auto constToList = val.toList();
1935 for (
const QVariant &var : constToList )
1936 resultStringList << var.toString();
1939 resultStringList << val.toString();
1941 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1943 resultStringList.clear();
1945 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
1947 const auto constToList = definition->
defaultValue().toList();
1948 for (
const QVariant &var : constToList )
1949 resultStringList << var.toString();
1952 resultStringList << definition->
defaultValue().toString();
1955 if ( resultStringList.size() == 1 )
1957 resultStringList = resultStringList.at( 0 ).split(
',' );
1960 if ( resultStringList.size() < 2 )
1961 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1963 QList< double > result;
1965 double n = resultStringList.at( 0 ).toDouble( &ok );
1969 result << std::numeric_limits<double>::quiet_NaN() ;
1971 n = resultStringList.at( 1 ).toDouble( &ok );
1975 result << std::numeric_limits<double>::quiet_NaN() ;
1983 return QStringList();
1996 return QStringList();
2004 return QStringList();
2006 QStringList resultStringList;
2007 const QVariant val = value;
2008 if ( val.isValid() )
2010 if ( val.userType() == qMetaTypeId<QgsProperty>() )
2012 else if ( val.userType() == QMetaType::Type::QVariantList )
2014 const auto constToList = val.toList();
2015 for (
const QVariant &var : constToList )
2016 resultStringList << var.toString();
2018 else if ( val.userType() == QMetaType::Type::QStringList )
2020 resultStringList = val.toStringList();
2023 resultStringList.append( val.toString().split(
';' ) );
2026 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
2028 resultStringList.clear();
2032 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
2034 const auto constToList = definition->
defaultValue().toList();
2035 for (
const QVariant &var : constToList )
2036 resultStringList << var.toString();
2038 else if ( definition->
defaultValue().userType() == QMetaType::Type::QStringList )
2040 resultStringList = definition->
defaultValue().toStringList();
2043 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
2047 return resultStringList;
2061 if ( layoutName.isEmpty() )
2113 QVariant val = value;
2114 if ( val.userType() == qMetaTypeId<QgsProperty>() )
2118 if ( val.userType() == QMetaType::Type::QColor )
2120 QColor
c = val.
value< QColor >();
2122 if ( !colorParam->opacityEnabled() )
2130 if ( definition->
defaultValue().userType() == QMetaType::Type::QColor )
2136 if ( colorText.isEmpty() )
2139 bool containsAlpha =
false;
2142 if (
c.isValid() && !colorParam->opacityEnabled() )
2214 const QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
2215 const QString name = map.value( QStringLiteral(
"name" ) ).toString();
2216 std::unique_ptr< QgsProcessingParameterDefinition > def;
2293 def.reset( paramType->
create( name ) );
2299 def->fromVariantMap( map );
2300 return def.release();
2305 QString desc = name;
2306 desc.replace(
'_',
' ' );
2312 bool isOptional =
false;
2316 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2321 if ( type == QLatin1String(
"boolean" ) )
2323 else if ( type == QLatin1String(
"crs" ) )
2325 else if ( type == QLatin1String(
"layer" ) )
2327 else if ( type == QLatin1String(
"extent" ) )
2329 else if ( type == QLatin1String(
"point" ) )
2331 else if ( type == QLatin1String(
"geometry" ) )
2333 else if ( type == QLatin1String(
"file" ) )
2335 else if ( type == QLatin1String(
"folder" ) )
2337 else if ( type == QLatin1String(
"matrix" ) )
2339 else if ( type == QLatin1String(
"multiple" ) )
2341 else if ( type == QLatin1String(
"number" ) )
2343 else if ( type == QLatin1String(
"distance" ) )
2345 else if ( type == QLatin1String(
"area" ) )
2347 else if ( type == QLatin1String(
"volume" ) )
2349 else if ( type == QLatin1String(
"duration" ) )
2351 else if ( type == QLatin1String(
"scale" ) )
2353 else if ( type == QLatin1String(
"range" ) )
2355 else if ( type == QLatin1String(
"raster" ) )
2357 else if ( type == QLatin1String(
"enum" ) )
2359 else if ( type == QLatin1String(
"string" ) )
2361 else if ( type == QLatin1String(
"authcfg" ) )
2363 else if ( type == QLatin1String(
"expression" ) )
2365 else if ( type == QLatin1String(
"field" ) )
2367 else if ( type == QLatin1String(
"vector" ) )
2369 else if ( type == QLatin1String(
"source" ) )
2371 else if ( type == QLatin1String(
"sink" ) )
2373 else if ( type == QLatin1String(
"vectordestination" ) )
2375 else if ( type == QLatin1String(
"rasterdestination" ) )
2377 else if ( type == QLatin1String(
"pointclouddestination" ) )
2379 else if ( type == QLatin1String(
"filedestination" ) )
2381 else if ( type == QLatin1String(
"folderdestination" ) )
2383 else if ( type == QLatin1String(
"band" ) )
2385 else if ( type == QLatin1String(
"mesh" ) )
2387 else if ( type == QLatin1String(
"layout" ) )
2389 else if ( type == QLatin1String(
"layoutitem" ) )
2391 else if ( type == QLatin1String(
"color" ) )
2393 else if ( type == QLatin1String(
"coordinateoperation" ) )
2395 else if ( type == QLatin1String(
"maptheme" ) )
2397 else if ( type == QLatin1String(
"datetime" ) )
2399 else if ( type == QLatin1String(
"providerconnection" ) )
2401 else if ( type == QLatin1String(
"databaseschema" ) )
2403 else if ( type == QLatin1String(
"databasetable" ) )
2405 else if ( type == QLatin1String(
"pointcloud" ) )
2407 else if ( type == QLatin1String(
"annotation" ) )
2409 else if ( type == QLatin1String(
"attribute" ) )
2411 else if ( type == QLatin1String(
"vectortiledestination" ) )
2417bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2419 const thread_local QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
2420 QRegularExpressionMatch m = re.match( code );
2421 if ( !m.hasMatch() )
2424 name = m.captured( 1 );
2425 QString tokens = m.captured( 2 );
2426 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
2429 tokens.remove( 0, 8 );
2436 tokens = tokens.trimmed();
2438 const thread_local QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2439 m = re2.match( tokens );
2440 if ( !m.hasMatch() )
2442 type = tokens.toLower().trimmed();
2447 type = m.captured( 1 ).toLower().trimmed();
2448 definition = m.captured( 2 );
2459 , mDescription( description )
2461 , mDefault( defaultValue )
2462 , mFlags( optional ?
Qgis::ProcessingParameterFlag::Optional :
Qgis::ProcessingParameterFlag() )
2468 if ( defaultSettingsValue.isValid() )
2470 return defaultSettingsValue;
2478 if ( defaultSettingsValue.isValid() )
2480 return defaultSettingsValue;
2490 QVariant settingValue = s.
value( QStringLiteral(
"/Processing/DefaultGuiParam/%1/%2" ).arg(
mAlgorithm->
id() ).arg(
mName ) );
2491 if ( settingValue.isValid() )
2493 return settingValue;
2501 if ( !input.isValid() && !
mDefault.isValid() )
2504 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
2505 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
2513 if ( !value.isValid() )
2514 return QStringLiteral(
"None" );
2516 if ( value.userType() == qMetaTypeId<QgsProperty>() )
2517 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2529 if ( !value.isValid() )
2533 if ( value.userType() == QMetaType::Type::QVariantMap )
2535 const QVariantMap sourceMap = value.toMap();
2536 QVariantMap resultMap;
2537 for (
auto it = sourceMap.constBegin(); it != sourceMap.constEnd(); it++ )
2543 else if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
2545 const QVariantList sourceList = value.toList();
2546 QVariantList resultList;
2547 resultList.reserve( sourceList.size() );
2548 for (
const QVariant &v : sourceList )
2556 switch ( value.userType() )
2559 case QMetaType::Bool:
2560 case QMetaType::Char:
2561 case QMetaType::Int:
2562 case QMetaType::Double:
2563 case QMetaType::Float:
2564 case QMetaType::LongLong:
2565 case QMetaType::ULongLong:
2566 case QMetaType::UInt:
2567 case QMetaType::ULong:
2568 case QMetaType::UShort:
2575 if ( value.userType() == qMetaTypeId<QgsProperty>() )
2585 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"field" ), prop.
field() }} );
2587 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"expression" ), prop.
expressionString() }} );
2592 if ( value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
2602 else if ( value.userType() == qMetaTypeId<QgsRectangle>() )
2610 else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
2619 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
2631 else if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
2646 else if ( value.userType() == qMetaTypeId<QgsPointXY>() )
2652 else if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
2659 else if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
2666 else if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
2671 else if ( value.userType() == qMetaTypeId<QColor>() )
2673 const QColor fromVar = value.value< QColor >();
2674 if ( !fromVar.isValid() )
2677 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2679 else if ( value.userType() == qMetaTypeId<QDateTime>() )
2681 const QDateTime fromVar = value.toDateTime();
2682 if ( !fromVar.isValid() )
2685 return fromVar.toString( Qt::ISODate );
2687 else if ( value.userType() == qMetaTypeId<QDate>() )
2689 const QDate fromVar = value.toDate();
2690 if ( !fromVar.isValid() )
2693 return fromVar.toString( Qt::ISODate );
2695 else if ( value.userType() == qMetaTypeId<QTime>() )
2697 const QTime fromVar = value.toTime();
2698 if ( !fromVar.isValid() )
2701 return fromVar.toString( Qt::ISODate );
2708 p.insert(
name(), value );
2716 if ( value.userType() == QMetaType::QString )
2721 Q_ASSERT_X(
false,
"QgsProcessingParameterDefinition::valueAsJsonObject", QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ).toLocal8Bit() );
2734 if ( !value.isValid() )
2737 switch ( value.userType() )
2740 case QMetaType::Bool:
2741 case QMetaType::Char:
2742 case QMetaType::Int:
2743 case QMetaType::Double:
2744 case QMetaType::Float:
2745 case QMetaType::LongLong:
2746 case QMetaType::ULongLong:
2747 case QMetaType::UInt:
2748 case QMetaType::ULong:
2749 case QMetaType::UShort:
2750 return value.toString();
2756 if ( value.userType() == qMetaTypeId<QgsProperty>() )
2766 return QStringLiteral(
"field:%1" ).arg( prop.
field() );
2773 if ( value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
2783 else if ( value.userType() == qMetaTypeId<QgsRectangle>() )
2791 else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
2799 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
2811 else if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
2826 else if ( value.userType() == qMetaTypeId<QgsPointXY>() )
2832 else if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
2839 else if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
2844 else if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
2849 else if ( value.userType() == qMetaTypeId<QColor>() )
2851 const QColor fromVar = value.value< QColor >();
2852 if ( !fromVar.isValid() )
2855 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2857 else if ( value.userType() == qMetaTypeId<QDateTime>() )
2859 const QDateTime fromVar = value.toDateTime();
2860 if ( !fromVar.isValid() )
2863 return fromVar.toString( Qt::ISODate );
2865 else if ( value.userType() == qMetaTypeId<QDate>() )
2867 const QDate fromVar = value.toDate();
2868 if ( !fromVar.isValid() )
2871 return fromVar.toString( Qt::ISODate );
2873 else if ( value.userType() == qMetaTypeId<QTime>() )
2875 const QTime fromVar = value.toTime();
2876 if ( !fromVar.isValid() )
2879 return fromVar.toString( Qt::ISODate );
2886 p.insert(
name(), value );
2894 if ( value.userType() == QMetaType::QString )
2895 return value.toString();
2898 QgsDebugError( QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ) );
2900 return value.toString();
2906 if ( !value.isValid( ) )
2907 return QStringList();
2909 if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
2911 const QVariantList sourceList = value.toList();
2912 QStringList resultList;
2913 resultList.reserve( sourceList.size() );
2914 for (
const QVariant &v : sourceList )
2923 return QStringList();
2935 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2937 code += QLatin1String(
"optional " );
2938 code +=
type() +
' ';
2940 return code.trimmed();
2948 switch ( outputType )
2952 QString code = t->className() + QStringLiteral(
"('%1', %2" )
2955 code += QLatin1String(
", optional=True" );
2971 map.insert( QStringLiteral(
"parameter_type" ),
type() );
2972 map.insert( QStringLiteral(
"name" ),
mName );
2973 map.insert( QStringLiteral(
"description" ),
mDescription );
2974 map.insert( QStringLiteral(
"help" ),
mHelp );
2975 map.insert( QStringLiteral(
"default" ),
mDefault );
2976 map.insert( QStringLiteral(
"defaultGui" ),
mGuiDefault );
2977 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
mFlags ) );
2978 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
2984 mName = map.value( QStringLiteral(
"name" ) ).toString();
2985 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
2986 mHelp = map.value( QStringLiteral(
"help" ) ).toString();
2987 mDefault = map.value( QStringLiteral(
"default" ) );
2988 mGuiDefault = map.value( QStringLiteral(
"defaultGui" ) );
2990 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
3006 QString text = QStringLiteral(
"<p><b>%1</b></p>" ).arg(
description() );
3007 if ( !
help().isEmpty() )
3009 text += QStringLiteral(
"<p>%1</p>" ).arg(
help() );
3011 text += QStringLiteral(
"<p>%1</p>" ).arg( QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
3026 if ( !val.isValid() )
3027 return QStringLiteral(
"None" );
3029 if ( val.userType() == qMetaTypeId<QgsProperty>() )
3031 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
3036 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3038 code += QLatin1String(
"optional " );
3039 code +=
type() +
' ';
3040 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
3041 return code.trimmed();
3063 if ( !input.isValid() )
3071 if ( input.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
3075 else if ( input.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
3079 else if ( input.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
3084 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3089 if ( input.type() == QVariant::String )
3091 const QString
string = input.toString();
3092 if (
string.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
3101 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3104 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3112 if ( !value.isValid() )
3113 return QStringLiteral(
"None" );
3115 if ( value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
3118 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
3123 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3124 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3126 if ( value.type() == QVariant::String )
3128 const QString
string = value.toString();
3129 if (
string.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
3138 p.insert(
name(), value );
3148 if ( value.type() == QVariant::String )
3150 const QString
string = value.toString();
3151 if (
string.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
3164 if ( value.type() == QVariant::String )
3166 const QString
string = value.toString();
3167 if (
string.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
3199 if ( !input.isValid() )
3207 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3212 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3217 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3235 if ( !val.isValid() )
3236 return QStringLiteral(
"None" );
3238 if ( val.userType() == qMetaTypeId<QgsProperty>() )
3242 p.insert(
name(), val );
3262 for (
const QString &raster : rasters )
3264 if ( !vectors.contains( raster ) )
3268 for (
const QString &mesh : meshFilters )
3270 if ( !vectors.contains( mesh ) )
3274 for (
const QString &pointCloud : pointCloudFilters )
3276 if ( !vectors.contains( pointCloud ) )
3277 vectors << pointCloud;
3279 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
3280 std::sort( vectors.begin(), vectors.end() );
3282 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QLatin1String(
";;" ) );
3292 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3294 code += QLatin1String(
"optional " );
3295 code += QLatin1String(
"layer " );
3302 code += QLatin1String(
"table " );
3306 code += QLatin1String(
"hasgeometry " );
3310 code += QLatin1String(
"point " );
3314 code += QLatin1String(
"line " );
3318 code += QLatin1String(
"polygon " );
3322 code += QLatin1String(
"raster " );
3326 code += QLatin1String(
"mesh " );
3330 code += QLatin1String(
"plugin " );
3334 code += QLatin1String(
"pointcloud " );
3338 code += QLatin1String(
"annotation " );
3347 return code.trimmed();
3353 QString def = definition;
3356 if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
3362 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
3365 def = def.mid( 12 );
3368 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
3374 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
3380 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
3386 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
3392 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
3398 else if ( def.startsWith( QLatin1String(
"plugin" ), Qt::CaseInsensitive ) )
3404 else if ( def.startsWith( QLatin1String(
"pointcloud" ), Qt::CaseInsensitive ) )
3407 def = def.mid( 11 );
3410 else if ( def.startsWith( QLatin1String(
"annotation" ), Qt::CaseInsensitive ) )
3413 def = def.mid( 11 );
3424 switch ( outputType )
3428 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', %2" )
3431 code += QLatin1String(
", optional=True" );
3438 QStringList options;
3442 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
3446 code += QLatin1Char(
')' );
3463 map.insert( QStringLiteral(
"data_types" ), types );
3471 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3472 for (
const QVariant &val : values )
3493 if ( !input.isValid() )
3501 if ( input.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
3505 else if ( input.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
3510 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3515 if ( input.userType() == qMetaTypeId<QgsRectangle>() )
3520 if ( input.userType() == qMetaTypeId< QgsGeometry>() )
3524 if ( input.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3531 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3534 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3537 if ( variantIsValidStringForExtent( input ) )
3550bool QgsProcessingParameterExtent::variantIsValidStringForExtent(
const QVariant &value )
3552 if ( value.userType() == QMetaType::Type::QString )
3554 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
3555 const QRegularExpressionMatch match = rx.match( value.toString() );
3556 if ( match.hasMatch() )
3558 bool xMinOk =
false;
3559 ( void )match.captured( 1 ).toDouble( &xMinOk );
3560 bool xMaxOk =
false;
3561 ( void )match.captured( 2 ).toDouble( &xMaxOk );
3562 bool yMinOk =
false;
3563 ( void )match.captured( 3 ).toDouble( &yMinOk );
3564 bool yMaxOk =
false;
3565 ( void )match.captured( 4 ).toDouble( &yMaxOk );
3566 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
3575 if ( !value.isValid() )
3576 return QStringLiteral(
"None" );
3578 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3579 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3581 if ( value.userType() == qMetaTypeId<QgsRectangle>() )
3589 else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3597 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
3602 const QString wkt = g.
asWkt();
3603 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3606 else if ( variantIsValidStringForExtent( value ) )
3612 p.insert(
name(), value );
3622 if ( variantIsValidStringForExtent( value ) )
3624 return value.toString();
3632 if ( variantIsValidStringForExtent( value ) )
3659 if ( !input.isValid() )
3667 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3672 if ( input.userType() == qMetaTypeId<QgsPointXY>() )
3676 if ( input.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3680 if ( input.userType() == qMetaTypeId< QgsGeometry>() )
3685 if ( input.userType() == QMetaType::Type::QString )
3687 if ( input.toString().isEmpty() )
3691 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3693 const QRegularExpressionMatch match = rx.match( input.toString() );
3694 if ( match.hasMatch() )
3697 ( void )match.captured( 1 ).toDouble( &xOk );
3699 ( void )match.captured( 2 ).toDouble( &yOk );
3708 if ( !value.isValid() )
3709 return QStringLiteral(
"None" );
3711 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3712 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3714 if ( value.userType() == qMetaTypeId<QgsPointXY>() )
3720 else if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3727 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
3732 const QString wkt = g.
asWkt();
3733 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3746 const QVariant &defaultValue,
bool optional,
const QList<int> &geometryTypes,
bool allowMultipart )
3748 mGeomTypes( geometryTypes ),
3749 mAllowMultipart( allowMultipart )
3762 if ( !input.isValid() )
3770 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3777 if ( input.userType() == qMetaTypeId< QgsGeometry>() )
3779 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( input.value<
QgsGeometry>().
type() ) ) ) &&
3780 ( mAllowMultipart || !input.value<
QgsGeometry>().isMultipart() );
3783 if ( input.userType() == qMetaTypeId<QgsReferencedGeometry>() )
3789 if ( input.userType() == qMetaTypeId<QgsPointXY>() )
3794 if ( input.userType() == qMetaTypeId<QgsRectangle>() )
3799 if ( input.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3804 if ( input.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3809 if ( input.userType() == QMetaType::Type::QString )
3811 if ( input.toString().isEmpty() )
3816 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3818 const QRegularExpressionMatch match = rx.match( input.toString() );
3819 if ( match.hasMatch() )
3824 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( g.
type() ) ) ) && ( mAllowMultipart || !g.
isMultipart() );
3844 if ( !value.isValid() )
3845 return QStringLiteral(
"None" );
3847 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3850 if ( value.userType() == qMetaTypeId< QgsGeometry>() )
3857 if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
3864 if ( value.userType() == qMetaTypeId<QgsPointXY>() )
3871 if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3878 if ( value.userType() == qMetaTypeId<QgsRectangle>() )
3885 if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3897 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3899 code += QLatin1String(
"optional " );
3900 code +=
type() +
' ';
3902 for (
const int type : mGeomTypes )
3907 code += QLatin1String(
"point " );
3911 code += QLatin1String(
"line " );
3915 code += QLatin1String(
"polygon " );
3919 code += QLatin1String(
"unknown " );
3925 return code.trimmed();
3930 switch ( outputType )
3934 QString code = QStringLiteral(
"QgsProcessingParameterGeometry('%1', %2" )
3937 code += QLatin1String(
", optional=True" );
3939 if ( !mGeomTypes.empty() )
3946 return QStringLiteral(
"PointGeometry" );
3949 return QStringLiteral(
"LineGeometry" );
3952 return QStringLiteral(
"PolygonGeometry" );
3955 return QStringLiteral(
"UnknownGeometry" );
3958 return QStringLiteral(
"NullGeometry" );
3963 QStringList options;
3964 options.reserve( mGeomTypes.size() );
3965 for (
const int type : mGeomTypes )
3967 options << QStringLiteral(
" QgsWkbTypes.%1" ).arg( geomTypeToString(
static_cast<Qgis::GeometryType>(
type ) ) );
3969 code += QStringLiteral(
", geometryTypes=[%1 ]" ).arg( options.join(
',' ) );
3972 if ( ! mAllowMultipart )
3974 code += QLatin1String(
", allowMultipart=False" );
3989 for (
const int type : mGeomTypes )
3993 map.insert( QStringLiteral(
"geometrytypes" ), types );
3994 map.insert( QStringLiteral(
"multipart" ), mAllowMultipart );
4002 const QVariantList values = map.value( QStringLiteral(
"geometrytypes" ) ).toList();
4003 for (
const QVariant &val : values )
4005 mGeomTypes << val.toInt();
4007 mAllowMultipart = map.value( QStringLiteral(
"multipart" ) ).toBool();
4018 , mBehavior( behavior )
4019 , mExtension( fileFilter.isEmpty() ? extension : QString() )
4020 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
4033 if ( !input.isValid() )
4041 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4046 const QString
string = input.toString().trimmed();
4048 if ( input.userType() != QMetaType::Type::QString ||
string.isEmpty() )
4051 switch ( mBehavior )
4055 if ( !mExtension.isEmpty() )
4057 return string.endsWith( mExtension, Qt::CaseInsensitive );
4059 else if ( !mFileFilter.isEmpty() )
4077 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4079 code += QLatin1String(
"optional " );
4082 return code.trimmed();
4087 switch ( outputType )
4092 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', %2" )
4095 code += QLatin1String(
", optional=True" );
4096 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
Qgis::ProcessingFileParameterBehavior::File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
4097 if ( !mExtension.isEmpty() )
4098 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
4099 if ( !mFileFilter.isEmpty() )
4100 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
4111 switch ( mBehavior )
4115 if ( !mFileFilter.isEmpty() )
4116 return mFileFilter != QObject::tr(
"All files (*.*)" ) ? mFileFilter + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" ) : mFileFilter;
4117 else if ( !mExtension.isEmpty() )
4118 return QObject::tr(
"%1 files" ).arg( mExtension.toUpper() ) + QStringLiteral(
" (*." ) + mExtension.toLower() + QStringLiteral(
");;" ) + QObject::tr(
"All files (*.*)" );
4120 return QObject::tr(
"All files (*.*)" );
4132 mFileFilter.clear();
4142 mFileFilter = filter;
4149 map.insert( QStringLiteral(
"behavior" ),
static_cast< int >( mBehavior ) );
4150 map.insert( QStringLiteral(
"extension" ), mExtension );
4151 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
4159 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
4160 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
4171 , mHeaders( headers )
4172 , mNumberRows( numberRows )
4173 , mFixedNumberRows( fixedNumberRows )
4186 if ( !input.isValid() )
4194 if ( input.userType() == QMetaType::Type::QString )
4196 if ( input.toString().isEmpty() )
4200 else if ( input.userType() == QMetaType::Type::QVariantList )
4202 if ( input.toList().isEmpty() )
4206 else if ( input.userType() == QMetaType::Type::Double || input.userType() == QMetaType::Type::Int )
4216 if ( !value.isValid() )
4217 return QStringLiteral(
"None" );
4219 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4220 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4223 p.insert(
name(), value );
4231 switch ( outputType )
4235 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', %2" )
4238 code += QLatin1String(
", optional=True" );
4239 code += QStringLiteral(
", numberRows=%1" ).arg( mNumberRows );
4240 code += QStringLiteral(
", hasFixedNumberRows=%1" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4243 headers.reserve( mHeaders.size() );
4244 for (
const QString &h : mHeaders )
4246 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
4278 return mFixedNumberRows;
4283 mFixedNumberRows = fixedNumberRows;
4289 map.insert( QStringLiteral(
"headers" ), mHeaders );
4290 map.insert( QStringLiteral(
"rows" ), mNumberRows );
4291 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
4298 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
4299 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
4300 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
4311 , mLayerType( layerType )
4324 if ( !input.isValid() )
4334 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
4340 if ( input.userType() == QMetaType::Type::QString )
4342 if ( input.toString().isEmpty() )
4345 if ( mMinimumNumberInputs > 1 )
4356 else if ( input.userType() == QMetaType::Type::QVariantList )
4358 if ( input.toList().count() < mMinimumNumberInputs )
4361 if ( mMinimumNumberInputs > input.toList().count() )
4369 const auto constToList = input.toList();
4370 for (
const QVariant &v : constToList )
4372 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
4381 else if ( input.userType() == QMetaType::Type::QStringList )
4383 if ( input.toStringList().count() < mMinimumNumberInputs )
4386 if ( mMinimumNumberInputs > input.toStringList().count() )
4394 const auto constToStringList = input.toStringList();
4395 for (
const QString &v : constToStringList )
4408 if ( !value.isValid() )
4409 return QStringLiteral(
"None" );
4411 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4412 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4417 if ( value.userType() == QMetaType::Type::QStringList )
4419 const QStringList list = value.toStringList();
4420 parts.reserve( list.count() );
4421 for (
const QString &v : list )
4424 else if ( value.userType() == QMetaType::Type::QVariantList )
4426 const QVariantList list = value.toList();
4427 parts.reserve( list.count() );
4428 for (
const QVariant &v : list )
4431 if ( !parts.isEmpty() )
4432 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4437 p.insert(
name(), value );
4439 if ( !list.isEmpty() )
4442 parts.reserve( list.count() );
4447 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4466 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4468 code += QLatin1String(
"optional " );
4469 switch ( mLayerType )
4472 code += QLatin1String(
"multiple raster" );
4476 code += QLatin1String(
"multiple file" );
4480 code += QLatin1String(
"multiple vector" );
4484 if (
mDefault.userType() == QMetaType::Type::QVariantList )
4487 const auto constToList =
mDefault.toList();
4488 for (
const QVariant &var : constToList )
4490 parts << var.toString();
4492 code += parts.join(
',' );
4494 else if (
mDefault.userType() == QMetaType::Type::QStringList )
4496 code +=
mDefault.toStringList().join(
',' );
4502 return code.trimmed();
4507 switch ( outputType )
4511 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', %2" )
4514 code += QLatin1String(
", optional=True" );
4518 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
4529 switch ( mLayerType )
4532 return QObject::tr(
"All files (*.*)" );
4571 return mMinimumNumberInputs;
4583 map.insert( QStringLiteral(
"layer_type" ),
static_cast< int >( mLayerType ) );
4584 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
4592 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
4598 QString
type = definition;
4600 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
4601 const QRegularExpressionMatch m = re.match( definition );
4604 type = m.captured( 1 ).toLower().trimmed();
4605 defaultVal = m.captured( 2 );
4608 if (
type == QLatin1String(
"vector" ) )
4610 else if (
type == QLatin1String(
"raster" ) )
4612 else if (
type == QLatin1String(
"file" ) )
4625 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
4636 QVariant input = value;
4637 if ( !input.isValid() )
4645 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4651 const double res = input.toDouble( &ok );
4655 return !( res < mMin || res > mMax );
4660 if ( !value.isValid() )
4661 return QStringLiteral(
"None" );
4663 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4664 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4666 return value.toString();
4673 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
4674 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
4675 if ( mMax < std::numeric_limits<double>::max() )
4676 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
4679 const QString extra = parts.join( QLatin1String(
"<br />" ) );
4680 if ( !extra.isEmpty() )
4681 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
4687 switch ( outputType )
4691 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', %2" )
4694 code += QLatin1String(
", optional=True" );
4696 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Qgis::ProcessingNumberParameterType::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4698 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
4699 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
4700 if ( mMax != std::numeric_limits<double>::max() )
4701 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
4743 map.insert( QStringLiteral(
"min" ), mMin );
4744 map.insert( QStringLiteral(
"max" ), mMax );
4745 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
4752 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
4753 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
4761 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4779 if ( !input.isValid() )
4787 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4792 if ( input.userType() == QMetaType::Type::QString )
4794 const QStringList list = input.toString().split(
',' );
4795 if ( list.count() != 2 )
4798 list.at( 0 ).toDouble( &ok );
4800 list.at( 1 ).toDouble( &ok2 );
4805 else if ( input.userType() == QMetaType::Type::QVariantList )
4807 if ( input.toList().count() != 2 )
4811 input.toList().at( 0 ).toDouble( &ok );
4813 input.toList().at( 1 ).toDouble( &ok2 );
4824 if ( !value.isValid() )
4825 return QStringLiteral(
"None" );
4827 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4828 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4831 p.insert(
name(), value );
4834 QStringList stringParts;
4835 const auto constParts = parts;
4836 for (
const double v : constParts )
4838 stringParts << QString::number( v );
4840 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
4845 switch ( outputType )
4849 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', %2" )
4852 code += QLatin1String(
", optional=True" );
4854 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Qgis::ProcessingNumberParameterType::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4877 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
4891 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4908 if ( !input.isValid() )
4916 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4921 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4924 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
4942 if ( !val.isValid() )
4943 return QStringLiteral(
"None" );
4945 if ( val.userType() == qMetaTypeId<QgsProperty>() )
4949 p.insert(
name(), val );
4977 , mOptions( options )
4978 , mAllowMultiple( allowMultiple )
4979 , mUsesStaticStrings( usesStaticStrings )
4991 QVariant input = value;
4992 if ( !input.isValid() )
5000 if ( input.userType() == qMetaTypeId<QgsProperty>() )
5005 if ( mUsesStaticStrings )
5007 if ( input.userType() == QMetaType::Type::QVariantList )
5009 if ( !mAllowMultiple )
5012 const QVariantList values = input.toList();
5016 for (
const QVariant &val : values )
5018 if ( !mOptions.contains( val.toString() ) )
5024 else if ( input.userType() == QMetaType::Type::QStringList )
5026 if ( !mAllowMultiple )
5029 const QStringList values = input.toStringList();
5034 if ( values.count() > 1 && !mAllowMultiple )
5037 for (
const QString &val : values )
5039 if ( !mOptions.contains( val ) )
5044 else if ( input.userType() == QMetaType::Type::QString )
5046 const QStringList parts = input.toString().split(
',' );
5047 if ( parts.count() > 1 && !mAllowMultiple )
5050 const auto constParts = parts;
5051 for (
const QString &part : constParts )
5053 if ( !mOptions.contains( part ) )
5061 if ( input.userType() == QMetaType::Type::QVariantList )
5063 if ( !mAllowMultiple )
5066 const QVariantList values = input.toList();
5070 for (
const QVariant &val : values )
5073 const int res = val.toInt( &ok );
5076 else if ( res < 0 || res >= mOptions.count() )
5082 else if ( input.userType() == QMetaType::Type::QString )
5084 const QStringList parts = input.toString().split(
',' );
5085 if ( parts.count() > 1 && !mAllowMultiple )
5088 const auto constParts = parts;
5089 for (
const QString &part : constParts )
5092 const int res = part.toInt( &ok );
5095 else if ( res < 0 || res >= mOptions.count() )
5100 else if ( input.userType() == QMetaType::Type::Int || input.userType() == QMetaType::Type::Double )
5103 const int res = input.toInt( &ok );
5106 else if ( res >= 0 && res < mOptions.count() )
5116 if ( !value.isValid() )
5117 return QStringLiteral(
"None" );
5119 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5120 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5122 if ( mUsesStaticStrings )
5124 if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
5127 const QStringList constList = value.toStringList();
5128 for (
const QString &val : constList )
5132 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5134 else if ( value.userType() == QMetaType::Type::QString )
5137 const QStringList constList = value.toString().split(
',' );
5138 if ( constList.count() > 1 )
5140 for (
const QString &val : constList )
5144 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5152 if ( value.userType() == QMetaType::Type::QVariantList )
5155 const auto constToList = value.toList();
5156 for (
const QVariant &val : constToList )
5158 parts << QString::number( static_cast< int >( val.toDouble() ) );
5160 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5162 else if ( value.userType() == QMetaType::Type::QString )
5164 const QStringList parts = value.toString().split(
',' );
5165 if ( parts.count() > 1 )
5167 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5171 return QString::number(
static_cast< int >( value.toDouble() ) );
5177 if ( !value.isValid() )
5180 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5183 if ( mUsesStaticStrings )
5189 if ( value.userType() == QMetaType::Type::QVariantList )
5192 const QVariantList toList = value.toList();
5193 parts.reserve( toList.size() );
5194 for (
const QVariant &val : toList )
5196 parts << mOptions.value(
static_cast< int >( val.toDouble() ) );
5198 return parts.join(
',' );
5200 else if ( value.userType() == QMetaType::Type::QString )
5202 const QStringList parts = value.toString().split(
',' );
5203 QStringList comments;
5204 if ( parts.count() > 1 )
5206 for (
const QString &part : parts )
5209 const int val = part.toInt( &ok );
5211 comments << mOptions.value( val );
5213 return comments.join(
',' );
5217 return mOptions.value(
static_cast< int >( value.toDouble() ) );
5223 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5225 code += QLatin1String(
"optional " );
5226 code += QLatin1String(
"enum " );
5228 if ( mAllowMultiple )
5229 code += QLatin1String(
"multiple " );
5231 if ( mUsesStaticStrings )
5232 code += QLatin1String(
"static " );
5234 code += mOptions.join(
';' ) +
' ';
5237 return code.trimmed();
5242 switch ( outputType )
5246 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', %2" )
5249 code += QLatin1String(
", optional=True" );
5252 options.reserve( mOptions.size() );
5253 for (
const QString &o : mOptions )
5255 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
5257 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5259 code += QStringLiteral(
", usesStaticStrings=%1" ).arg( mUsesStaticStrings ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5282 return mAllowMultiple;
5292 return mUsesStaticStrings;
5303 map.insert( QStringLiteral(
"options" ), mOptions );
5304 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5305 map.insert( QStringLiteral(
"uses_static_strings" ), mUsesStaticStrings );
5312 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
5313 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5314 mUsesStaticStrings = map.value( QStringLiteral(
"uses_static_strings" ) ).toBool();
5321 QString def = definition;
5323 bool multiple =
false;
5324 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5330 bool staticStrings =
false;
5331 if ( def.startsWith( QLatin1String(
"static" ), Qt::CaseInsensitive ) )
5333 staticStrings =
true;
5337 const thread_local QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
5338 const QRegularExpressionMatch m = re.match( def );
5339 QString values = def;
5342 values = m.captured( 1 ).trimmed();
5343 defaultVal = m.captured( 2 );
5351 , mMultiLine( multiLine )
5364 return QStringLiteral(
"None" );
5366 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5367 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5369 const QString s = value.toString();
5375 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5377 code += QLatin1String(
"optional " );
5378 code += QLatin1String(
"string " );
5381 code += QLatin1String(
"long " );
5384 return code.trimmed();
5389 switch ( outputType )
5393 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', %2" )
5396 code += QLatin1String(
", optional=True" );
5397 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5420 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
5427 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
5433 QString def = definition;
5435 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
5441 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5443 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5447 if ( def == QLatin1String(
"None" ) )
5470 if ( !value.isValid() )
5471 return QStringLiteral(
"None" );
5473 const QString s = value.toString();
5479 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5481 code += QLatin1String(
"optional " );
5482 code += QLatin1String(
"authcfg " );
5485 return code.trimmed();
5490 QString def = definition;
5492 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5494 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5498 if ( def == QLatin1String(
"None" ) )
5511 , mParentLayerParameterName( parentLayerParameterName )
5512 , mExpressionType( type )
5524 if ( !value.isValid() )
5525 return QStringLiteral(
"None" );
5527 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5528 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5530 const QString s = value.toString();
5536 QStringList depends;
5537 if ( !mParentLayerParameterName.isEmpty() )
5538 depends << mParentLayerParameterName;
5544 switch ( outputType )
5548 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', %2" )
5551 code += QLatin1String(
", optional=True" );
5553 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5559 switch ( mExpressionType )
5562 code += QLatin1String(
", type=Qgis.ExpressionType.PointCloud)" );
5565 code += QLatin1String(
", type=Qgis.ExpressionType.RasterCalculator)" );
5568 code += QLatin1Char(
')' );
5579 return mParentLayerParameterName;
5589 return mExpressionType;
5600 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5601 map.insert( QStringLiteral(
"expression_type" ),
static_cast< int >( mExpressionType ) );
5608 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5609 mExpressionType =
static_cast< Qgis::ExpressionType >( map.value( QStringLiteral(
"expression_type" ) ).toInt() );
5634 if ( !var.isValid() )
5642 if ( var.userType() == qMetaTypeId<QgsProperty>() )
5655 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
5658 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
5676 if ( !val.isValid() )
5677 return QStringLiteral(
"None" );
5679 if ( val.userType() == qMetaTypeId<QgsProperty>() )
5683 p.insert(
name(), val );
5701 switch ( outputType )
5705 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', %2" )
5708 code += QLatin1String(
", optional=True" );
5712 QStringList options;
5715 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
5749 map.insert( QStringLiteral(
"data_types" ), types );
5757 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
5758 for (
const QVariant &val : values )
5771 const QVariant &defaultValue,
bool optional )
5786 if ( !var.isValid() )
5794 if ( var.userType() == qMetaTypeId<QgsProperty>() )
5807 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
5810 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
5828 if ( !val.isValid() )
5829 return QStringLiteral(
"None" );
5831 if ( val.userType() == qMetaTypeId<QgsProperty>() )
5835 p.insert(
name(), val );
5863 , mParentLayerParameterName( parentLayerParameterName )
5865 , mAllowMultiple( allowMultiple )
5866 , mDefaultToAllFields( defaultToAllFields )
5880 if ( !input.isValid() )
5888 if ( input.userType() == qMetaTypeId<QgsProperty>() )
5893 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
5895 if ( !mAllowMultiple )
5901 else if ( input.userType() == QMetaType::Type::QString )
5903 if ( input.toString().isEmpty() )
5906 const QStringList parts = input.toString().split(
';' );
5907 if ( parts.count() > 1 && !mAllowMultiple )
5912 if ( input.toString().isEmpty() )
5920 if ( !value.isValid() )
5921 return QStringLiteral(
"None" );
5923 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5924 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5926 if ( value.userType() == QMetaType::Type::QVariantList )
5929 const auto constToList = value.toList();
5930 for (
const QVariant &val : constToList )
5934 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5936 else if ( value.userType() == QMetaType::Type::QStringList )
5939 const auto constToStringList = value.toStringList();
5940 for (
const QString &s : constToStringList )
5944 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5952 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5954 code += QLatin1String(
"optional " );
5955 code += QLatin1String(
"field " );
5957 switch ( mDataType )
5960 code += QLatin1String(
"numeric " );
5964 code += QLatin1String(
"string " );
5968 code += QLatin1String(
"datetime " );
5972 code += QLatin1String(
"binary " );
5976 code += QLatin1String(
"boolean " );
5983 if ( mAllowMultiple )
5984 code += QLatin1String(
"multiple " );
5986 if ( mDefaultToAllFields )
5987 code += QLatin1String(
"default_to_all_fields " );
5989 code += mParentLayerParameterName +
' ';
5992 return code.trimmed();
5997 switch ( outputType )
6001 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', %2" )
6004 code += QLatin1String(
", optional=True" );
6007 switch ( mDataType )
6010 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
6014 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
6018 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
6022 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
6026 dataType = QStringLiteral(
"QgsProcessingParameterField.Binary" );
6030 dataType = QStringLiteral(
"QgsProcessingParameterField.Boolean" );
6033 code += QStringLiteral(
", type=%1" ).arg(
dataType );
6035 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
6036 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6040 if ( mDefaultToAllFields )
6041 code += QLatin1String(
", defaultToAllFields=True" );
6053 QStringList depends;
6054 if ( !mParentLayerParameterName.isEmpty() )
6055 depends << mParentLayerParameterName;
6061 return mParentLayerParameterName;
6081 return mAllowMultiple;
6091 return mDefaultToAllFields;
6096 mDefaultToAllFields = enabled;
6102 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
6103 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
6104 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
6105 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
6112 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
6114 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
6115 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
6125 QString def = definition;
6127 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
6132 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
6137 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
6142 else if ( def.startsWith( QLatin1String(
"binary " ), Qt::CaseInsensitive ) )
6147 else if ( def.startsWith( QLatin1String(
"boolean " ), Qt::CaseInsensitive ) )
6153 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
6156 def = def.mid( 8 ).trimmed();
6159 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
6162 def = def.mid( 21 ).trimmed();
6165 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
6166 const QRegularExpressionMatch m = re.match( def );
6169 parent = m.captured( 1 ).trimmed();
6170 def = m.captured( 2 );
6195 QVariant var = input;
6196 if ( !var.isValid() )
6204 if ( var.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
6209 else if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6216 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6228 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
6233 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
6251 if ( !value.isValid() )
6252 return QStringLiteral(
"None" );
6254 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6257 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
6260 QString geometryCheckString;
6264 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
6268 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
6272 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
6279 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
6281 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
6282 if ( !
flags.empty() )
6283 flagString =
flags.join( QLatin1String(
" | " ) );
6290 layerString = layer->source();
6297 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6298 geometryCheckString,
6310 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression(%1), selectedFeaturesOnly=%2, featureLimit=%3%4%6, geometryCheck=%5)" )
6314 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6315 geometryCheckString,
6324 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
6329 QString layerString = value.toString();
6333 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
6350 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6352 code += QLatin1String(
"optional " );
6353 code += QLatin1String(
"source " );
6360 code += QLatin1String(
"point " );
6364 code += QLatin1String(
"line " );
6368 code += QLatin1String(
"polygon " );
6377 return code.trimmed();
6382 switch ( outputType )
6386 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', %2" )
6389 code += QLatin1String(
", optional=True" );
6393 QStringList options;
6397 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
6414 : mDataTypes( types )
6427 map.insert( QStringLiteral(
"data_types" ), types );
6435 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
6436 for (
const QVariant &val : values )
6446 QString def = definition;
6449 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6455 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6461 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6476 , mSupportsAppend( supportsAppend )
6487 QVariant var = input;
6488 if ( !var.isValid() )
6496 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6502 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6515 if ( var.userType() != QMetaType::Type::QString )
6518 if ( var.toString().isEmpty() )
6526 if ( !value.isValid() )
6527 return QStringLiteral(
"None" );
6529 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6530 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6532 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6541 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6550 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6552 code += QLatin1String(
"optional " );
6553 code += QLatin1String(
"sink " );
6555 switch ( mDataType )
6558 code += QLatin1String(
"point " );
6562 code += QLatin1String(
"line " );
6566 code += QLatin1String(
"polygon " );
6570 code += QLatin1String(
"table " );
6578 return code.trimmed();
6590 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6594 return p->defaultVectorFileExtension(
hasGeometry() );
6604 return QStringLiteral(
"dbf" );
6611 switch ( outputType )
6615 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', %2" )
6618 code += QLatin1String(
", optional=True" );
6622 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6623 if ( mSupportsAppend )
6624 code += QLatin1String(
", supportsAppend=True" );
6637 QStringList filters;
6638 for (
const QString &ext : exts )
6640 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6642 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6651 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6653 return lOriginalProvider->supportedOutputTableExtensions();
6658 return p->supportedOutputVectorLayerExtensions();
6660 return p->supportedOutputTableExtensions();
6675 switch ( mDataType )
6705 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
6706 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
6714 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
6721 return QStringLiteral(
"memory:%1" ).arg(
description() );
6729 QString def = definition;
6730 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6735 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6740 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6745 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
6756 return mSupportsAppend;
6776 QVariant var = input;
6777 if ( !var.isValid() )
6785 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6791 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6804 if ( var.userType() != QMetaType::Type::QString )
6807 if ( var.toString().isEmpty() )
6815 if ( !value.isValid() )
6816 return QStringLiteral(
"None" );
6818 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6819 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6821 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6830 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6846 return lOriginalProvider->defaultRasterFileExtension();
6850 return p->defaultRasterFileExtension();
6861 QStringList filters;
6862 for (
const QString &ext : exts )
6864 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6866 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6873 return lOriginalProvider->supportedOutputRasterLayerExtensions();
6877 return p->supportedOutputRasterLayerExtensions();
6893 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
6905 QVariant var = input;
6906 if ( !var.isValid() )
6914 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6920 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6933 if ( var.userType() != QMetaType::Type::QString )
6936 if ( var.toString().isEmpty() )
6946 if ( !value.isValid() )
6947 return QStringLiteral(
"None" );
6949 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6950 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6952 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6961 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6970 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
6982 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
6983 return QStringLiteral(
"file" );
6986 const thread_local QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
6987 const QRegularExpressionMatch match = rx.match( mFileFilter );
6988 if ( !match.hasMatch() )
6989 return QStringLiteral(
"file" );
6991 return match.captured( 1 );
6996 switch ( outputType )
7000 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', %2" )
7003 code += QLatin1String(
", optional=True" );
7007 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7019 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
7035 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
7042 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
7063 QVariant var = input;
7064 if ( !var.isValid() )
7072 if ( var.userType() == qMetaTypeId<QgsProperty>() )
7085 if ( var.userType() != QMetaType::Type::QString )
7088 if ( var.toString().isEmpty() )
7111 , mCreateByDefault( createByDefault )
7119 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
7120 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
7127 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
7128 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
7134 switch ( outputType )
7141 QString code = t->className() + QStringLiteral(
"('%1', %2" )
7144 code += QLatin1String(
", optional=True" );
7146 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7161 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
7168 const thread_local QRegularExpression rx( QStringLiteral(
"[.]" ) );
7169 QString sanitizedName =
name();
7170 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
7185 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
7194 return mCreateByDefault;
7216 QVariant var = input;
7217 if ( !var.isValid() )
7225 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
7231 if ( var.userType() == qMetaTypeId<QgsProperty>() )
7244 if ( var.userType() != QMetaType::Type::QString )
7247 if ( var.toString().isEmpty() )
7255 if ( !value.isValid() )
7256 return QStringLiteral(
"None" );
7258 if ( value.userType() == qMetaTypeId<QgsProperty>() )
7259 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7261 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
7270 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
7279 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7281 code += QLatin1String(
"optional " );
7282 code += QLatin1String(
"vectorDestination " );
7284 switch ( mDataType )
7287 code += QLatin1String(
"point " );
7291 code += QLatin1String(
"line " );
7295 code += QLatin1String(
"polygon " );
7303 return code.trimmed();
7315 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
7319 return p->defaultVectorFileExtension(
hasGeometry() );
7329 return QStringLiteral(
"dbf" );
7336 switch ( outputType )
7340 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', %2" )
7343 code += QLatin1String(
", optional=True" );
7347 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7360 QStringList filters;
7361 for (
const QString &ext : exts )
7363 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
7365 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
7373 return lOriginalProvider->supportedOutputVectorLayerExtensions();
7375 return lOriginalProvider->supportedOutputTableExtensions();
7380 return p->supportedOutputVectorLayerExtensions();
7382 return p->supportedOutputTableExtensions();
7397 switch ( mDataType )
7427 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
7441 QString def = definition;
7442 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
7447 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
7452 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
7463 , mParentLayerParameterName( parentLayerParameterName )
7464 , mAllowMultiple( allowMultiple )
7476 QVariant input = value;
7477 if ( !input.isValid() )
7485 if ( input.userType() == qMetaTypeId<QgsProperty>() )
7490 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
7492 if ( !mAllowMultiple )
7501 const double res = input.toInt( &ok );
7511 return mAllowMultiple;
7521 if ( !value.isValid() )
7522 return QStringLiteral(
"None" );
7524 if ( value.userType() == qMetaTypeId<QgsProperty>() )
7525 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7527 if ( value.userType() == QMetaType::Type::QVariantList )
7530 const QVariantList values = value.toList();
7531 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7533 parts << QString::number( static_cast< int >( it->toDouble() ) );
7535 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7537 else if ( value.userType() == QMetaType::Type::QStringList )
7540 const QStringList values = value.toStringList();
7541 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7543 parts << QString::number( static_cast< int >( it->toDouble() ) );
7545 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7548 return value.toString();
7553 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7555 code += QLatin1String(
"optional " );
7556 code += QLatin1String(
"band " );
7558 if ( mAllowMultiple )
7559 code += QLatin1String(
"multiple " );
7561 code += mParentLayerParameterName +
' ';
7564 return code.trimmed();
7569 QStringList depends;
7570 if ( !mParentLayerParameterName.isEmpty() )
7571 depends << mParentLayerParameterName;
7577 switch ( outputType )
7581 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', %2" )
7584 code += QLatin1String(
", optional=True" );
7586 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
7587 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7599 return mParentLayerParameterName;
7610 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
7611 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
7618 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
7619 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
7626 QString def = definition;
7629 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
7632 def = def.mid( 8 ).trimmed();
7635 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7636 const QRegularExpressionMatch m = re.match( def );
7639 parent = m.captured( 1 ).trimmed();
7640 def = m.captured( 2 );
7657 , mParentParameterName( parentParameterName )
7674 QStringList depends;
7675 if ( !mParentParameterName.isEmpty() )
7676 depends << mParentParameterName;
7682 switch ( outputType )
7686 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', %2" )
7689 code += QLatin1String(
", optional=True" );
7691 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7693 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7694 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7695 if (
maximum() != std::numeric_limits<double>::max() )
7696 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7707 return mParentParameterName;
7718 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7719 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7726 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7739 , mParentParameterName( parentParameterName )
7756 QStringList depends;
7757 if ( !mParentParameterName.isEmpty() )
7758 depends << mParentParameterName;
7764 switch ( outputType )
7768 QString code = QStringLiteral(
"QgsProcessingParameterArea('%1', %2" )
7771 code += QLatin1String(
", optional=True" );
7773 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7776 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7777 if (
maximum() != std::numeric_limits<double>::max() )
7778 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7789 return mParentParameterName;
7800 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7801 map.insert( QStringLiteral(
"default_unit" ),
qgsEnumValueToKey( mDefaultUnit ) );
7808 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7821 , mParentParameterName( parentParameterName )
7838 QStringList depends;
7839 if ( !mParentParameterName.isEmpty() )
7840 depends << mParentParameterName;
7846 switch ( outputType )
7850 QString code = QStringLiteral(
"QgsProcessingParameterVolume('%1', %2" )
7853 code += QLatin1String(
", optional=True" );
7855 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7858 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7859 if (
maximum() != std::numeric_limits<double>::max() )
7860 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7871 return mParentParameterName;
7882 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7883 map.insert( QStringLiteral(
"default_unit" ),
qgsEnumValueToKey( mDefaultUnit ) );
7890 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7917 switch ( outputType )
7921 QString code = QStringLiteral(
"QgsProcessingParameterDuration('%1', %2" )
7924 code += QLatin1String(
", optional=True" );
7926 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7927 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7928 if (
maximum() != std::numeric_limits<double>::max() )
7929 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7941 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7975 switch ( outputType )
7979 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', %2" )
7982 code += QLatin1String(
", optional=True" );
7994 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
8014 return QStringLiteral(
"None" );
8016 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8017 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8019 const QString s = value.toString();
8025 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8027 code += QLatin1String(
"optional " );
8028 code += QLatin1String(
"layout " );
8031 return code.trimmed();
8036 switch ( outputType )
8040 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', %2" )
8043 code += QLatin1String(
", optional=True" );
8054 QString def = definition;
8056 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8058 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8062 if ( def == QLatin1String(
"None" ) )
8075 , mParentLayoutParameterName( parentLayoutParameterName )
8076 , mItemType( itemType )
8089 return QStringLiteral(
"None" );
8091 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8092 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8094 const QString s = value.toString();
8100 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8102 code += QLatin1String(
"optional " );
8103 code += QLatin1String(
"layoutitem " );
8104 if ( mItemType >= 0 )
8105 code += QString::number( mItemType ) +
' ';
8107 code += mParentLayoutParameterName +
' ';
8110 return code.trimmed();
8115 switch ( outputType )
8119 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', %2" )
8122 code += QLatin1String(
", optional=True" );
8124 if ( mItemType >= 0 )
8125 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
8127 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
8140 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
8141 map.insert( QStringLiteral(
"item_type" ), mItemType );
8148 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
8149 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
8155 QStringList depends;
8156 if ( !mParentLayoutParameterName.isEmpty() )
8157 depends << mParentLayoutParameterName;
8164 QString def = definition;
8166 const thread_local QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
8167 const QRegularExpressionMatch m = re.match( def );
8170 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
8171 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
8172 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
8185 return mParentLayoutParameterName;
8190 mParentLayoutParameterName =
name;
8209 , mAllowOpacity( opacityEnabled )
8222 return QStringLiteral(
"None" );
8224 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8225 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8227 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
8228 return QStringLiteral(
"QColor()" );
8230 if ( value.canConvert< QColor >() )
8232 const QColor
c = value.value< QColor >();
8233 if ( !mAllowOpacity ||
c.alpha() == 255 )
8234 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
8236 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
8239 const QString s = value.toString();
8245 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8247 code += QLatin1String(
"optional " );
8248 code += QLatin1String(
"color " );
8250 if ( mAllowOpacity )
8251 code += QLatin1String(
"withopacity " );
8254 return code.trimmed();
8259 switch ( outputType )
8263 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', %2" )
8266 code += QLatin1String(
", optional=True" );
8268 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
8280 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
8283 if ( !input.isValid() )
8286 if ( input.userType() == QMetaType::Type::QColor )
8290 else if ( input.userType() == qMetaTypeId<QgsProperty>() )
8295 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
8298 bool containsAlpha =
false;
8305 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
8312 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
8318 return mAllowOpacity;
8323 mAllowOpacity = enabled;
8328 QString def = definition;
8330 bool allowOpacity =
false;
8331 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
8333 allowOpacity =
true;
8334 def = def.mid( 12 );
8337 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8339 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8343 if ( def == QLatin1String(
"None" ) || def.isEmpty() )
8354 , mSourceParameterName( sourceCrsParameterName )
8355 , mDestParameterName( destinationCrsParameterName )
8356 , mSourceCrs( staticSourceCrs )
8357 , mDestCrs( staticDestinationCrs )
8369 return valueAsPythonStringPrivate( value, context,
false );
8372QString QgsProcessingParameterCoordinateOperation::valueAsPythonStringPrivate(
const QVariant &value,
QgsProcessingContext &context,
bool allowNonStringValues )
const
8375 return QStringLiteral(
"None" );
8377 if ( allowNonStringValues && value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
8380 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
8385 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8386 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8388 if ( allowNonStringValues )
8391 p.insert(
name(), value );
8397 const QString s = value.toString();
8403 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8405 code += QLatin1String(
"optional " );
8406 code += QLatin1String(
"coordinateoperation " );
8409 return code.trimmed();
8414 switch ( outputType )
8419 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', %2" )
8422 code += QLatin1String(
", optional=True" );
8423 if ( !mSourceParameterName.isEmpty() )
8424 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg( valueAsPythonStringPrivate( mSourceParameterName,
c,
false ) );
8425 if ( !mDestParameterName.isEmpty() )
8426 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg( valueAsPythonStringPrivate( mDestParameterName,
c,
false ) );
8428 if ( mSourceCrs.isValid() )
8429 code += QStringLiteral(
", staticSourceCrs=%1" ).arg( valueAsPythonStringPrivate( mSourceCrs,
c,
true ) );
8430 if ( mDestCrs.isValid() )
8431 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg( valueAsPythonStringPrivate( mDestCrs,
c,
true ) );
8433 code += QStringLiteral(
", defaultValue=%1)" ).arg( valueAsPythonStringPrivate(
mDefault,
c,
false ) );
8443 if ( !mSourceParameterName.isEmpty() )
8444 res << mSourceParameterName;
8445 if ( !mDestParameterName.isEmpty() )
8446 res << mDestParameterName;
8453 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
8454 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
8455 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
8456 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
8463 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
8464 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
8465 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
8466 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
8472 QString def = definition;
8474 if ( def.startsWith(
'"' ) )
8477 if ( def.endsWith(
'"' ) )
8480 else if ( def.startsWith(
'\'' ) )
8483 if ( def.endsWith(
'\'' ) )
8488 if ( def == QLatin1String(
"None" ) )
8513 if ( !input.isValid() && !
mDefault.isValid() )
8516 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8517 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8525 if ( !value.isValid() )
8526 return QStringLiteral(
"None" );
8528 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8529 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8536 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8538 code += QLatin1String(
"optional " );
8539 code += QLatin1String(
"maptheme " );
8542 return code.trimmed();
8547 switch ( outputType )
8551 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', %2" )
8554 code += QLatin1String(
", optional=True" );
8579 QString def = definition;
8580 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8582 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8604 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
8606 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
8617 QVariant input = value;
8618 if ( !input.isValid() )
8626 if ( input.userType() == qMetaTypeId<QgsProperty>() )
8631 if ( input.userType() != QMetaType::Type::QDateTime && input.userType() != QMetaType::Type::QDate && input.userType() != QMetaType::Type::QTime && input.userType() != QMetaType::Type::QString )
8637 if ( input.userType() == QMetaType::Type::QString )
8639 const QString s = input.toString();
8643 input = QDateTime::fromString( s, Qt::ISODate );
8646 if ( !input.toDateTime().isValid() )
8647 input = QTime::fromString( s );
8649 input = input.toDateTime().time();
8655 const QDateTime res = input.toDateTime();
8656 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
8660 const QTime res = input.toTime();
8661 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
8667 if ( !value.isValid() )
8668 return QStringLiteral(
"None" );
8670 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8671 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8673 if ( value.userType() == QMetaType::Type::QDateTime )
8675 const QDateTime dt = value.toDateTime();
8676 if ( !dt.isValid() )
8677 return QStringLiteral(
"QDateTime()" );
8679 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
8680 .arg( dt.date().month() )
8681 .arg( dt.date().day() )
8682 .arg( dt.time().hour() )
8683 .arg( dt.time().minute() )
8684 .arg( dt.time().second() );
8686 else if ( value.userType() == QMetaType::Type::QDate )
8688 const QDate dt = value.toDate();
8689 if ( !dt.isValid() )
8690 return QStringLiteral(
"QDate()" );
8692 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
8696 else if ( value.userType() == QMetaType::Type::QTime )
8698 const QTime dt = value.toTime();
8699 if ( !dt.isValid() )
8700 return QStringLiteral(
"QTime()" );
8702 return QStringLiteral(
"QTime(%4, %5, %6)" )
8705 .arg( dt.second() );
8707 return value.toString();
8714 if ( mMin.isValid() )
8715 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
8716 if ( mMax.isValid() )
8717 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
8721 const QString extra = parts.join( QLatin1String(
"<br />" ) );
8722 if ( !extra.isEmpty() )
8723 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
8729 switch ( outputType )
8733 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', %2" )
8736 code += QLatin1String(
", optional=True" );
8740 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
8743 if ( mMin.isValid() )
8745 if ( mMax.isValid() )
8787 map.insert( QStringLiteral(
"min" ), mMin );
8788 map.insert( QStringLiteral(
"max" ), mMax );
8789 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
8796 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
8797 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
8805 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
8816 , mProviderId( provider )
8829 if ( !input.isValid() && !
mDefault.isValid() )
8832 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8833 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8841 if ( !value.isValid() )
8842 return QStringLiteral(
"None" );
8844 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8845 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8852 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8854 code += QLatin1String(
"optional " );
8855 code += QLatin1String(
"providerconnection " );
8856 code += mProviderId +
' ';
8859 return code.trimmed();
8864 switch ( outputType )
8868 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', %2, '%3'" )
8871 code += QLatin1String(
", optional=True" );
8885 map.insert( QStringLiteral(
"provider" ), mProviderId );
8892 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
8898 QString def = definition;
8900 if ( def.contains(
' ' ) )
8902 provider = def.left( def.indexOf(
' ' ) );
8903 def = def.mid( def.indexOf(
' ' ) + 1 );
8911 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8913 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8931 , mParentConnectionParameterName( parentLayerParameterName )
8944 if ( !input.isValid() && !
mDefault.isValid() )
8947 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8948 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8956 if ( !value.isValid() )
8957 return QStringLiteral(
"None" );
8959 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8960 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8967 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8969 code += QLatin1String(
"optional " );
8970 code += QLatin1String(
"databaseschema " );
8972 code += mParentConnectionParameterName +
' ';
8975 return code.trimmed();
8980 switch ( outputType )
8984 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', %2" )
8987 code += QLatin1String(
", optional=True" );
8989 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
9003 QStringList depends;
9004 if ( !mParentConnectionParameterName.isEmpty() )
9005 depends << mParentConnectionParameterName;
9011 return mParentConnectionParameterName;
9016 mParentConnectionParameterName =
name;
9022 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
9029 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
9036 QString def = definition;
9038 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
9039 const QRegularExpressionMatch m = re.match( def );
9042 parent = m.captured( 1 ).trimmed();
9043 def = m.captured( 2 );
9059 const QString &connectionParameterName,
9060 const QString &schemaParameterName,
9061 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
9063 , mParentConnectionParameterName( connectionParameterName )
9064 , mParentSchemaParameterName( schemaParameterName )
9065 , mAllowNewTableNames( allowNewTableNames )
9078 if ( !input.isValid() && !
mDefault.isValid() )
9081 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
9082 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
9090 if ( !value.isValid() )
9091 return QStringLiteral(
"None" );
9093 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9094 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9101 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
9103 code += QLatin1String(
"optional " );
9104 code += QLatin1String(
"databasetable " );
9106 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
9107 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
9110 return code.trimmed();
9115 switch ( outputType )
9119 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', %2" )
9122 code += QLatin1String(
", optional=True" );
9124 if ( mAllowNewTableNames )
9125 code += QLatin1String(
", allowNewTableNames=True" );
9127 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
9128 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
9142 QStringList depends;
9143 if ( !mParentConnectionParameterName.isEmpty() )
9144 depends << mParentConnectionParameterName;
9145 if ( !mParentSchemaParameterName.isEmpty() )
9146 depends << mParentSchemaParameterName;
9152 return mParentConnectionParameterName;
9157 mParentConnectionParameterName =
name;
9162 return mParentSchemaParameterName;
9167 mParentSchemaParameterName =
name;
9173 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
9174 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
9175 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
9182 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
9183 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
9184 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
9192 QString def = definition;
9194 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
9195 const QRegularExpressionMatch m = re.match( def );
9198 connection = m.captured( 1 ).trimmed();
9199 if ( connection == QLatin1String(
"none" ) )
9201 schema = m.captured( 2 ).trimmed();
9202 if ( schema == QLatin1String(
"none" ) )
9204 def = m.captured( 3 );
9212 return mAllowNewTableNames;
9225 const QVariant &defaultValue,
bool optional )
9239 if ( !var.isValid() )
9247 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9260 if ( qobject_cast< QgsPointCloudLayer * >( qvariant_cast<QObject *>( var ) ) )
9263 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
9281 if ( !val.isValid() )
9282 return QStringLiteral(
"None" );
9284 if ( val.userType() == qMetaTypeId<QgsProperty>() )
9288 p.insert(
name(), val );
9319 const QVariant &defaultValue,
bool optional )
9332 if ( !var.isValid() )
9340 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9353 if ( qobject_cast< QgsAnnotationLayer * >( qvariant_cast<QObject *>( var ) ) )
9356 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
9374 if ( !val.isValid() )
9375 return QStringLiteral(
"None" );
9377 if ( val.userType() == qMetaTypeId<QgsProperty>() )
9381 p.insert(
name(), val );
9414 QVariant var = input;
9415 if ( !var.isValid() )
9423 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9429 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9442 if ( var.userType() != QMetaType::Type::QString )
9445 if ( var.toString().isEmpty() )
9453 if ( !value.isValid() )
9454 return QStringLiteral(
"None" );
9456 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9457 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9459 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9468 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9484 return lOriginalProvider->defaultPointCloudFileExtension();
9488 return p->defaultPointCloudFileExtension();
9499 QStringList filters;
9500 for (
const QString &ext : exts )
9502 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9504 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9511 return lOriginalProvider->supportedOutputPointCloudLayerExtensions();
9515 return p->supportedOutputPointCloudLayerExtensions();
9520 return QStringList() << ext;
9535 , mParentLayerParameterName( parentLayerParameterName )
9536 , mAllowMultiple( allowMultiple )
9537 , mDefaultToAllAttributes( defaultToAllAttributes )
9557 if ( input.userType() == qMetaTypeId<QgsProperty>() )
9562 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
9564 if ( !mAllowMultiple )
9570 else if ( input.userType() == QMetaType::Type::QString )
9572 if ( input.toString().isEmpty() )
9575 const QStringList parts = input.toString().split(
';' );
9576 if ( parts.count() > 1 && !mAllowMultiple )
9581 if ( input.toString().isEmpty() )
9589 if ( !value.isValid() )
9590 return QStringLiteral(
"None" );
9592 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9593 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9595 if ( value.userType() == QMetaType::Type::QVariantList )
9598 const auto constToList = value.toList();
9599 for (
const QVariant &val : constToList )
9603 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9605 else if ( value.userType() == QMetaType::Type::QStringList )
9608 const auto constToStringList = value.toStringList();
9609 for (
const QString &s : constToStringList )
9613 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9621 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
9623 code += QLatin1String(
"optional " );
9624 code += QLatin1String(
"attribute " );
9626 if ( mAllowMultiple )
9627 code += QLatin1String(
"multiple " );
9629 if ( mDefaultToAllAttributes )
9630 code += QLatin1String(
"default_to_all_attributes " );
9632 code += mParentLayerParameterName +
' ';
9635 return code.trimmed();
9640 switch ( outputType )
9644 QString code = QStringLiteral(
"QgsProcessingParameterPointCloudAttribute('%1', %2" )
9647 code += QLatin1String(
", optional=True" );
9649 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
9650 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
9654 if ( mDefaultToAllAttributes )
9655 code += QLatin1String(
", defaultToAllAttributes=True" );
9667 QStringList depends;
9668 if ( !mParentLayerParameterName.isEmpty() )
9669 depends << mParentLayerParameterName;
9675 return mParentLayerParameterName;
9685 return mAllowMultiple;
9695 return mDefaultToAllAttributes;
9700 mDefaultToAllAttributes = enabled;
9706 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
9707 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
9708 map.insert( QStringLiteral(
"default_to_all_attributes" ), mDefaultToAllAttributes );
9715 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
9716 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
9717 mDefaultToAllAttributes = map.value( QStringLiteral(
"default_to_all_attributes" ) ).toBool();
9726 QString def = definition;
9728 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
9731 def = def.mid( 8 ).trimmed();
9734 if ( def.startsWith( QLatin1String(
"default_to_all_attributes" ), Qt::CaseInsensitive ) )
9737 def = def.mid( 25 ).trimmed();
9740 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
9741 const QRegularExpressionMatch m = re.match( def );
9744 parent = m.captured( 1 ).trimmed();
9745 def = m.captured( 2 );
9772 QVariant var = input;
9773 if ( !var.isValid() )
9781 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9787 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9800 if ( var.userType() != QMetaType::Type::QString )
9803 if ( var.toString().isEmpty() )
9811 if ( !value.isValid() )
9812 return QStringLiteral(
"None" );
9814 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9815 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9817 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9826 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9846 QStringList filters;
9847 for (
const QString &ext : exts )
9849 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9851 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9857 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)
@ 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.
DistanceUnit
Units of distance.
@ Unknown
Unknown distance unit.
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 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.
Abstract base class for processing algorithms.
QString id() const
Returns the unique ID for the algorithm, which is a combination of the algorithm provider's ID and th...
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
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.
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.
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.
An annotation layer parameter 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.
A double numeric parameter for area values.
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.
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.
A string parameter for authentication configuration ID values.
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.
A raster band parameter for Processing algorithms.
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.
A boolean parameter for processing algorithms.
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.
A coordinate operation parameter for processing algorithms.
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 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.
A coordinate reference system parameter for processing algorithms.
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).
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.
A database schema parameter for processing algorithms, allowing users to select from existing schemas...
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.
A database table name parameter for processing algorithms.
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.
A datetime (or pure date or time) parameter for processing algorithms.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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.
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.
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.
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.
A double numeric parameter for distance values.
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.
QgsProcessingParameterDistance * clone() const override
Creates a clone of the parameter definition.
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.
A double numeric parameter for duration values.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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...
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.
An expression parameter for processing algorithms.
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.
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.
A rectangular map extent 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...
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).
A feature sink output for processing algorithms.
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...
An input feature source (such as vector layers) parameter for processing algorithms.
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.
A vector layer or feature source field parameter for processing algorithms.
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.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
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.
An input file or folder parameter for processing algorithms.
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.
A folder destination parameter, for specifying the destination path for a folder created by the algor...
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.
A geometry parameter for processing algorithms.
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.
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.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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.
A print layout item parameter, allowing users to select a particular item from a print layout.
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.
A print layout parameter, allowing users to select a print layout.
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.
Can be inherited by parameters which require limits to their acceptable data types.
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.
A map layer parameter for processing algorithms.
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.
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
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...
A table (matrix) parameter for processing algorithms.
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.
A mesh layer parameter for processing algorithms.
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.
A parameter for processing algorithms which accepts multiple map layers.
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.
A numeric parameter for processing algorithms.
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.
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.
A point cloud layer attribute parameter for Processing algorithms.
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.
A point cloud layer destination parameter, for specifying the destination path for a point cloud laye...
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...
A point cloud layer 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...
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.
A point parameter for processing algorithms.
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...
A data provider connection parameter for processing algorithms, allowing users to select from availab...
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.
A numeric range parameter for processing algorithms.
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.
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.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
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.
virtual 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.
A raster layer parameter for processing algorithms.
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...
A double numeric parameter for map scale values.
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.
A string parameter for processing algorithms.
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.
A vector layer destination parameter, for specifying the destination path for a vector layer created ...
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...
A vector layer (with or without geometry) parameter for processing algorithms.
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.
A vector tile layer destination parameter, for specifying the destination path for a vector tile laye...
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...
A double numeric parameter for volume values.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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.
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 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...
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 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 defaultRasterExtension()
Returns the default raster extension to use, in the absence of all other constraints (e....
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 toVariant() const
Saves this property to a QVariantMap, wrapped in a QVariant.
bool loadVariant(const QVariant &property)
Loads this property from a QVariantMap, wrapped in a QVariant.
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 supportedFormatExtensions(RasterFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats.
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 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.
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()
const QgsCoordinateReferenceSystem & crs