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() == QMetaType::type(
"QgsProperty" ) )
139 QVariant val = value;
140 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
143 if ( !val.isValid() )
152 return destParam->generateTemporaryDestination( &context );
155 return val.toString();
171 const QVariant val = value;
172 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
175 if ( val.isValid() && !val.toString().isEmpty() )
179 return val.toString();
199 QVariant val = value;
200 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
204 const double res = val.toDouble( &ok );
210 return val.toDouble();
226 QVariant val = value;
227 if ( val.userType() == QMetaType::type(
"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() == QMetaType::type(
"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() == QMetaType::type(
"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() == QMetaType::type(
"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() == QMetaType::type(
"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() == QMetaType::type(
"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() == QMetaType::type(
"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() == QMetaType::type(
"QgsProperty" ) )
633 else if ( val.isValid() )
646 const QVariant val = value;
647 if ( val.userType() == QMetaType::type(
"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() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
689 useRemapDefinition =
true;
695 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
699 else if ( !val.isValid() || val.toString().isEmpty() )
715 dest = val.toString();
720 dest = destParam->generateTemporaryDestination( &context );
723 if ( dest.isEmpty() )
726 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType,
crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition : nullptr ) );
727 destinationIdentifier = dest;
729 if ( destinationProject )
731 if ( destName.isEmpty() && definition )
737 outputName = definition->
name();
741 return sink.release();
669QgsFeatureSink *
QgsProcessingParameters::parameterAsSink(
const QgsProcessingParameterDefinition *definition,
const QVariant &value,
const QgsFields &fields,
Qgis::WkbType geometryType,
const QgsCoordinateReferenceSystem &
crs,
QgsProcessingContext &context, QString &destinationIdentifier,
QgsFeatureSink::SinkFlags sinkFlags,
const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions ) {
…}
765 QVariant val = parameters.value( definition->
name() );
767 bool selectedFeaturesOnly =
false;
768 long long featureLimit = -1;
769 QString filterExpression;
770 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
779 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
786 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
792 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
797 if ( val.userType() == QMetaType::type(
"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() == QMetaType::type(
"QgsProperty" ) )
872 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
877 if ( val.userType() == QMetaType::type(
"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() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
956 if ( definition && val.userType() == QMetaType::type(
"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() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1024 if ( definition && val.userType() == QMetaType::type(
"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() == QMetaType::type(
"QgsRectangle" ) )
1091 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1097 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1116 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1122 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1135 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1138 if ( val.userType() == QMetaType::type(
"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() == QMetaType::type(
"QgsReferencedRectangle" ) )
1217 g = g.densifyByCount( 20 );
1231 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1237 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1250 if ( val.userType() == QMetaType::type(
"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() == QMetaType::type(
"QgsReferencedRectangle" ) )
1340 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1346 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1358 QString valueAsString;
1359 if ( val.userType() == QMetaType::type(
"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() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1380 else if ( val.userType() == QMetaType::type(
"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() == QMetaType::type(
"QgsPointXY" ) )
1422 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1428 if ( val.userType() == QMetaType::type(
"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() == QMetaType::type(
"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() == QMetaType::type(
"QgsGeometry" ) )
1541 if ( val.userType() == QMetaType::type(
"QgsPointXY" ) )
1546 if ( val.userType() == QMetaType::type(
"QgsRectangle" ) )
1551 if ( val.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1569 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1575 g = g.densifyByCount( 20 );
1589 if ( val.userType() == QMetaType::type(
"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() == QMetaType::type(
"QgsReferencedGeometry" ) )
1659 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1668 if ( value.userType() == QMetaType::type(
"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() == QMetaType::type(
"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() == QMetaType::type(
"QgsProperty" ) )
1803 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1807 const QVariant sink = fromVar.
sink;
1808 if ( sink.userType() == QMetaType::type(
"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() == QMetaType::type(
"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() == QMetaType::type(
"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() == QMetaType::type(
"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() == QMetaType::type(
"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(
"duration" ) )
2343 else if ( type == QLatin1String(
"scale" ) )
2345 else if ( type == QLatin1String(
"range" ) )
2347 else if ( type == QLatin1String(
"raster" ) )
2349 else if ( type == QLatin1String(
"enum" ) )
2351 else if ( type == QLatin1String(
"string" ) )
2353 else if ( type == QLatin1String(
"authcfg" ) )
2355 else if ( type == QLatin1String(
"expression" ) )
2357 else if ( type == QLatin1String(
"field" ) )
2359 else if ( type == QLatin1String(
"vector" ) )
2361 else if ( type == QLatin1String(
"source" ) )
2363 else if ( type == QLatin1String(
"sink" ) )
2365 else if ( type == QLatin1String(
"vectordestination" ) )
2367 else if ( type == QLatin1String(
"rasterdestination" ) )
2369 else if ( type == QLatin1String(
"pointclouddestination" ) )
2371 else if ( type == QLatin1String(
"filedestination" ) )
2373 else if ( type == QLatin1String(
"folderdestination" ) )
2375 else if ( type == QLatin1String(
"band" ) )
2377 else if ( type == QLatin1String(
"mesh" ) )
2379 else if ( type == QLatin1String(
"layout" ) )
2381 else if ( type == QLatin1String(
"layoutitem" ) )
2383 else if ( type == QLatin1String(
"color" ) )
2385 else if ( type == QLatin1String(
"coordinateoperation" ) )
2387 else if ( type == QLatin1String(
"maptheme" ) )
2389 else if ( type == QLatin1String(
"datetime" ) )
2391 else if ( type == QLatin1String(
"providerconnection" ) )
2393 else if ( type == QLatin1String(
"databaseschema" ) )
2395 else if ( type == QLatin1String(
"databasetable" ) )
2397 else if ( type == QLatin1String(
"pointcloud" ) )
2399 else if ( type == QLatin1String(
"annotation" ) )
2401 else if ( type == QLatin1String(
"attribute" ) )
2403 else if ( type == QLatin1String(
"vectortiledestination" ) )
2409bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2411 const thread_local QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
2412 QRegularExpressionMatch m = re.match( code );
2413 if ( !m.hasMatch() )
2416 name = m.captured( 1 );
2417 QString tokens = m.captured( 2 );
2418 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
2421 tokens.remove( 0, 8 );
2428 tokens = tokens.trimmed();
2430 const thread_local QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2431 m = re2.match( tokens );
2432 if ( !m.hasMatch() )
2434 type = tokens.toLower().trimmed();
2439 type = m.captured( 1 ).toLower().trimmed();
2440 definition = m.captured( 2 );
2451 , mDescription( description )
2453 , mDefault( defaultValue )
2454 , mFlags( optional ?
Qgis::ProcessingParameterFlag::Optional :
Qgis::ProcessingParameterFlag() )
2460 if ( defaultSettingsValue.isValid() )
2462 return defaultSettingsValue;
2470 if ( defaultSettingsValue.isValid() )
2472 return defaultSettingsValue;
2482 QVariant settingValue = s.
value( QStringLiteral(
"/Processing/DefaultGuiParam/%1/%2" ).arg(
mAlgorithm->
id() ).arg(
mName ) );
2483 if ( settingValue.isValid() )
2485 return settingValue;
2493 if ( !input.isValid() && !
mDefault.isValid() )
2496 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
2497 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
2505 if ( !value.isValid() )
2506 return QStringLiteral(
"None" );
2508 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2509 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2521 if ( !value.isValid() )
2525 if ( value.userType() == QMetaType::Type::QVariantMap )
2527 const QVariantMap sourceMap = value.toMap();
2528 QVariantMap resultMap;
2529 for (
auto it = sourceMap.constBegin(); it != sourceMap.constEnd(); it++ )
2535 else if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
2537 const QVariantList sourceList = value.toList();
2538 QVariantList resultList;
2539 resultList.reserve( sourceList.size() );
2540 for (
const QVariant &v : sourceList )
2548 switch ( value.userType() )
2551 case QMetaType::Bool:
2552 case QMetaType::Char:
2553 case QMetaType::Int:
2554 case QMetaType::Double:
2555 case QMetaType::Float:
2556 case QMetaType::LongLong:
2557 case QMetaType::ULongLong:
2558 case QMetaType::UInt:
2559 case QMetaType::ULong:
2560 case QMetaType::UShort:
2567 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2577 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"field" ), prop.
field() }} );
2579 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"expression" ), prop.
expressionString() }} );
2584 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2594 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2602 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2611 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2623 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2638 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2644 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2651 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2658 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2663 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2665 const QColor fromVar = value.value< QColor >();
2666 if ( !fromVar.isValid() )
2669 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2671 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2673 const QDateTime fromVar = value.toDateTime();
2674 if ( !fromVar.isValid() )
2677 return fromVar.toString( Qt::ISODate );
2679 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2681 const QDate fromVar = value.toDate();
2682 if ( !fromVar.isValid() )
2685 return fromVar.toString( Qt::ISODate );
2687 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2689 const QTime fromVar = value.toTime();
2690 if ( !fromVar.isValid() )
2693 return fromVar.toString( Qt::ISODate );
2700 p.insert(
name(), value );
2708 if ( value.userType() == QMetaType::QString )
2713 Q_ASSERT_X(
false,
"QgsProcessingParameterDefinition::valueAsJsonObject", QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ).toLocal8Bit() );
2726 if ( !value.isValid() )
2729 switch ( value.userType() )
2732 case QMetaType::Bool:
2733 case QMetaType::Char:
2734 case QMetaType::Int:
2735 case QMetaType::Double:
2736 case QMetaType::Float:
2737 case QMetaType::LongLong:
2738 case QMetaType::ULongLong:
2739 case QMetaType::UInt:
2740 case QMetaType::ULong:
2741 case QMetaType::UShort:
2742 return value.toString();
2748 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2758 return QStringLiteral(
"field:%1" ).arg( prop.
field() );
2765 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2775 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2783 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2791 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2803 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2818 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2824 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2831 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2836 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2841 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2843 const QColor fromVar = value.value< QColor >();
2844 if ( !fromVar.isValid() )
2847 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2849 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2851 const QDateTime fromVar = value.toDateTime();
2852 if ( !fromVar.isValid() )
2855 return fromVar.toString( Qt::ISODate );
2857 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2859 const QDate fromVar = value.toDate();
2860 if ( !fromVar.isValid() )
2863 return fromVar.toString( Qt::ISODate );
2865 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2867 const QTime fromVar = value.toTime();
2868 if ( !fromVar.isValid() )
2871 return fromVar.toString( Qt::ISODate );
2878 p.insert(
name(), value );
2886 if ( value.userType() == QMetaType::QString )
2887 return value.toString();
2890 QgsDebugError( QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ) );
2892 return value.toString();
2898 if ( !value.isValid( ) )
2899 return QStringList();
2901 if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
2903 const QVariantList sourceList = value.toList();
2904 QStringList resultList;
2905 resultList.reserve( sourceList.size() );
2906 for (
const QVariant &v : sourceList )
2915 return QStringList();
2927 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2929 code += QLatin1String(
"optional " );
2930 code +=
type() +
' ';
2932 return code.trimmed();
2940 switch ( outputType )
2944 QString code = t->className() + QStringLiteral(
"('%1', %2" )
2947 code += QLatin1String(
", optional=True" );
2963 map.insert( QStringLiteral(
"parameter_type" ),
type() );
2964 map.insert( QStringLiteral(
"name" ),
mName );
2965 map.insert( QStringLiteral(
"description" ),
mDescription );
2966 map.insert( QStringLiteral(
"help" ),
mHelp );
2967 map.insert( QStringLiteral(
"default" ),
mDefault );
2968 map.insert( QStringLiteral(
"defaultGui" ),
mGuiDefault );
2969 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
mFlags ) );
2970 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
2976 mName = map.value( QStringLiteral(
"name" ) ).toString();
2977 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
2978 mHelp = map.value( QStringLiteral(
"help" ) ).toString();
2979 mDefault = map.value( QStringLiteral(
"default" ) );
2980 mGuiDefault = map.value( QStringLiteral(
"defaultGui" ) );
2982 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
2998 QString text = QStringLiteral(
"<p><b>%1</b></p>" ).arg(
description() );
2999 if ( !
help().isEmpty() )
3001 text += QStringLiteral(
"<p>%1</p>" ).arg(
help() );
3003 text += QStringLiteral(
"<p>%1</p>" ).arg( QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
3018 if ( !val.isValid() )
3019 return QStringLiteral(
"None" );
3021 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
3023 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
3028 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3030 code += QLatin1String(
"optional " );
3031 code +=
type() +
' ';
3032 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
3033 return code.trimmed();
3055 if ( !input.isValid() )
3063 if ( input.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
3067 else if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3071 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3076 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3081 if ( input.type() == QVariant::String )
3083 const QString
string = input.toString();
3084 if (
string.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
3093 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3096 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3104 if ( !value.isValid() )
3105 return QStringLiteral(
"None" );
3107 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
3110 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
3115 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3116 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3118 if ( value.type() == QVariant::String )
3120 const QString
string = value.toString();
3121 if (
string.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
3130 p.insert(
name(), value );
3140 if ( value.type() == QVariant::String )
3142 const QString
string = value.toString();
3143 if (
string.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
3156 if ( value.type() == QVariant::String )
3158 const QString
string = value.toString();
3159 if (
string.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
3191 if ( !input.isValid() )
3199 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3204 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3209 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3227 if ( !val.isValid() )
3228 return QStringLiteral(
"None" );
3230 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
3234 p.insert(
name(), val );
3254 for (
const QString &raster : rasters )
3256 if ( !vectors.contains( raster ) )
3260 for (
const QString &mesh : meshFilters )
3262 if ( !vectors.contains( mesh ) )
3266 for (
const QString &pointCloud : pointCloudFilters )
3268 if ( !vectors.contains( pointCloud ) )
3269 vectors << pointCloud;
3271 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
3272 std::sort( vectors.begin(), vectors.end() );
3274 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QLatin1String(
";;" ) );
3284 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3286 code += QLatin1String(
"optional " );
3287 code += QLatin1String(
"layer " );
3294 code += QLatin1String(
"hasgeometry " );
3298 code += QLatin1String(
"point " );
3302 code += QLatin1String(
"line " );
3306 code += QLatin1String(
"polygon " );
3310 code += QLatin1String(
"raster " );
3314 code += QLatin1String(
"mesh " );
3318 code += QLatin1String(
"plugin " );
3322 code += QLatin1String(
"pointcloud " );
3326 code += QLatin1String(
"annotation " );
3335 return code.trimmed();
3341 QString def = definition;
3344 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
3347 def = def.mid( 12 );
3350 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
3356 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
3362 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
3368 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
3374 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
3380 else if ( def.startsWith( QLatin1String(
"plugin" ), Qt::CaseInsensitive ) )
3386 else if ( def.startsWith( QLatin1String(
"pointcloud" ), Qt::CaseInsensitive ) )
3389 def = def.mid( 11 );
3392 else if ( def.startsWith( QLatin1String(
"annotation" ), Qt::CaseInsensitive ) )
3395 def = def.mid( 11 );
3406 switch ( outputType )
3410 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', %2" )
3413 code += QLatin1String(
", optional=True" );
3420 QStringList options;
3424 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
3428 code += QLatin1Char(
')' );
3445 map.insert( QStringLiteral(
"data_types" ), types );
3453 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3454 for (
const QVariant &val : values )
3475 if ( !input.isValid() )
3483 if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3487 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3492 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3497 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3502 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3506 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3513 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3516 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
3519 if ( variantIsValidStringForExtent( input ) )
3532bool QgsProcessingParameterExtent::variantIsValidStringForExtent(
const QVariant &value )
3534 if ( value.userType() == QMetaType::Type::QString )
3536 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
3537 const QRegularExpressionMatch match = rx.match( value.toString() );
3538 if ( match.hasMatch() )
3540 bool xMinOk =
false;
3541 ( void )match.captured( 1 ).toDouble( &xMinOk );
3542 bool xMaxOk =
false;
3543 ( void )match.captured( 2 ).toDouble( &xMaxOk );
3544 bool yMinOk =
false;
3545 ( void )match.captured( 3 ).toDouble( &yMinOk );
3546 bool yMaxOk =
false;
3547 ( void )match.captured( 4 ).toDouble( &yMaxOk );
3548 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
3557 if ( !value.isValid() )
3558 return QStringLiteral(
"None" );
3560 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3561 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3563 if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
3571 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3579 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3584 const QString wkt = g.
asWkt();
3585 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3588 else if ( variantIsValidStringForExtent( value ) )
3594 p.insert(
name(), value );
3604 if ( variantIsValidStringForExtent( value ) )
3606 return value.toString();
3614 if ( variantIsValidStringForExtent( value ) )
3641 if ( !input.isValid() )
3649 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3654 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3658 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3662 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3667 if ( input.userType() == QMetaType::Type::QString )
3669 if ( input.toString().isEmpty() )
3673 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3675 const QRegularExpressionMatch match = rx.match( input.toString() );
3676 if ( match.hasMatch() )
3679 ( void )match.captured( 1 ).toDouble( &xOk );
3681 ( void )match.captured( 2 ).toDouble( &yOk );
3690 if ( !value.isValid() )
3691 return QStringLiteral(
"None" );
3693 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3694 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3696 if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
3702 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3709 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3714 const QString wkt = g.
asWkt();
3715 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3728 const QVariant &defaultValue,
bool optional,
const QList<int> &geometryTypes,
bool allowMultipart )
3730 mGeomTypes( geometryTypes ),
3731 mAllowMultipart( allowMultipart )
3744 if ( !input.isValid() )
3752 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3759 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3761 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( input.value<
QgsGeometry>().
type() ) ) ) &&
3762 ( mAllowMultipart || !input.value<
QgsGeometry>().isMultipart() );
3765 if ( input.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3771 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3776 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3781 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3786 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3791 if ( input.userType() == QMetaType::Type::QString )
3793 if ( input.toString().isEmpty() )
3798 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3800 const QRegularExpressionMatch match = rx.match( input.toString() );
3801 if ( match.hasMatch() )
3806 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( g.
type() ) ) ) && ( mAllowMultipart || !g.
isMultipart() );
3826 if ( !value.isValid() )
3827 return QStringLiteral(
"None" );
3829 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3832 if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3839 if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3846 if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
3853 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3860 if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
3867 if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3879 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3881 code += QLatin1String(
"optional " );
3882 code +=
type() +
' ';
3884 for (
const int type : mGeomTypes )
3889 code += QLatin1String(
"point " );
3893 code += QLatin1String(
"line " );
3897 code += QLatin1String(
"polygon " );
3901 code += QLatin1String(
"unknown " );
3907 return code.trimmed();
3912 switch ( outputType )
3916 QString code = QStringLiteral(
"QgsProcessingParameterGeometry('%1', %2" )
3919 code += QLatin1String(
", optional=True" );
3921 if ( !mGeomTypes.empty() )
3928 return QStringLiteral(
"PointGeometry" );
3931 return QStringLiteral(
"LineGeometry" );
3934 return QStringLiteral(
"PolygonGeometry" );
3937 return QStringLiteral(
"UnknownGeometry" );
3940 return QStringLiteral(
"NullGeometry" );
3945 QStringList options;
3946 options.reserve( mGeomTypes.size() );
3947 for (
const int type : mGeomTypes )
3949 options << QStringLiteral(
" QgsWkbTypes.%1" ).arg( geomTypeToString(
static_cast<Qgis::GeometryType>(
type ) ) );
3951 code += QStringLiteral(
", geometryTypes=[%1 ]" ).arg( options.join(
',' ) );
3954 if ( ! mAllowMultipart )
3956 code += QLatin1String(
", allowMultipart=False" );
3971 for (
const int type : mGeomTypes )
3975 map.insert( QStringLiteral(
"geometrytypes" ), types );
3976 map.insert( QStringLiteral(
"multipart" ), mAllowMultipart );
3984 const QVariantList values = map.value( QStringLiteral(
"geometrytypes" ) ).toList();
3985 for (
const QVariant &val : values )
3987 mGeomTypes << val.toInt();
3989 mAllowMultipart = map.value( QStringLiteral(
"multipart" ) ).toBool();
4000 , mBehavior( behavior )
4001 , mExtension( fileFilter.isEmpty() ? extension : QString() )
4002 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
4015 if ( !input.isValid() )
4023 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4028 const QString
string = input.toString().trimmed();
4030 if ( input.userType() != QMetaType::Type::QString ||
string.isEmpty() )
4033 switch ( mBehavior )
4037 if ( !mExtension.isEmpty() )
4039 return string.endsWith( mExtension, Qt::CaseInsensitive );
4041 else if ( !mFileFilter.isEmpty() )
4059 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4061 code += QLatin1String(
"optional " );
4064 return code.trimmed();
4069 switch ( outputType )
4074 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', %2" )
4077 code += QLatin1String(
", optional=True" );
4078 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
Qgis::ProcessingFileParameterBehavior::File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
4079 if ( !mExtension.isEmpty() )
4080 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
4081 if ( !mFileFilter.isEmpty() )
4082 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
4093 switch ( mBehavior )
4097 if ( !mFileFilter.isEmpty() )
4098 return mFileFilter != QObject::tr(
"All files (*.*)" ) ? mFileFilter + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" ) : mFileFilter;
4099 else if ( !mExtension.isEmpty() )
4100 return QObject::tr(
"%1 files" ).arg( mExtension.toUpper() ) + QStringLiteral(
" (*." ) + mExtension.toLower() + QStringLiteral(
");;" ) + QObject::tr(
"All files (*.*)" );
4102 return QObject::tr(
"All files (*.*)" );
4114 mFileFilter.clear();
4124 mFileFilter = filter;
4131 map.insert( QStringLiteral(
"behavior" ),
static_cast< int >( mBehavior ) );
4132 map.insert( QStringLiteral(
"extension" ), mExtension );
4133 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
4141 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
4142 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
4153 , mHeaders( headers )
4154 , mNumberRows( numberRows )
4155 , mFixedNumberRows( fixedNumberRows )
4168 if ( !input.isValid() )
4176 if ( input.userType() == QMetaType::Type::QString )
4178 if ( input.toString().isEmpty() )
4182 else if ( input.userType() == QMetaType::Type::QVariantList )
4184 if ( input.toList().isEmpty() )
4188 else if ( input.userType() == QMetaType::Type::Double || input.userType() == QMetaType::Type::Int )
4198 if ( !value.isValid() )
4199 return QStringLiteral(
"None" );
4201 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4202 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4205 p.insert(
name(), value );
4213 switch ( outputType )
4217 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', %2" )
4220 code += QLatin1String(
", optional=True" );
4221 code += QStringLiteral(
", numberRows=%1" ).arg( mNumberRows );
4222 code += QStringLiteral(
", hasFixedNumberRows=%1" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4225 headers.reserve( mHeaders.size() );
4226 for (
const QString &h : mHeaders )
4228 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
4260 return mFixedNumberRows;
4265 mFixedNumberRows = fixedNumberRows;
4271 map.insert( QStringLiteral(
"headers" ), mHeaders );
4272 map.insert( QStringLiteral(
"rows" ), mNumberRows );
4273 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
4280 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
4281 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
4282 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
4293 , mLayerType( layerType )
4306 if ( !input.isValid() )
4316 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
4322 if ( input.userType() == QMetaType::Type::QString )
4324 if ( input.toString().isEmpty() )
4327 if ( mMinimumNumberInputs > 1 )
4338 else if ( input.userType() == QMetaType::Type::QVariantList )
4340 if ( input.toList().count() < mMinimumNumberInputs )
4343 if ( mMinimumNumberInputs > input.toList().count() )
4351 const auto constToList = input.toList();
4352 for (
const QVariant &v : constToList )
4354 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
4363 else if ( input.userType() == QMetaType::Type::QStringList )
4365 if ( input.toStringList().count() < mMinimumNumberInputs )
4368 if ( mMinimumNumberInputs > input.toStringList().count() )
4376 const auto constToStringList = input.toStringList();
4377 for (
const QString &v : constToStringList )
4390 if ( !value.isValid() )
4391 return QStringLiteral(
"None" );
4393 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4394 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4399 if ( value.userType() == QMetaType::Type::QStringList )
4401 const QStringList list = value.toStringList();
4402 parts.reserve( list.count() );
4403 for (
const QString &v : list )
4406 else if ( value.userType() == QMetaType::Type::QVariantList )
4408 const QVariantList list = value.toList();
4409 parts.reserve( list.count() );
4410 for (
const QVariant &v : list )
4413 if ( !parts.isEmpty() )
4414 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4419 p.insert(
name(), value );
4421 if ( !list.isEmpty() )
4424 parts.reserve( list.count() );
4429 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4448 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4450 code += QLatin1String(
"optional " );
4451 switch ( mLayerType )
4454 code += QLatin1String(
"multiple raster" );
4458 code += QLatin1String(
"multiple file" );
4462 code += QLatin1String(
"multiple vector" );
4466 if (
mDefault.userType() == QMetaType::Type::QVariantList )
4469 const auto constToList =
mDefault.toList();
4470 for (
const QVariant &var : constToList )
4472 parts << var.toString();
4474 code += parts.join(
',' );
4476 else if (
mDefault.userType() == QMetaType::Type::QStringList )
4478 code +=
mDefault.toStringList().join(
',' );
4484 return code.trimmed();
4489 switch ( outputType )
4493 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', %2" )
4496 code += QLatin1String(
", optional=True" );
4500 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
4511 switch ( mLayerType )
4514 return QObject::tr(
"All files (*.*)" );
4553 return mMinimumNumberInputs;
4565 map.insert( QStringLiteral(
"layer_type" ),
static_cast< int >( mLayerType ) );
4566 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
4574 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
4580 QString
type = definition;
4582 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
4583 const QRegularExpressionMatch m = re.match( definition );
4586 type = m.captured( 1 ).toLower().trimmed();
4587 defaultVal = m.captured( 2 );
4590 if (
type == QLatin1String(
"vector" ) )
4592 else if (
type == QLatin1String(
"raster" ) )
4594 else if (
type == QLatin1String(
"file" ) )
4607 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
4618 QVariant input = value;
4619 if ( !input.isValid() )
4627 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4633 const double res = input.toDouble( &ok );
4637 return !( res < mMin || res > mMax );
4642 if ( !value.isValid() )
4643 return QStringLiteral(
"None" );
4645 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4646 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4648 return value.toString();
4655 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
4656 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
4657 if ( mMax < std::numeric_limits<double>::max() )
4658 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
4661 const QString extra = parts.join( QLatin1String(
"<br />" ) );
4662 if ( !extra.isEmpty() )
4663 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
4669 switch ( outputType )
4673 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', %2" )
4676 code += QLatin1String(
", optional=True" );
4678 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Qgis::ProcessingNumberParameterType::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4680 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
4681 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
4682 if ( mMax != std::numeric_limits<double>::max() )
4683 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
4725 map.insert( QStringLiteral(
"min" ), mMin );
4726 map.insert( QStringLiteral(
"max" ), mMax );
4727 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
4734 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
4735 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
4743 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4761 if ( !input.isValid() )
4769 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4774 if ( input.userType() == QMetaType::Type::QString )
4776 const QStringList list = input.toString().split(
',' );
4777 if ( list.count() != 2 )
4780 list.at( 0 ).toDouble( &ok );
4782 list.at( 1 ).toDouble( &ok2 );
4787 else if ( input.userType() == QMetaType::Type::QVariantList )
4789 if ( input.toList().count() != 2 )
4793 input.toList().at( 0 ).toDouble( &ok );
4795 input.toList().at( 1 ).toDouble( &ok2 );
4806 if ( !value.isValid() )
4807 return QStringLiteral(
"None" );
4809 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4810 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4813 p.insert(
name(), value );
4816 QStringList stringParts;
4817 const auto constParts = parts;
4818 for (
const double v : constParts )
4820 stringParts << QString::number( v );
4822 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
4827 switch ( outputType )
4831 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', %2" )
4834 code += QLatin1String(
", optional=True" );
4836 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Qgis::ProcessingNumberParameterType::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4859 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
4873 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4890 if ( !input.isValid() )
4898 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4903 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4906 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
4924 if ( !val.isValid() )
4925 return QStringLiteral(
"None" );
4927 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
4931 p.insert(
name(), val );
4959 , mOptions( options )
4960 , mAllowMultiple( allowMultiple )
4961 , mUsesStaticStrings( usesStaticStrings )
4973 QVariant input = value;
4974 if ( !input.isValid() )
4982 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4987 if ( mUsesStaticStrings )
4989 if ( input.userType() == QMetaType::Type::QVariantList )
4991 if ( !mAllowMultiple )
4994 const QVariantList values = input.toList();
4998 for (
const QVariant &val : values )
5000 if ( !mOptions.contains( val.toString() ) )
5006 else if ( input.userType() == QMetaType::Type::QStringList )
5008 if ( !mAllowMultiple )
5011 const QStringList values = input.toStringList();
5016 if ( values.count() > 1 && !mAllowMultiple )
5019 for (
const QString &val : values )
5021 if ( !mOptions.contains( val ) )
5026 else if ( input.userType() == QMetaType::Type::QString )
5028 const QStringList parts = input.toString().split(
',' );
5029 if ( parts.count() > 1 && !mAllowMultiple )
5032 const auto constParts = parts;
5033 for (
const QString &part : constParts )
5035 if ( !mOptions.contains( part ) )
5043 if ( input.userType() == QMetaType::Type::QVariantList )
5045 if ( !mAllowMultiple )
5048 const QVariantList values = input.toList();
5052 for (
const QVariant &val : values )
5055 const int res = val.toInt( &ok );
5058 else if ( res < 0 || res >= mOptions.count() )
5064 else if ( input.userType() == QMetaType::Type::QString )
5066 const QStringList parts = input.toString().split(
',' );
5067 if ( parts.count() > 1 && !mAllowMultiple )
5070 const auto constParts = parts;
5071 for (
const QString &part : constParts )
5074 const int res = part.toInt( &ok );
5077 else if ( res < 0 || res >= mOptions.count() )
5082 else if ( input.userType() == QMetaType::Type::Int || input.userType() == QMetaType::Type::Double )
5085 const int res = input.toInt( &ok );
5088 else if ( res >= 0 && res < mOptions.count() )
5098 if ( !value.isValid() )
5099 return QStringLiteral(
"None" );
5101 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5102 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5104 if ( mUsesStaticStrings )
5106 if ( value.userType() == QMetaType::Type::QVariantList || value.userType() == QMetaType::Type::QStringList )
5109 const QStringList constList = value.toStringList();
5110 for (
const QString &val : constList )
5114 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5116 else if ( value.userType() == QMetaType::Type::QString )
5119 const QStringList constList = value.toString().split(
',' );
5120 if ( constList.count() > 1 )
5122 for (
const QString &val : constList )
5126 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5134 if ( value.userType() == QMetaType::Type::QVariantList )
5137 const auto constToList = value.toList();
5138 for (
const QVariant &val : constToList )
5140 parts << QString::number( static_cast< int >( val.toDouble() ) );
5142 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5144 else if ( value.userType() == QMetaType::Type::QString )
5146 const QStringList parts = value.toString().split(
',' );
5147 if ( parts.count() > 1 )
5149 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5153 return QString::number(
static_cast< int >( value.toDouble() ) );
5159 if ( !value.isValid() )
5162 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5165 if ( mUsesStaticStrings )
5171 if ( value.userType() == QMetaType::Type::QVariantList )
5174 const QVariantList toList = value.toList();
5175 parts.reserve( toList.size() );
5176 for (
const QVariant &val : toList )
5178 parts << mOptions.value(
static_cast< int >( val.toDouble() ) );
5180 return parts.join(
',' );
5182 else if ( value.userType() == QMetaType::Type::QString )
5184 const QStringList parts = value.toString().split(
',' );
5185 QStringList comments;
5186 if ( parts.count() > 1 )
5188 for (
const QString &part : parts )
5191 const int val = part.toInt( &ok );
5193 comments << mOptions.value( val );
5195 return comments.join(
',' );
5199 return mOptions.value(
static_cast< int >( value.toDouble() ) );
5205 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5207 code += QLatin1String(
"optional " );
5208 code += QLatin1String(
"enum " );
5210 if ( mAllowMultiple )
5211 code += QLatin1String(
"multiple " );
5213 if ( mUsesStaticStrings )
5214 code += QLatin1String(
"static " );
5216 code += mOptions.join(
';' ) +
' ';
5219 return code.trimmed();
5224 switch ( outputType )
5228 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', %2" )
5231 code += QLatin1String(
", optional=True" );
5234 options.reserve( mOptions.size() );
5235 for (
const QString &o : mOptions )
5237 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
5239 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5241 code += QStringLiteral(
", usesStaticStrings=%1" ).arg( mUsesStaticStrings ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5264 return mAllowMultiple;
5274 return mUsesStaticStrings;
5285 map.insert( QStringLiteral(
"options" ), mOptions );
5286 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5287 map.insert( QStringLiteral(
"uses_static_strings" ), mUsesStaticStrings );
5294 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
5295 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5296 mUsesStaticStrings = map.value( QStringLiteral(
"uses_static_strings" ) ).toBool();
5303 QString def = definition;
5305 bool multiple =
false;
5306 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5312 bool staticStrings =
false;
5313 if ( def.startsWith( QLatin1String(
"static" ), Qt::CaseInsensitive ) )
5315 staticStrings =
true;
5319 const thread_local QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
5320 const QRegularExpressionMatch m = re.match( def );
5321 QString values = def;
5324 values = m.captured( 1 ).trimmed();
5325 defaultVal = m.captured( 2 );
5333 , mMultiLine( multiLine )
5346 return QStringLiteral(
"None" );
5348 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5349 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5351 const QString s = value.toString();
5357 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5359 code += QLatin1String(
"optional " );
5360 code += QLatin1String(
"string " );
5363 code += QLatin1String(
"long " );
5366 return code.trimmed();
5371 switch ( outputType )
5375 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', %2" )
5378 code += QLatin1String(
", optional=True" );
5379 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5402 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
5409 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
5415 QString def = definition;
5417 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
5423 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5425 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5429 if ( def == QLatin1String(
"None" ) )
5452 if ( !value.isValid() )
5453 return QStringLiteral(
"None" );
5455 const QString s = value.toString();
5461 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5463 code += QLatin1String(
"optional " );
5464 code += QLatin1String(
"authcfg " );
5467 return code.trimmed();
5472 QString def = definition;
5474 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5476 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5480 if ( def == QLatin1String(
"None" ) )
5493 , mParentLayerParameterName( parentLayerParameterName )
5494 , mExpressionType( type )
5506 if ( !value.isValid() )
5507 return QStringLiteral(
"None" );
5509 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5510 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5512 const QString s = value.toString();
5518 QStringList depends;
5519 if ( !mParentLayerParameterName.isEmpty() )
5520 depends << mParentLayerParameterName;
5526 switch ( outputType )
5530 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', %2" )
5533 code += QLatin1String(
", optional=True" );
5535 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5541 switch ( mExpressionType )
5544 code += QLatin1String(
", type=Qgis.ExpressionType.PointCloud)" );
5547 code += QLatin1String(
", type=Qgis.ExpressionType.RasterCalculator)" );
5550 code += QLatin1Char(
')' );
5561 return mParentLayerParameterName;
5571 return mExpressionType;
5582 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5583 map.insert( QStringLiteral(
"expression_type" ),
static_cast< int >( mExpressionType ) );
5590 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5591 mExpressionType =
static_cast< Qgis::ExpressionType >( map.value( QStringLiteral(
"expression_type" ) ).toInt() );
5616 if ( !var.isValid() )
5624 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5637 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
5640 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
5658 if ( !val.isValid() )
5659 return QStringLiteral(
"None" );
5661 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
5665 p.insert(
name(), val );
5683 switch ( outputType )
5687 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', %2" )
5690 code += QLatin1String(
", optional=True" );
5694 QStringList options;
5697 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
5731 map.insert( QStringLiteral(
"data_types" ), types );
5739 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
5740 for (
const QVariant &val : values )
5753 const QVariant &defaultValue,
bool optional )
5768 if ( !var.isValid() )
5776 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5789 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
5792 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
5810 if ( !val.isValid() )
5811 return QStringLiteral(
"None" );
5813 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
5817 p.insert(
name(), val );
5845 , mParentLayerParameterName( parentLayerParameterName )
5847 , mAllowMultiple( allowMultiple )
5848 , mDefaultToAllFields( defaultToAllFields )
5862 if ( !input.isValid() )
5870 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
5875 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
5877 if ( !mAllowMultiple )
5883 else if ( input.userType() == QMetaType::Type::QString )
5885 if ( input.toString().isEmpty() )
5888 const QStringList parts = input.toString().split(
';' );
5889 if ( parts.count() > 1 && !mAllowMultiple )
5894 if ( input.toString().isEmpty() )
5902 if ( !value.isValid() )
5903 return QStringLiteral(
"None" );
5905 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5906 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5908 if ( value.userType() == QMetaType::Type::QVariantList )
5911 const auto constToList = value.toList();
5912 for (
const QVariant &val : constToList )
5916 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5918 else if ( value.userType() == QMetaType::Type::QStringList )
5921 const auto constToStringList = value.toStringList();
5922 for (
const QString &s : constToStringList )
5926 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5934 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5936 code += QLatin1String(
"optional " );
5937 code += QLatin1String(
"field " );
5939 switch ( mDataType )
5942 code += QLatin1String(
"numeric " );
5946 code += QLatin1String(
"string " );
5950 code += QLatin1String(
"datetime " );
5954 code += QLatin1String(
"binary " );
5958 code += QLatin1String(
"boolean " );
5965 if ( mAllowMultiple )
5966 code += QLatin1String(
"multiple " );
5968 if ( mDefaultToAllFields )
5969 code += QLatin1String(
"default_to_all_fields " );
5971 code += mParentLayerParameterName +
' ';
5974 return code.trimmed();
5979 switch ( outputType )
5983 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', %2" )
5986 code += QLatin1String(
", optional=True" );
5989 switch ( mDataType )
5992 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
5996 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
6000 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
6004 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
6008 dataType = QStringLiteral(
"QgsProcessingParameterField.Binary" );
6012 dataType = QStringLiteral(
"QgsProcessingParameterField.Boolean" );
6015 code += QStringLiteral(
", type=%1" ).arg(
dataType );
6017 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
6018 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6022 if ( mDefaultToAllFields )
6023 code += QLatin1String(
", defaultToAllFields=True" );
6035 QStringList depends;
6036 if ( !mParentLayerParameterName.isEmpty() )
6037 depends << mParentLayerParameterName;
6043 return mParentLayerParameterName;
6063 return mAllowMultiple;
6073 return mDefaultToAllFields;
6078 mDefaultToAllFields = enabled;
6084 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
6085 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
6086 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
6087 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
6094 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
6096 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
6097 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
6107 QString def = definition;
6109 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
6114 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
6119 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
6124 else if ( def.startsWith( QLatin1String(
"binary " ), Qt::CaseInsensitive ) )
6129 else if ( def.startsWith( QLatin1String(
"boolean " ), Qt::CaseInsensitive ) )
6135 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
6138 def = def.mid( 8 ).trimmed();
6141 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
6144 def = def.mid( 21 ).trimmed();
6147 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
6148 const QRegularExpressionMatch m = re.match( def );
6151 parent = m.captured( 1 ).trimmed();
6152 def = m.captured( 2 );
6177 QVariant var = input;
6178 if ( !var.isValid() )
6186 if ( var.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
6191 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6198 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6210 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
6215 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
6233 if ( !value.isValid() )
6234 return QStringLiteral(
"None" );
6236 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6239 if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
6242 QString geometryCheckString;
6246 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
6250 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
6254 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
6261 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
6263 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
6264 if ( !
flags.empty() )
6265 flagString =
flags.join( QLatin1String(
" | " ) );
6272 layerString = layer->source();
6279 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6280 geometryCheckString,
6292 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression(%1), selectedFeaturesOnly=%2, featureLimit=%3%4%6, geometryCheck=%5)" )
6296 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6297 geometryCheckString,
6306 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
6311 QString layerString = value.toString();
6315 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
6332 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6334 code += QLatin1String(
"optional " );
6335 code += QLatin1String(
"source " );
6342 code += QLatin1String(
"point " );
6346 code += QLatin1String(
"line " );
6350 code += QLatin1String(
"polygon " );
6359 return code.trimmed();
6364 switch ( outputType )
6368 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', %2" )
6371 code += QLatin1String(
", optional=True" );
6375 QStringList options;
6379 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
6396 : mDataTypes( types )
6409 map.insert( QStringLiteral(
"data_types" ), types );
6417 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
6418 for (
const QVariant &val : values )
6428 QString def = definition;
6431 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6437 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6443 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6458 , mSupportsAppend( supportsAppend )
6469 QVariant var = input;
6470 if ( !var.isValid() )
6478 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6484 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6497 if ( var.userType() != QMetaType::Type::QString )
6500 if ( var.toString().isEmpty() )
6508 if ( !value.isValid() )
6509 return QStringLiteral(
"None" );
6511 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6512 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6514 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6523 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6532 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6534 code += QLatin1String(
"optional " );
6535 code += QLatin1String(
"sink " );
6537 switch ( mDataType )
6540 code += QLatin1String(
"point " );
6544 code += QLatin1String(
"line " );
6548 code += QLatin1String(
"polygon " );
6552 code += QLatin1String(
"table " );
6560 return code.trimmed();
6572 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6576 return p->defaultVectorFileExtension(
hasGeometry() );
6586 return QStringLiteral(
"dbf" );
6593 switch ( outputType )
6597 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', %2" )
6600 code += QLatin1String(
", optional=True" );
6604 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6605 if ( mSupportsAppend )
6606 code += QLatin1String(
", supportsAppend=True" );
6619 QStringList filters;
6620 for (
const QString &ext : exts )
6622 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6624 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6633 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6635 return lOriginalProvider->supportedOutputTableExtensions();
6640 return p->supportedOutputVectorLayerExtensions();
6642 return p->supportedOutputTableExtensions();
6657 switch ( mDataType )
6687 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
6688 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
6696 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
6703 return QStringLiteral(
"memory:%1" ).arg(
description() );
6711 QString def = definition;
6712 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6717 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6722 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6727 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
6738 return mSupportsAppend;
6758 QVariant var = input;
6759 if ( !var.isValid() )
6767 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6773 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6786 if ( var.userType() != QMetaType::Type::QString )
6789 if ( var.toString().isEmpty() )
6797 if ( !value.isValid() )
6798 return QStringLiteral(
"None" );
6800 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6801 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6803 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6812 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6828 return lOriginalProvider->defaultRasterFileExtension();
6832 return p->defaultRasterFileExtension();
6843 QStringList filters;
6844 for (
const QString &ext : exts )
6846 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6848 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6855 return lOriginalProvider->supportedOutputRasterLayerExtensions();
6859 return p->supportedOutputRasterLayerExtensions();
6875 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
6887 QVariant var = input;
6888 if ( !var.isValid() )
6896 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6902 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6915 if ( var.userType() != QMetaType::Type::QString )
6918 if ( var.toString().isEmpty() )
6928 if ( !value.isValid() )
6929 return QStringLiteral(
"None" );
6931 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6932 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6934 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6943 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6952 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
6964 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
6965 return QStringLiteral(
"file" );
6968 const thread_local QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
6969 const QRegularExpressionMatch match = rx.match( mFileFilter );
6970 if ( !match.hasMatch() )
6971 return QStringLiteral(
"file" );
6973 return match.captured( 1 );
6978 switch ( outputType )
6982 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', %2" )
6985 code += QLatin1String(
", optional=True" );
6989 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7001 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
7017 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
7024 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
7045 QVariant var = input;
7046 if ( !var.isValid() )
7054 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
7067 if ( var.userType() != QMetaType::Type::QString )
7070 if ( var.toString().isEmpty() )
7093 , mCreateByDefault( createByDefault )
7101 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
7102 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
7109 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
7110 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
7116 switch ( outputType )
7123 QString code = t->className() + QStringLiteral(
"('%1', %2" )
7126 code += QLatin1String(
", optional=True" );
7128 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7143 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
7150 const thread_local QRegularExpression rx( QStringLiteral(
"[.]" ) );
7151 QString sanitizedName =
name();
7152 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
7167 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
7176 return mCreateByDefault;
7198 QVariant var = input;
7199 if ( !var.isValid() )
7207 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
7213 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
7226 if ( var.userType() != QMetaType::Type::QString )
7229 if ( var.toString().isEmpty() )
7237 if ( !value.isValid() )
7238 return QStringLiteral(
"None" );
7240 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7241 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7243 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
7252 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
7261 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7263 code += QLatin1String(
"optional " );
7264 code += QLatin1String(
"vectorDestination " );
7266 switch ( mDataType )
7269 code += QLatin1String(
"point " );
7273 code += QLatin1String(
"line " );
7277 code += QLatin1String(
"polygon " );
7285 return code.trimmed();
7297 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
7301 return p->defaultVectorFileExtension(
hasGeometry() );
7311 return QStringLiteral(
"dbf" );
7318 switch ( outputType )
7322 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', %2" )
7325 code += QLatin1String(
", optional=True" );
7329 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7342 QStringList filters;
7343 for (
const QString &ext : exts )
7345 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
7347 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
7355 return lOriginalProvider->supportedOutputVectorLayerExtensions();
7357 return lOriginalProvider->supportedOutputTableExtensions();
7362 return p->supportedOutputVectorLayerExtensions();
7364 return p->supportedOutputTableExtensions();
7379 switch ( mDataType )
7409 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
7423 QString def = definition;
7424 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
7429 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
7434 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
7445 , mParentLayerParameterName( parentLayerParameterName )
7446 , mAllowMultiple( allowMultiple )
7458 QVariant input = value;
7459 if ( !input.isValid() )
7467 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
7472 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
7474 if ( !mAllowMultiple )
7483 const double res = input.toInt( &ok );
7493 return mAllowMultiple;
7503 if ( !value.isValid() )
7504 return QStringLiteral(
"None" );
7506 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7507 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7509 if ( value.userType() == QMetaType::Type::QVariantList )
7512 const QVariantList values = value.toList();
7513 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7515 parts << QString::number( static_cast< int >( it->toDouble() ) );
7517 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7519 else if ( value.userType() == QMetaType::Type::QStringList )
7522 const QStringList values = value.toStringList();
7523 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7525 parts << QString::number( static_cast< int >( it->toDouble() ) );
7527 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7530 return value.toString();
7535 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7537 code += QLatin1String(
"optional " );
7538 code += QLatin1String(
"band " );
7540 if ( mAllowMultiple )
7541 code += QLatin1String(
"multiple " );
7543 code += mParentLayerParameterName +
' ';
7546 return code.trimmed();
7551 QStringList depends;
7552 if ( !mParentLayerParameterName.isEmpty() )
7553 depends << mParentLayerParameterName;
7559 switch ( outputType )
7563 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', %2" )
7566 code += QLatin1String(
", optional=True" );
7568 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
7569 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7581 return mParentLayerParameterName;
7592 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
7593 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
7600 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
7601 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
7608 QString def = definition;
7611 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
7614 def = def.mid( 8 ).trimmed();
7617 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7618 const QRegularExpressionMatch m = re.match( def );
7621 parent = m.captured( 1 ).trimmed();
7622 def = m.captured( 2 );
7639 , mParentParameterName( parentParameterName )
7656 QStringList depends;
7657 if ( !mParentParameterName.isEmpty() )
7658 depends << mParentParameterName;
7664 switch ( outputType )
7668 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', %2" )
7671 code += QLatin1String(
", optional=True" );
7673 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7675 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7676 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7677 if (
maximum() != std::numeric_limits<double>::max() )
7678 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7689 return mParentParameterName;
7700 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7701 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7708 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7735 switch ( outputType )
7739 QString code = QStringLiteral(
"QgsProcessingParameterDuration('%1', %2" )
7742 code += QLatin1String(
", optional=True" );
7744 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7745 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7746 if (
maximum() != std::numeric_limits<double>::max() )
7747 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7759 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7793 switch ( outputType )
7797 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', %2" )
7800 code += QLatin1String(
", optional=True" );
7812 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
7832 return QStringLiteral(
"None" );
7834 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7835 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7837 const QString s = value.toString();
7843 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7845 code += QLatin1String(
"optional " );
7846 code += QLatin1String(
"layout " );
7849 return code.trimmed();
7854 switch ( outputType )
7858 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', %2" )
7861 code += QLatin1String(
", optional=True" );
7872 QString def = definition;
7874 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7876 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7880 if ( def == QLatin1String(
"None" ) )
7893 , mParentLayoutParameterName( parentLayoutParameterName )
7894 , mItemType( itemType )
7907 return QStringLiteral(
"None" );
7909 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7910 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7912 const QString s = value.toString();
7918 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7920 code += QLatin1String(
"optional " );
7921 code += QLatin1String(
"layoutitem " );
7922 if ( mItemType >= 0 )
7923 code += QString::number( mItemType ) +
' ';
7925 code += mParentLayoutParameterName +
' ';
7928 return code.trimmed();
7933 switch ( outputType )
7937 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', %2" )
7940 code += QLatin1String(
", optional=True" );
7942 if ( mItemType >= 0 )
7943 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
7945 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
7958 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
7959 map.insert( QStringLiteral(
"item_type" ), mItemType );
7966 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
7967 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
7973 QStringList depends;
7974 if ( !mParentLayoutParameterName.isEmpty() )
7975 depends << mParentLayoutParameterName;
7982 QString def = definition;
7984 const thread_local QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
7985 const QRegularExpressionMatch m = re.match( def );
7988 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
7989 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
7990 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
8003 return mParentLayoutParameterName;
8008 mParentLayoutParameterName =
name;
8027 , mAllowOpacity( opacityEnabled )
8040 return QStringLiteral(
"None" );
8042 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8043 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8045 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
8046 return QStringLiteral(
"QColor()" );
8048 if ( value.canConvert< QColor >() )
8050 const QColor
c = value.value< QColor >();
8051 if ( !mAllowOpacity ||
c.alpha() == 255 )
8052 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
8054 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
8057 const QString s = value.toString();
8063 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8065 code += QLatin1String(
"optional " );
8066 code += QLatin1String(
"color " );
8068 if ( mAllowOpacity )
8069 code += QLatin1String(
"withopacity " );
8072 return code.trimmed();
8077 switch ( outputType )
8081 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', %2" )
8084 code += QLatin1String(
", optional=True" );
8086 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
8098 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
8101 if ( !input.isValid() )
8104 if ( input.userType() == QMetaType::Type::QColor )
8108 else if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
8113 if ( input.userType() != QMetaType::Type::QString || input.toString().isEmpty() )
8116 bool containsAlpha =
false;
8123 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
8130 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
8136 return mAllowOpacity;
8141 mAllowOpacity = enabled;
8146 QString def = definition;
8148 bool allowOpacity =
false;
8149 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
8151 allowOpacity =
true;
8152 def = def.mid( 12 );
8155 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8157 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8161 if ( def == QLatin1String(
"None" ) || def.isEmpty() )
8172 , mSourceParameterName( sourceCrsParameterName )
8173 , mDestParameterName( destinationCrsParameterName )
8174 , mSourceCrs( staticSourceCrs )
8175 , mDestCrs( staticDestinationCrs )
8188 return QStringLiteral(
"None" );
8190 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
8193 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
8198 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8199 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8202 p.insert(
name(), value );
8207 const QString s = value.toString();
8213 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8215 code += QLatin1String(
"optional " );
8216 code += QLatin1String(
"coordinateoperation " );
8219 return code.trimmed();
8224 switch ( outputType )
8229 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', %2" )
8232 code += QLatin1String(
", optional=True" );
8233 if ( !mSourceParameterName.isEmpty() )
8234 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg(
valueAsPythonString( mSourceParameterName,
c ) );
8235 if ( !mDestParameterName.isEmpty() )
8236 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg(
valueAsPythonString( mDestParameterName,
c ) );
8238 if ( mSourceCrs.isValid() )
8240 if ( mDestCrs.isValid() )
8241 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg(
valueAsPythonString( mDestCrs,
c ) );
8253 if ( !mSourceParameterName.isEmpty() )
8254 res << mSourceParameterName;
8255 if ( !mDestParameterName.isEmpty() )
8256 res << mDestParameterName;
8263 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
8264 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
8265 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
8266 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
8273 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
8274 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
8275 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
8276 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
8282 QString def = definition;
8284 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8286 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8290 if ( def == QLatin1String(
"None" ) )
8315 if ( !input.isValid() && !
mDefault.isValid() )
8318 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8319 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8327 if ( !value.isValid() )
8328 return QStringLiteral(
"None" );
8330 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8331 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8338 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8340 code += QLatin1String(
"optional " );
8341 code += QLatin1String(
"maptheme " );
8344 return code.trimmed();
8349 switch ( outputType )
8353 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', %2" )
8356 code += QLatin1String(
", optional=True" );
8381 QString def = definition;
8382 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8384 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8406 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
8408 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
8419 QVariant input = value;
8420 if ( !input.isValid() )
8428 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
8433 if ( input.userType() != QMetaType::Type::QDateTime && input.userType() != QMetaType::Type::QDate && input.userType() != QMetaType::Type::QTime && input.userType() != QMetaType::Type::QString )
8439 if ( input.userType() == QMetaType::Type::QString )
8441 const QString s = input.toString();
8445 input = QDateTime::fromString( s, Qt::ISODate );
8448 if ( !input.toDateTime().isValid() )
8449 input = QTime::fromString( s );
8451 input = input.toDateTime().time();
8457 const QDateTime res = input.toDateTime();
8458 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
8462 const QTime res = input.toTime();
8463 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
8469 if ( !value.isValid() )
8470 return QStringLiteral(
"None" );
8472 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8473 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8475 if ( value.userType() == QMetaType::Type::QDateTime )
8477 const QDateTime dt = value.toDateTime();
8478 if ( !dt.isValid() )
8479 return QStringLiteral(
"QDateTime()" );
8481 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
8482 .arg( dt.date().month() )
8483 .arg( dt.date().day() )
8484 .arg( dt.time().hour() )
8485 .arg( dt.time().minute() )
8486 .arg( dt.time().second() );
8488 else if ( value.userType() == QMetaType::Type::QDate )
8490 const QDate dt = value.toDate();
8491 if ( !dt.isValid() )
8492 return QStringLiteral(
"QDate()" );
8494 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
8498 else if ( value.userType() == QMetaType::Type::QTime )
8500 const QTime dt = value.toTime();
8501 if ( !dt.isValid() )
8502 return QStringLiteral(
"QTime()" );
8504 return QStringLiteral(
"QTime(%4, %5, %6)" )
8507 .arg( dt.second() );
8509 return value.toString();
8516 if ( mMin.isValid() )
8517 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
8518 if ( mMax.isValid() )
8519 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
8523 const QString extra = parts.join( QLatin1String(
"<br />" ) );
8524 if ( !extra.isEmpty() )
8525 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
8531 switch ( outputType )
8535 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', %2" )
8538 code += QLatin1String(
", optional=True" );
8542 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
8545 if ( mMin.isValid() )
8547 if ( mMax.isValid() )
8589 map.insert( QStringLiteral(
"min" ), mMin );
8590 map.insert( QStringLiteral(
"max" ), mMax );
8591 map.insert( QStringLiteral(
"data_type" ),
static_cast< int >( mDataType ) );
8598 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
8599 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
8607 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
8618 , mProviderId( provider )
8631 if ( !input.isValid() && !
mDefault.isValid() )
8634 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8635 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8643 if ( !value.isValid() )
8644 return QStringLiteral(
"None" );
8646 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8647 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8654 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8656 code += QLatin1String(
"optional " );
8657 code += QLatin1String(
"providerconnection " );
8658 code += mProviderId +
' ';
8661 return code.trimmed();
8666 switch ( outputType )
8670 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', %2, '%3'" )
8673 code += QLatin1String(
", optional=True" );
8687 map.insert( QStringLiteral(
"provider" ), mProviderId );
8694 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
8700 QString def = definition;
8702 if ( def.contains(
' ' ) )
8704 provider = def.left( def.indexOf(
' ' ) );
8705 def = def.mid( def.indexOf(
' ' ) + 1 );
8713 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8715 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8733 , mParentConnectionParameterName( parentLayerParameterName )
8746 if ( !input.isValid() && !
mDefault.isValid() )
8749 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8750 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8758 if ( !value.isValid() )
8759 return QStringLiteral(
"None" );
8761 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8762 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8769 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8771 code += QLatin1String(
"optional " );
8772 code += QLatin1String(
"databaseschema " );
8774 code += mParentConnectionParameterName +
' ';
8777 return code.trimmed();
8782 switch ( outputType )
8786 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', %2" )
8789 code += QLatin1String(
", optional=True" );
8791 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8805 QStringList depends;
8806 if ( !mParentConnectionParameterName.isEmpty() )
8807 depends << mParentConnectionParameterName;
8813 return mParentConnectionParameterName;
8818 mParentConnectionParameterName =
name;
8824 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8831 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8838 QString def = definition;
8840 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
8841 const QRegularExpressionMatch m = re.match( def );
8844 parent = m.captured( 1 ).trimmed();
8845 def = m.captured( 2 );
8861 const QString &connectionParameterName,
8862 const QString &schemaParameterName,
8863 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
8865 , mParentConnectionParameterName( connectionParameterName )
8866 , mParentSchemaParameterName( schemaParameterName )
8867 , mAllowNewTableNames( allowNewTableNames )
8880 if ( !input.isValid() && !
mDefault.isValid() )
8883 if ( ( input.userType() == QMetaType::Type::QString && input.toString().isEmpty() )
8884 || ( !input.isValid() &&
mDefault.userType() == QMetaType::Type::QString &&
mDefault.toString().isEmpty() ) )
8892 if ( !value.isValid() )
8893 return QStringLiteral(
"None" );
8895 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8896 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8903 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8905 code += QLatin1String(
"optional " );
8906 code += QLatin1String(
"databasetable " );
8908 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
8909 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
8912 return code.trimmed();
8917 switch ( outputType )
8921 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', %2" )
8924 code += QLatin1String(
", optional=True" );
8926 if ( mAllowNewTableNames )
8927 code += QLatin1String(
", allowNewTableNames=True" );
8929 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8930 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
8944 QStringList depends;
8945 if ( !mParentConnectionParameterName.isEmpty() )
8946 depends << mParentConnectionParameterName;
8947 if ( !mParentSchemaParameterName.isEmpty() )
8948 depends << mParentSchemaParameterName;
8954 return mParentConnectionParameterName;
8959 mParentConnectionParameterName =
name;
8964 return mParentSchemaParameterName;
8969 mParentSchemaParameterName =
name;
8975 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8976 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
8977 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
8984 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8985 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
8986 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
8994 QString def = definition;
8996 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
8997 const QRegularExpressionMatch m = re.match( def );
9000 connection = m.captured( 1 ).trimmed();
9001 if ( connection == QLatin1String(
"none" ) )
9003 schema = m.captured( 2 ).trimmed();
9004 if ( schema == QLatin1String(
"none" ) )
9006 def = m.captured( 3 );
9014 return mAllowNewTableNames;
9027 const QVariant &defaultValue,
bool optional )
9041 if ( !var.isValid() )
9049 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
9062 if ( qobject_cast< QgsPointCloudLayer * >( qvariant_cast<QObject *>( var ) ) )
9065 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
9083 if ( !val.isValid() )
9084 return QStringLiteral(
"None" );
9086 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
9090 p.insert(
name(), val );
9121 const QVariant &defaultValue,
bool optional )
9134 if ( !var.isValid() )
9142 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
9155 if ( qobject_cast< QgsAnnotationLayer * >( qvariant_cast<QObject *>( var ) ) )
9158 if ( var.userType() != QMetaType::Type::QString || var.toString().isEmpty() )
9176 if ( !val.isValid() )
9177 return QStringLiteral(
"None" );
9179 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
9183 p.insert(
name(), val );
9216 QVariant var = input;
9217 if ( !var.isValid() )
9225 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9231 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
9244 if ( var.userType() != QMetaType::Type::QString )
9247 if ( var.toString().isEmpty() )
9255 if ( !value.isValid() )
9256 return QStringLiteral(
"None" );
9258 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
9259 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9261 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9270 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9286 return lOriginalProvider->defaultPointCloudFileExtension();
9290 return p->defaultPointCloudFileExtension();
9301 QStringList filters;
9302 for (
const QString &ext : exts )
9304 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9306 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9313 return lOriginalProvider->supportedOutputPointCloudLayerExtensions();
9317 return p->supportedOutputPointCloudLayerExtensions();
9322 return QStringList() << ext;
9337 , mParentLayerParameterName( parentLayerParameterName )
9338 , mAllowMultiple( allowMultiple )
9339 , mDefaultToAllAttributes( defaultToAllAttributes )
9359 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
9364 if ( input.userType() == QMetaType::Type::QVariantList || input.userType() == QMetaType::Type::QStringList )
9366 if ( !mAllowMultiple )
9372 else if ( input.userType() == QMetaType::Type::QString )
9374 if ( input.toString().isEmpty() )
9377 const QStringList parts = input.toString().split(
';' );
9378 if ( parts.count() > 1 && !mAllowMultiple )
9383 if ( input.toString().isEmpty() )
9391 if ( !value.isValid() )
9392 return QStringLiteral(
"None" );
9394 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
9395 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9397 if ( value.userType() == QMetaType::Type::QVariantList )
9400 const auto constToList = value.toList();
9401 for (
const QVariant &val : constToList )
9405 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9407 else if ( value.userType() == QMetaType::Type::QStringList )
9410 const auto constToStringList = value.toStringList();
9411 for (
const QString &s : constToStringList )
9415 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9423 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
9425 code += QLatin1String(
"optional " );
9426 code += QLatin1String(
"attribute " );
9428 if ( mAllowMultiple )
9429 code += QLatin1String(
"multiple " );
9431 if ( mDefaultToAllAttributes )
9432 code += QLatin1String(
"default_to_all_attributes " );
9434 code += mParentLayerParameterName +
' ';
9437 return code.trimmed();
9442 switch ( outputType )
9446 QString code = QStringLiteral(
"QgsProcessingParameterPointCloudAttribute('%1', %2" )
9449 code += QLatin1String(
", optional=True" );
9451 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
9452 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
9456 if ( mDefaultToAllAttributes )
9457 code += QLatin1String(
", defaultToAllAttributes=True" );
9469 QStringList depends;
9470 if ( !mParentLayerParameterName.isEmpty() )
9471 depends << mParentLayerParameterName;
9477 return mParentLayerParameterName;
9487 return mAllowMultiple;
9497 return mDefaultToAllAttributes;
9502 mDefaultToAllAttributes = enabled;
9508 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
9509 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
9510 map.insert( QStringLiteral(
"default_to_all_attributes" ), mDefaultToAllAttributes );
9517 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
9518 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
9519 mDefaultToAllAttributes = map.value( QStringLiteral(
"default_to_all_attributes" ) ).toBool();
9528 QString def = definition;
9530 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
9533 def = def.mid( 8 ).trimmed();
9536 if ( def.startsWith( QLatin1String(
"default_to_all_attributes" ), Qt::CaseInsensitive ) )
9539 def = def.mid( 25 ).trimmed();
9542 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
9543 const QRegularExpressionMatch m = re.match( def );
9546 parent = m.captured( 1 ).trimmed();
9547 def = m.captured( 2 );
9574 QVariant var = input;
9575 if ( !var.isValid() )
9583 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9589 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
9602 if ( var.userType() != QMetaType::Type::QString )
9605 if ( var.toString().isEmpty() )
9613 if ( !value.isValid() )
9614 return QStringLiteral(
"None" );
9616 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
9617 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9619 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9628 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9648 QStringList filters;
9649 for (
const QString &ext : exts )
9651 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9653 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9659 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 (since QGIS 3.34)
@ 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.
@ 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.
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 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...
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
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
#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