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(
"hasgeometry " );
3302 code += QLatin1String(
"point " );
3306 code += QLatin1String(
"line " );
3310 code += QLatin1String(
"polygon " );
3314 code += QLatin1String(
"raster " );
3318 code += QLatin1String(
"mesh " );
3322 code += QLatin1String(
"plugin " );
3326 code += QLatin1String(
"pointcloud " );
3330 code += QLatin1String(
"annotation " );
3339 return code.trimmed();
3345 QString def = definition;
3348 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
3351 def = def.mid( 12 );
3354 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
3360 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
3366 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
3372 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
3378 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
3384 else if ( def.startsWith( QLatin1String(
"plugin" ), Qt::CaseInsensitive ) )
3390 else if ( def.startsWith( QLatin1String(
"pointcloud" ), Qt::CaseInsensitive ) )
3393 def = def.mid( 11 );
3396 else if ( def.startsWith( QLatin1String(
"annotation" ), Qt::CaseInsensitive ) )
3399 def = def.mid( 11 );
3410 switch ( outputType )
3414 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', %2" )
3417 code += QLatin1String(
", optional=True" );
3424 QStringList options;
3428 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
3432 code += QLatin1Char(
')' );
3449 map.insert( QStringLiteral(
"data_types" ), types );
3457 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3458 for (
const QVariant &val : values )
3479 if ( !input.isValid() )
3487 if ( input.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
3491 else if ( input.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
3496 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3501 if ( input.userType() == qMetaTypeId<QgsRectangle>() )
3506 if ( input.userType() == qMetaTypeId< QgsGeometry>() )
3510 if ( input.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3517 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3520 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3523 if ( variantIsValidStringForExtent( input ) )
3536bool QgsProcessingParameterExtent::variantIsValidStringForExtent(
const QVariant &value )
3538 if ( value.userType() == QMetaType::Type::QString )
3540 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
3541 const QRegularExpressionMatch match = rx.match( value.toString() );
3542 if ( match.hasMatch() )
3544 bool xMinOk =
false;
3545 ( void )match.captured( 1 ).toDouble( &xMinOk );
3546 bool xMaxOk =
false;
3547 ( void )match.captured( 2 ).toDouble( &xMaxOk );
3548 bool yMinOk =
false;
3549 ( void )match.captured( 3 ).toDouble( &yMinOk );
3550 bool yMaxOk =
false;
3551 ( void )match.captured( 4 ).toDouble( &yMaxOk );
3552 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
3561 if ( !value.isValid() )
3562 return QStringLiteral(
"None" );
3564 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3565 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3567 if ( value.userType() == qMetaTypeId<QgsRectangle>() )
3575 else if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3583 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
3588 const QString wkt = g.
asWkt();
3589 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3592 else if ( variantIsValidStringForExtent( value ) )
3598 p.insert(
name(), value );
3608 if ( variantIsValidStringForExtent( value ) )
3610 return value.toString();
3618 if ( variantIsValidStringForExtent( value ) )
3645 if ( !input.isValid() )
3653 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3658 if ( input.userType() == qMetaTypeId<QgsPointXY>() )
3662 if ( input.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3666 if ( input.userType() == qMetaTypeId< QgsGeometry>() )
3671 if ( input.userType() == QMetaType::Type::QString )
3673 if ( input.toString().isEmpty() )
3677 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3679 const QRegularExpressionMatch match = rx.match( input.toString() );
3680 if ( match.hasMatch() )
3683 ( void )match.captured( 1 ).toDouble( &xOk );
3685 ( void )match.captured( 2 ).toDouble( &yOk );
3694 if ( !value.isValid() )
3695 return QStringLiteral(
"None" );
3697 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3698 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3700 if ( value.userType() == qMetaTypeId<QgsPointXY>() )
3706 else if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3713 else if ( value.userType() == qMetaTypeId< QgsGeometry>() )
3718 const QString wkt = g.
asWkt();
3719 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3732 const QVariant &defaultValue,
bool optional,
const QList<int> &geometryTypes,
bool allowMultipart )
3734 mGeomTypes( geometryTypes ),
3735 mAllowMultipart( allowMultipart )
3748 if ( !input.isValid() )
3756 if ( input.userType() == qMetaTypeId<QgsProperty>() )
3763 if ( input.userType() == qMetaTypeId< QgsGeometry>() )
3765 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( input.value<
QgsGeometry>().
type() ) ) ) &&
3766 ( mAllowMultipart || !input.value<
QgsGeometry>().isMultipart() );
3769 if ( input.userType() == qMetaTypeId<QgsReferencedGeometry>() )
3775 if ( input.userType() == qMetaTypeId<QgsPointXY>() )
3780 if ( input.userType() == qMetaTypeId<QgsRectangle>() )
3785 if ( input.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3790 if ( input.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3795 if ( input.userType() == QMetaType::Type::QString )
3797 if ( input.toString().isEmpty() )
3802 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3804 const QRegularExpressionMatch match = rx.match( input.toString() );
3805 if ( match.hasMatch() )
3810 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( g.
type() ) ) ) && ( mAllowMultipart || !g.
isMultipart() );
3830 if ( !value.isValid() )
3831 return QStringLiteral(
"None" );
3833 if ( value.userType() == qMetaTypeId<QgsProperty>() )
3836 if ( value.userType() == qMetaTypeId< QgsGeometry>() )
3843 if ( value.userType() == qMetaTypeId<QgsReferencedGeometry>() )
3850 if ( value.userType() == qMetaTypeId<QgsPointXY>() )
3857 if ( value.userType() == qMetaTypeId<QgsReferencedPointXY>() )
3864 if ( value.userType() == qMetaTypeId<QgsRectangle>() )
3871 if ( value.userType() == qMetaTypeId<QgsReferencedRectangle>() )
3883 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3885 code += QLatin1String(
"optional " );
3886 code +=
type() +
' ';
3888 for (
const int type : mGeomTypes )
3893 code += QLatin1String(
"point " );
3897 code += QLatin1String(
"line " );
3901 code += QLatin1String(
"polygon " );
3905 code += QLatin1String(
"unknown " );
3911 return code.trimmed();
3916 switch ( outputType )
3920 QString code = QStringLiteral(
"QgsProcessingParameterGeometry('%1', %2" )
3923 code += QLatin1String(
", optional=True" );
3925 if ( !mGeomTypes.empty() )
3932 return QStringLiteral(
"PointGeometry" );
3935 return QStringLiteral(
"LineGeometry" );
3938 return QStringLiteral(
"PolygonGeometry" );
3941 return QStringLiteral(
"UnknownGeometry" );
3944 return QStringLiteral(
"NullGeometry" );
3949 QStringList options;
3950 options.reserve( mGeomTypes.size() );
3951 for (
const int type : mGeomTypes )
3953 options << QStringLiteral(
" QgsWkbTypes.%1" ).arg( geomTypeToString(
static_cast<Qgis::GeometryType>(
type ) ) );
3955 code += QStringLiteral(
", geometryTypes=[%1 ]" ).arg( options.join(
',' ) );
3958 if ( ! mAllowMultipart )
3960 code += QLatin1String(
", allowMultipart=False" );
3975 for (
const int type : mGeomTypes )
3979 map.insert( QStringLiteral(
"geometrytypes" ), types );
3980 map.insert( QStringLiteral(
"multipart" ), mAllowMultipart );
3988 const QVariantList values = map.value( QStringLiteral(
"geometrytypes" ) ).toList();
3989 for (
const QVariant &val : values )
3991 mGeomTypes << val.toInt();
3993 mAllowMultipart = map.value( QStringLiteral(
"multipart" ) ).toBool();
4004 , mBehavior( behavior )
4005 , mExtension( fileFilter.isEmpty() ? extension : QString() )
4006 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
4019 if ( !input.isValid() )
4027 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4032 const QString
string = input.toString().trimmed();
4034 if ( input.userType() != QMetaType::Type::QString ||
string.isEmpty() )
4037 switch ( mBehavior )
4041 if ( !mExtension.isEmpty() )
4043 return string.endsWith( mExtension, Qt::CaseInsensitive );
4045 else if ( !mFileFilter.isEmpty() )
4063 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4065 code += QLatin1String(
"optional " );
4068 return code.trimmed();
4073 switch ( outputType )
4078 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', %2" )
4081 code += QLatin1String(
", optional=True" );
4082 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
Qgis::ProcessingFileParameterBehavior::File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
4083 if ( !mExtension.isEmpty() )
4084 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
4085 if ( !mFileFilter.isEmpty() )
4086 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
4097 switch ( mBehavior )
4101 if ( !mFileFilter.isEmpty() )
4102 return mFileFilter != QObject::tr(
"All files (*.*)" ) ? mFileFilter + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" ) : mFileFilter;
4103 else if ( !mExtension.isEmpty() )
4104 return QObject::tr(
"%1 files" ).arg( mExtension.toUpper() ) + QStringLiteral(
" (*." ) + mExtension.toLower() + QStringLiteral(
");;" ) + QObject::tr(
"All files (*.*)" );
4106 return QObject::tr(
"All files (*.*)" );
4118 mFileFilter.clear();
4128 mFileFilter = filter;
4135 map.insert( QStringLiteral(
"behavior" ),
static_cast< int >( mBehavior ) );
4136 map.insert( QStringLiteral(
"extension" ), mExtension );
4137 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
4145 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
4146 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
4157 , mHeaders( headers )
4158 , mNumberRows( numberRows )
4159 , mFixedNumberRows( fixedNumberRows )
4172 if ( !input.isValid() )
4180 if ( input.userType() == QMetaType::Type::QString )
4182 if ( input.toString().isEmpty() )
4186 else if ( input.userType() == QMetaType::Type::QVariantList )
4188 if ( input.toList().isEmpty() )
4192 else if ( input.userType() == QMetaType::Type::Double || input.userType() == QMetaType::Type::Int )
4202 if ( !value.isValid() )
4203 return QStringLiteral(
"None" );
4205 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4206 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4209 p.insert(
name(), value );
4217 switch ( outputType )
4221 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', %2" )
4224 code += QLatin1String(
", optional=True" );
4225 code += QStringLiteral(
", numberRows=%1" ).arg( mNumberRows );
4226 code += QStringLiteral(
", hasFixedNumberRows=%1" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4229 headers.reserve( mHeaders.size() );
4230 for (
const QString &h : mHeaders )
4232 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
4264 return mFixedNumberRows;
4269 mFixedNumberRows = fixedNumberRows;
4275 map.insert( QStringLiteral(
"headers" ), mHeaders );
4276 map.insert( QStringLiteral(
"rows" ), mNumberRows );
4277 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
4284 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
4285 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
4286 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
4297 , mLayerType( layerType )
4310 if ( !input.isValid() )
4320 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
4326 if ( input.userType() == QMetaType::Type::QString )
4328 if ( input.toString().isEmpty() )
4331 if ( mMinimumNumberInputs > 1 )
4342 else if ( input.userType() == QMetaType::Type::QVariantList )
4344 if ( input.toList().count() < mMinimumNumberInputs )
4347 if ( mMinimumNumberInputs > input.toList().count() )
4355 const auto constToList = input.toList();
4356 for (
const QVariant &v : constToList )
4358 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
4367 else if ( input.userType() == QMetaType::Type::QStringList )
4369 if ( input.toStringList().count() < mMinimumNumberInputs )
4372 if ( mMinimumNumberInputs > input.toStringList().count() )
4380 const auto constToStringList = input.toStringList();
4381 for (
const QString &v : constToStringList )
4394 if ( !value.isValid() )
4395 return QStringLiteral(
"None" );
4397 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4398 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4403 if ( value.userType() == QMetaType::Type::QStringList )
4405 const QStringList list = value.toStringList();
4406 parts.reserve( list.count() );
4407 for (
const QString &v : list )
4410 else if ( value.userType() == QMetaType::Type::QVariantList )
4412 const QVariantList list = value.toList();
4413 parts.reserve( list.count() );
4414 for (
const QVariant &v : list )
4417 if ( !parts.isEmpty() )
4418 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4423 p.insert(
name(), value );
4425 if ( !list.isEmpty() )
4428 parts.reserve( list.count() );
4433 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4452 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4454 code += QLatin1String(
"optional " );
4455 switch ( mLayerType )
4458 code += QLatin1String(
"multiple raster" );
4462 code += QLatin1String(
"multiple file" );
4466 code += QLatin1String(
"multiple vector" );
4470 if (
mDefault.userType() == QMetaType::Type::QVariantList )
4473 const auto constToList =
mDefault.toList();
4474 for (
const QVariant &var : constToList )
4476 parts << var.toString();
4478 code += parts.join(
',' );
4480 else if (
mDefault.userType() == QMetaType::Type::QStringList )
4482 code +=
mDefault.toStringList().join(
',' );
4488 return code.trimmed();
4493 switch ( outputType )
4497 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', %2" )
4500 code += QLatin1String(
", optional=True" );
4504 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
4515 switch ( mLayerType )
4518 return QObject::tr(
"All files (*.*)" );
4557 return mMinimumNumberInputs;
4569 map.insert( QStringLiteral(
"layer_type" ),
static_cast< int >( mLayerType ) );
4570 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
4578 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
4584 QString
type = definition;
4586 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
4587 const QRegularExpressionMatch m = re.match( definition );
4590 type = m.captured( 1 ).toLower().trimmed();
4591 defaultVal = m.captured( 2 );
4594 if (
type == QLatin1String(
"vector" ) )
4596 else if (
type == QLatin1String(
"raster" ) )
4598 else if (
type == QLatin1String(
"file" ) )
4611 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
4622 QVariant input = value;
4623 if ( !input.isValid() )
4631 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4637 const double res = input.toDouble( &ok );
4641 return !( res < mMin || res > mMax );
4646 if ( !value.isValid() )
4647 return QStringLiteral(
"None" );
4649 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4650 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4652 return value.toString();
4659 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
4660 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
4661 if ( mMax < std::numeric_limits<double>::max() )
4662 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
4665 const QString extra = parts.join( QLatin1String(
"<br />" ) );
4666 if ( !extra.isEmpty() )
4667 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
4673 switch ( outputType )
4677 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', %2" )
4680 code += QLatin1String(
", optional=True" );
4682 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Qgis::ProcessingNumberParameterType::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4684 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
4685 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
4686 if ( mMax != std::numeric_limits<double>::max() )
4687 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
4729 map.insert( QStringLiteral(
"min" ), mMin );
4730 map.insert( QStringLiteral(
"max" ), mMax );
4731 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
4738 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
4739 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
4747 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4765 if ( !input.isValid() )
4773 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4778 if ( input.userType() == QMetaType::Type::QString )
4780 const QStringList list = input.toString().split(
',' );
4781 if ( list.count() != 2 )
4784 list.at( 0 ).toDouble( &ok );
4786 list.at( 1 ).toDouble( &ok2 );
4791 else if ( input.userType() == QMetaType::Type::QVariantList )
4793 if ( input.toList().count() != 2 )
4797 input.toList().at( 0 ).toDouble( &ok );
4799 input.toList().at( 1 ).toDouble( &ok2 );
4810 if ( !value.isValid() )
4811 return QStringLiteral(
"None" );
4813 if ( value.userType() == qMetaTypeId<QgsProperty>() )
4814 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4817 p.insert(
name(), value );
4820 QStringList stringParts;
4821 const auto constParts = parts;
4822 for (
const double v : constParts )
4824 stringParts << QString::number( v );
4826 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
4831 switch ( outputType )
4835 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', %2" )
4838 code += QLatin1String(
", optional=True" );
4840 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Qgis::ProcessingNumberParameterType::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4863 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
4877 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4894 if ( !input.isValid() )
4902 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4907 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4910 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
4928 if ( !val.isValid() )
4929 return QStringLiteral(
"None" );
4931 if ( val.userType() == qMetaTypeId<QgsProperty>() )
4935 p.insert(
name(), val );
4963 , mOptions( options )
4964 , mAllowMultiple( allowMultiple )
4965 , mUsesStaticStrings( usesStaticStrings )
4977 QVariant input = value;
4978 if ( !input.isValid() )
4986 if ( input.userType() == qMetaTypeId<QgsProperty>() )
4991 if ( mUsesStaticStrings )
4993 if ( input.userType() == QMetaType::Type::QVariantList )
4995 if ( !mAllowMultiple )
4998 const QVariantList values = input.toList();
5002 for (
const QVariant &val : values )
5004 if ( !mOptions.contains( val.toString() ) )
5010 else if ( input.userType() == QMetaType::Type::QStringList )
5012 if ( !mAllowMultiple )
5015 const QStringList values = input.toStringList();
5020 if ( values.count() > 1 && !mAllowMultiple )
5023 for (
const QString &val : values )
5025 if ( !mOptions.contains( val ) )
5030 else if ( input.userType() == QMetaType::Type::QString )
5032 const QStringList parts = input.toString().split(
',' );
5033 if ( parts.count() > 1 && !mAllowMultiple )
5036 const auto constParts = parts;
5037 for (
const QString &part : constParts )
5039 if ( !mOptions.contains( part ) )
5047 if ( input.userType() == QMetaType::Type::QVariantList )
5049 if ( !mAllowMultiple )
5052 const QVariantList values = input.toList();
5056 for (
const QVariant &val : values )
5059 const int res = val.toInt( &ok );
5062 else if ( res < 0 || res >= mOptions.count() )
5068 else if ( input.userType() == QMetaType::Type::QString )
5070 const QStringList parts = input.toString().split(
',' );
5071 if ( parts.count() > 1 && !mAllowMultiple )
5074 const auto constParts = parts;
5075 for (
const QString &part : constParts )
5078 const int res = part.toInt( &ok );
5081 else if ( res < 0 || res >= mOptions.count() )
5086 else if ( input.userType() == QMetaType::Type::Int || input.userType() == QMetaType::Type::Double )
5089 const int res = input.toInt( &ok );
5092 else if ( res >= 0 && res < mOptions.count() )
5102 if ( !value.isValid() )
5103 return QStringLiteral(
"None" );
5105 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5106 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5108 if ( mUsesStaticStrings )
5110 if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
5113 const QStringList constList = value.toStringList();
5114 for (
const QString &val : constList )
5118 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5120 else if ( value.userType() == QMetaType::Type::QString )
5123 const QStringList constList = value.toString().split(
',' );
5124 if ( constList.count() > 1 )
5126 for (
const QString &val : constList )
5130 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5138 if ( value.userType() == QMetaType::Type::QVariantList )
5141 const auto constToList = value.toList();
5142 for (
const QVariant &val : constToList )
5144 parts << QString::number( static_cast< int >( val.toDouble() ) );
5146 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5148 else if ( value.userType() == QMetaType::Type::QString )
5150 const QStringList parts = value.toString().split(
',' );
5151 if ( parts.count() > 1 )
5153 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5157 return QString::number(
static_cast< int >( value.toDouble() ) );
5163 if ( !value.isValid() )
5166 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5169 if ( mUsesStaticStrings )
5175 if ( value.userType() == QMetaType::Type::QVariantList )
5178 const QVariantList toList = value.toList();
5179 parts.reserve( toList.size() );
5180 for (
const QVariant &val : toList )
5182 parts << mOptions.value(
static_cast< int >( val.toDouble() ) );
5184 return parts.join(
',' );
5186 else if ( value.userType() == QMetaType::Type::QString )
5188 const QStringList parts = value.toString().split(
',' );
5189 QStringList comments;
5190 if ( parts.count() > 1 )
5192 for (
const QString &part : parts )
5195 const int val = part.toInt( &ok );
5197 comments << mOptions.value( val );
5199 return comments.join(
',' );
5203 return mOptions.value(
static_cast< int >( value.toDouble() ) );
5209 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5211 code += QLatin1String(
"optional " );
5212 code += QLatin1String(
"enum " );
5214 if ( mAllowMultiple )
5215 code += QLatin1String(
"multiple " );
5217 if ( mUsesStaticStrings )
5218 code += QLatin1String(
"static " );
5220 code += mOptions.join(
';' ) +
' ';
5223 return code.trimmed();
5228 switch ( outputType )
5232 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', %2" )
5235 code += QLatin1String(
", optional=True" );
5238 options.reserve( mOptions.size() );
5239 for (
const QString &o : mOptions )
5241 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
5243 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5245 code += QStringLiteral(
", usesStaticStrings=%1" ).arg( mUsesStaticStrings ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5268 return mAllowMultiple;
5278 return mUsesStaticStrings;
5289 map.insert( QStringLiteral(
"options" ), mOptions );
5290 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5291 map.insert( QStringLiteral(
"uses_static_strings" ), mUsesStaticStrings );
5298 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
5299 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5300 mUsesStaticStrings = map.value( QStringLiteral(
"uses_static_strings" ) ).toBool();
5307 QString def = definition;
5309 bool multiple =
false;
5310 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5316 bool staticStrings =
false;
5317 if ( def.startsWith( QLatin1String(
"static" ), Qt::CaseInsensitive ) )
5319 staticStrings =
true;
5323 const thread_local QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
5324 const QRegularExpressionMatch m = re.match( def );
5325 QString values = def;
5328 values = m.captured( 1 ).trimmed();
5329 defaultVal = m.captured( 2 );
5337 , mMultiLine( multiLine )
5350 return QStringLiteral(
"None" );
5352 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5353 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5355 const QString s = value.toString();
5361 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5363 code += QLatin1String(
"optional " );
5364 code += QLatin1String(
"string " );
5367 code += QLatin1String(
"long " );
5370 return code.trimmed();
5375 switch ( outputType )
5379 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', %2" )
5382 code += QLatin1String(
", optional=True" );
5383 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5406 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
5413 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
5419 QString def = definition;
5421 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
5427 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5429 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5433 if ( def == QLatin1String(
"None" ) )
5456 if ( !value.isValid() )
5457 return QStringLiteral(
"None" );
5459 const QString s = value.toString();
5465 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5467 code += QLatin1String(
"optional " );
5468 code += QLatin1String(
"authcfg " );
5471 return code.trimmed();
5476 QString def = definition;
5478 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5480 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5484 if ( def == QLatin1String(
"None" ) )
5497 , mParentLayerParameterName( parentLayerParameterName )
5498 , mExpressionType( type )
5510 if ( !value.isValid() )
5511 return QStringLiteral(
"None" );
5513 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5514 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5516 const QString s = value.toString();
5522 QStringList depends;
5523 if ( !mParentLayerParameterName.isEmpty() )
5524 depends << mParentLayerParameterName;
5530 switch ( outputType )
5534 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', %2" )
5537 code += QLatin1String(
", optional=True" );
5539 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5545 switch ( mExpressionType )
5548 code += QLatin1String(
", type=Qgis.ExpressionType.PointCloud)" );
5551 code += QLatin1String(
", type=Qgis.ExpressionType.RasterCalculator)" );
5554 code += QLatin1Char(
')' );
5565 return mParentLayerParameterName;
5575 return mExpressionType;
5586 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5587 map.insert( QStringLiteral(
"expression_type" ),
static_cast< int >( mExpressionType ) );
5594 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5595 mExpressionType =
static_cast< Qgis::ExpressionType >( map.value( QStringLiteral(
"expression_type" ) ).toInt() );
5620 if ( !var.isValid() )
5628 if ( var.userType() == qMetaTypeId<QgsProperty>() )
5641 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
5644 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
5662 if ( !val.isValid() )
5663 return QStringLiteral(
"None" );
5665 if ( val.userType() == qMetaTypeId<QgsProperty>() )
5669 p.insert(
name(), val );
5687 switch ( outputType )
5691 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', %2" )
5694 code += QLatin1String(
", optional=True" );
5698 QStringList options;
5701 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
5735 map.insert( QStringLiteral(
"data_types" ), types );
5743 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
5744 for (
const QVariant &val : values )
5757 const QVariant &defaultValue,
bool optional )
5772 if ( !var.isValid() )
5780 if ( var.userType() == qMetaTypeId<QgsProperty>() )
5793 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
5796 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
5814 if ( !val.isValid() )
5815 return QStringLiteral(
"None" );
5817 if ( val.userType() == qMetaTypeId<QgsProperty>() )
5821 p.insert(
name(), val );
5849 , mParentLayerParameterName( parentLayerParameterName )
5851 , mAllowMultiple( allowMultiple )
5852 , mDefaultToAllFields( defaultToAllFields )
5866 if ( !input.isValid() )
5874 if ( input.userType() == qMetaTypeId<QgsProperty>() )
5879 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
5881 if ( !mAllowMultiple )
5887 else if ( input.userType() == QMetaType::Type::QString )
5889 if ( input.toString().isEmpty() )
5892 const QStringList parts = input.toString().split(
';' );
5893 if ( parts.count() > 1 && !mAllowMultiple )
5898 if ( input.toString().isEmpty() )
5906 if ( !value.isValid() )
5907 return QStringLiteral(
"None" );
5909 if ( value.userType() == qMetaTypeId<QgsProperty>() )
5910 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5912 if ( value.userType() == QMetaType::Type::QVariantList )
5915 const auto constToList = value.toList();
5916 for (
const QVariant &val : constToList )
5920 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5922 else if ( value.userType() == QMetaType::Type::QStringList )
5925 const auto constToStringList = value.toStringList();
5926 for (
const QString &s : constToStringList )
5930 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5938 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5940 code += QLatin1String(
"optional " );
5941 code += QLatin1String(
"field " );
5943 switch ( mDataType )
5946 code += QLatin1String(
"numeric " );
5950 code += QLatin1String(
"string " );
5954 code += QLatin1String(
"datetime " );
5958 code += QLatin1String(
"binary " );
5962 code += QLatin1String(
"boolean " );
5969 if ( mAllowMultiple )
5970 code += QLatin1String(
"multiple " );
5972 if ( mDefaultToAllFields )
5973 code += QLatin1String(
"default_to_all_fields " );
5975 code += mParentLayerParameterName +
' ';
5978 return code.trimmed();
5983 switch ( outputType )
5987 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', %2" )
5990 code += QLatin1String(
", optional=True" );
5993 switch ( mDataType )
5996 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
6000 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
6004 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
6008 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
6012 dataType = QStringLiteral(
"QgsProcessingParameterField.Binary" );
6016 dataType = QStringLiteral(
"QgsProcessingParameterField.Boolean" );
6019 code += QStringLiteral(
", type=%1" ).arg(
dataType );
6021 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
6022 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6026 if ( mDefaultToAllFields )
6027 code += QLatin1String(
", defaultToAllFields=True" );
6039 QStringList depends;
6040 if ( !mParentLayerParameterName.isEmpty() )
6041 depends << mParentLayerParameterName;
6047 return mParentLayerParameterName;
6067 return mAllowMultiple;
6077 return mDefaultToAllFields;
6082 mDefaultToAllFields = enabled;
6088 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
6089 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
6090 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
6091 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
6098 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
6100 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
6101 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
6111 QString def = definition;
6113 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
6118 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
6123 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
6128 else if ( def.startsWith( QLatin1String(
"binary " ), Qt::CaseInsensitive ) )
6133 else if ( def.startsWith( QLatin1String(
"boolean " ), Qt::CaseInsensitive ) )
6139 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
6142 def = def.mid( 8 ).trimmed();
6145 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
6148 def = def.mid( 21 ).trimmed();
6151 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
6152 const QRegularExpressionMatch m = re.match( def );
6155 parent = m.captured( 1 ).trimmed();
6156 def = m.captured( 2 );
6181 QVariant var = input;
6182 if ( !var.isValid() )
6190 if ( var.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
6195 else if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6202 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6214 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
6219 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
6237 if ( !value.isValid() )
6238 return QStringLiteral(
"None" );
6240 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6243 if ( value.userType() == qMetaTypeId<QgsProcessingFeatureSourceDefinition>() )
6246 QString geometryCheckString;
6250 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
6254 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
6258 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
6265 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
6267 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
6268 if ( !
flags.empty() )
6269 flagString =
flags.join( QLatin1String(
" | " ) );
6276 layerString = layer->source();
6283 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6284 geometryCheckString,
6296 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression(%1), selectedFeaturesOnly=%2, featureLimit=%3%4%6, geometryCheck=%5)" )
6300 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6301 geometryCheckString,
6310 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
6315 QString layerString = value.toString();
6319 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
6336 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6338 code += QLatin1String(
"optional " );
6339 code += QLatin1String(
"source " );
6346 code += QLatin1String(
"point " );
6350 code += QLatin1String(
"line " );
6354 code += QLatin1String(
"polygon " );
6363 return code.trimmed();
6368 switch ( outputType )
6372 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', %2" )
6375 code += QLatin1String(
", optional=True" );
6379 QStringList options;
6383 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
6400 : mDataTypes( types )
6413 map.insert( QStringLiteral(
"data_types" ), types );
6421 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
6422 for (
const QVariant &val : values )
6432 QString def = definition;
6435 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6441 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6447 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6462 , mSupportsAppend( supportsAppend )
6473 QVariant var = input;
6474 if ( !var.isValid() )
6482 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6488 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6501 if ( var.userType() != QMetaType::Type::QString )
6504 if ( var.toString().isEmpty() )
6512 if ( !value.isValid() )
6513 return QStringLiteral(
"None" );
6515 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6516 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6518 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6527 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6536 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6538 code += QLatin1String(
"optional " );
6539 code += QLatin1String(
"sink " );
6541 switch ( mDataType )
6544 code += QLatin1String(
"point " );
6548 code += QLatin1String(
"line " );
6552 code += QLatin1String(
"polygon " );
6556 code += QLatin1String(
"table " );
6564 return code.trimmed();
6576 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6580 return p->defaultVectorFileExtension(
hasGeometry() );
6590 return QStringLiteral(
"dbf" );
6597 switch ( outputType )
6601 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', %2" )
6604 code += QLatin1String(
", optional=True" );
6608 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6609 if ( mSupportsAppend )
6610 code += QLatin1String(
", supportsAppend=True" );
6623 QStringList filters;
6624 for (
const QString &ext : exts )
6626 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6628 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6637 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6639 return lOriginalProvider->supportedOutputTableExtensions();
6644 return p->supportedOutputVectorLayerExtensions();
6646 return p->supportedOutputTableExtensions();
6661 switch ( mDataType )
6691 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
6692 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
6700 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
6707 return QStringLiteral(
"memory:%1" ).arg(
description() );
6715 QString def = definition;
6716 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6721 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6726 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6731 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
6742 return mSupportsAppend;
6762 QVariant var = input;
6763 if ( !var.isValid() )
6771 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6777 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6790 if ( var.userType() != QMetaType::Type::QString )
6793 if ( var.toString().isEmpty() )
6801 if ( !value.isValid() )
6802 return QStringLiteral(
"None" );
6804 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6805 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6807 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6816 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6832 return lOriginalProvider->defaultRasterFileExtension();
6836 return p->defaultRasterFileExtension();
6847 QStringList filters;
6848 for (
const QString &ext : exts )
6850 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6852 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6859 return lOriginalProvider->supportedOutputRasterLayerExtensions();
6863 return p->supportedOutputRasterLayerExtensions();
6879 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
6891 QVariant var = input;
6892 if ( !var.isValid() )
6900 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6906 if ( var.userType() == qMetaTypeId<QgsProperty>() )
6919 if ( var.userType() != QMetaType::Type::QString )
6922 if ( var.toString().isEmpty() )
6932 if ( !value.isValid() )
6933 return QStringLiteral(
"None" );
6935 if ( value.userType() == qMetaTypeId<QgsProperty>() )
6936 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6938 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
6947 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6956 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
6968 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
6969 return QStringLiteral(
"file" );
6972 const thread_local QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
6973 const QRegularExpressionMatch match = rx.match( mFileFilter );
6974 if ( !match.hasMatch() )
6975 return QStringLiteral(
"file" );
6977 return match.captured( 1 );
6982 switch ( outputType )
6986 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', %2" )
6989 code += QLatin1String(
", optional=True" );
6993 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7005 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
7021 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
7028 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
7049 QVariant var = input;
7050 if ( !var.isValid() )
7058 if ( var.userType() == qMetaTypeId<QgsProperty>() )
7071 if ( var.userType() != QMetaType::Type::QString )
7074 if ( var.toString().isEmpty() )
7097 , mCreateByDefault( createByDefault )
7105 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
7106 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
7113 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
7114 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
7120 switch ( outputType )
7127 QString code = t->className() + QStringLiteral(
"('%1', %2" )
7130 code += QLatin1String(
", optional=True" );
7132 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7147 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
7154 const thread_local QRegularExpression rx( QStringLiteral(
"[.]" ) );
7155 QString sanitizedName =
name();
7156 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
7171 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
7180 return mCreateByDefault;
7202 QVariant var = input;
7203 if ( !var.isValid() )
7211 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
7217 if ( var.userType() == qMetaTypeId<QgsProperty>() )
7230 if ( var.userType() != QMetaType::Type::QString )
7233 if ( var.toString().isEmpty() )
7241 if ( !value.isValid() )
7242 return QStringLiteral(
"None" );
7244 if ( value.userType() == qMetaTypeId<QgsProperty>() )
7245 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7247 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
7256 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
7265 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7267 code += QLatin1String(
"optional " );
7268 code += QLatin1String(
"vectorDestination " );
7270 switch ( mDataType )
7273 code += QLatin1String(
"point " );
7277 code += QLatin1String(
"line " );
7281 code += QLatin1String(
"polygon " );
7289 return code.trimmed();
7301 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
7305 return p->defaultVectorFileExtension(
hasGeometry() );
7315 return QStringLiteral(
"dbf" );
7322 switch ( outputType )
7326 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', %2" )
7329 code += QLatin1String(
", optional=True" );
7333 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7346 QStringList filters;
7347 for (
const QString &ext : exts )
7349 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
7351 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
7359 return lOriginalProvider->supportedOutputVectorLayerExtensions();
7361 return lOriginalProvider->supportedOutputTableExtensions();
7366 return p->supportedOutputVectorLayerExtensions();
7368 return p->supportedOutputTableExtensions();
7383 switch ( mDataType )
7413 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
7427 QString def = definition;
7428 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
7433 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
7438 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
7449 , mParentLayerParameterName( parentLayerParameterName )
7450 , mAllowMultiple( allowMultiple )
7462 QVariant input = value;
7463 if ( !input.isValid() )
7471 if ( input.userType() == qMetaTypeId<QgsProperty>() )
7476 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
7478 if ( !mAllowMultiple )
7487 const double res = input.toInt( &ok );
7497 return mAllowMultiple;
7507 if ( !value.isValid() )
7508 return QStringLiteral(
"None" );
7510 if ( value.userType() == qMetaTypeId<QgsProperty>() )
7511 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7513 if ( value.userType() == QMetaType::Type::QVariantList )
7516 const QVariantList values = value.toList();
7517 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7519 parts << QString::number( static_cast< int >( it->toDouble() ) );
7521 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7523 else if ( value.userType() == QMetaType::Type::QStringList )
7526 const QStringList values = value.toStringList();
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(
']' );
7534 return value.toString();
7539 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7541 code += QLatin1String(
"optional " );
7542 code += QLatin1String(
"band " );
7544 if ( mAllowMultiple )
7545 code += QLatin1String(
"multiple " );
7547 code += mParentLayerParameterName +
' ';
7550 return code.trimmed();
7555 QStringList depends;
7556 if ( !mParentLayerParameterName.isEmpty() )
7557 depends << mParentLayerParameterName;
7563 switch ( outputType )
7567 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', %2" )
7570 code += QLatin1String(
", optional=True" );
7572 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
7573 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7585 return mParentLayerParameterName;
7596 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
7597 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
7604 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
7605 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
7612 QString def = definition;
7615 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
7618 def = def.mid( 8 ).trimmed();
7621 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7622 const QRegularExpressionMatch m = re.match( def );
7625 parent = m.captured( 1 ).trimmed();
7626 def = m.captured( 2 );
7643 , mParentParameterName( parentParameterName )
7660 QStringList depends;
7661 if ( !mParentParameterName.isEmpty() )
7662 depends << mParentParameterName;
7668 switch ( outputType )
7672 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', %2" )
7675 code += QLatin1String(
", optional=True" );
7677 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7679 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7680 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7681 if (
maximum() != std::numeric_limits<double>::max() )
7682 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7693 return mParentParameterName;
7704 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7705 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7712 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7725 , mParentParameterName( parentParameterName )
7742 QStringList depends;
7743 if ( !mParentParameterName.isEmpty() )
7744 depends << mParentParameterName;
7750 switch ( outputType )
7754 QString code = QStringLiteral(
"QgsProcessingParameterArea('%1', %2" )
7757 code += QLatin1String(
", optional=True" );
7759 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7762 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7763 if (
maximum() != std::numeric_limits<double>::max() )
7764 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7775 return mParentParameterName;
7786 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7787 map.insert( QStringLiteral(
"default_unit" ),
qgsEnumValueToKey( mDefaultUnit ) );
7794 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7807 , mParentParameterName( parentParameterName )
7824 QStringList depends;
7825 if ( !mParentParameterName.isEmpty() )
7826 depends << mParentParameterName;
7832 switch ( outputType )
7836 QString code = QStringLiteral(
"QgsProcessingParameterVolume('%1', %2" )
7839 code += QLatin1String(
", optional=True" );
7841 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7844 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7845 if (
maximum() != std::numeric_limits<double>::max() )
7846 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7857 return mParentParameterName;
7868 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7869 map.insert( QStringLiteral(
"default_unit" ),
qgsEnumValueToKey( mDefaultUnit ) );
7876 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7903 switch ( outputType )
7907 QString code = QStringLiteral(
"QgsProcessingParameterDuration('%1', %2" )
7910 code += QLatin1String(
", optional=True" );
7912 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7913 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7914 if (
maximum() != std::numeric_limits<double>::max() )
7915 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7927 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7961 switch ( outputType )
7965 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', %2" )
7968 code += QLatin1String(
", optional=True" );
7980 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
8000 return QStringLiteral(
"None" );
8002 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8003 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8005 const QString s = value.toString();
8011 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8013 code += QLatin1String(
"optional " );
8014 code += QLatin1String(
"layout " );
8017 return code.trimmed();
8022 switch ( outputType )
8026 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', %2" )
8029 code += QLatin1String(
", optional=True" );
8040 QString def = definition;
8042 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8044 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8048 if ( def == QLatin1String(
"None" ) )
8061 , mParentLayoutParameterName( parentLayoutParameterName )
8062 , mItemType( itemType )
8075 return QStringLiteral(
"None" );
8077 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8078 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8080 const QString s = value.toString();
8086 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8088 code += QLatin1String(
"optional " );
8089 code += QLatin1String(
"layoutitem " );
8090 if ( mItemType >= 0 )
8091 code += QString::number( mItemType ) +
' ';
8093 code += mParentLayoutParameterName +
' ';
8096 return code.trimmed();
8101 switch ( outputType )
8105 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', %2" )
8108 code += QLatin1String(
", optional=True" );
8110 if ( mItemType >= 0 )
8111 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
8113 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
8126 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
8127 map.insert( QStringLiteral(
"item_type" ), mItemType );
8134 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
8135 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
8141 QStringList depends;
8142 if ( !mParentLayoutParameterName.isEmpty() )
8143 depends << mParentLayoutParameterName;
8150 QString def = definition;
8152 const thread_local QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
8153 const QRegularExpressionMatch m = re.match( def );
8156 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
8157 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
8158 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
8171 return mParentLayoutParameterName;
8176 mParentLayoutParameterName =
name;
8195 , mAllowOpacity( opacityEnabled )
8208 return QStringLiteral(
"None" );
8210 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8211 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8213 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
8214 return QStringLiteral(
"QColor()" );
8216 if ( value.canConvert< QColor >() )
8218 const QColor
c = value.value< QColor >();
8219 if ( !mAllowOpacity ||
c.alpha() == 255 )
8220 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
8222 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
8225 const QString s = value.toString();
8231 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8233 code += QLatin1String(
"optional " );
8234 code += QLatin1String(
"color " );
8236 if ( mAllowOpacity )
8237 code += QLatin1String(
"withopacity " );
8240 return code.trimmed();
8245 switch ( outputType )
8249 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', %2" )
8252 code += QLatin1String(
", optional=True" );
8254 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
8266 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
8269 if ( !input.isValid() )
8272 if ( input.userType() == QMetaType::Type::QColor )
8276 else if ( input.userType() == qMetaTypeId<QgsProperty>() )
8281 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
8284 bool containsAlpha =
false;
8291 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
8298 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
8304 return mAllowOpacity;
8309 mAllowOpacity = enabled;
8314 QString def = definition;
8316 bool allowOpacity =
false;
8317 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
8319 allowOpacity =
true;
8320 def = def.mid( 12 );
8323 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8325 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8329 if ( def == QLatin1String(
"None" ) || def.isEmpty() )
8340 , mSourceParameterName( sourceCrsParameterName )
8341 , mDestParameterName( destinationCrsParameterName )
8342 , mSourceCrs( staticSourceCrs )
8343 , mDestCrs( staticDestinationCrs )
8355 return valueAsPythonStringPrivate( value, context,
false );
8358QString QgsProcessingParameterCoordinateOperation::valueAsPythonStringPrivate(
const QVariant &value,
QgsProcessingContext &context,
bool allowNonStringValues )
const
8361 return QStringLiteral(
"None" );
8363 if ( allowNonStringValues && value.userType() == qMetaTypeId<QgsCoordinateReferenceSystem>() )
8366 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
8371 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8372 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8374 if ( allowNonStringValues )
8377 p.insert(
name(), value );
8383 const QString s = value.toString();
8389 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8391 code += QLatin1String(
"optional " );
8392 code += QLatin1String(
"coordinateoperation " );
8395 return code.trimmed();
8400 switch ( outputType )
8405 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', %2" )
8408 code += QLatin1String(
", optional=True" );
8409 if ( !mSourceParameterName.isEmpty() )
8410 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg( valueAsPythonStringPrivate( mSourceParameterName,
c,
false ) );
8411 if ( !mDestParameterName.isEmpty() )
8412 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg( valueAsPythonStringPrivate( mDestParameterName,
c,
false ) );
8414 if ( mSourceCrs.isValid() )
8415 code += QStringLiteral(
", staticSourceCrs=%1" ).arg( valueAsPythonStringPrivate( mSourceCrs,
c,
true ) );
8416 if ( mDestCrs.isValid() )
8417 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg( valueAsPythonStringPrivate( mDestCrs,
c,
true ) );
8419 code += QStringLiteral(
", defaultValue=%1)" ).arg( valueAsPythonStringPrivate(
mDefault,
c,
false ) );
8429 if ( !mSourceParameterName.isEmpty() )
8430 res << mSourceParameterName;
8431 if ( !mDestParameterName.isEmpty() )
8432 res << mDestParameterName;
8439 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
8440 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
8441 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
8442 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
8449 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
8450 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
8451 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
8452 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
8458 QString def = definition;
8460 if ( def.startsWith(
'"' ) )
8463 if ( def.endsWith(
'"' ) )
8466 else if ( def.startsWith(
'\'' ) )
8469 if ( def.endsWith(
'\'' ) )
8474 if ( def == QLatin1String(
"None" ) )
8499 if ( !input.isValid() && !
mDefault.isValid() )
8502 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8503 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8511 if ( !value.isValid() )
8512 return QStringLiteral(
"None" );
8514 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8515 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8522 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8524 code += QLatin1String(
"optional " );
8525 code += QLatin1String(
"maptheme " );
8528 return code.trimmed();
8533 switch ( outputType )
8537 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', %2" )
8540 code += QLatin1String(
", optional=True" );
8565 QString def = definition;
8566 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8568 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8590 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
8592 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
8603 QVariant input = value;
8604 if ( !input.isValid() )
8612 if ( input.userType() == qMetaTypeId<QgsProperty>() )
8617 if ( input.userType() != QMetaType::Type::QDateTime && input.userType() != QMetaType::Type::QDate && input.userType() != QMetaType::Type::QTime && input.userType() != QMetaType::Type::QString )
8623 if ( input.userType() == QMetaType::Type::QString )
8625 const QString s = input.toString();
8629 input = QDateTime::fromString( s, Qt::ISODate );
8632 if ( !input.toDateTime().isValid() )
8633 input = QTime::fromString( s );
8635 input = input.toDateTime().time();
8641 const QDateTime res = input.toDateTime();
8642 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
8646 const QTime res = input.toTime();
8647 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
8653 if ( !value.isValid() )
8654 return QStringLiteral(
"None" );
8656 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8657 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8659 if ( value.userType() == QMetaType::Type::QDateTime )
8661 const QDateTime dt = value.toDateTime();
8662 if ( !dt.isValid() )
8663 return QStringLiteral(
"QDateTime()" );
8665 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
8666 .arg( dt.date().month() )
8667 .arg( dt.date().day() )
8668 .arg( dt.time().hour() )
8669 .arg( dt.time().minute() )
8670 .arg( dt.time().second() );
8672 else if ( value.userType() == QMetaType::Type::QDate )
8674 const QDate dt = value.toDate();
8675 if ( !dt.isValid() )
8676 return QStringLiteral(
"QDate()" );
8678 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
8682 else if ( value.userType() == QMetaType::Type::QTime )
8684 const QTime dt = value.toTime();
8685 if ( !dt.isValid() )
8686 return QStringLiteral(
"QTime()" );
8688 return QStringLiteral(
"QTime(%4, %5, %6)" )
8691 .arg( dt.second() );
8693 return value.toString();
8700 if ( mMin.isValid() )
8701 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
8702 if ( mMax.isValid() )
8703 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
8707 const QString extra = parts.join( QLatin1String(
"<br />" ) );
8708 if ( !extra.isEmpty() )
8709 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
8715 switch ( outputType )
8719 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', %2" )
8722 code += QLatin1String(
", optional=True" );
8726 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
8729 if ( mMin.isValid() )
8731 if ( mMax.isValid() )
8773 map.insert( QStringLiteral(
"min" ), mMin );
8774 map.insert( QStringLiteral(
"max" ), mMax );
8775 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
8782 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
8783 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
8791 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
8802 , mProviderId( provider )
8815 if ( !input.isValid() && !
mDefault.isValid() )
8818 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8819 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8827 if ( !value.isValid() )
8828 return QStringLiteral(
"None" );
8830 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8831 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8838 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8840 code += QLatin1String(
"optional " );
8841 code += QLatin1String(
"providerconnection " );
8842 code += mProviderId +
' ';
8845 return code.trimmed();
8850 switch ( outputType )
8854 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', %2, '%3'" )
8857 code += QLatin1String(
", optional=True" );
8871 map.insert( QStringLiteral(
"provider" ), mProviderId );
8878 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
8884 QString def = definition;
8886 if ( def.contains(
' ' ) )
8888 provider = def.left( def.indexOf(
' ' ) );
8889 def = def.mid( def.indexOf(
' ' ) + 1 );
8897 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8899 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8917 , mParentConnectionParameterName( parentLayerParameterName )
8930 if ( !input.isValid() && !
mDefault.isValid() )
8933 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8934 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8942 if ( !value.isValid() )
8943 return QStringLiteral(
"None" );
8945 if ( value.userType() == qMetaTypeId<QgsProperty>() )
8946 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8953 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8955 code += QLatin1String(
"optional " );
8956 code += QLatin1String(
"databaseschema " );
8958 code += mParentConnectionParameterName +
' ';
8961 return code.trimmed();
8966 switch ( outputType )
8970 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', %2" )
8973 code += QLatin1String(
", optional=True" );
8975 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8989 QStringList depends;
8990 if ( !mParentConnectionParameterName.isEmpty() )
8991 depends << mParentConnectionParameterName;
8997 return mParentConnectionParameterName;
9002 mParentConnectionParameterName =
name;
9008 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
9015 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
9022 QString def = definition;
9024 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
9025 const QRegularExpressionMatch m = re.match( def );
9028 parent = m.captured( 1 ).trimmed();
9029 def = m.captured( 2 );
9045 const QString &connectionParameterName,
9046 const QString &schemaParameterName,
9047 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
9049 , mParentConnectionParameterName( connectionParameterName )
9050 , mParentSchemaParameterName( schemaParameterName )
9051 , mAllowNewTableNames( allowNewTableNames )
9064 if ( !input.isValid() && !
mDefault.isValid() )
9067 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
9068 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
9076 if ( !value.isValid() )
9077 return QStringLiteral(
"None" );
9079 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9080 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9087 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
9089 code += QLatin1String(
"optional " );
9090 code += QLatin1String(
"databasetable " );
9092 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
9093 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
9096 return code.trimmed();
9101 switch ( outputType )
9105 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', %2" )
9108 code += QLatin1String(
", optional=True" );
9110 if ( mAllowNewTableNames )
9111 code += QLatin1String(
", allowNewTableNames=True" );
9113 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
9114 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
9128 QStringList depends;
9129 if ( !mParentConnectionParameterName.isEmpty() )
9130 depends << mParentConnectionParameterName;
9131 if ( !mParentSchemaParameterName.isEmpty() )
9132 depends << mParentSchemaParameterName;
9138 return mParentConnectionParameterName;
9143 mParentConnectionParameterName =
name;
9148 return mParentSchemaParameterName;
9153 mParentSchemaParameterName =
name;
9159 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
9160 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
9161 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
9168 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
9169 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
9170 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
9178 QString def = definition;
9180 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
9181 const QRegularExpressionMatch m = re.match( def );
9184 connection = m.captured( 1 ).trimmed();
9185 if ( connection == QLatin1String(
"none" ) )
9187 schema = m.captured( 2 ).trimmed();
9188 if ( schema == QLatin1String(
"none" ) )
9190 def = m.captured( 3 );
9198 return mAllowNewTableNames;
9211 const QVariant &defaultValue,
bool optional )
9225 if ( !var.isValid() )
9233 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9246 if ( qobject_cast< QgsPointCloudLayer * >( qvariant_cast<QObject *>( var ) ) )
9249 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
9267 if ( !val.isValid() )
9268 return QStringLiteral(
"None" );
9270 if ( val.userType() == qMetaTypeId<QgsProperty>() )
9274 p.insert(
name(), val );
9305 const QVariant &defaultValue,
bool optional )
9318 if ( !var.isValid() )
9326 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9339 if ( qobject_cast< QgsAnnotationLayer * >( qvariant_cast<QObject *>( var ) ) )
9342 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
9360 if ( !val.isValid() )
9361 return QStringLiteral(
"None" );
9363 if ( val.userType() == qMetaTypeId<QgsProperty>() )
9367 p.insert(
name(), val );
9400 QVariant var = input;
9401 if ( !var.isValid() )
9409 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9415 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9428 if ( var.userType() != QMetaType::Type::QString )
9431 if ( var.toString().isEmpty() )
9439 if ( !value.isValid() )
9440 return QStringLiteral(
"None" );
9442 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9443 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9445 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9454 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9470 return lOriginalProvider->defaultPointCloudFileExtension();
9474 return p->defaultPointCloudFileExtension();
9485 QStringList filters;
9486 for (
const QString &ext : exts )
9488 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9490 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9497 return lOriginalProvider->supportedOutputPointCloudLayerExtensions();
9501 return p->supportedOutputPointCloudLayerExtensions();
9506 return QStringList() << ext;
9521 , mParentLayerParameterName( parentLayerParameterName )
9522 , mAllowMultiple( allowMultiple )
9523 , mDefaultToAllAttributes( defaultToAllAttributes )
9543 if ( input.userType() == qMetaTypeId<QgsProperty>() )
9548 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
9550 if ( !mAllowMultiple )
9556 else if ( input.userType() == QMetaType::Type::QString )
9558 if ( input.toString().isEmpty() )
9561 const QStringList parts = input.toString().split(
';' );
9562 if ( parts.count() > 1 && !mAllowMultiple )
9567 if ( input.toString().isEmpty() )
9575 if ( !value.isValid() )
9576 return QStringLiteral(
"None" );
9578 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9579 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9581 if ( value.userType() == QMetaType::Type::QVariantList )
9584 const auto constToList = value.toList();
9585 for (
const QVariant &val : constToList )
9589 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9591 else if ( value.userType() == QMetaType::Type::QStringList )
9594 const auto constToStringList = value.toStringList();
9595 for (
const QString &s : constToStringList )
9599 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9607 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
9609 code += QLatin1String(
"optional " );
9610 code += QLatin1String(
"attribute " );
9612 if ( mAllowMultiple )
9613 code += QLatin1String(
"multiple " );
9615 if ( mDefaultToAllAttributes )
9616 code += QLatin1String(
"default_to_all_attributes " );
9618 code += mParentLayerParameterName +
' ';
9621 return code.trimmed();
9626 switch ( outputType )
9630 QString code = QStringLiteral(
"QgsProcessingParameterPointCloudAttribute('%1', %2" )
9633 code += QLatin1String(
", optional=True" );
9635 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
9636 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
9640 if ( mDefaultToAllAttributes )
9641 code += QLatin1String(
", defaultToAllAttributes=True" );
9653 QStringList depends;
9654 if ( !mParentLayerParameterName.isEmpty() )
9655 depends << mParentLayerParameterName;
9661 return mParentLayerParameterName;
9671 return mAllowMultiple;
9681 return mDefaultToAllAttributes;
9686 mDefaultToAllAttributes = enabled;
9692 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
9693 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
9694 map.insert( QStringLiteral(
"default_to_all_attributes" ), mDefaultToAllAttributes );
9701 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
9702 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
9703 mDefaultToAllAttributes = map.value( QStringLiteral(
"default_to_all_attributes" ) ).toBool();
9712 QString def = definition;
9714 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
9717 def = def.mid( 8 ).trimmed();
9720 if ( def.startsWith( QLatin1String(
"default_to_all_attributes" ), Qt::CaseInsensitive ) )
9723 def = def.mid( 25 ).trimmed();
9726 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
9727 const QRegularExpressionMatch m = re.match( def );
9730 parent = m.captured( 1 ).trimmed();
9731 def = m.captured( 2 );
9758 QVariant var = input;
9759 if ( !var.isValid() )
9767 if ( var.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9773 if ( var.userType() == qMetaTypeId<QgsProperty>() )
9786 if ( var.userType() != QMetaType::Type::QString )
9789 if ( var.toString().isEmpty() )
9797 if ( !value.isValid() )
9798 return QStringLiteral(
"None" );
9800 if ( value.userType() == qMetaTypeId<QgsProperty>() )
9801 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9803 if ( value.userType() == qMetaTypeId<QgsProcessingOutputLayerDefinition>() )
9812 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9832 QStringList filters;
9833 for (
const QString &ext : exts )
9835 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9837 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9843 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)
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 generateTempFilename(const QString &basename, const QgsProcessingContext *context=nullptr)
Returns a temporary filename for a given file, putting it into a temporary folder (creating that fold...
static QString encodeProviderKeyAndUri(const QString &providerKey, const QString &uri)
Encodes a provider key and layer uri to a single string, for use with decodeProviderKeyAndUri()
LayerHint
Layer type hints.
@ Annotation
Annotation layer type, since QGIS 3.22.
@ Vector
Vector layer type.
@ VectorTile
Vector tile layer type, since QGIS 3.32.
@ Mesh
Mesh layer type, since QGIS 3.6.
@ Raster
Raster layer type.
@ UnknownType
Unknown layer type.
@ PointCloud
Point cloud layer type, since QGIS 3.22.
static QString layerToStringIdentifier(const QgsMapLayer *layer)
Returns a string representation of the source for a layer.
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.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
bool isNull() const
Test if the rectangle is null (holding no spatial information).
double yMaximum() const
Returns the y maximum value (top side of rectangle).
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