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();
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 )
1295 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1324 const QVariant val = parameters.value( definition->
name() );
1330 QVariant val = value;
1331 if ( val.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1340 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
1346 else if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1358 QString valueAsString;
1359 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1362 valueAsString = val.toString();
1364 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1366 const QRegularExpressionMatch match = rx.match( valueAsString );
1367 if ( match.hasMatch() )
1374 if ( val.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
1380 else if ( val.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1393 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1394 return layer->crs();
1396 return layer->crs();
1398 if (
auto *lProject = context.
project() )
1399 return lProject->crs();
1417 const QVariant val = value;
1418 if ( val.userType() == qMetaTypeId<QgsPointXY>() )
1422 if ( val.userType() == qMetaTypeId< QgsGeometry>() )
1428 if ( val.userType() == qMetaTypeId<QgsReferencedPointXY>() )
1447 if ( pointText.isEmpty() )
1450 if ( pointText.isEmpty() )
1453 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1456 const QRegularExpressionMatch match = rx.match( valueAsString );
1457 if ( match.hasMatch() )
1460 const double x = match.captured( 1 ).toDouble( &xOk );
1462 const double y = match.captured( 2 ).toDouble( &yOk );
1490 const QVariant val = parameters.value( definition->
name() );
1496 if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
1505 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1508 const QRegularExpressionMatch match = rx.match( valueAsString );
1509 if ( match.hasMatch() )
1516 if (
auto *lProject = context.
project() )
1517 return lProject->crs();
1535 const QVariant val = value;
1536 if ( val.userType() == qMetaTypeId< QgsGeometry>() )
1541 if ( val.userType() == qMetaTypeId<QgsPointXY>() )
1546 if ( val.userType() == qMetaTypeId<QgsRectangle>() )
1551 if ( val.userType() == qMetaTypeId<QgsReferencedPointXY>() )
1569 if ( val.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1575 g = g.densifyByCount( 20 );
1589 if ( val.userType() == qMetaTypeId<QgsReferencedGeometry>() )
1608 if ( valueAsString.isEmpty() )
1611 if ( valueAsString.isEmpty() )
1614 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1616 const QRegularExpressionMatch match = rx.match( valueAsString );
1617 if ( match.hasMatch() )
1644 const QVariant val = parameters.value( definition->
name() );
1650 if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
1659 if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
1668 if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
1678 const QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1681 const QRegularExpressionMatch match = rx.match( valueAsString );
1682 if ( match.hasMatch() )
1689 if (
auto *lProject = context.
project() )
1690 return lProject->crs();
1701 if ( fileText.isEmpty() )
1712 if ( fileText.isEmpty() )
1720 return QVariantList();
1728 return QVariantList();
1730 QString resultString;
1731 const QVariant val = value;
1732 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1734 else if ( val.userType() == QMetaType::Type::QVariantList )
1735 return val.toList();
1737 resultString = val.toString();
1739 if ( resultString.isEmpty() )
1742 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
1748 QVariantList result;
1749 const auto constSplit = resultString.split(
',' );
1752 for (
const QString &s : constSplit )
1754 number = s.toDouble( &ok );
1755 result << ( ok ? QVariant( number ) : s );
1764 return QList<QgsMapLayer *>();
1772 return QList<QgsMapLayer *>();
1774 const QVariant val = value;
1775 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1777 return QList<QgsMapLayer *>() << layer;
1780 QList<QgsMapLayer *> layers;
1782 std::function< void(
const QVariant &var ) > processVariant;
1783 processVariant = [ &layers, &context, &definition, flags, &processVariant](
const QVariant & var )
1785 if ( var.userType() == QMetaType::Type::QVariantList )
1787 const auto constToList = var.toList();
1788 for (
const QVariant &listVar : constToList )
1790 processVariant( listVar );
1793 else if ( var.userType() == QMetaType::Type::QStringList )
1795 const auto constToStringList = var.toStringList();
1796 for (
const QString &s : constToStringList )
1798 processVariant( s );
1801 else if ( var.userType() == qMetaTypeId<QgsProperty>() )
1803 else if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
1807 const QVariant sink = fromVar.
sink;
1808 if ( sink.userType() == qMetaTypeId<QgsProperty>() )
1813 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1825 processVariant( val );
1827 if ( layers.isEmpty() )
1830 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->
defaultValue() ) ) )
1834 else if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
1836 const auto constToList = definition->
defaultValue().toList();
1837 for (
const QVariant &var : constToList )
1839 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1845 processVariant( var );
1859 return QStringList();
1861 const QVariant val = value;
1865 std::function< void(
const QVariant &var ) > processVariant;
1866 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1868 if ( var.userType() == QMetaType::Type::QVariantList )
1870 const auto constToList = var.toList();
1871 for (
const QVariant &listVar : constToList )
1873 processVariant( listVar );
1876 else if ( var.userType() == QMetaType::Type::QStringList )
1878 const auto constToStringList = var.toStringList();
1879 for (
const QString &s : constToStringList )
1881 processVariant( s );
1884 else if ( var.userType() == qMetaTypeId<QgsProperty>() )
1888 files << var.toString();
1892 processVariant( val );
1894 if ( files.isEmpty() )
1905 return QStringList();
1913 return QList<double>();
1921 return QList<double>();
1923 QStringList resultStringList;
1924 const QVariant val = value;
1926 if ( val.userType() == qMetaTypeId<QgsProperty>() )
1928 else if ( val.userType() == QMetaType::Type::QVariantList )
1930 const auto constToList = val.toList();
1931 for (
const QVariant &var : constToList )
1932 resultStringList << var.toString();
1935 resultStringList << val.toString();
1937 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1939 resultStringList.clear();
1941 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
1943 const auto constToList = definition->
defaultValue().toList();
1944 for (
const QVariant &var : constToList )
1945 resultStringList << var.toString();
1948 resultStringList << definition->
defaultValue().toString();
1951 if ( resultStringList.size() == 1 )
1953 resultStringList = resultStringList.at( 0 ).split(
',' );
1956 if ( resultStringList.size() < 2 )
1957 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1959 QList< double > result;
1961 double n = resultStringList.at( 0 ).toDouble( &ok );
1965 result << std::numeric_limits<double>::quiet_NaN() ;
1967 n = resultStringList.at( 1 ).toDouble( &ok );
1971 result << std::numeric_limits<double>::quiet_NaN() ;
1979 return QStringList();
1992 return QStringList();
2000 return QStringList();
2002 QStringList resultStringList;
2003 const QVariant val = value;
2004 if ( val.isValid() )
2006 if ( val.userType() == qMetaTypeId<QgsProperty>() )
2008 else if ( val.userType() == QMetaType::Type::QVariantList )
2010 const auto constToList = val.toList();
2011 for (
const QVariant &var : constToList )
2012 resultStringList << var.toString();
2014 else if ( val.userType() == QMetaType::Type::QStringList )
2016 resultStringList = val.toStringList();
2019 resultStringList.append( val.toString().split(
';' ) );
2022 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
2024 resultStringList.clear();
2028 if ( definition->
defaultValue().userType() == QMetaType::Type::QVariantList )
2030 const auto constToList = definition->
defaultValue().toList();
2031 for (
const QVariant &var : constToList )
2032 resultStringList << var.toString();
2034 else if ( definition->
defaultValue().userType() == QMetaType::Type::QStringList )
2036 resultStringList = definition->
defaultValue().toStringList();
2039 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
2043 return resultStringList;
2057 if ( layoutName.isEmpty() )
2109 QVariant val = value;
2110 if ( val.userType() == qMetaTypeId<QgsProperty>() )
2114 if ( val.userType() == QMetaType::Type::QColor )
2116 QColor
c = val.
value< QColor >();
2118 if ( !colorParam->opacityEnabled() )
2126 if ( definition->
defaultValue().userType() == QMetaType::Type::QColor )
2132 if ( colorText.isEmpty() )
2135 bool containsAlpha =
false;
2138 if (
c.isValid() && !colorParam->opacityEnabled() )
2210 const QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
2211 const QString name = map.value( QStringLiteral(
"name" ) ).toString();
2212 std::unique_ptr< QgsProcessingParameterDefinition > def;
2289 def.reset( paramType->
create( name ) );
2295 def->fromVariantMap( map );
2296 return def.release();
2301 QString desc = name;
2302 desc.replace(
'_',
' ' );
2308 bool isOptional =
false;
2312 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2317 if ( type == QLatin1String(
"boolean" ) )
2319 else if ( type == QLatin1String(
"crs" ) )
2321 else if ( type == QLatin1String(
"layer" ) )
2323 else if ( type == QLatin1String(
"extent" ) )
2325 else if ( type == QLatin1String(
"point" ) )
2327 else if ( type == QLatin1String(
"geometry" ) )
2329 else if ( type == QLatin1String(
"file" ) )
2331 else if ( type == QLatin1String(
"folder" ) )
2333 else if ( type == QLatin1String(
"matrix" ) )
2335 else if ( type == QLatin1String(
"multiple" ) )
2337 else if ( type == QLatin1String(
"number" ) )
2339 else if ( type == QLatin1String(
"distance" ) )
2341 else if ( type == QLatin1String(
"area" ) )
2343 else if ( type == QLatin1String(
"volume" ) )
2345 else if ( type == QLatin1String(
"duration" ) )
2347 else if ( type == QLatin1String(
"scale" ) )
2349 else if ( type == QLatin1String(
"range" ) )
2351 else if ( type == QLatin1String(
"raster" ) )
2353 else if ( type == QLatin1String(
"enum" ) )
2355 else if ( type == QLatin1String(
"string" ) )
2357 else if ( type == QLatin1String(
"authcfg" ) )
2359 else if ( type == QLatin1String(
"expression" ) )
2361 else if ( type == QLatin1String(
"field" ) )
2363 else if ( type == QLatin1String(
"vector" ) )
2365 else if ( type == QLatin1String(
"source" ) )
2367 else if ( type == QLatin1String(
"sink" ) )
2369 else if ( type == QLatin1String(
"vectordestination" ) )
2371 else if ( type == QLatin1String(
"rasterdestination" ) )
2373 else if ( type == QLatin1String(
"pointclouddestination" ) )
2375 else if ( type == QLatin1String(
"filedestination" ) )
2377 else if ( type == QLatin1String(
"folderdestination" ) )
2379 else if ( type == QLatin1String(
"band" ) )
2381 else if ( type == QLatin1String(
"mesh" ) )
2383 else if ( type == QLatin1String(
"layout" ) )
2385 else if ( type == QLatin1String(
"layoutitem" ) )
2387 else if ( type == QLatin1String(
"color" ) )
2389 else if ( type == QLatin1String(
"coordinateoperation" ) )
2391 else if ( type == QLatin1String(
"maptheme" ) )
2393 else if ( type == QLatin1String(
"datetime" ) )
2395 else if ( type == QLatin1String(
"providerconnection" ) )
2397 else if ( type == QLatin1String(
"databaseschema" ) )
2399 else if ( type == QLatin1String(
"databasetable" ) )
2401 else if ( type == QLatin1String(
"pointcloud" ) )
2403 else if ( type == QLatin1String(
"annotation" ) )
2405 else if ( type == QLatin1String(
"attribute" ) )
2407 else if ( type == QLatin1String(
"vectortiledestination" ) )
2413bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2415 const thread_local QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
2416 QRegularExpressionMatch m = re.match( code );
2417 if ( !m.hasMatch() )
2420 name = m.captured( 1 );
2421 QString tokens = m.captured( 2 );
2422 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
2425 tokens.remove( 0, 8 );
2432 tokens = tokens.trimmed();
2434 const thread_local QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2435 m = re2.match( tokens );
2436 if ( !m.hasMatch() )
2438 type = tokens.toLower().trimmed();
2443 type = m.captured( 1 ).toLower().trimmed();
2444 definition = m.captured( 2 );
2455 , mDescription( description )
2457 , mDefault( defaultValue )
2458 , mFlags( optional ?
Qgis::ProcessingParameterFlag::Optional :
Qgis::ProcessingParameterFlag() )
2464 if ( defaultSettingsValue.isValid() )
2466 return defaultSettingsValue;
2474 if ( defaultSettingsValue.isValid() )
2476 return defaultSettingsValue;
2486 QVariant settingValue = s.
value( QStringLiteral(
"/Processing/DefaultGuiParam/%1/%2" ).arg(
mAlgorithm->
id() ).arg(
mName ) );
2487 if ( settingValue.isValid() )
2489 return settingValue;
2497 if ( !input.isValid() && !
mDefault.isValid() )
2500 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
2501 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
2509 if ( !value.isValid() )
2510 return QStringLiteral(
"None" );
2512 if ( value.userType() == qMetaTypeId<QgsProperty>() )
2513 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2525 if ( !value.isValid() )
2529 if ( value.userType() == QMetaType::Type::QVariantMap )
2531 const QVariantMap sourceMap = value.toMap();
2532 QVariantMap resultMap;
2533 for (
auto it = sourceMap.constBegin(); it != sourceMap.constEnd(); it++ )
2539 else if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
2541 const QVariantList sourceList = value.toList();
2542 QVariantList resultList;
2543 resultList.reserve( sourceList.size() );
2544 for (
const QVariant &v : sourceList )
2552 switch ( value.userType() )
2555 case QMetaType::Bool:
2556 case QMetaType::Char:
2557 case QMetaType::Int:
2558 case QMetaType::Double:
2559 case QMetaType::Float:
2560 case QMetaType::LongLong:
2561 case QMetaType::ULongLong:
2562 case QMetaType::UInt:
2563 case QMetaType::ULong:
2564 case QMetaType::UShort:
2571 if ( value.userType() == qMetaTypeId<QgsProperty>() )
2581 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"field" ), prop.
field() }} );
2583 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"expression" ), prop.
expressionString() }} );
2588 if ( value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
2598 else if ( value.userType() == qMetaTypeId<QgsRectangle>() )
2606 else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
2615 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
2627 else if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
2642 else if ( value.userType() == qMetaTypeId<QgsPointXY>() )
2648 else if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
2655 else if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
2662 else if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
2667 else if ( value.userType() == qMetaTypeId<QColor>() )
2669 const QColor fromVar = value.value< QColor >();
2670 if ( !fromVar.isValid() )
2673 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2675 else if ( value.userType() == qMetaTypeId<QDateTime>() )
2677 const QDateTime fromVar = value.toDateTime();
2678 if ( !fromVar.isValid() )
2681 return fromVar.toString( Qt::ISODate );
2683 else if ( value.userType() == qMetaTypeId<QDate>() )
2685 const QDate fromVar = value.toDate();
2686 if ( !fromVar.isValid() )
2689 return fromVar.toString( Qt::ISODate );
2691 else if ( value.userType() == qMetaTypeId<QTime>() )
2693 const QTime fromVar = value.toTime();
2694 if ( !fromVar.isValid() )
2697 return fromVar.toString( Qt::ISODate );
2704 p.insert(
name(), value );
2712 if ( value.userType() == QMetaType::QString )
2717 Q_ASSERT_X(
false,
"QgsProcessingParameterDefinition::valueAsJsonObject", QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ).toLocal8Bit() );
2730 if ( !value.isValid() )
2733 switch ( value.userType() )
2736 case QMetaType::Bool:
2737 case QMetaType::Char:
2738 case QMetaType::Int:
2739 case QMetaType::Double:
2740 case QMetaType::Float:
2741 case QMetaType::LongLong:
2742 case QMetaType::ULongLong:
2743 case QMetaType::UInt:
2744 case QMetaType::ULong:
2745 case QMetaType::UShort:
2746 return value.toString();
2752 if ( value.userType() == qMetaTypeId<QgsProperty>() )
2762 return QStringLiteral(
"field:%1" ).arg( prop.
field() );
2769 if ( value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
2779 else if ( value.userType() == qMetaTypeId<QgsRectangle>() )
2787 else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
2795 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
2807 else if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
2822 else if ( value.userType() == qMetaTypeId<QgsPointXY>() )
2828 else if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
2835 else if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
2840 else if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
2845 else if ( value.userType() == qMetaTypeId<QColor>() )
2847 const QColor fromVar = value.value< QColor >();
2848 if ( !fromVar.isValid() )
2851 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2853 else if ( value.userType() == qMetaTypeId<QDateTime>() )
2855 const QDateTime fromVar = value.toDateTime();
2856 if ( !fromVar.isValid() )
2859 return fromVar.toString( Qt::ISODate );
2861 else if ( value.userType() == qMetaTypeId<QDate>() )
2863 const QDate fromVar = value.toDate();
2864 if ( !fromVar.isValid() )
2867 return fromVar.toString( Qt::ISODate );
2869 else if ( value.userType() == qMetaTypeId<QTime>() )
2871 const QTime fromVar = value.toTime();
2872 if ( !fromVar.isValid() )
2875 return fromVar.toString( Qt::ISODate );
2882 p.insert(
name(), value );
2890 if ( value.userType() == QMetaType::QString )
2891 return value.toString();
2894 QgsDebugError( QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ) );
2896 return value.toString();
2902 if ( !value.isValid( ) )
2903 return QStringList();
2905 if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
2907 const QVariantList sourceList = value.toList();
2908 QStringList resultList;
2909 resultList.reserve( sourceList.size() );
2910 for (
const QVariant &v : sourceList )
2919 return QStringList();
2931 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2933 code += QLatin1String(
"optional " );
2934 code +=
type() +
' ';
2936 return code.trimmed();
2944 switch ( outputType )
2948 QString code = t->className() + QStringLiteral(
"('%1', %2" )
2951 code += QLatin1String(
", optional=True" );
2967 map.insert( QStringLiteral(
"parameter_type" ),
type() );
2968 map.insert( QStringLiteral(
"name" ),
mName );
2969 map.insert( QStringLiteral(
"description" ),
mDescription );
2970 map.insert( QStringLiteral(
"help" ),
mHelp );
2971 map.insert( QStringLiteral(
"default" ),
mDefault );
2972 map.insert( QStringLiteral(
"defaultGui" ),
mGuiDefault );
2973 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
mFlags ) );
2974 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
2980 mName = map.value( QStringLiteral(
"name" ) ).toString();
2981 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
2982 mHelp = map.value( QStringLiteral(
"help" ) ).toString();
2983 mDefault = map.value( QStringLiteral(
"default" ) );
2984 mGuiDefault = map.value( QStringLiteral(
"defaultGui" ) );
2986 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
3002 QString text = QStringLiteral(
"<p><b>%1</b></p>" ).arg(
description() );
3003 if ( !
help().isEmpty() )
3005 text += QStringLiteral(
"<p>%1</p>" ).arg(
help() );
3007 text += QStringLiteral(
"<p>%1</p>" ).arg( QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
3022 if ( !val.isValid() )
3023 return QStringLiteral(
"None" );
3025 if ( val.userType() == qMetaTypeId<QgsProperty>() )
3027 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
3032 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3034 code += QLatin1String(
"optional " );
3035 code +=
type() +
' ';
3036 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
3037 return code.trimmed();
3059 if ( !input.isValid() )
3067 if ( input.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
3071 else if ( input.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
3075 else if ( input.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
3080 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3085 if ( input.type() == QVariant::String )
3087 const QString
string = input.toString();
3088 if (
string.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
3097 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3100 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3108 if ( !value.isValid() )
3109 return QStringLiteral(
"None" );
3111 if ( value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
3114 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
3119 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3120 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3122 if ( value.type() == QVariant::String )
3124 const QString
string = value.toString();
3125 if (
string.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
3134 p.insert(
name(), value );
3144 if ( value.type() == QVariant::String )
3146 const QString
string = value.toString();
3147 if (
string.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
3160 if ( value.type() == QVariant::String )
3162 const QString
string = value.toString();
3163 if (
string.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
3195 if ( !input.isValid() )
3203 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3208 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3213 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3231 if ( !val.isValid() )
3232 return QStringLiteral(
"None" );
3234 if ( val.userType() == qMetaTypeId<QgsProperty>() )
3238 p.insert(
name(), val );
3258 for (
const QString &raster : rasters )
3260 if ( !vectors.contains( raster ) )
3264 for (
const QString &mesh : meshFilters )
3266 if ( !vectors.contains( mesh ) )
3270 for (
const QString &pointCloud : pointCloudFilters )
3272 if ( !vectors.contains( pointCloud ) )
3273 vectors << pointCloud;
3275 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
3276 std::sort( vectors.begin(), vectors.end() );
3278 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QLatin1String(
";;" ) );
3288 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3290 code += QLatin1String(
"optional " );
3291 code += QLatin1String(
"layer " );
3298 code += QLatin1String(
"table " );
3302 code += QLatin1String(
"hasgeometry " );
3306 code += QLatin1String(
"point " );
3310 code += QLatin1String(
"line " );
3314 code += QLatin1String(
"polygon " );
3318 code += QLatin1String(
"raster " );
3322 code += QLatin1String(
"mesh " );
3326 code += QLatin1String(
"plugin " );
3330 code += QLatin1String(
"pointcloud " );
3334 code += QLatin1String(
"annotation " );
3343 return code.trimmed();
3349 QString def = definition;
3352 if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
3358 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
3361 def = def.mid( 12 );
3364 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
3370 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
3376 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
3382 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
3388 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
3394 else if ( def.startsWith( QLatin1String(
"plugin" ), Qt::CaseInsensitive ) )
3400 else if ( def.startsWith( QLatin1String(
"pointcloud" ), Qt::CaseInsensitive ) )
3403 def = def.mid( 11 );
3406 else if ( def.startsWith( QLatin1String(
"annotation" ), Qt::CaseInsensitive ) )
3409 def = def.mid( 11 );
3420 switch ( outputType )
3424 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', %2" )
3427 code += QLatin1String(
", optional=True" );
3434 QStringList options;
3438 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
3442 code += QLatin1Char(
')' );
3459 map.insert( QStringLiteral(
"data_types" ), types );
3467 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3468 for (
const QVariant &val : values )
3489 if ( !input.isValid() )
3497 if ( input.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
3501 else if ( input.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
3506 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3511 if ( input.userType() == qMetaTypeId<QgsRectangle>() )
3516 if ( input.userType() == qMetaTypeId< QgsGeometry>() )
3520 if ( input.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3527 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3530 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3533 if ( variantIsValidStringForExtent( input ) )
3546bool QgsProcessingParameterExtent::variantIsValidStringForExtent(
const QVariant &value )
3548 if ( value.userType() == QMetaType::Type::QString )
3550 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
3551 const QRegularExpressionMatch match = rx.match( value.toString() );
3552 if ( match.hasMatch() )
3554 bool xMinOk =
false;
3555 ( void )match.captured( 1 ).toDouble( &xMinOk );
3556 bool xMaxOk =
false;
3557 ( void )match.captured( 2 ).toDouble( &xMaxOk );
3558 bool yMinOk =
false;
3559 ( void )match.captured( 3 ).toDouble( &yMinOk );
3560 bool yMaxOk =
false;
3561 ( void )match.captured( 4 ).toDouble( &yMaxOk );
3562 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
3571 if ( !value.isValid() )
3572 return QStringLiteral(
"None" );
3574 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3575 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3577 if ( value.userType() == qMetaTypeId<QgsRectangle>() )
3585 else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3593 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
3598 const QString wkt = g.
asWkt();
3599 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3602 else if ( variantIsValidStringForExtent( value ) )
3608 p.insert(
name(), value );
3618 if ( variantIsValidStringForExtent( value ) )
3620 return value.toString();
3628 if ( variantIsValidStringForExtent( value ) )
3655 if ( !input.isValid() )
3663 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3668 if ( input.userType() == qMetaTypeId<QgsPointXY>() )
3672 if ( input.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3676 if ( input.userType() == qMetaTypeId< QgsGeometry>() )
3681 if ( input.userType() == QMetaType::Type::QString )
3683 if ( input.toString().isEmpty() )
3687 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3689 const QRegularExpressionMatch match = rx.match( input.toString() );
3690 if ( match.hasMatch() )
3693 ( void )match.captured( 1 ).toDouble( &xOk );
3695 ( void )match.captured( 2 ).toDouble( &yOk );
3704 if ( !value.isValid() )
3705 return QStringLiteral(
"None" );
3707 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3708 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3710 if ( value.userType() == qMetaTypeId<QgsPointXY>() )
3716 else if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3723 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
3728 const QString wkt = g.
asWkt();
3729 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3742 const QVariant &defaultValue,
bool optional,
const QList<int> &geometryTypes,
bool allowMultipart )
3744 mGeomTypes( geometryTypes ),
3745 mAllowMultipart( allowMultipart )
3758 if ( !input.isValid() )
3766 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3773 if ( input.userType() == qMetaTypeId< QgsGeometry>() )
3775 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( input.value<
QgsGeometry>().
type() ) ) ) &&
3776 ( mAllowMultipart || !input.value<
QgsGeometry>().isMultipart() );
3779 if ( input.userType() == qMetaTypeId<QgsReferencedGeometry>() )
3785 if ( input.userType() == qMetaTypeId<QgsPointXY>() )
3790 if ( input.userType() == qMetaTypeId<QgsRectangle>() )
3795 if ( input.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3800 if ( input.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3805 if ( input.userType() == QMetaType::Type::QString )
3807 if ( input.toString().isEmpty() )
3812 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3814 const QRegularExpressionMatch match = rx.match( input.toString() );
3815 if ( match.hasMatch() )
3820 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( g.
type() ) ) ) && ( mAllowMultipart || !g.
isMultipart() );
3840 if ( !value.isValid() )
3841 return QStringLiteral(
"None" );
3843 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3846 if ( value.userType() == qMetaTypeId< QgsGeometry>() )
3853 if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
3860 if ( value.userType() == qMetaTypeId<QgsPointXY>() )
3867 if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3874 if ( value.userType() == qMetaTypeId<QgsRectangle>() )
3881 if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3893 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3895 code += QLatin1String(
"optional " );
3896 code +=
type() +
' ';
3898 for (
const int type : mGeomTypes )
3903 code += QLatin1String(
"point " );
3907 code += QLatin1String(
"line " );
3911 code += QLatin1String(
"polygon " );
3915 code += QLatin1String(
"unknown " );
3921 return code.trimmed();
3926 switch ( outputType )
3930 QString code = QStringLiteral(
"QgsProcessingParameterGeometry('%1', %2" )
3933 code += QLatin1String(
", optional=True" );
3935 if ( !mGeomTypes.empty() )
3942 return QStringLiteral(
"PointGeometry" );
3945 return QStringLiteral(
"LineGeometry" );
3948 return QStringLiteral(
"PolygonGeometry" );
3951 return QStringLiteral(
"UnknownGeometry" );
3954 return QStringLiteral(
"NullGeometry" );
3959 QStringList options;
3960 options.reserve( mGeomTypes.size() );
3961 for (
const int type : mGeomTypes )
3963 options << QStringLiteral(
" QgsWkbTypes.%1" ).arg( geomTypeToString(
static_cast<Qgis::GeometryType>(
type ) ) );
3965 code += QStringLiteral(
", geometryTypes=[%1 ]" ).arg( options.join(
',' ) );
3968 if ( ! mAllowMultipart )
3970 code += QLatin1String(
", allowMultipart=False" );
3985 for (
const int type : mGeomTypes )
3989 map.insert( QStringLiteral(
"geometrytypes" ), types );
3990 map.insert( QStringLiteral(
"multipart" ), mAllowMultipart );
3998 const QVariantList values = map.value( QStringLiteral(
"geometrytypes" ) ).toList();
3999 for (
const QVariant &val : values )
4001 mGeomTypes << val.toInt();
4003 mAllowMultipart = map.value( QStringLiteral(
"multipart" ) ).toBool();
4014 , mBehavior( behavior )
4015 , mExtension( fileFilter.isEmpty() ? extension : QString() )
4016 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
4029 if ( !input.isValid() )
4037 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4042 const QString
string = input.toString().trimmed();
4044 if ( input.userType() != QMetaType::Type::QString ||
string.isEmpty() )
4047 switch ( mBehavior )
4051 if ( !mExtension.isEmpty() )
4053 return string.endsWith( mExtension, Qt::CaseInsensitive );
4055 else if ( !mFileFilter.isEmpty() )
4073 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4075 code += QLatin1String(
"optional " );
4078 return code.trimmed();
4083 switch ( outputType )
4088 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', %2" )
4091 code += QLatin1String(
", optional=True" );
4092 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
Qgis::ProcessingFileParameterBehavior::File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
4093 if ( !mExtension.isEmpty() )
4094 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
4095 if ( !mFileFilter.isEmpty() )
4096 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
4107 switch ( mBehavior )
4111 if ( !mFileFilter.isEmpty() )
4112 return mFileFilter != QObject::tr(
"All files (*.*)" ) ? mFileFilter + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" ) : mFileFilter;
4113 else if ( !mExtension.isEmpty() )
4114 return QObject::tr(
"%1 files" ).arg( mExtension.toUpper() ) + QStringLiteral(
" (*." ) + mExtension.toLower() + QStringLiteral(
");;" ) + QObject::tr(
"All files (*.*)" );
4116 return QObject::tr(
"All files (*.*)" );
4128 mFileFilter.clear();
4138 mFileFilter = filter;
4145 map.insert( QStringLiteral(
"behavior" ),
static_cast< int >( mBehavior ) );
4146 map.insert( QStringLiteral(
"extension" ), mExtension );
4147 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
4155 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
4156 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
4167 , mHeaders( headers )
4168 , mNumberRows( numberRows )
4169 , mFixedNumberRows( fixedNumberRows )
4182 if ( !input.isValid() )
4190 if ( input.userType() == QMetaType::Type::QString )
4192 if ( input.toString().isEmpty() )
4196 else if ( input.userType() == QMetaType::Type::QVariantList )
4198 if ( input.toList().isEmpty() )
4202 else if ( input.userType() == QMetaType::Type::Double || input.userType() == QMetaType::Type::Int )
4212 if ( !value.isValid() )
4213 return QStringLiteral(
"None" );
4215 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4216 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4219 p.insert(
name(), value );
4227 switch ( outputType )
4231 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', %2" )
4234 code += QLatin1String(
", optional=True" );
4235 code += QStringLiteral(
", numberRows=%1" ).arg( mNumberRows );
4236 code += QStringLiteral(
", hasFixedNumberRows=%1" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4239 headers.reserve( mHeaders.size() );
4240 for (
const QString &h : mHeaders )
4242 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
4274 return mFixedNumberRows;
4279 mFixedNumberRows = fixedNumberRows;
4285 map.insert( QStringLiteral(
"headers" ), mHeaders );
4286 map.insert( QStringLiteral(
"rows" ), mNumberRows );
4287 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
4294 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
4295 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
4296 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
4307 , mLayerType( layerType )
4320 if ( !input.isValid() )
4330 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
4336 if ( input.userType() == QMetaType::Type::QString )
4338 if ( input.toString().isEmpty() )
4341 if ( mMinimumNumberInputs > 1 )
4352 else if ( input.userType() == QMetaType::Type::QVariantList )
4354 if ( input.toList().count() < mMinimumNumberInputs )
4357 if ( mMinimumNumberInputs > input.toList().count() )
4365 const auto constToList = input.toList();
4366 for (
const QVariant &v : constToList )
4368 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
4377 else if ( input.userType() == QMetaType::Type::QStringList )
4379 if ( input.toStringList().count() < mMinimumNumberInputs )
4382 if ( mMinimumNumberInputs > input.toStringList().count() )
4390 const auto constToStringList = input.toStringList();
4391 for (
const QString &v : constToStringList )
4404 if ( !value.isValid() )
4405 return QStringLiteral(
"None" );
4407 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4408 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4413 if ( value.userType() == QMetaType::Type::QStringList )
4415 const QStringList list = value.toStringList();
4416 parts.reserve( list.count() );
4417 for (
const QString &v : list )
4420 else if ( value.userType() == QMetaType::Type::QVariantList )
4422 const QVariantList list = value.toList();
4423 parts.reserve( list.count() );
4424 for (
const QVariant &v : list )
4427 if ( !parts.isEmpty() )
4428 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4433 p.insert(
name(), value );
4435 if ( !list.isEmpty() )
4438 parts.reserve( list.count() );
4443 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4462 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4464 code += QLatin1String(
"optional " );
4465 switch ( mLayerType )
4468 code += QLatin1String(
"multiple raster" );
4472 code += QLatin1String(
"multiple file" );
4476 code += QLatin1String(
"multiple vector" );
4480 if (
mDefault.userType() == QMetaType::Type::QVariantList )
4483 const auto constToList =
mDefault.toList();
4484 for (
const QVariant &var : constToList )
4486 parts << var.toString();
4488 code += parts.join(
',' );
4490 else if (
mDefault.userType() == QMetaType::Type::QStringList )
4492 code +=
mDefault.toStringList().join(
',' );
4498 return code.trimmed();
4503 switch ( outputType )
4507 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', %2" )
4510 code += QLatin1String(
", optional=True" );
4514 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
4525 switch ( mLayerType )
4528 return QObject::tr(
"All files (*.*)" );
4567 return mMinimumNumberInputs;
4579 map.insert( QStringLiteral(
"layer_type" ),
static_cast< int >( mLayerType ) );
4580 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
4588 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
4594 QString
type = definition;
4596 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
4597 const QRegularExpressionMatch m = re.match( definition );
4600 type = m.captured( 1 ).toLower().trimmed();
4601 defaultVal = m.captured( 2 );
4604 if (
type == QLatin1String(
"vector" ) )
4606 else if (
type == QLatin1String(
"raster" ) )
4608 else if (
type == QLatin1String(
"file" ) )
4621 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
4632 QVariant input = value;
4633 if ( !input.isValid() )
4641 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4647 const double res = input.toDouble( &ok );
4651 return !( res < mMin || res > mMax );
4656 if ( !value.isValid() )
4657 return QStringLiteral(
"None" );
4659 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4660 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4662 return value.toString();
4669 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
4670 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
4671 if ( mMax < std::numeric_limits<double>::max() )
4672 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
4675 const QString extra = parts.join( QLatin1String(
"<br />" ) );
4676 if ( !extra.isEmpty() )
4677 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
4683 switch ( outputType )
4687 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', %2" )
4690 code += QLatin1String(
", optional=True" );
4692 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Qgis::ProcessingNumberParameterType::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4694 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
4695 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
4696 if ( mMax != std::numeric_limits<double>::max() )
4697 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
4739 map.insert( QStringLiteral(
"min" ), mMin );
4740 map.insert( QStringLiteral(
"max" ), mMax );
4741 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
4748 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
4749 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
4757 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4775 if ( !input.isValid() )
4783 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4788 if ( input.userType() == QMetaType::Type::QString )
4790 const QStringList list = input.toString().split(
',' );
4791 if ( list.count() != 2 )
4794 list.at( 0 ).toDouble( &ok );
4796 list.at( 1 ).toDouble( &ok2 );
4801 else if ( input.userType() == QMetaType::Type::QVariantList )
4803 if ( input.toList().count() != 2 )
4807 input.toList().at( 0 ).toDouble( &ok );
4809 input.toList().at( 1 ).toDouble( &ok2 );
4820 if ( !value.isValid() )
4821 return QStringLiteral(
"None" );
4823 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4824 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4827 p.insert(
name(), value );
4830 QStringList stringParts;
4831 const auto constParts = parts;
4832 for (
const double v : constParts )
4834 stringParts << QString::number( v );
4836 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
4841 switch ( outputType )
4845 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', %2" )
4848 code += QLatin1String(
", optional=True" );
4850 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Qgis::ProcessingNumberParameterType::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4873 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
4887 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4904 if ( !input.isValid() )
4912 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4917 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4920 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
4938 if ( !val.isValid() )
4939 return QStringLiteral(
"None" );
4941 if ( val.userType() == qMetaTypeId<QgsProperty>() )
4945 p.insert(
name(), val );
4973 , mOptions( options )
4974 , mAllowMultiple( allowMultiple )
4975 , mUsesStaticStrings( usesStaticStrings )
4987 QVariant input = value;
4988 if ( !input.isValid() )
4996 if ( input.userType() == qMetaTypeId<QgsProperty>() )
5001 if ( mUsesStaticStrings )
5003 if ( input.userType() == QMetaType::Type::QVariantList )
5005 if ( !mAllowMultiple )
5008 const QVariantList values = input.toList();
5012 for (
const QVariant &val : values )
5014 if ( !mOptions.contains( val.toString() ) )
5020 else if ( input.userType() == QMetaType::Type::QStringList )
5022 if ( !mAllowMultiple )
5025 const QStringList values = input.toStringList();
5030 if ( values.count() > 1 && !mAllowMultiple )
5033 for (
const QString &val : values )
5035 if ( !mOptions.contains( val ) )
5040 else if ( input.userType() == QMetaType::Type::QString )
5042 const QStringList parts = input.toString().split(
',' );
5043 if ( parts.count() > 1 && !mAllowMultiple )
5046 const auto constParts = parts;
5047 for (
const QString &part : constParts )
5049 if ( !mOptions.contains( part ) )
5057 if ( input.userType() == QMetaType::Type::QVariantList )
5059 if ( !mAllowMultiple )
5062 const QVariantList values = input.toList();
5066 for (
const QVariant &val : values )
5069 const int res = val.toInt( &ok );
5072 else if ( res < 0 || res >= mOptions.count() )
5078 else if ( input.userType() == QMetaType::Type::QString )
5080 const QStringList parts = input.toString().split(
',' );
5081 if ( parts.count() > 1 && !mAllowMultiple )
5084 const auto constParts = parts;
5085 for (
const QString &part : constParts )
5088 const int res = part.toInt( &ok );
5091 else if ( res < 0 || res >= mOptions.count() )
5096 else if ( input.userType() == QMetaType::Type::Int || input.userType() == QMetaType::Type::Double )
5099 const int res = input.toInt( &ok );
5102 else if ( res >= 0 && res < mOptions.count() )
5112 if ( !value.isValid() )
5113 return QStringLiteral(
"None" );
5115 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5116 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5118 if ( mUsesStaticStrings )
5120 if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
5123 const QStringList constList = value.toStringList();
5124 for (
const QString &val : constList )
5128 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5130 else if ( value.userType() == QMetaType::Type::QString )
5133 const QStringList constList = value.toString().split(
',' );
5134 if ( constList.count() > 1 )
5136 for (
const QString &val : constList )
5140 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5148 if ( value.userType() == QMetaType::Type::QVariantList )
5151 const auto constToList = value.toList();
5152 for (
const QVariant &val : constToList )
5154 parts << QString::number( static_cast< int >( val.toDouble() ) );
5156 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5158 else if ( value.userType() == QMetaType::Type::QString )
5160 const QStringList parts = value.toString().split(
',' );
5161 if ( parts.count() > 1 )
5163 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5167 return QString::number(
static_cast< int >( value.toDouble() ) );
5173 if ( !value.isValid() )
5176 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5179 if ( mUsesStaticStrings )
5185 if ( value.userType() == QMetaType::Type::QVariantList )
5188 const QVariantList toList = value.toList();
5189 parts.reserve( toList.size() );
5190 for (
const QVariant &val : toList )
5192 parts << mOptions.value(
static_cast< int >( val.toDouble() ) );
5194 return parts.join(
',' );
5196 else if ( value.userType() == QMetaType::Type::QString )
5198 const QStringList parts = value.toString().split(
',' );
5199 QStringList comments;
5200 if ( parts.count() > 1 )
5202 for (
const QString &part : parts )
5205 const int val = part.toInt( &ok );
5207 comments << mOptions.value( val );
5209 return comments.join(
',' );
5213 return mOptions.value(
static_cast< int >( value.toDouble() ) );
5219 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5221 code += QLatin1String(
"optional " );
5222 code += QLatin1String(
"enum " );
5224 if ( mAllowMultiple )
5225 code += QLatin1String(
"multiple " );
5227 if ( mUsesStaticStrings )
5228 code += QLatin1String(
"static " );
5230 code += mOptions.join(
';' ) +
' ';
5233 return code.trimmed();
5238 switch ( outputType )
5242 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', %2" )
5245 code += QLatin1String(
", optional=True" );
5248 options.reserve( mOptions.size() );
5249 for (
const QString &o : mOptions )
5251 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
5253 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5255 code += QStringLiteral(
", usesStaticStrings=%1" ).arg( mUsesStaticStrings ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5278 return mAllowMultiple;
5288 return mUsesStaticStrings;
5299 map.insert( QStringLiteral(
"options" ), mOptions );
5300 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5301 map.insert( QStringLiteral(
"uses_static_strings" ), mUsesStaticStrings );
5308 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
5309 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5310 mUsesStaticStrings = map.value( QStringLiteral(
"uses_static_strings" ) ).toBool();
5317 QString def = definition;
5319 bool multiple =
false;
5320 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5326 bool staticStrings =
false;
5327 if ( def.startsWith( QLatin1String(
"static" ), Qt::CaseInsensitive ) )
5329 staticStrings =
true;
5333 const thread_local QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
5334 const QRegularExpressionMatch m = re.match( def );
5335 QString values = def;
5338 values = m.captured( 1 ).trimmed();
5339 defaultVal = m.captured( 2 );
5347 , mMultiLine( multiLine )
5360 return QStringLiteral(
"None" );
5362 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5363 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5365 const QString s = value.toString();
5371 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5373 code += QLatin1String(
"optional " );
5374 code += QLatin1String(
"string " );
5377 code += QLatin1String(
"long " );
5380 return code.trimmed();
5385 switch ( outputType )
5389 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', %2" )
5392 code += QLatin1String(
", optional=True" );
5393 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5416 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
5423 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
5429 QString def = definition;
5431 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
5437 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5439 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5443 if ( def == QLatin1String(
"None" ) )
5466 if ( !value.isValid() )
5467 return QStringLiteral(
"None" );
5469 const QString s = value.toString();
5475 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5477 code += QLatin1String(
"optional " );
5478 code += QLatin1String(
"authcfg " );
5481 return code.trimmed();
5486 QString def = definition;
5488 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5490 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5494 if ( def == QLatin1String(
"None" ) )
5507 , mParentLayerParameterName( parentLayerParameterName )
5508 , mExpressionType( type )
5520 if ( !value.isValid() )
5521 return QStringLiteral(
"None" );
5523 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5524 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5526 const QString s = value.toString();
5532 QStringList depends;
5533 if ( !mParentLayerParameterName.isEmpty() )
5534 depends << mParentLayerParameterName;
5540 switch ( outputType )
5544 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', %2" )
5547 code += QLatin1String(
", optional=True" );
5549 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5555 switch ( mExpressionType )
5558 code += QLatin1String(
", type=Qgis.ExpressionType.PointCloud)" );
5561 code += QLatin1String(
", type=Qgis.ExpressionType.RasterCalculator)" );
5564 code += QLatin1Char(
')' );
5575 return mParentLayerParameterName;
5585 return mExpressionType;
5596 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5597 map.insert( QStringLiteral(
"expression_type" ),
static_cast< int >( mExpressionType ) );
5604 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5605 mExpressionType =
static_cast< Qgis::ExpressionType >( map.value( QStringLiteral(
"expression_type" ) ).toInt() );
5630 if ( !var.isValid() )
5638 if ( var.userType() == qMetaTypeId<QgsProperty>() )
5651 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
5654 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
5672 if ( !val.isValid() )
5673 return QStringLiteral(
"None" );
5675 if ( val.userType() == qMetaTypeId<QgsProperty>() )
5679 p.insert(
name(), val );
5697 switch ( outputType )
5701 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', %2" )
5704 code += QLatin1String(
", optional=True" );
5708 QStringList options;
5711 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
5745 map.insert( QStringLiteral(
"data_types" ), types );
5753 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
5754 for (
const QVariant &val : values )
5767 const QVariant &defaultValue,
bool optional )
5782 if ( !var.isValid() )
5790 if ( var.userType() == qMetaTypeId<QgsProperty>() )
5803 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
5806 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
5824 if ( !val.isValid() )
5825 return QStringLiteral(
"None" );
5827 if ( val.userType() == qMetaTypeId<QgsProperty>() )
5831 p.insert(
name(), val );
5859 , mParentLayerParameterName( parentLayerParameterName )
5861 , mAllowMultiple( allowMultiple )
5862 , mDefaultToAllFields( defaultToAllFields )
5876 if ( !input.isValid() )
5884 if ( input.userType() == qMetaTypeId<QgsProperty>() )
5889 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
5891 if ( !mAllowMultiple )
5897 else if ( input.userType() == QMetaType::Type::QString )
5899 if ( input.toString().isEmpty() )
5902 const QStringList parts = input.toString().split(
';' );
5903 if ( parts.count() > 1 && !mAllowMultiple )
5908 if ( input.toString().isEmpty() )
5916 if ( !value.isValid() )
5917 return QStringLiteral(
"None" );
5919 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5920 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5922 if ( value.userType() == QMetaType::Type::QVariantList )
5925 const auto constToList = value.toList();
5926 for (
const QVariant &val : constToList )
5930 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5932 else if ( value.userType() == QMetaType::Type::QStringList )
5935 const auto constToStringList = value.toStringList();
5936 for (
const QString &s : constToStringList )
5940 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5948 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5950 code += QLatin1String(
"optional " );
5951 code += QLatin1String(
"field " );
5953 switch ( mDataType )
5956 code += QLatin1String(
"numeric " );
5960 code += QLatin1String(
"string " );
5964 code += QLatin1String(
"datetime " );
5968 code += QLatin1String(
"binary " );
5972 code += QLatin1String(
"boolean " );
5979 if ( mAllowMultiple )
5980 code += QLatin1String(
"multiple " );
5982 if ( mDefaultToAllFields )
5983 code += QLatin1String(
"default_to_all_fields " );
5985 code += mParentLayerParameterName +
' ';
5988 return code.trimmed();
5993 switch ( outputType )
5997 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', %2" )
6000 code += QLatin1String(
", optional=True" );
6003 switch ( mDataType )
6006 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
6010 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
6014 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
6018 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
6022 dataType = QStringLiteral(
"QgsProcessingParameterField.Binary" );
6026 dataType = QStringLiteral(
"QgsProcessingParameterField.Boolean" );
6029 code += QStringLiteral(
", type=%1" ).arg(
dataType );
6031 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
6032 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6036 if ( mDefaultToAllFields )
6037 code += QLatin1String(
", defaultToAllFields=True" );
6049 QStringList depends;
6050 if ( !mParentLayerParameterName.isEmpty() )
6051 depends << mParentLayerParameterName;
6057 return mParentLayerParameterName;
6077 return mAllowMultiple;
6087 return mDefaultToAllFields;
6092 mDefaultToAllFields = enabled;
6098 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
6099 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
6100 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
6101 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
6108 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
6110 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
6111 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
6121 QString def = definition;
6123 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
6128 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
6133 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
6138 else if ( def.startsWith( QLatin1String(
"binary " ), Qt::CaseInsensitive ) )
6143 else if ( def.startsWith( QLatin1String(
"boolean " ), Qt::CaseInsensitive ) )
6149 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
6152 def = def.mid( 8 ).trimmed();
6155 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
6158 def = def.mid( 21 ).trimmed();
6161 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
6162 const QRegularExpressionMatch m = re.match( def );
6165 parent = m.captured( 1 ).trimmed();
6166 def = m.captured( 2 );
6191 QVariant var = input;
6192 if ( !var.isValid() )
6200 if ( var.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
6205 else if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6212 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6224 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
6229 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
6247 if ( !value.isValid() )
6248 return QStringLiteral(
"None" );
6250 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6253 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
6256 QString geometryCheckString;
6260 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
6264 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
6268 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
6275 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
6277 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
6278 if ( !
flags.empty() )
6279 flagString =
flags.join( QLatin1String(
" | " ) );
6286 layerString = layer->source();
6293 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6294 geometryCheckString,
6306 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression(%1), selectedFeaturesOnly=%2, featureLimit=%3%4%6, geometryCheck=%5)" )
6310 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6311 geometryCheckString,
6320 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
6325 QString layerString = value.toString();
6329 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
6346 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6348 code += QLatin1String(
"optional " );
6349 code += QLatin1String(
"source " );
6356 code += QLatin1String(
"point " );
6360 code += QLatin1String(
"line " );
6364 code += QLatin1String(
"polygon " );
6373 return code.trimmed();
6378 switch ( outputType )
6382 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', %2" )
6385 code += QLatin1String(
", optional=True" );
6389 QStringList options;
6393 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
6410 : mDataTypes( types )
6423 map.insert( QStringLiteral(
"data_types" ), types );
6431 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
6432 for (
const QVariant &val : values )
6442 QString def = definition;
6445 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6451 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6457 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6472 , mSupportsAppend( supportsAppend )
6483 QVariant var = input;
6484 if ( !var.isValid() )
6492 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6498 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6511 if ( var.userType() != QMetaType::Type::QString )
6514 if ( var.toString().isEmpty() )
6522 if ( !value.isValid() )
6523 return QStringLiteral(
"None" );
6525 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6526 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6528 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6537 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6546 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6548 code += QLatin1String(
"optional " );
6549 code += QLatin1String(
"sink " );
6551 switch ( mDataType )
6554 code += QLatin1String(
"point " );
6558 code += QLatin1String(
"line " );
6562 code += QLatin1String(
"polygon " );
6566 code += QLatin1String(
"table " );
6574 return code.trimmed();
6586 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6590 return p->defaultVectorFileExtension(
hasGeometry() );
6600 return QStringLiteral(
"dbf" );
6607 switch ( outputType )
6611 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', %2" )
6614 code += QLatin1String(
", optional=True" );
6618 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6619 if ( mSupportsAppend )
6620 code += QLatin1String(
", supportsAppend=True" );
6633 QStringList filters;
6634 for (
const QString &ext : exts )
6636 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6638 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6647 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6649 return lOriginalProvider->supportedOutputTableExtensions();
6654 return p->supportedOutputVectorLayerExtensions();
6656 return p->supportedOutputTableExtensions();
6671 switch ( mDataType )
6701 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
6702 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
6710 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
6717 return QStringLiteral(
"memory:%1" ).arg(
description() );
6725 QString def = definition;
6726 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6731 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6736 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6741 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
6752 return mSupportsAppend;
6772 QVariant var = input;
6773 if ( !var.isValid() )
6781 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6787 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6800 if ( var.userType() != QMetaType::Type::QString )
6803 if ( var.toString().isEmpty() )
6811 if ( !value.isValid() )
6812 return QStringLiteral(
"None" );
6814 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6815 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6817 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6826 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6842 return lOriginalProvider->defaultRasterFileExtension();
6846 return p->defaultRasterFileExtension();
6857 QStringList filters;
6858 for (
const QString &ext : exts )
6860 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6862 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6869 return lOriginalProvider->supportedOutputRasterLayerExtensions();
6873 return p->supportedOutputRasterLayerExtensions();
6889 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
6901 QVariant var = input;
6902 if ( !var.isValid() )
6910 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6916 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6929 if ( var.userType() != QMetaType::Type::QString )
6932 if ( var.toString().isEmpty() )
6942 if ( !value.isValid() )
6943 return QStringLiteral(
"None" );
6945 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6946 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6948 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6957 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6966 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
6978 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
6979 return QStringLiteral(
"file" );
6982 const thread_local QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
6983 const QRegularExpressionMatch match = rx.match( mFileFilter );
6984 if ( !match.hasMatch() )
6985 return QStringLiteral(
"file" );
6987 return match.captured( 1 );
6992 switch ( outputType )
6996 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', %2" )
6999 code += QLatin1String(
", optional=True" );
7003 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7015 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
7031 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
7038 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
7059 QVariant var = input;
7060 if ( !var.isValid() )
7068 if ( var.userType() == qMetaTypeId<QgsProperty>() )
7081 if ( var.userType() != QMetaType::Type::QString )
7084 if ( var.toString().isEmpty() )
7107 , mCreateByDefault( createByDefault )
7115 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
7116 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
7123 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
7124 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
7130 switch ( outputType )
7137 QString code = t->className() + QStringLiteral(
"('%1', %2" )
7140 code += QLatin1String(
", optional=True" );
7142 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7157 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
7164 const thread_local QRegularExpression rx( QStringLiteral(
"[.]" ) );
7165 QString sanitizedName =
name();
7166 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
7181 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
7190 return mCreateByDefault;
7212 QVariant var = input;
7213 if ( !var.isValid() )
7221 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
7227 if ( var.userType() == qMetaTypeId<QgsProperty>() )
7240 if ( var.userType() != QMetaType::Type::QString )
7243 if ( var.toString().isEmpty() )
7251 if ( !value.isValid() )
7252 return QStringLiteral(
"None" );
7254 if ( value.userType() == qMetaTypeId<QgsProperty>() )
7255 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7257 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
7266 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
7275 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7277 code += QLatin1String(
"optional " );
7278 code += QLatin1String(
"vectorDestination " );
7280 switch ( mDataType )
7283 code += QLatin1String(
"point " );
7287 code += QLatin1String(
"line " );
7291 code += QLatin1String(
"polygon " );
7299 return code.trimmed();
7311 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
7315 return p->defaultVectorFileExtension(
hasGeometry() );
7325 return QStringLiteral(
"dbf" );
7332 switch ( outputType )
7336 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', %2" )
7339 code += QLatin1String(
", optional=True" );
7343 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7356 QStringList filters;
7357 for (
const QString &ext : exts )
7359 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
7361 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
7369 return lOriginalProvider->supportedOutputVectorLayerExtensions();
7371 return lOriginalProvider->supportedOutputTableExtensions();
7376 return p->supportedOutputVectorLayerExtensions();
7378 return p->supportedOutputTableExtensions();
7393 switch ( mDataType )
7423 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
7437 QString def = definition;
7438 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
7443 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
7448 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
7459 , mParentLayerParameterName( parentLayerParameterName )
7460 , mAllowMultiple( allowMultiple )
7472 QVariant input = value;
7473 if ( !input.isValid() )
7481 if ( input.userType() == qMetaTypeId<QgsProperty>() )
7486 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
7488 if ( !mAllowMultiple )
7497 const double res = input.toInt( &ok );
7507 return mAllowMultiple;
7517 if ( !value.isValid() )
7518 return QStringLiteral(
"None" );
7520 if ( value.userType() == qMetaTypeId<QgsProperty>() )
7521 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7523 if ( value.userType() == QMetaType::Type::QVariantList )
7526 const QVariantList values = value.toList();
7527 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7529 parts << QString::number( static_cast< int >( it->toDouble() ) );
7531 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7533 else if ( value.userType() == QMetaType::Type::QStringList )
7536 const QStringList values = value.toStringList();
7537 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7539 parts << QString::number( static_cast< int >( it->toDouble() ) );
7541 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7544 return value.toString();
7549 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7551 code += QLatin1String(
"optional " );
7552 code += QLatin1String(
"band " );
7554 if ( mAllowMultiple )
7555 code += QLatin1String(
"multiple " );
7557 code += mParentLayerParameterName +
' ';
7560 return code.trimmed();
7565 QStringList depends;
7566 if ( !mParentLayerParameterName.isEmpty() )
7567 depends << mParentLayerParameterName;
7573 switch ( outputType )
7577 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', %2" )
7580 code += QLatin1String(
", optional=True" );
7582 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
7583 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7595 return mParentLayerParameterName;
7606 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
7607 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
7614 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
7615 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
7622 QString def = definition;
7625 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
7628 def = def.mid( 8 ).trimmed();
7631 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7632 const QRegularExpressionMatch m = re.match( def );
7635 parent = m.captured( 1 ).trimmed();
7636 def = m.captured( 2 );
7653 , mParentParameterName( parentParameterName )
7670 QStringList depends;
7671 if ( !mParentParameterName.isEmpty() )
7672 depends << mParentParameterName;
7678 switch ( outputType )
7682 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', %2" )
7685 code += QLatin1String(
", optional=True" );
7687 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7689 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7690 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7691 if (
maximum() != std::numeric_limits<double>::max() )
7692 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7703 return mParentParameterName;
7714 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7715 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7722 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7735 , mParentParameterName( parentParameterName )
7752 QStringList depends;
7753 if ( !mParentParameterName.isEmpty() )
7754 depends << mParentParameterName;
7760 switch ( outputType )
7764 QString code = QStringLiteral(
"QgsProcessingParameterArea('%1', %2" )
7767 code += QLatin1String(
", optional=True" );
7769 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7772 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7773 if (
maximum() != std::numeric_limits<double>::max() )
7774 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7785 return mParentParameterName;
7796 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7797 map.insert( QStringLiteral(
"default_unit" ),
qgsEnumValueToKey( mDefaultUnit ) );
7804 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7817 , mParentParameterName( parentParameterName )
7834 QStringList depends;
7835 if ( !mParentParameterName.isEmpty() )
7836 depends << mParentParameterName;
7842 switch ( outputType )
7846 QString code = QStringLiteral(
"QgsProcessingParameterVolume('%1', %2" )
7849 code += QLatin1String(
", optional=True" );
7851 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7854 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7855 if (
maximum() != std::numeric_limits<double>::max() )
7856 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7867 return mParentParameterName;
7878 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7879 map.insert( QStringLiteral(
"default_unit" ),
qgsEnumValueToKey( mDefaultUnit ) );
7886 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7913 switch ( outputType )
7917 QString code = QStringLiteral(
"QgsProcessingParameterDuration('%1', %2" )
7920 code += QLatin1String(
", optional=True" );
7922 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7923 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7924 if (
maximum() != std::numeric_limits<double>::max() )
7925 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7937 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7971 switch ( outputType )
7975 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', %2" )
7978 code += QLatin1String(
", optional=True" );
7990 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
8010 return QStringLiteral(
"None" );
8012 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8013 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8015 const QString s = value.toString();
8021 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8023 code += QLatin1String(
"optional " );
8024 code += QLatin1String(
"layout " );
8027 return code.trimmed();
8032 switch ( outputType )
8036 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', %2" )
8039 code += QLatin1String(
", optional=True" );
8050 QString def = definition;
8052 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8054 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8058 if ( def == QLatin1String(
"None" ) )
8071 , mParentLayoutParameterName( parentLayoutParameterName )
8072 , mItemType( itemType )
8085 return QStringLiteral(
"None" );
8087 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8088 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8090 const QString s = value.toString();
8096 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8098 code += QLatin1String(
"optional " );
8099 code += QLatin1String(
"layoutitem " );
8100 if ( mItemType >= 0 )
8101 code += QString::number( mItemType ) +
' ';
8103 code += mParentLayoutParameterName +
' ';
8106 return code.trimmed();
8111 switch ( outputType )
8115 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', %2" )
8118 code += QLatin1String(
", optional=True" );
8120 if ( mItemType >= 0 )
8121 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
8123 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
8136 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
8137 map.insert( QStringLiteral(
"item_type" ), mItemType );
8144 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
8145 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
8151 QStringList depends;
8152 if ( !mParentLayoutParameterName.isEmpty() )
8153 depends << mParentLayoutParameterName;
8160 QString def = definition;
8162 const thread_local QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
8163 const QRegularExpressionMatch m = re.match( def );
8166 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
8167 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
8168 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
8181 return mParentLayoutParameterName;
8186 mParentLayoutParameterName =
name;
8205 , mAllowOpacity( opacityEnabled )
8218 return QStringLiteral(
"None" );
8220 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8221 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8223 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
8224 return QStringLiteral(
"QColor()" );
8226 if ( value.canConvert< QColor >() )
8228 const QColor
c = value.value< QColor >();
8229 if ( !mAllowOpacity ||
c.alpha() == 255 )
8230 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
8232 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
8235 const QString s = value.toString();
8241 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8243 code += QLatin1String(
"optional " );
8244 code += QLatin1String(
"color " );
8246 if ( mAllowOpacity )
8247 code += QLatin1String(
"withopacity " );
8250 return code.trimmed();
8255 switch ( outputType )
8259 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', %2" )
8262 code += QLatin1String(
", optional=True" );
8264 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
8276 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
8279 if ( !input.isValid() )
8282 if ( input.userType() == QMetaType::Type::QColor )
8286 else if ( input.userType() == qMetaTypeId<QgsProperty>() )
8291 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
8294 bool containsAlpha =
false;
8301 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
8308 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
8314 return mAllowOpacity;
8319 mAllowOpacity = enabled;
8324 QString def = definition;
8326 bool allowOpacity =
false;
8327 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
8329 allowOpacity =
true;
8330 def = def.mid( 12 );
8333 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8335 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8339 if ( def == QLatin1String(
"None" ) || def.isEmpty() )
8350 , mSourceParameterName( sourceCrsParameterName )
8351 , mDestParameterName( destinationCrsParameterName )
8352 , mSourceCrs( staticSourceCrs )
8353 , mDestCrs( staticDestinationCrs )
8365 return valueAsPythonStringPrivate( value, context,
false );
8368QString QgsProcessingParameterCoordinateOperation::valueAsPythonStringPrivate(
const QVariant &value,
QgsProcessingContext &context,
bool allowNonStringValues )
const
8371 return QStringLiteral(
"None" );
8373 if ( allowNonStringValues && value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
8376 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
8381 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8382 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8384 if ( allowNonStringValues )
8387 p.insert(
name(), value );
8393 const QString s = value.toString();
8399 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8401 code += QLatin1String(
"optional " );
8402 code += QLatin1String(
"coordinateoperation " );
8405 return code.trimmed();
8410 switch ( outputType )
8415 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', %2" )
8418 code += QLatin1String(
", optional=True" );
8419 if ( !mSourceParameterName.isEmpty() )
8420 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg( valueAsPythonStringPrivate( mSourceParameterName,
c,
false ) );
8421 if ( !mDestParameterName.isEmpty() )
8422 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg( valueAsPythonStringPrivate( mDestParameterName,
c,
false ) );
8424 if ( mSourceCrs.isValid() )
8425 code += QStringLiteral(
", staticSourceCrs=%1" ).arg( valueAsPythonStringPrivate( mSourceCrs,
c,
true ) );
8426 if ( mDestCrs.isValid() )
8427 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg( valueAsPythonStringPrivate( mDestCrs,
c,
true ) );
8429 code += QStringLiteral(
", defaultValue=%1)" ).arg( valueAsPythonStringPrivate(
mDefault,
c,
false ) );
8439 if ( !mSourceParameterName.isEmpty() )
8440 res << mSourceParameterName;
8441 if ( !mDestParameterName.isEmpty() )
8442 res << mDestParameterName;
8449 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
8450 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
8451 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
8452 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
8459 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
8460 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
8461 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
8462 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
8468 QString def = definition;
8470 if ( def.startsWith(
'"' ) )
8473 if ( def.endsWith(
'"' ) )
8476 else if ( def.startsWith(
'\'' ) )
8479 if ( def.endsWith(
'\'' ) )
8484 if ( def == QLatin1String(
"None" ) )
8509 if ( !input.isValid() && !
mDefault.isValid() )
8512 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8513 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8521 if ( !value.isValid() )
8522 return QStringLiteral(
"None" );
8524 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8525 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8532 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8534 code += QLatin1String(
"optional " );
8535 code += QLatin1String(
"maptheme " );
8538 return code.trimmed();
8543 switch ( outputType )
8547 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', %2" )
8550 code += QLatin1String(
", optional=True" );
8575 QString def = definition;
8576 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8578 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8600 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
8602 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
8613 QVariant input = value;
8614 if ( !input.isValid() )
8622 if ( input.userType() == qMetaTypeId<QgsProperty>() )
8627 if ( input.userType() != QMetaType::Type::QDateTime && input.userType() != QMetaType::Type::QDate && input.userType() != QMetaType::Type::QTime && input.userType() != QMetaType::Type::QString )
8633 if ( input.userType() == QMetaType::Type::QString )
8635 const QString s = input.toString();
8639 input = QDateTime::fromString( s, Qt::ISODate );
8642 if ( !input.toDateTime().isValid() )
8643 input = QTime::fromString( s );
8645 input = input.toDateTime().time();
8651 const QDateTime res = input.toDateTime();
8652 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
8656 const QTime res = input.toTime();
8657 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
8663 if ( !value.isValid() )
8664 return QStringLiteral(
"None" );
8666 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8667 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8669 if ( value.userType() == QMetaType::Type::QDateTime )
8671 const QDateTime dt = value.toDateTime();
8672 if ( !dt.isValid() )
8673 return QStringLiteral(
"QDateTime()" );
8675 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
8676 .arg( dt.date().month() )
8677 .arg( dt.date().day() )
8678 .arg( dt.time().hour() )
8679 .arg( dt.time().minute() )
8680 .arg( dt.time().second() );
8682 else if ( value.userType() == QMetaType::Type::QDate )
8684 const QDate dt = value.toDate();
8685 if ( !dt.isValid() )
8686 return QStringLiteral(
"QDate()" );
8688 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
8692 else if ( value.userType() == QMetaType::Type::QTime )
8694 const QTime dt = value.toTime();
8695 if ( !dt.isValid() )
8696 return QStringLiteral(
"QTime()" );
8698 return QStringLiteral(
"QTime(%4, %5, %6)" )
8701 .arg( dt.second() );
8703 return value.toString();
8710 if ( mMin.isValid() )
8711 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
8712 if ( mMax.isValid() )
8713 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
8717 const QString extra = parts.join( QLatin1String(
"<br />" ) );
8718 if ( !extra.isEmpty() )
8719 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
8725 switch ( outputType )
8729 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', %2" )
8732 code += QLatin1String(
", optional=True" );
8736 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
8739 if ( mMin.isValid() )
8741 if ( mMax.isValid() )
8783 map.insert( QStringLiteral(
"min" ), mMin );
8784 map.insert( QStringLiteral(
"max" ), mMax );
8785 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
8792 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
8793 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
8801 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
8812 , mProviderId( provider )
8825 if ( !input.isValid() && !
mDefault.isValid() )
8828 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8829 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8837 if ( !value.isValid() )
8838 return QStringLiteral(
"None" );
8840 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8841 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8848 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8850 code += QLatin1String(
"optional " );
8851 code += QLatin1String(
"providerconnection " );
8852 code += mProviderId +
' ';
8855 return code.trimmed();
8860 switch ( outputType )
8864 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', %2, '%3'" )
8867 code += QLatin1String(
", optional=True" );
8881 map.insert( QStringLiteral(
"provider" ), mProviderId );
8888 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
8894 QString def = definition;
8896 if ( def.contains(
' ' ) )
8898 provider = def.left( def.indexOf(
' ' ) );
8899 def = def.mid( def.indexOf(
' ' ) + 1 );
8907 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8909 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8927 , mParentConnectionParameterName( parentLayerParameterName )
8940 if ( !input.isValid() && !
mDefault.isValid() )
8943 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8944 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8952 if ( !value.isValid() )
8953 return QStringLiteral(
"None" );
8955 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8956 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8963 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8965 code += QLatin1String(
"optional " );
8966 code += QLatin1String(
"databaseschema " );
8968 code += mParentConnectionParameterName +
' ';
8971 return code.trimmed();
8976 switch ( outputType )
8980 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', %2" )
8983 code += QLatin1String(
", optional=True" );
8985 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8999 QStringList depends;
9000 if ( !mParentConnectionParameterName.isEmpty() )
9001 depends << mParentConnectionParameterName;
9007 return mParentConnectionParameterName;
9012 mParentConnectionParameterName =
name;
9018 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
9025 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
9032 QString def = definition;
9034 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
9035 const QRegularExpressionMatch m = re.match( def );
9038 parent = m.captured( 1 ).trimmed();
9039 def = m.captured( 2 );
9055 const QString &connectionParameterName,
9056 const QString &schemaParameterName,
9057 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
9059 , mParentConnectionParameterName( connectionParameterName )
9060 , mParentSchemaParameterName( schemaParameterName )
9061 , mAllowNewTableNames( allowNewTableNames )
9074 if ( !input.isValid() && !
mDefault.isValid() )
9077 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
9078 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
9086 if ( !value.isValid() )
9087 return QStringLiteral(
"None" );
9089 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9090 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9097 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
9099 code += QLatin1String(
"optional " );
9100 code += QLatin1String(
"databasetable " );
9102 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
9103 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
9106 return code.trimmed();
9111 switch ( outputType )
9115 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', %2" )
9118 code += QLatin1String(
", optional=True" );
9120 if ( mAllowNewTableNames )
9121 code += QLatin1String(
", allowNewTableNames=True" );
9123 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
9124 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
9138 QStringList depends;
9139 if ( !mParentConnectionParameterName.isEmpty() )
9140 depends << mParentConnectionParameterName;
9141 if ( !mParentSchemaParameterName.isEmpty() )
9142 depends << mParentSchemaParameterName;
9148 return mParentConnectionParameterName;
9153 mParentConnectionParameterName =
name;
9158 return mParentSchemaParameterName;
9163 mParentSchemaParameterName =
name;
9169 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
9170 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
9171 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
9178 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
9179 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
9180 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
9188 QString def = definition;
9190 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
9191 const QRegularExpressionMatch m = re.match( def );
9194 connection = m.captured( 1 ).trimmed();
9195 if ( connection == QLatin1String(
"none" ) )
9197 schema = m.captured( 2 ).trimmed();
9198 if ( schema == QLatin1String(
"none" ) )
9200 def = m.captured( 3 );
9208 return mAllowNewTableNames;
9221 const QVariant &defaultValue,
bool optional )
9235 if ( !var.isValid() )
9243 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9256 if ( qobject_cast< QgsPointCloudLayer * >( qvariant_cast<QObject *>( var ) ) )
9259 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
9277 if ( !val.isValid() )
9278 return QStringLiteral(
"None" );
9280 if ( val.userType() == qMetaTypeId<QgsProperty>() )
9284 p.insert(
name(), val );
9315 const QVariant &defaultValue,
bool optional )
9328 if ( !var.isValid() )
9336 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9349 if ( qobject_cast< QgsAnnotationLayer * >( qvariant_cast<QObject *>( var ) ) )
9352 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
9370 if ( !val.isValid() )
9371 return QStringLiteral(
"None" );
9373 if ( val.userType() == qMetaTypeId<QgsProperty>() )
9377 p.insert(
name(), val );
9410 QVariant var = input;
9411 if ( !var.isValid() )
9419 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9425 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9438 if ( var.userType() != QMetaType::Type::QString )
9441 if ( var.toString().isEmpty() )
9449 if ( !value.isValid() )
9450 return QStringLiteral(
"None" );
9452 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9453 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9455 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9464 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9480 return lOriginalProvider->defaultPointCloudFileExtension();
9484 return p->defaultPointCloudFileExtension();
9495 QStringList filters;
9496 for (
const QString &ext : exts )
9498 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9500 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9507 return lOriginalProvider->supportedOutputPointCloudLayerExtensions();
9511 return p->supportedOutputPointCloudLayerExtensions();
9516 return QStringList() << ext;
9531 , mParentLayerParameterName( parentLayerParameterName )
9532 , mAllowMultiple( allowMultiple )
9533 , mDefaultToAllAttributes( defaultToAllAttributes )
9553 if ( input.userType() == qMetaTypeId<QgsProperty>() )
9558 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
9560 if ( !mAllowMultiple )
9566 else if ( input.userType() == QMetaType::Type::QString )
9568 if ( input.toString().isEmpty() )
9571 const QStringList parts = input.toString().split(
';' );
9572 if ( parts.count() > 1 && !mAllowMultiple )
9577 if ( input.toString().isEmpty() )
9585 if ( !value.isValid() )
9586 return QStringLiteral(
"None" );
9588 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9589 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9591 if ( value.userType() == QMetaType::Type::QVariantList )
9594 const auto constToList = value.toList();
9595 for (
const QVariant &val : constToList )
9599 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9601 else if ( value.userType() == QMetaType::Type::QStringList )
9604 const auto constToStringList = value.toStringList();
9605 for (
const QString &s : constToStringList )
9609 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9617 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
9619 code += QLatin1String(
"optional " );
9620 code += QLatin1String(
"attribute " );
9622 if ( mAllowMultiple )
9623 code += QLatin1String(
"multiple " );
9625 if ( mDefaultToAllAttributes )
9626 code += QLatin1String(
"default_to_all_attributes " );
9628 code += mParentLayerParameterName +
' ';
9631 return code.trimmed();
9636 switch ( outputType )
9640 QString code = QStringLiteral(
"QgsProcessingParameterPointCloudAttribute('%1', %2" )
9643 code += QLatin1String(
", optional=True" );
9645 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
9646 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
9650 if ( mDefaultToAllAttributes )
9651 code += QLatin1String(
", defaultToAllAttributes=True" );
9663 QStringList depends;
9664 if ( !mParentLayerParameterName.isEmpty() )
9665 depends << mParentLayerParameterName;
9671 return mParentLayerParameterName;
9681 return mAllowMultiple;
9691 return mDefaultToAllAttributes;
9696 mDefaultToAllAttributes = enabled;
9702 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
9703 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
9704 map.insert( QStringLiteral(
"default_to_all_attributes" ), mDefaultToAllAttributes );
9711 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
9712 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
9713 mDefaultToAllAttributes = map.value( QStringLiteral(
"default_to_all_attributes" ) ).toBool();
9722 QString def = definition;
9724 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
9727 def = def.mid( 8 ).trimmed();
9730 if ( def.startsWith( QLatin1String(
"default_to_all_attributes" ), Qt::CaseInsensitive ) )
9733 def = def.mid( 25 ).trimmed();
9736 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
9737 const QRegularExpressionMatch m = re.match( def );
9740 parent = m.captured( 1 ).trimmed();
9741 def = m.captured( 2 );
9768 QVariant var = input;
9769 if ( !var.isValid() )
9777 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9783 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9796 if ( var.userType() != QMetaType::Type::QString )
9799 if ( var.toString().isEmpty() )
9807 if ( !value.isValid() )
9808 return QStringLiteral(
"None" );
9810 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9811 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9813 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9822 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9842 QStringList filters;
9843 for (
const QString &ext : exts )
9845 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9847 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9853 return QStringList() << ext;
The Qgis class provides global constants 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,...
This class 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.
Class for 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.
A class to represent a 2D point.
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, for selection between available coordinat...
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, allowing users to select from existing dat...
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.
This class is a composition of two QSettings instances:
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 data sets.
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