42#include <QRegularExpression>
50 map.insert( QStringLiteral(
"feature_limit" ),
featureLimit );
52 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
flags ) );
53 map.insert( QStringLiteral(
"geometry_check" ),
static_cast< int >(
geometryCheck ) );
61 featureLimit = map.value( QStringLiteral(
"feature_limit" ), -1 ).toLongLong();
63 flags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ), 0 ).toInt() );
76 mRemappingDefinition = definition;
83 map.insert( QStringLiteral(
"create_options" ),
createOptions );
85 map.insert( QStringLiteral(
"remapping" ), QVariant::fromValue( mRemappingDefinition ) );
92 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
93 if ( map.contains( QStringLiteral(
"remapping" ) ) )
100 mUseRemapping =
false;
108 && mUseRemapping == other.mUseRemapping && mRemappingDefinition == other.mRemappingDefinition;
113 return !( *
this == other );
118 const QVariant val = parameters.value( name );
119 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
138 QVariant val = value;
139 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
142 if ( !val.isValid() )
151 return destParam->generateTemporaryDestination( &context );
154 return val.toString();
170 const QVariant val = value;
171 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
174 if ( val.isValid() && !val.toString().isEmpty() )
178 return val.toString();
198 QVariant val = value;
199 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
203 const double res = val.toDouble( &ok );
209 return val.toDouble();
225 QVariant val = value;
226 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
230 double dbl = val.toDouble( &ok );
235 dbl = val.toDouble( &ok );
242 const double round = std::round( dbl );
243 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
248 return static_cast< int >( std::round( dbl ) );
257 return QList< int >();
265 return QList< int >();
267 QList< int > resultList;
268 const QVariant val = value;
271 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
273 else if ( val.type() == QVariant::List )
275 const QVariantList list = val.toList();
276 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
277 resultList << it->toInt();
281 const QStringList parts = val.toString().split(
';' );
282 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
283 resultList << it->toInt();
287 if ( resultList.isEmpty() )
292 if ( definition->
defaultValue().type() == QVariant::List )
294 const QVariantList list = definition->
defaultValue().toList();
295 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
296 resultList << it->toInt();
300 const QStringList parts = definition->
defaultValue().toString().split(
';' );
301 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
302 resultList << it->toInt();
323 QVariant val = value;
324 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
327 QDateTime d = val.toDateTime();
328 if ( !d.isValid() && val.type() == QVariant::String )
330 d = QDateTime::fromString( val.toString() );
337 d = val.toDateTime();
339 if ( !d.isValid() && val.type() == QVariant::String )
341 d = QDateTime::fromString( val.toString() );
360 QVariant val = value;
361 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
364 QDate d = val.toDate();
365 if ( !d.isValid() && val.type() == QVariant::String )
367 d = QDate::fromString( val.toString() );
376 if ( !d.isValid() && val.type() == QVariant::String )
378 d = QDate::fromString( val.toString() );
397 QVariant val = value;
398 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
403 if ( val.type() == QVariant::DateTime )
404 d = val.toDateTime().time();
408 if ( !d.isValid() && val.type() == QVariant::String )
410 d = QTime::fromString( val.toString() );
419 if ( !d.isValid() && val.type() == QVariant::String )
421 d = QTime::fromString( val.toString() );
442 if ( enumDef && val >= enumDef->
options().size() )
462 QVariantList resultList;
463 const QVariant val = value;
464 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
466 else if ( val.type() == QVariant::List )
468 const auto constToList = val.toList();
469 for (
const QVariant &var : constToList )
472 else if ( val.type() == QVariant::String )
474 const auto constSplit = val.toString().split(
',' );
475 for (
const QString &var : constSplit )
481 if ( resultList.isEmpty() )
482 return QList< int >();
484 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
488 if ( definition->
defaultValue().type() == QVariant::List )
490 const auto constToList = definition->
defaultValue().toList();
491 for (
const QVariant &var : constToList )
494 else if ( definition->
defaultValue().type() == QVariant::String )
496 const auto constSplit = definition->
defaultValue().toString().split(
',' );
497 for (
const QString &var : constSplit )
506 const auto constResultList = resultList;
507 for (
const QVariant &var : constResultList )
509 const int resInt = var.toInt();
510 if ( !enumDef || resInt < enumDef->options().size() )
533 if ( enumText.isEmpty() || !enumDef->
options().contains( enumText ) )
542 return QStringList();
550 return QStringList();
552 const QVariant val = value;
554 QStringList enumValues;
556 std::function< void(
const QVariant &var ) > processVariant;
557 processVariant = [ &enumValues, &context, &definition, &processVariant ](
const QVariant & var )
559 if ( var.type() == QVariant::List )
561 const auto constToList = var.toList();
562 for (
const QVariant &listVar : constToList )
564 processVariant( listVar );
567 else if ( var.type() == QVariant::StringList )
569 const auto constToStringList = var.toStringList();
570 for (
const QString &s : constToStringList )
575 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
579 const QStringList parts = var.toString().split(
',' );
580 for (
const QString &s : parts )
587 processVariant( val );
593 const QStringList options = enumDef->
options();
594 const QSet<QString> subtraction = QSet<QString>( enumValues.begin(), enumValues.end() ).subtract( QSet<QString>( options.begin(), options.end() ) );
596 if ( enumValues.isEmpty() || !subtraction.isEmpty() )
629 const QVariant val = value;
630 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
632 else if ( val.isValid() )
645 const QVariant val = value;
646 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
648 else if ( val.isValid() )
656 QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
657 const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
662 val = parameters.value( definition->
name() );
665 return parameterAsSink( definition, val, fields, geometryType,
crs, context, destinationIdentifier, sinkFlags, createOptions, datasourceOptions, layerOptions );
668QgsFeatureSink *
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 )
670 QVariantMap options = createOptions;
671 QVariant val = value;
676 bool useRemapDefinition =
false;
677 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
688 useRemapDefinition =
true;
694 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
698 else if ( !val.isValid() || val.toString().isEmpty() )
714 dest = val.toString();
719 dest = destParam->generateTemporaryDestination( &context );
722 if ( dest.isEmpty() )
725 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType,
crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition : nullptr ) );
726 destinationIdentifier = dest;
728 if ( destinationProject )
730 if ( destName.isEmpty() && definition )
736 outputName = definition->
name();
740 return sink.release();
764 QVariant val = parameters.value( definition->
name() );
766 bool selectedFeaturesOnly =
false;
767 long long featureLimit = -1;
768 QString filterExpression;
769 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
778 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
785 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
791 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
796 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
800 else if ( !val.isValid() || val.toString().isEmpty() )
806 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
812 layerRef = val.toString();
817 if ( layerRef.isEmpty() )
829 compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit, filterExpression );
832 compatibleFormats, preferredFormat, context, feedback, featureLimit, filterExpression );
842 QString *destLayer = layerName;
857 return parameterAsLayer( definition, parameters.value( definition->
name() ), context, layerHint, flags );
865 QVariant val = value;
866 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
871 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
876 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
888 if ( !val.isValid() || val.toString().isEmpty() )
894 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
899 QString layerRef = val.toString();
900 if ( layerRef.isEmpty() )
903 if ( layerRef.isEmpty() )
934 val = parameters.value( definition->
name() );
941 QVariant val = value;
945 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
955 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
959 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
966 dest = val.toString();
971 dest = destParam->generateTemporaryDestination( &context );
974 if ( destinationProject )
977 if ( destName.isEmpty() && definition )
982 outputName = definition->
name();
1005 val = parameters.value( definition->
name() );
1012 QVariant val = value;
1014 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1022 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
1026 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
1033 dest = val.toString();
1038 dest = destParam->generateTemporaryDestination( &context );
1058 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
1083 QVariant val = value;
1085 if ( val.userType() == QMetaType::type(
"QgsRectangle" ) )
1089 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1095 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1114 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1120 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1133 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1136 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1139 rectText = val.toString();
1141 if ( rectText.isEmpty() && !layer )
1144 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1145 const QRegularExpressionMatch match = rx.match( rectText );
1146 if ( match.hasMatch() )
1148 bool xMinOk =
false;
1149 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1150 bool xMaxOk =
false;
1151 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1152 bool yMinOk =
false;
1153 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1154 bool yMaxOk =
false;
1155 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1156 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1207 QVariant val = parameters.value( definition->
name() );
1209 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1215 g = g.densifyByCount( 20 );
1229 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1235 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1248 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1251 rectText = val.toString();
1253 if ( !rectText.isEmpty() )
1255 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1256 const QRegularExpressionMatch match = rx.match( rectText );
1257 if ( match.hasMatch() )
1259 bool xMinOk =
false;
1260 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1261 bool xMaxOk =
false;
1262 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1263 bool yMinOk =
false;
1264 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1265 bool yMaxOk =
false;
1266 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1267 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1293 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1322 const QVariant val = parameters.value( definition->
name() );
1328 QVariant val = value;
1329 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1338 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1344 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1356 QString valueAsString;
1357 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1360 valueAsString = val.toString();
1362 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1364 const QRegularExpressionMatch match = rx.match( valueAsString );
1365 if ( match.hasMatch() )
1372 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1378 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1391 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1392 return layer->crs();
1394 return layer->crs();
1396 if (
auto *lProject = context.
project() )
1397 return lProject->crs();
1415 const QVariant val = value;
1416 if ( val.userType() == QMetaType::type(
"QgsPointXY" ) )
1420 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1426 if ( val.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1445 if ( pointText.isEmpty() )
1448 if ( pointText.isEmpty() )
1451 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1454 const QRegularExpressionMatch match = rx.match( valueAsString );
1455 if ( match.hasMatch() )
1458 const double x = match.captured( 1 ).toDouble( &xOk );
1460 const double y = match.captured( 2 ).toDouble( &yOk );
1488 const QVariant val = parameters.value( definition->
name() );
1494 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1503 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1506 const QRegularExpressionMatch match = rx.match( valueAsString );
1507 if ( match.hasMatch() )
1514 if (
auto *lProject = context.
project() )
1515 return lProject->crs();
1533 const QVariant val = value;
1534 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1539 if ( val.userType() == QMetaType::type(
"QgsPointXY" ) )
1544 if ( val.userType() == QMetaType::type(
"QgsRectangle" ) )
1549 if ( val.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1567 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1573 g = g.densifyByCount( 20 );
1587 if ( val.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
1606 if ( valueAsString.isEmpty() )
1609 if ( valueAsString.isEmpty() )
1612 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1614 const QRegularExpressionMatch match = rx.match( valueAsString );
1615 if ( match.hasMatch() )
1642 const QVariant val = parameters.value( definition->
name() );
1648 if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
1657 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1666 if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1676 const QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1679 const QRegularExpressionMatch match = rx.match( valueAsString );
1680 if ( match.hasMatch() )
1687 if (
auto *lProject = context.
project() )
1688 return lProject->crs();
1699 if ( fileText.isEmpty() )
1710 if ( fileText.isEmpty() )
1718 return QVariantList();
1726 return QVariantList();
1728 QString resultString;
1729 const QVariant val = value;
1730 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1732 else if ( val.type() == QVariant::List )
1733 return val.toList();
1735 resultString = val.toString();
1737 if ( resultString.isEmpty() )
1740 if ( definition->
defaultValue().type() == QVariant::List )
1746 QVariantList result;
1747 const auto constSplit = resultString.split(
',' );
1750 for (
const QString &s : constSplit )
1752 number = s.toDouble( &ok );
1753 result << ( ok ? QVariant( number ) : s );
1762 return QList<QgsMapLayer *>();
1770 return QList<QgsMapLayer *>();
1772 const QVariant val = value;
1773 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1775 return QList<QgsMapLayer *>() << layer;
1778 QList<QgsMapLayer *> layers;
1780 std::function< void(
const QVariant &var ) > processVariant;
1781 processVariant = [ &layers, &context, &definition, flags, &processVariant](
const QVariant & var )
1783 if ( var.type() == QVariant::List )
1785 const auto constToList = var.toList();
1786 for (
const QVariant &listVar : constToList )
1788 processVariant( listVar );
1791 else if ( var.type() == QVariant::StringList )
1793 const auto constToStringList = var.toStringList();
1794 for (
const QString &s : constToStringList )
1796 processVariant( s );
1799 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
1801 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1805 const QVariant sink = fromVar.
sink;
1806 if ( sink.userType() == QMetaType::type(
"QgsProperty" ) )
1811 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1823 processVariant( val );
1825 if ( layers.isEmpty() )
1828 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->
defaultValue() ) ) )
1832 else if ( definition->
defaultValue().type() == QVariant::List )
1834 const auto constToList = definition->
defaultValue().toList();
1835 for (
const QVariant &var : constToList )
1837 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1843 processVariant( var );
1857 return QStringList();
1859 const QVariant val = value;
1863 std::function< void(
const QVariant &var ) > processVariant;
1864 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1866 if ( var.type() == QVariant::List )
1868 const auto constToList = var.toList();
1869 for (
const QVariant &listVar : constToList )
1871 processVariant( listVar );
1874 else if ( var.type() == QVariant::StringList )
1876 const auto constToStringList = var.toStringList();
1877 for (
const QString &s : constToStringList )
1879 processVariant( s );
1882 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
1886 files << var.toString();
1890 processVariant( val );
1892 if ( files.isEmpty() )
1903 return QStringList();
1911 return QList<double>();
1919 return QList<double>();
1921 QStringList resultStringList;
1922 const QVariant val = value;
1924 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1926 else if ( val.type() == QVariant::List )
1928 const auto constToList = val.toList();
1929 for (
const QVariant &var : constToList )
1930 resultStringList << var.toString();
1933 resultStringList << val.toString();
1935 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1937 resultStringList.clear();
1939 if ( definition->
defaultValue().type() == QVariant::List )
1941 const auto constToList = definition->
defaultValue().toList();
1942 for (
const QVariant &var : constToList )
1943 resultStringList << var.toString();
1946 resultStringList << definition->
defaultValue().toString();
1949 if ( resultStringList.size() == 1 )
1951 resultStringList = resultStringList.at( 0 ).split(
',' );
1954 if ( resultStringList.size() < 2 )
1955 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1957 QList< double > result;
1959 double n = resultStringList.at( 0 ).toDouble( &ok );
1963 result << std::numeric_limits<double>::quiet_NaN() ;
1965 n = resultStringList.at( 1 ).toDouble( &ok );
1969 result << std::numeric_limits<double>::quiet_NaN() ;
1977 return QStringList();
1990 return QStringList();
1998 return QStringList();
2000 QStringList resultStringList;
2001 const QVariant val = value;
2002 if ( val.isValid() )
2004 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
2006 else if ( val.type() == QVariant::List )
2008 const auto constToList = val.toList();
2009 for (
const QVariant &var : constToList )
2010 resultStringList << var.toString();
2012 else if ( val.type() == QVariant::StringList )
2014 resultStringList = val.toStringList();
2017 resultStringList.append( val.toString().split(
';' ) );
2020 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
2022 resultStringList.clear();
2026 if ( definition->
defaultValue().type() == QVariant::List )
2028 const auto constToList = definition->
defaultValue().toList();
2029 for (
const QVariant &var : constToList )
2030 resultStringList << var.toString();
2032 else if ( definition->
defaultValue().type() == QVariant::StringList )
2034 resultStringList = definition->
defaultValue().toStringList();
2037 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
2041 return resultStringList;
2055 if ( layoutName.isEmpty() )
2107 QVariant val = value;
2108 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
2112 if ( val.type() == QVariant::Color )
2114 QColor
c = val.
value< QColor >();
2116 if ( !colorParam->opacityEnabled() )
2124 if ( definition->
defaultValue().type() == QVariant::Color )
2130 if ( colorText.isEmpty() )
2133 bool containsAlpha =
false;
2136 if (
c.isValid() && !colorParam->opacityEnabled() )
2208 const QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
2209 const QString name = map.value( QStringLiteral(
"name" ) ).toString();
2210 std::unique_ptr< QgsProcessingParameterDefinition > def;
2287 def.reset( paramType->
create( name ) );
2293 def->fromVariantMap( map );
2294 return def.release();
2299 QString desc = name;
2300 desc.replace(
'_',
' ' );
2306 bool isOptional =
false;
2310 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2315 if ( type == QLatin1String(
"boolean" ) )
2317 else if ( type == QLatin1String(
"crs" ) )
2319 else if ( type == QLatin1String(
"layer" ) )
2321 else if ( type == QLatin1String(
"extent" ) )
2323 else if ( type == QLatin1String(
"point" ) )
2325 else if ( type == QLatin1String(
"geometry" ) )
2327 else if ( type == QLatin1String(
"file" ) )
2329 else if ( type == QLatin1String(
"folder" ) )
2331 else if ( type == QLatin1String(
"matrix" ) )
2333 else if ( type == QLatin1String(
"multiple" ) )
2335 else if ( type == QLatin1String(
"number" ) )
2337 else if ( type == QLatin1String(
"distance" ) )
2339 else if ( type == QLatin1String(
"duration" ) )
2341 else if ( type == QLatin1String(
"scale" ) )
2343 else if ( type == QLatin1String(
"range" ) )
2345 else if ( type == QLatin1String(
"raster" ) )
2347 else if ( type == QLatin1String(
"enum" ) )
2349 else if ( type == QLatin1String(
"string" ) )
2351 else if ( type == QLatin1String(
"authcfg" ) )
2353 else if ( type == QLatin1String(
"expression" ) )
2355 else if ( type == QLatin1String(
"field" ) )
2357 else if ( type == QLatin1String(
"vector" ) )
2359 else if ( type == QLatin1String(
"source" ) )
2361 else if ( type == QLatin1String(
"sink" ) )
2363 else if ( type == QLatin1String(
"vectordestination" ) )
2365 else if ( type == QLatin1String(
"rasterdestination" ) )
2367 else if ( type == QLatin1String(
"pointclouddestination" ) )
2369 else if ( type == QLatin1String(
"filedestination" ) )
2371 else if ( type == QLatin1String(
"folderdestination" ) )
2373 else if ( type == QLatin1String(
"band" ) )
2375 else if ( type == QLatin1String(
"mesh" ) )
2377 else if ( type == QLatin1String(
"layout" ) )
2379 else if ( type == QLatin1String(
"layoutitem" ) )
2381 else if ( type == QLatin1String(
"color" ) )
2383 else if ( type == QLatin1String(
"coordinateoperation" ) )
2385 else if ( type == QLatin1String(
"maptheme" ) )
2387 else if ( type == QLatin1String(
"datetime" ) )
2389 else if ( type == QLatin1String(
"providerconnection" ) )
2391 else if ( type == QLatin1String(
"databaseschema" ) )
2393 else if ( type == QLatin1String(
"databasetable" ) )
2395 else if ( type == QLatin1String(
"pointcloud" ) )
2397 else if ( type == QLatin1String(
"annotation" ) )
2399 else if ( type == QLatin1String(
"attribute" ) )
2401 else if ( type == QLatin1String(
"vectortiledestination" ) )
2407bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2409 const thread_local QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
2410 QRegularExpressionMatch m = re.match( code );
2411 if ( !m.hasMatch() )
2414 name = m.captured( 1 );
2415 QString tokens = m.captured( 2 );
2416 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
2419 tokens.remove( 0, 8 );
2426 tokens = tokens.trimmed();
2428 const thread_local QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2429 m = re2.match( tokens );
2430 if ( !m.hasMatch() )
2432 type = tokens.toLower().trimmed();
2437 type = m.captured( 1 ).toLower().trimmed();
2438 definition = m.captured( 2 );
2449 , mDescription( description )
2451 , mDefault( defaultValue )
2452 , mFlags( optional ? FlagOptional : 0 )
2458 if ( defaultSettingsValue.isValid() )
2460 return defaultSettingsValue;
2468 if ( defaultSettingsValue.isValid() )
2470 return defaultSettingsValue;
2480 QVariant settingValue = s.
value( QStringLiteral(
"/Processing/DefaultGuiParam/%1/%2" ).arg(
mAlgorithm->
id() ).arg(
mName ) );
2481 if ( settingValue.isValid() )
2483 return settingValue;
2491 if ( !input.isValid() && !
mDefault.isValid() )
2494 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
2495 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
2503 if ( !value.isValid() )
2504 return QStringLiteral(
"None" );
2506 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2507 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2519 if ( !value.isValid() )
2523 if ( value.type() == QVariant::Type::Map )
2525 const QVariantMap sourceMap = value.toMap();
2526 QVariantMap resultMap;
2527 for (
auto it = sourceMap.constBegin(); it != sourceMap.constEnd(); it++ )
2533 else if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList )
2535 const QVariantList sourceList = value.toList();
2536 QVariantList resultList;
2537 resultList.reserve( sourceList.size() );
2538 for (
const QVariant &v : sourceList )
2546 switch ( value.userType() )
2549 case QMetaType::Bool:
2550 case QMetaType::Char:
2551 case QMetaType::Int:
2552 case QMetaType::Double:
2553 case QMetaType::Float:
2554 case QMetaType::LongLong:
2555 case QMetaType::ULongLong:
2556 case QMetaType::UInt:
2557 case QMetaType::ULong:
2558 case QMetaType::UShort:
2565 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2575 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"field" ), prop.
field() }} );
2577 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"expression" ), prop.
expressionString() }} );
2582 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2592 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2600 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2609 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2621 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2636 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2642 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2649 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2656 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2661 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2663 const QColor fromVar = value.value< QColor >();
2664 if ( !fromVar.isValid() )
2667 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2669 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2671 const QDateTime fromVar = value.toDateTime();
2672 if ( !fromVar.isValid() )
2675 return fromVar.toString( Qt::ISODate );
2677 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2679 const QDate fromVar = value.toDate();
2680 if ( !fromVar.isValid() )
2683 return fromVar.toString( Qt::ISODate );
2685 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2687 const QTime fromVar = value.toTime();
2688 if ( !fromVar.isValid() )
2691 return fromVar.toString( Qt::ISODate );
2698 p.insert(
name(), value );
2702 if ( !source.isEmpty() )
2709 if ( value.userType() == QMetaType::QString )
2714 Q_ASSERT_X(
false,
"QgsProcessingParameterDefinition::valueAsJsonObject", QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ).toLocal8Bit() );
2727 if ( !value.isValid() )
2730 switch ( value.userType() )
2733 case QMetaType::Bool:
2734 case QMetaType::Char:
2735 case QMetaType::Int:
2736 case QMetaType::Double:
2737 case QMetaType::Float:
2738 case QMetaType::LongLong:
2739 case QMetaType::ULongLong:
2740 case QMetaType::UInt:
2741 case QMetaType::ULong:
2742 case QMetaType::UShort:
2743 return value.toString();
2749 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2759 return QStringLiteral(
"field:%1" ).arg( prop.
field() );
2766 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2776 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2784 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2792 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2804 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2819 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2825 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2832 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2837 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2842 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2844 const QColor fromVar = value.value< QColor >();
2845 if ( !fromVar.isValid() )
2848 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2850 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2852 const QDateTime fromVar = value.toDateTime();
2853 if ( !fromVar.isValid() )
2856 return fromVar.toString( Qt::ISODate );
2858 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2860 const QDate fromVar = value.toDate();
2861 if ( !fromVar.isValid() )
2864 return fromVar.toString( Qt::ISODate );
2866 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2868 const QTime fromVar = value.toTime();
2869 if ( !fromVar.isValid() )
2872 return fromVar.toString( Qt::ISODate );
2879 p.insert(
name(), value );
2883 if ( !source.isEmpty() )
2890 if ( value.userType() == QMetaType::QString )
2891 return value.toString();
2894 QgsDebugError( QStringLiteral(
"unsupported variant type %1" ).arg( QMetaType::typeName( value.userType() ) ) );
2896 return value.toString();
2902 if ( !value.isValid( ) )
2903 return QStringList();
2905 if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList )
2907 const QVariantList sourceList = value.toList();
2908 QStringList resultList;
2909 resultList.reserve( sourceList.size() );
2910 for (
const QVariant &v : sourceList )
2919 return QStringList();
2931 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2933 code += QLatin1String(
"optional " );
2934 code +=
type() +
' ';
2936 return code.trimmed();
2944 switch ( outputType )
2948 QString code = t->className() + QStringLiteral(
"('%1', %2" )
2951 code += QLatin1String(
", optional=True" );
2967 map.insert( QStringLiteral(
"parameter_type" ),
type() );
2968 map.insert( QStringLiteral(
"name" ),
mName );
2969 map.insert( QStringLiteral(
"description" ),
mDescription );
2970 map.insert( QStringLiteral(
"help" ),
mHelp );
2971 map.insert( QStringLiteral(
"default" ),
mDefault );
2972 map.insert( QStringLiteral(
"defaultGui" ),
mGuiDefault );
2973 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
mFlags ) );
2974 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
2980 mName = map.value( QStringLiteral(
"name" ) ).toString();
2981 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
2982 mHelp = map.value( QStringLiteral(
"help" ) ).toString();
2983 mDefault = map.value( QStringLiteral(
"default" ) );
2984 mGuiDefault = map.value( QStringLiteral(
"defaultGui" ) );
2985 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
2986 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
3002 QString text = QStringLiteral(
"<p><b>%1</b></p>" ).arg(
description() );
3003 if ( !
help().isEmpty() )
3005 text += QStringLiteral(
"<p>%1</p>" ).arg(
help() );
3007 text += QStringLiteral(
"<p>%1</p>" ).arg( QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
3022 if ( !val.isValid() )
3023 return QStringLiteral(
"None" );
3025 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
3027 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
3032 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3034 code += QLatin1String(
"optional " );
3035 code +=
type() +
' ';
3036 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
3037 return code.trimmed();
3059 if ( !input.isValid() )
3067 if ( input.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
3071 else if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3075 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3080 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3086 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3089 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3097 if ( !value.isValid() )
3098 return QStringLiteral(
"None" );
3100 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
3103 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
3108 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3109 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3112 p.insert(
name(), value );
3151 if ( !input.isValid() )
3159 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3164 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3169 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3187 if ( !val.isValid() )
3188 return QStringLiteral(
"None" );
3190 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
3194 p.insert(
name(), val );
3214 for (
const QString &raster : rasters )
3216 if ( !vectors.contains( raster ) )
3220 for (
const QString &mesh : meshFilters )
3222 if ( !vectors.contains( mesh ) )
3226 for (
const QString &pointCloud : pointCloudFilters )
3228 if ( !vectors.contains( pointCloud ) )
3229 vectors << pointCloud;
3231 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
3232 std::sort( vectors.begin(), vectors.end() );
3234 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QLatin1String(
";;" ) );
3244 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3246 code += QLatin1String(
"optional " );
3247 code += QLatin1String(
"layer " );
3254 code += QLatin1String(
"hasgeometry " );
3258 code += QLatin1String(
"point " );
3262 code += QLatin1String(
"line " );
3266 code += QLatin1String(
"polygon " );
3270 code += QLatin1String(
"raster " );
3274 code += QLatin1String(
"mesh " );
3278 code += QLatin1String(
"plugin " );
3282 code += QLatin1String(
"pointcloud " );
3286 code += QLatin1String(
"annotation " );
3292 return code.trimmed();
3298 QString def = definition;
3301 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
3304 def = def.mid( 12 );
3307 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
3313 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
3319 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
3325 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
3331 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
3337 else if ( def.startsWith( QLatin1String(
"plugin" ), Qt::CaseInsensitive ) )
3343 else if ( def.startsWith( QLatin1String(
"pointcloud" ), Qt::CaseInsensitive ) )
3346 def = def.mid( 11 );
3349 else if ( def.startsWith( QLatin1String(
"annotation" ), Qt::CaseInsensitive ) )
3352 def = def.mid( 11 );
3363 switch ( outputType )
3367 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', %2" )
3370 code += QLatin1String(
", optional=True" );
3377 QStringList options;
3381 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
3385 code += QLatin1Char(
')' );
3402 map.insert( QStringLiteral(
"data_types" ), types );
3410 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3411 for (
const QVariant &val : values )
3432 if ( !input.isValid() )
3440 if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3444 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3449 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3454 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3459 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3463 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3470 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3473 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3482 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
3483 const QRegularExpressionMatch match = rx.match( input.toString() );
3484 if ( match.hasMatch() )
3486 bool xMinOk =
false;
3487 ( void )match.captured( 1 ).toDouble( &xMinOk );
3488 bool xMaxOk =
false;
3489 ( void )match.captured( 2 ).toDouble( &xMaxOk );
3490 bool yMinOk =
false;
3491 ( void )match.captured( 3 ).toDouble( &yMinOk );
3492 bool yMaxOk =
false;
3493 ( void )match.captured( 4 ).toDouble( &yMaxOk );
3494 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
3504 if ( !value.isValid() )
3505 return QStringLiteral(
"None" );
3507 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3508 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3510 if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
3518 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3526 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3531 const QString wkt = g.
asWkt();
3532 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3537 p.insert(
name(), value );
3574 if ( !input.isValid() )
3582 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3587 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3591 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3595 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3600 if ( input.type() == QVariant::String )
3602 if ( input.toString().isEmpty() )
3606 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3608 const QRegularExpressionMatch match = rx.match( input.toString() );
3609 if ( match.hasMatch() )
3612 ( void )match.captured( 1 ).toDouble( &xOk );
3614 ( void )match.captured( 2 ).toDouble( &yOk );
3623 if ( !value.isValid() )
3624 return QStringLiteral(
"None" );
3626 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3627 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3629 if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
3635 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3642 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3647 const QString wkt = g.
asWkt();
3648 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3661 const QVariant &defaultValue,
bool optional,
const QList<int> &geometryTypes,
bool allowMultipart )
3663 mGeomTypes( geometryTypes ),
3664 mAllowMultipart( allowMultipart )
3677 if ( !input.isValid() )
3685 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3692 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3694 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( input.value<
QgsGeometry>().
type() ) ) ) &&
3695 ( mAllowMultipart || !input.value<
QgsGeometry>().isMultipart() );
3698 if ( input.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3704 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3709 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3714 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3719 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3724 if ( input.type() == QVariant::String )
3726 if ( input.toString().isEmpty() )
3731 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3733 const QRegularExpressionMatch match = rx.match( input.toString() );
3734 if ( match.hasMatch() )
3739 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( g.
type() ) ) ) && ( mAllowMultipart || !g.
isMultipart() );
3759 if ( !value.isValid() )
3760 return QStringLiteral(
"None" );
3762 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3765 if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3772 if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3779 if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
3786 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3793 if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
3800 if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3812 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3814 code += QLatin1String(
"optional " );
3815 code +=
type() +
' ';
3817 for (
const int type : mGeomTypes )
3822 code += QLatin1String(
"point " );
3826 code += QLatin1String(
"line " );
3830 code += QLatin1String(
"polygon " );
3834 code += QLatin1String(
"unknown " );
3840 return code.trimmed();
3845 switch ( outputType )
3849 QString code = QStringLiteral(
"QgsProcessingParameterGeometry('%1', %2" )
3852 code += QLatin1String(
", optional=True" );
3854 if ( !mGeomTypes.empty() )
3861 return QStringLiteral(
"PointGeometry" );
3864 return QStringLiteral(
"LineGeometry" );
3867 return QStringLiteral(
"PolygonGeometry" );
3870 return QStringLiteral(
"UnknownGeometry" );
3873 return QStringLiteral(
"NullGeometry" );
3878 QStringList options;
3879 options.reserve( mGeomTypes.size() );
3880 for (
const int type : mGeomTypes )
3882 options << QStringLiteral(
" QgsWkbTypes.%1" ).arg( geomTypeToString(
static_cast<Qgis::GeometryType>(
type ) ) );
3884 code += QStringLiteral(
", geometryTypes=[%1 ]" ).arg( options.join(
',' ) );
3887 if ( ! mAllowMultipart )
3889 code += QLatin1String(
", allowMultipart=False" );
3904 for (
const int type : mGeomTypes )
3908 map.insert( QStringLiteral(
"geometrytypes" ), types );
3909 map.insert( QStringLiteral(
"multipart" ), mAllowMultipart );
3917 const QVariantList values = map.value( QStringLiteral(
"geometrytypes" ) ).toList();
3918 for (
const QVariant &val : values )
3920 mGeomTypes << val.toInt();
3922 mAllowMultipart = map.value( QStringLiteral(
"multipart" ) ).toBool();
3933 , mBehavior( behavior )
3934 , mExtension( fileFilter.isEmpty() ? extension : QString() )
3935 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
3948 if ( !input.isValid() )
3956 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3961 const QString
string = input.toString().trimmed();
3963 if ( input.type() != QVariant::String ||
string.isEmpty() )
3966 switch ( mBehavior )
3970 if ( !mExtension.isEmpty() )
3972 return string.endsWith( mExtension, Qt::CaseInsensitive );
3974 else if ( !mFileFilter.isEmpty() )
3992 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3994 code += QLatin1String(
"optional " );
3995 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
3997 return code.trimmed();
4002 switch ( outputType )
4007 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', %2" )
4010 code += QLatin1String(
", optional=True" );
4011 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
4012 if ( !mExtension.isEmpty() )
4013 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
4014 if ( !mFileFilter.isEmpty() )
4015 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
4026 switch ( mBehavior )
4030 if ( !mFileFilter.isEmpty() )
4031 return mFileFilter != QObject::tr(
"All files (*.*)" ) ? mFileFilter + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" ) : mFileFilter;
4032 else if ( !mExtension.isEmpty() )
4033 return QObject::tr(
"%1 files" ).arg( mExtension.toUpper() ) + QStringLiteral(
" (*." ) + mExtension.toLower() + QStringLiteral(
");;" ) + QObject::tr(
"All files (*.*)" );
4035 return QObject::tr(
"All files (*.*)" );
4047 mFileFilter.clear();
4057 mFileFilter = filter;
4064 map.insert( QStringLiteral(
"behavior" ), mBehavior );
4065 map.insert( QStringLiteral(
"extension" ), mExtension );
4066 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
4073 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
4074 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
4075 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
4086 , mHeaders( headers )
4087 , mNumberRows( numberRows )
4088 , mFixedNumberRows( fixedNumberRows )
4101 if ( !input.isValid() )
4109 if ( input.type() == QVariant::String )
4111 if ( input.toString().isEmpty() )
4115 else if ( input.type() == QVariant::List )
4117 if ( input.toList().isEmpty() )
4121 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
4131 if ( !value.isValid() )
4132 return QStringLiteral(
"None" );
4134 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4135 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4138 p.insert(
name(), value );
4146 switch ( outputType )
4150 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', %2" )
4153 code += QLatin1String(
", optional=True" );
4154 code += QStringLiteral(
", numberRows=%1" ).arg( mNumberRows );
4155 code += QStringLiteral(
", hasFixedNumberRows=%1" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4158 headers.reserve( mHeaders.size() );
4159 for (
const QString &h : mHeaders )
4161 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
4193 return mFixedNumberRows;
4198 mFixedNumberRows = fixedNumberRows;
4204 map.insert( QStringLiteral(
"headers" ), mHeaders );
4205 map.insert( QStringLiteral(
"rows" ), mNumberRows );
4206 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
4213 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
4214 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
4215 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
4226 , mLayerType( layerType )
4239 if ( !input.isValid() )
4249 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
4255 if ( input.type() == QVariant::String )
4257 if ( input.toString().isEmpty() )
4260 if ( mMinimumNumberInputs > 1 )
4271 else if ( input.type() == QVariant::List )
4273 if ( input.toList().count() < mMinimumNumberInputs )
4276 if ( mMinimumNumberInputs > input.toList().count() )
4284 const auto constToList = input.toList();
4285 for (
const QVariant &v : constToList )
4287 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
4296 else if ( input.type() == QVariant::StringList )
4298 if ( input.toStringList().count() < mMinimumNumberInputs )
4301 if ( mMinimumNumberInputs > input.toStringList().count() )
4309 const auto constToStringList = input.toStringList();
4310 for (
const QString &v : constToStringList )
4323 if ( !value.isValid() )
4324 return QStringLiteral(
"None" );
4326 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4327 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4332 if ( value.type() == QVariant::StringList )
4334 const QStringList list = value.toStringList();
4335 parts.reserve( list.count() );
4336 for (
const QString &v : list )
4339 else if ( value.type() == QVariant::List )
4341 const QVariantList list = value.toList();
4342 parts.reserve( list.count() );
4343 for (
const QVariant &v : list )
4346 if ( !parts.isEmpty() )
4347 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4352 p.insert(
name(), value );
4354 if ( !list.isEmpty() )
4357 parts.reserve( list.count() );
4362 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4381 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4383 code += QLatin1String(
"optional " );
4384 switch ( mLayerType )
4387 code += QLatin1String(
"multiple raster" );
4391 code += QLatin1String(
"multiple file" );
4395 code += QLatin1String(
"multiple vector" );
4399 if (
mDefault.type() == QVariant::List )
4402 const auto constToList =
mDefault.toList();
4403 for (
const QVariant &var : constToList )
4405 parts << var.toString();
4407 code += parts.join(
',' );
4409 else if (
mDefault.type() == QVariant::StringList )
4411 code +=
mDefault.toStringList().join(
',' );
4417 return code.trimmed();
4422 switch ( outputType )
4426 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', %2" )
4429 code += QLatin1String(
", optional=True" );
4433 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
4444 switch ( mLayerType )
4447 return QObject::tr(
"All files (*.*)" );
4486 return mMinimumNumberInputs;
4498 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
4499 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
4507 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
4513 QString
type = definition;
4515 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
4516 const QRegularExpressionMatch m = re.match( definition );
4519 type = m.captured( 1 ).toLower().trimmed();
4520 defaultVal = m.captured( 2 );
4523 if (
type == QLatin1String(
"vector" ) )
4525 else if (
type == QLatin1String(
"raster" ) )
4527 else if (
type == QLatin1String(
"file" ) )
4540 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
4551 QVariant input = value;
4552 if ( !input.isValid() )
4560 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4566 const double res = input.toDouble( &ok );
4570 return !( res < mMin || res > mMax );
4575 if ( !value.isValid() )
4576 return QStringLiteral(
"None" );
4578 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4579 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4581 return value.toString();
4588 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
4589 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
4590 if ( mMax < std::numeric_limits<double>::max() )
4591 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
4593 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
4594 const QString extra = parts.join( QLatin1String(
"<br />" ) );
4595 if ( !extra.isEmpty() )
4596 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
4602 switch ( outputType )
4606 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', %2" )
4609 code += QLatin1String(
", optional=True" );
4611 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4613 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
4614 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
4615 if ( mMax != std::numeric_limits<double>::max() )
4616 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
4658 map.insert( QStringLiteral(
"min" ), mMin );
4659 map.insert( QStringLiteral(
"max" ), mMax );
4660 map.insert( QStringLiteral(
"data_type" ), mDataType );
4667 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
4668 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
4669 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
4676 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4694 if ( !input.isValid() )
4702 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4707 if ( input.type() == QVariant::String )
4709 const QStringList list = input.toString().split(
',' );
4710 if ( list.count() != 2 )
4713 list.at( 0 ).toDouble( &ok );
4715 list.at( 1 ).toDouble( &ok2 );
4720 else if ( input.type() == QVariant::List )
4722 if ( input.toList().count() != 2 )
4726 input.toList().at( 0 ).toDouble( &ok );
4728 input.toList().at( 1 ).toDouble( &ok2 );
4739 if ( !value.isValid() )
4740 return QStringLiteral(
"None" );
4742 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4743 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4746 p.insert(
name(), value );
4749 QStringList stringParts;
4750 const auto constParts = parts;
4751 for (
const double v : constParts )
4753 stringParts << QString::number( v );
4755 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
4760 switch ( outputType )
4764 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', %2" )
4767 code += QLatin1String(
", optional=True" );
4769 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
QgsProcessingParameterNumber::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4792 map.insert( QStringLiteral(
"data_type" ), mDataType );
4806 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4823 if ( !input.isValid() )
4831 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4836 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4839 if ( input.type() != QVariant::String || input.toString().isEmpty() )
4857 if ( !val.isValid() )
4858 return QStringLiteral(
"None" );
4860 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
4864 p.insert(
name(), val );
4892 , mOptions( options )
4893 , mAllowMultiple( allowMultiple )
4894 , mUsesStaticStrings( usesStaticStrings )
4906 QVariant input = value;
4907 if ( !input.isValid() )
4915 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4920 if ( mUsesStaticStrings )
4922 if ( input.type() == QVariant::List )
4924 if ( !mAllowMultiple )
4927 const QVariantList values = input.toList();
4931 for (
const QVariant &val : values )
4933 if ( !mOptions.contains( val.toString() ) )
4939 else if ( input.type() == QVariant::StringList )
4941 if ( !mAllowMultiple )
4944 const QStringList values = input.toStringList();
4949 if ( values.count() > 1 && !mAllowMultiple )
4952 for (
const QString &val : values )
4954 if ( !mOptions.contains( val ) )
4959 else if ( input.type() == QVariant::String )
4961 const QStringList parts = input.toString().split(
',' );
4962 if ( parts.count() > 1 && !mAllowMultiple )
4965 const auto constParts = parts;
4966 for (
const QString &part : constParts )
4968 if ( !mOptions.contains( part ) )
4976 if ( input.type() == QVariant::List )
4978 if ( !mAllowMultiple )
4981 const QVariantList values = input.toList();
4985 for (
const QVariant &val : values )
4988 const int res = val.toInt( &ok );
4991 else if ( res < 0 || res >= mOptions.count() )
4997 else if ( input.type() == QVariant::String )
4999 const QStringList parts = input.toString().split(
',' );
5000 if ( parts.count() > 1 && !mAllowMultiple )
5003 const auto constParts = parts;
5004 for (
const QString &part : constParts )
5007 const int res = part.toInt( &ok );
5010 else if ( res < 0 || res >= mOptions.count() )
5015 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
5018 const int res = input.toInt( &ok );
5021 else if ( res >= 0 && res < mOptions.count() )
5031 if ( !value.isValid() )
5032 return QStringLiteral(
"None" );
5034 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5035 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5037 if ( mUsesStaticStrings )
5039 if ( value.type() == QVariant::List || value.type() == QVariant::StringList )
5042 const QStringList constList = value.toStringList();
5043 for (
const QString &val : constList )
5047 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5049 else if ( value.type() == QVariant::String )
5052 const QStringList constList = value.toString().split(
',' );
5053 if ( constList.count() > 1 )
5055 for (
const QString &val : constList )
5059 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5067 if ( value.type() == QVariant::List )
5070 const auto constToList = value.toList();
5071 for (
const QVariant &val : constToList )
5073 parts << QString::number( static_cast< int >( val.toDouble() ) );
5075 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5077 else if ( value.type() == QVariant::String )
5079 const QStringList parts = value.toString().split(
',' );
5080 if ( parts.count() > 1 )
5082 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5086 return QString::number(
static_cast< int >( value.toDouble() ) );
5092 if ( !value.isValid() )
5095 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5098 if ( mUsesStaticStrings )
5104 if ( value.type() == QVariant::List )
5107 const QVariantList toList = value.toList();
5108 parts.reserve( toList.size() );
5109 for (
const QVariant &val : toList )
5111 parts << mOptions.value(
static_cast< int >( val.toDouble() ) );
5113 return parts.join(
',' );
5115 else if ( value.type() == QVariant::String )
5117 const QStringList parts = value.toString().split(
',' );
5118 QStringList comments;
5119 if ( parts.count() > 1 )
5121 for (
const QString &part : parts )
5124 const int val = part.toInt( &ok );
5126 comments << mOptions.value( val );
5128 return comments.join(
',' );
5132 return mOptions.value(
static_cast< int >( value.toDouble() ) );
5138 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5140 code += QLatin1String(
"optional " );
5141 code += QLatin1String(
"enum " );
5143 if ( mAllowMultiple )
5144 code += QLatin1String(
"multiple " );
5146 if ( mUsesStaticStrings )
5147 code += QLatin1String(
"static " );
5149 code += mOptions.join(
';' ) +
' ';
5152 return code.trimmed();
5157 switch ( outputType )
5161 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', %2" )
5164 code += QLatin1String(
", optional=True" );
5167 options.reserve( mOptions.size() );
5168 for (
const QString &o : mOptions )
5170 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
5172 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5174 code += QStringLiteral(
", usesStaticStrings=%1" ).arg( mUsesStaticStrings ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5197 return mAllowMultiple;
5207 return mUsesStaticStrings;
5218 map.insert( QStringLiteral(
"options" ), mOptions );
5219 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5220 map.insert( QStringLiteral(
"uses_static_strings" ), mUsesStaticStrings );
5227 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
5228 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5229 mUsesStaticStrings = map.value( QStringLiteral(
"uses_static_strings" ) ).toBool();
5236 QString def = definition;
5238 bool multiple =
false;
5239 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5245 bool staticStrings =
false;
5246 if ( def.startsWith( QLatin1String(
"static" ), Qt::CaseInsensitive ) )
5248 staticStrings =
true;
5252 const thread_local QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
5253 const QRegularExpressionMatch m = re.match( def );
5254 QString values = def;
5257 values = m.captured( 1 ).trimmed();
5258 defaultVal = m.captured( 2 );
5266 , mMultiLine( multiLine )
5279 return QStringLiteral(
"None" );
5281 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5282 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5284 const QString s = value.toString();
5290 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5292 code += QLatin1String(
"optional " );
5293 code += QLatin1String(
"string " );
5296 code += QLatin1String(
"long " );
5299 return code.trimmed();
5304 switch ( outputType )
5308 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', %2" )
5311 code += QLatin1String(
", optional=True" );
5312 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5335 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
5342 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
5348 QString def = definition;
5350 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
5356 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5358 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5362 if ( def == QLatin1String(
"None" ) )
5385 if ( !value.isValid() )
5386 return QStringLiteral(
"None" );
5388 const QString s = value.toString();
5394 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5396 code += QLatin1String(
"optional " );
5397 code += QLatin1String(
"authcfg " );
5400 return code.trimmed();
5405 QString def = definition;
5407 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5409 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5413 if ( def == QLatin1String(
"None" ) )
5426 , mParentLayerParameterName( parentLayerParameterName )
5427 , mExpressionType( type )
5439 if ( !value.isValid() )
5440 return QStringLiteral(
"None" );
5442 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5443 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5445 const QString s = value.toString();
5451 QStringList depends;
5452 if ( !mParentLayerParameterName.isEmpty() )
5453 depends << mParentLayerParameterName;
5459 switch ( outputType )
5463 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', %2" )
5466 code += QLatin1String(
", optional=True" );
5468 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5474 switch ( mExpressionType )
5477 code += QLatin1String(
", type=Qgis.ExpressionType.PointCloud)" );
5480 code += QLatin1String(
", type=Qgis.ExpressionType.RasterCalculator)" );
5483 code += QLatin1Char(
')' );
5494 return mParentLayerParameterName;
5504 return mExpressionType;
5515 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5516 map.insert( QStringLiteral(
"expression_type" ),
static_cast< int >( mExpressionType ) );
5523 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5524 mExpressionType =
static_cast< Qgis::ExpressionType >( map.value( QStringLiteral(
"expression_type" ) ).toInt() );
5549 if ( !var.isValid() )
5557 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5570 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
5573 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5591 if ( !val.isValid() )
5592 return QStringLiteral(
"None" );
5594 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
5598 p.insert(
name(), val );
5616 switch ( outputType )
5620 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', %2" )
5623 code += QLatin1String(
", optional=True" );
5627 QStringList options;
5630 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
5664 map.insert( QStringLiteral(
"data_types" ), types );
5672 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
5673 for (
const QVariant &val : values )
5686 const QVariant &defaultValue,
bool optional )
5701 if ( !var.isValid() )
5709 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5722 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
5725 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5743 if ( !val.isValid() )
5744 return QStringLiteral(
"None" );
5746 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
5750 p.insert(
name(), val );
5778 , mParentLayerParameterName( parentLayerParameterName )
5780 , mAllowMultiple( allowMultiple )
5781 , mDefaultToAllFields( defaultToAllFields )
5795 if ( !input.isValid() )
5803 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
5808 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
5810 if ( !mAllowMultiple )
5816 else if ( input.type() == QVariant::String )
5818 if ( input.toString().isEmpty() )
5821 const QStringList parts = input.toString().split(
';' );
5822 if ( parts.count() > 1 && !mAllowMultiple )
5827 if ( input.toString().isEmpty() )
5835 if ( !value.isValid() )
5836 return QStringLiteral(
"None" );
5838 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5839 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5841 if ( value.type() == QVariant::List )
5844 const auto constToList = value.toList();
5845 for (
const QVariant &val : constToList )
5849 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5851 else if ( value.type() == QVariant::StringList )
5854 const auto constToStringList = value.toStringList();
5855 for (
const QString &s : constToStringList )
5859 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5867 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5869 code += QLatin1String(
"optional " );
5870 code += QLatin1String(
"field " );
5872 switch ( mDataType )
5875 code += QLatin1String(
"numeric " );
5879 code += QLatin1String(
"string " );
5883 code += QLatin1String(
"datetime " );
5887 code += QLatin1String(
"binary " );
5891 code += QLatin1String(
"boolean " );
5898 if ( mAllowMultiple )
5899 code += QLatin1String(
"multiple " );
5901 if ( mDefaultToAllFields )
5902 code += QLatin1String(
"default_to_all_fields " );
5904 code += mParentLayerParameterName +
' ';
5907 return code.trimmed();
5912 switch ( outputType )
5916 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', %2" )
5919 code += QLatin1String(
", optional=True" );
5922 switch ( mDataType )
5925 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
5929 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
5933 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
5937 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
5941 dataType = QStringLiteral(
"QgsProcessingParameterField.Binary" );
5945 dataType = QStringLiteral(
"QgsProcessingParameterField.Boolean" );
5948 code += QStringLiteral(
", type=%1" ).arg(
dataType );
5950 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5951 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5955 if ( mDefaultToAllFields )
5956 code += QLatin1String(
", defaultToAllFields=True" );
5968 QStringList depends;
5969 if ( !mParentLayerParameterName.isEmpty() )
5970 depends << mParentLayerParameterName;
5976 return mParentLayerParameterName;
5996 return mAllowMultiple;
6006 return mDefaultToAllFields;
6011 mDefaultToAllFields = enabled;
6017 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
6018 map.insert( QStringLiteral(
"data_type" ), mDataType );
6019 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
6020 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
6027 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
6028 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
6029 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
6030 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
6040 QString def = definition;
6042 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
6047 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
6052 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
6057 else if ( def.startsWith( QLatin1String(
"binary " ), Qt::CaseInsensitive ) )
6062 else if ( def.startsWith( QLatin1String(
"boolean " ), Qt::CaseInsensitive ) )
6068 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
6071 def = def.mid( 8 ).trimmed();
6074 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
6077 def = def.mid( 21 ).trimmed();
6080 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
6081 const QRegularExpressionMatch m = re.match( def );
6084 parent = m.captured( 1 ).trimmed();
6085 def = m.captured( 2 );
6110 QVariant var = input;
6111 if ( !var.isValid() )
6119 if ( var.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
6124 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6131 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6143 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
6148 if ( var.type() != QVariant::String || var.toString().isEmpty() )
6166 if ( !value.isValid() )
6167 return QStringLiteral(
"None" );
6169 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6172 if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
6175 QString geometryCheckString;
6179 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
6183 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
6187 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
6194 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
6196 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
6197 if ( !
flags.empty() )
6198 flagString =
flags.join( QLatin1String(
" | " ) );
6205 layerString = layer->source();
6212 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6213 geometryCheckString,
6225 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression(%1), selectedFeaturesOnly=%2, featureLimit=%3%4%6, geometryCheck=%5)" )
6229 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6230 geometryCheckString,
6239 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
6244 QString layerString = value.toString();
6248 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
6265 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6267 code += QLatin1String(
"optional " );
6268 code += QLatin1String(
"source " );
6275 code += QLatin1String(
"point " );
6279 code += QLatin1String(
"line " );
6283 code += QLatin1String(
"polygon " );
6290 return code.trimmed();
6295 switch ( outputType )
6299 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', %2" )
6302 code += QLatin1String(
", optional=True" );
6306 QStringList options;
6310 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
6327 : mDataTypes( types )
6340 map.insert( QStringLiteral(
"data_types" ), types );
6348 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
6349 for (
const QVariant &val : values )
6359 QString def = definition;
6362 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6368 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6374 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6389 , mSupportsAppend( supportsAppend )
6400 QVariant var = input;
6401 if ( !var.isValid() )
6409 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6415 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6428 if ( var.type() != QVariant::String )
6431 if ( var.toString().isEmpty() )
6439 if ( !value.isValid() )
6440 return QStringLiteral(
"None" );
6442 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6443 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6445 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6454 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6463 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6465 code += QLatin1String(
"optional " );
6466 code += QLatin1String(
"sink " );
6468 switch ( mDataType )
6471 code += QLatin1String(
"point " );
6475 code += QLatin1String(
"line " );
6479 code += QLatin1String(
"polygon " );
6483 code += QLatin1String(
"table " );
6491 return code.trimmed();
6503 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6507 return p->defaultVectorFileExtension(
hasGeometry() );
6517 return QStringLiteral(
"dbf" );
6524 switch ( outputType )
6528 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', %2" )
6531 code += QLatin1String(
", optional=True" );
6535 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6536 if ( mSupportsAppend )
6537 code += QLatin1String(
", supportsAppend=True" );
6550 QStringList filters;
6551 for (
const QString &ext : exts )
6553 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6555 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6564 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6566 return lOriginalProvider->supportedOutputTableExtensions();
6571 return p->supportedOutputVectorLayerExtensions();
6573 return p->supportedOutputTableExtensions();
6588 switch ( mDataType )
6618 map.insert( QStringLiteral(
"data_type" ), mDataType );
6619 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
6627 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
6634 return QStringLiteral(
"memory:%1" ).arg(
description() );
6642 QString def = definition;
6643 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6648 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6653 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6658 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
6669 return mSupportsAppend;
6689 QVariant var = input;
6690 if ( !var.isValid() )
6698 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6704 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6717 if ( var.type() != QVariant::String )
6720 if ( var.toString().isEmpty() )
6728 if ( !value.isValid() )
6729 return QStringLiteral(
"None" );
6731 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6732 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6734 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6743 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6759 return lOriginalProvider->defaultRasterFileExtension();
6763 return p->defaultRasterFileExtension();
6774 QStringList filters;
6775 for (
const QString &ext : exts )
6777 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6779 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6786 return lOriginalProvider->supportedOutputRasterLayerExtensions();
6790 return p->supportedOutputRasterLayerExtensions();
6806 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
6818 QVariant var = input;
6819 if ( !var.isValid() )
6827 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6833 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6846 if ( var.type() != QVariant::String )
6849 if ( var.toString().isEmpty() )
6859 if ( !value.isValid() )
6860 return QStringLiteral(
"None" );
6862 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6863 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6865 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6874 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6883 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
6895 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
6896 return QStringLiteral(
"file" );
6899 const thread_local QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
6900 const QRegularExpressionMatch match = rx.match( mFileFilter );
6901 if ( !match.hasMatch() )
6902 return QStringLiteral(
"file" );
6904 return match.captured( 1 );
6909 switch ( outputType )
6913 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', %2" )
6916 code += QLatin1String(
", optional=True" );
6920 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6932 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
6948 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
6955 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
6976 QVariant var = input;
6977 if ( !var.isValid() )
6985 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6998 if ( var.type() != QVariant::String )
7001 if ( var.toString().isEmpty() )
7024 , mCreateByDefault( createByDefault )
7032 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
7033 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
7040 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
7041 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
7047 switch ( outputType )
7054 QString code = t->className() + QStringLiteral(
"('%1', %2" )
7057 code += QLatin1String(
", optional=True" );
7059 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7074 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
7081 const thread_local QRegularExpression rx( QStringLiteral(
"[.]" ) );
7082 QString sanitizedName =
name();
7083 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
7098 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
7107 return mCreateByDefault;
7129 QVariant var = input;
7130 if ( !var.isValid() )
7138 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
7144 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
7157 if ( var.type() != QVariant::String )
7160 if ( var.toString().isEmpty() )
7168 if ( !value.isValid() )
7169 return QStringLiteral(
"None" );
7171 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7172 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7174 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
7183 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
7192 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7194 code += QLatin1String(
"optional " );
7195 code += QLatin1String(
"vectorDestination " );
7197 switch ( mDataType )
7200 code += QLatin1String(
"point " );
7204 code += QLatin1String(
"line " );
7208 code += QLatin1String(
"polygon " );
7216 return code.trimmed();
7228 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
7232 return p->defaultVectorFileExtension(
hasGeometry() );
7242 return QStringLiteral(
"dbf" );
7249 switch ( outputType )
7253 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', %2" )
7256 code += QLatin1String(
", optional=True" );
7260 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7273 QStringList filters;
7274 for (
const QString &ext : exts )
7276 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
7278 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
7286 return lOriginalProvider->supportedOutputVectorLayerExtensions();
7288 return lOriginalProvider->supportedOutputTableExtensions();
7293 return p->supportedOutputVectorLayerExtensions();
7295 return p->supportedOutputTableExtensions();
7310 switch ( mDataType )
7340 map.insert( QStringLiteral(
"data_type" ), mDataType );
7354 QString def = definition;
7355 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
7360 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
7365 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
7376 , mParentLayerParameterName( parentLayerParameterName )
7377 , mAllowMultiple( allowMultiple )
7389 QVariant input = value;
7390 if ( !input.isValid() )
7398 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
7403 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
7405 if ( !mAllowMultiple )
7414 const double res = input.toInt( &ok );
7424 return mAllowMultiple;
7434 if ( !value.isValid() )
7435 return QStringLiteral(
"None" );
7437 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7438 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7440 if ( value.type() == QVariant::List )
7443 const QVariantList values = value.toList();
7444 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7446 parts << QString::number( static_cast< int >( it->toDouble() ) );
7448 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7450 else if ( value.type() == QVariant::StringList )
7453 const QStringList values = value.toStringList();
7454 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7456 parts << QString::number( static_cast< int >( it->toDouble() ) );
7458 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7461 return value.toString();
7466 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7468 code += QLatin1String(
"optional " );
7469 code += QLatin1String(
"band " );
7471 if ( mAllowMultiple )
7472 code += QLatin1String(
"multiple " );
7474 code += mParentLayerParameterName +
' ';
7477 return code.trimmed();
7482 QStringList depends;
7483 if ( !mParentLayerParameterName.isEmpty() )
7484 depends << mParentLayerParameterName;
7490 switch ( outputType )
7494 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', %2" )
7497 code += QLatin1String(
", optional=True" );
7499 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
7500 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7512 return mParentLayerParameterName;
7523 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
7524 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
7531 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
7532 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
7539 QString def = definition;
7542 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
7545 def = def.mid( 8 ).trimmed();
7548 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7549 const QRegularExpressionMatch m = re.match( def );
7552 parent = m.captured( 1 ).trimmed();
7553 def = m.captured( 2 );
7570 , mParentParameterName( parentParameterName )
7587 QStringList depends;
7588 if ( !mParentParameterName.isEmpty() )
7589 depends << mParentParameterName;
7595 switch ( outputType )
7599 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', %2" )
7602 code += QLatin1String(
", optional=True" );
7604 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7606 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7607 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7608 if (
maximum() != std::numeric_limits<double>::max() )
7609 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7620 return mParentParameterName;
7631 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7632 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7639 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7666 switch ( outputType )
7670 QString code = QStringLiteral(
"QgsProcessingParameterDuration('%1', %2" )
7673 code += QLatin1String(
", optional=True" );
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() );
7690 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7724 switch ( outputType )
7728 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', %2" )
7731 code += QLatin1String(
", optional=True" );
7743 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
7763 return QStringLiteral(
"None" );
7765 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7766 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7768 const QString s = value.toString();
7774 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7776 code += QLatin1String(
"optional " );
7777 code += QLatin1String(
"layout " );
7780 return code.trimmed();
7785 switch ( outputType )
7789 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', %2" )
7792 code += QLatin1String(
", optional=True" );
7803 QString def = definition;
7805 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7807 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7811 if ( def == QLatin1String(
"None" ) )
7824 , mParentLayoutParameterName( parentLayoutParameterName )
7825 , mItemType( itemType )
7838 return QStringLiteral(
"None" );
7840 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7841 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7843 const QString s = value.toString();
7849 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7851 code += QLatin1String(
"optional " );
7852 code += QLatin1String(
"layoutitem " );
7853 if ( mItemType >= 0 )
7854 code += QString::number( mItemType ) +
' ';
7856 code += mParentLayoutParameterName +
' ';
7859 return code.trimmed();
7864 switch ( outputType )
7868 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', %2" )
7871 code += QLatin1String(
", optional=True" );
7873 if ( mItemType >= 0 )
7874 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
7876 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
7889 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
7890 map.insert( QStringLiteral(
"item_type" ), mItemType );
7897 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
7898 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
7904 QStringList depends;
7905 if ( !mParentLayoutParameterName.isEmpty() )
7906 depends << mParentLayoutParameterName;
7913 QString def = definition;
7915 const thread_local QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
7916 const QRegularExpressionMatch m = re.match( def );
7919 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
7920 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
7921 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
7934 return mParentLayoutParameterName;
7939 mParentLayoutParameterName =
name;
7958 , mAllowOpacity( opacityEnabled )
7971 return QStringLiteral(
"None" );
7973 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7974 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7976 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
7977 return QStringLiteral(
"QColor()" );
7979 if ( value.canConvert< QColor >() )
7981 const QColor
c = value.value< QColor >();
7982 if ( !mAllowOpacity ||
c.alpha() == 255 )
7983 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
7985 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
7988 const QString s = value.toString();
7994 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7996 code += QLatin1String(
"optional " );
7997 code += QLatin1String(
"color " );
7999 if ( mAllowOpacity )
8000 code += QLatin1String(
"withopacity " );
8003 return code.trimmed();
8008 switch ( outputType )
8012 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', %2" )
8015 code += QLatin1String(
", optional=True" );
8017 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
8029 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
8032 if ( !input.isValid() )
8035 if ( input.type() == QVariant::Color )
8039 else if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
8044 if ( input.type() != QVariant::String || input.toString().isEmpty() )
8047 bool containsAlpha =
false;
8054 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
8061 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
8067 return mAllowOpacity;
8072 mAllowOpacity = enabled;
8077 QString def = definition;
8079 bool allowOpacity =
false;
8080 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
8082 allowOpacity =
true;
8083 def = def.mid( 12 );
8086 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8088 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8092 if ( def == QLatin1String(
"None" ) || def.isEmpty() )
8103 , mSourceParameterName( sourceCrsParameterName )
8104 , mDestParameterName( destinationCrsParameterName )
8105 , mSourceCrs( staticSourceCrs )
8106 , mDestCrs( staticDestinationCrs )
8119 return QStringLiteral(
"None" );
8121 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
8124 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
8129 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8130 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8133 p.insert(
name(), value );
8138 const QString s = value.toString();
8144 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8146 code += QLatin1String(
"optional " );
8147 code += QLatin1String(
"coordinateoperation " );
8150 return code.trimmed();
8155 switch ( outputType )
8160 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', %2" )
8163 code += QLatin1String(
", optional=True" );
8164 if ( !mSourceParameterName.isEmpty() )
8165 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg(
valueAsPythonString( mSourceParameterName,
c ) );
8166 if ( !mDestParameterName.isEmpty() )
8167 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg(
valueAsPythonString( mDestParameterName,
c ) );
8169 if ( mSourceCrs.isValid() )
8171 if ( mDestCrs.isValid() )
8172 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg(
valueAsPythonString( mDestCrs,
c ) );
8184 if ( !mSourceParameterName.isEmpty() )
8185 res << mSourceParameterName;
8186 if ( !mDestParameterName.isEmpty() )
8187 res << mDestParameterName;
8194 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
8195 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
8196 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
8197 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
8204 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
8205 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
8206 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
8207 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
8213 QString def = definition;
8215 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8217 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8221 if ( def == QLatin1String(
"None" ) )
8246 if ( !input.isValid() && !
mDefault.isValid() )
8249 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8250 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8258 if ( !value.isValid() )
8259 return QStringLiteral(
"None" );
8261 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8262 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8269 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8271 code += QLatin1String(
"optional " );
8272 code += QLatin1String(
"maptheme " );
8275 return code.trimmed();
8280 switch ( outputType )
8284 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', %2" )
8287 code += QLatin1String(
", optional=True" );
8312 QString def = definition;
8313 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8315 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8337 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
8339 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
8350 QVariant input = value;
8351 if ( !input.isValid() )
8359 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
8364 if ( input.type() != QVariant::DateTime && input.type() != QVariant::Date && input.type() != QVariant::Time && input.type() != QVariant::String )
8367 if ( ( input.type() == QVariant::DateTime || input.type() == QVariant::Date ) && mDataType ==
Time )
8370 if ( input.type() == QVariant::String )
8372 const QString s = input.toString();
8376 input = QDateTime::fromString( s, Qt::ISODate );
8377 if ( mDataType ==
Time )
8379 if ( !input.toDateTime().isValid() )
8380 input = QTime::fromString( s );
8382 input = input.toDateTime().time();
8386 if ( mDataType !=
Time )
8388 const QDateTime res = input.toDateTime();
8389 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
8393 const QTime res = input.toTime();
8394 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
8400 if ( !value.isValid() )
8401 return QStringLiteral(
"None" );
8403 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8404 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8406 if ( value.type() == QVariant::DateTime )
8408 const QDateTime dt = value.toDateTime();
8409 if ( !dt.isValid() )
8410 return QStringLiteral(
"QDateTime()" );
8412 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
8413 .arg( dt.date().month() )
8414 .arg( dt.date().day() )
8415 .arg( dt.time().hour() )
8416 .arg( dt.time().minute() )
8417 .arg( dt.time().second() );
8419 else if ( value.type() == QVariant::Date )
8421 const QDate dt = value.toDate();
8422 if ( !dt.isValid() )
8423 return QStringLiteral(
"QDate()" );
8425 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
8429 else if ( value.type() == QVariant::Time )
8431 const QTime dt = value.toTime();
8432 if ( !dt.isValid() )
8433 return QStringLiteral(
"QTime()" );
8435 return QStringLiteral(
"QTime(%4, %5, %6)" )
8438 .arg( dt.second() );
8440 return value.toString();
8447 if ( mMin.isValid() )
8448 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
8449 if ( mMax.isValid() )
8450 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
8452 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
DateTime ?
mDefault.toDateTime().toString( Qt::ISODate ) :
8453 ( mDataType ==
Date ?
mDefault.toDate().toString( Qt::ISODate ) :
mDefault.toTime( ).toString() ) );
8454 const QString extra = parts.join( QLatin1String(
"<br />" ) );
8455 if ( !extra.isEmpty() )
8456 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
8462 switch ( outputType )
8466 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', %2" )
8469 code += QLatin1String(
", optional=True" );
8471 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
DateTime ? QStringLiteral(
"QgsProcessingParameterDateTime.DateTime" )
8472 : mDataType ==
Date ? QStringLiteral(
"QgsProcessingParameterDateTime.Date" )
8473 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
8476 if ( mMin.isValid() )
8478 if ( mMax.isValid() )
8520 map.insert( QStringLiteral(
"min" ), mMin );
8521 map.insert( QStringLiteral(
"max" ), mMax );
8522 map.insert( QStringLiteral(
"data_type" ), mDataType );
8529 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
8530 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
8531 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
8538 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
8549 , mProviderId( provider )
8562 if ( !input.isValid() && !
mDefault.isValid() )
8565 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8566 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8574 if ( !value.isValid() )
8575 return QStringLiteral(
"None" );
8577 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8578 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8585 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8587 code += QLatin1String(
"optional " );
8588 code += QLatin1String(
"providerconnection " );
8589 code += mProviderId +
' ';
8592 return code.trimmed();
8597 switch ( outputType )
8601 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', %2, '%3'" )
8604 code += QLatin1String(
", optional=True" );
8618 map.insert( QStringLiteral(
"provider" ), mProviderId );
8625 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
8631 QString def = definition;
8633 if ( def.contains(
' ' ) )
8635 provider = def.left( def.indexOf(
' ' ) );
8636 def = def.mid( def.indexOf(
' ' ) + 1 );
8644 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8646 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8664 , mParentConnectionParameterName( parentLayerParameterName )
8677 if ( !input.isValid() && !
mDefault.isValid() )
8680 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8681 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8689 if ( !value.isValid() )
8690 return QStringLiteral(
"None" );
8692 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8693 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8700 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8702 code += QLatin1String(
"optional " );
8703 code += QLatin1String(
"databaseschema " );
8705 code += mParentConnectionParameterName +
' ';
8708 return code.trimmed();
8713 switch ( outputType )
8717 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', %2" )
8720 code += QLatin1String(
", optional=True" );
8722 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8736 QStringList depends;
8737 if ( !mParentConnectionParameterName.isEmpty() )
8738 depends << mParentConnectionParameterName;
8744 return mParentConnectionParameterName;
8749 mParentConnectionParameterName =
name;
8755 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8762 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8769 QString def = definition;
8771 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
8772 const QRegularExpressionMatch m = re.match( def );
8775 parent = m.captured( 1 ).trimmed();
8776 def = m.captured( 2 );
8792 const QString &connectionParameterName,
8793 const QString &schemaParameterName,
8794 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
8796 , mParentConnectionParameterName( connectionParameterName )
8797 , mParentSchemaParameterName( schemaParameterName )
8798 , mAllowNewTableNames( allowNewTableNames )
8811 if ( !input.isValid() && !
mDefault.isValid() )
8814 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8815 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8823 if ( !value.isValid() )
8824 return QStringLiteral(
"None" );
8826 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8827 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8834 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8836 code += QLatin1String(
"optional " );
8837 code += QLatin1String(
"databasetable " );
8839 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
8840 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
8843 return code.trimmed();
8848 switch ( outputType )
8852 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', %2" )
8855 code += QLatin1String(
", optional=True" );
8857 if ( mAllowNewTableNames )
8858 code += QLatin1String(
", allowNewTableNames=True" );
8860 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8861 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
8875 QStringList depends;
8876 if ( !mParentConnectionParameterName.isEmpty() )
8877 depends << mParentConnectionParameterName;
8878 if ( !mParentSchemaParameterName.isEmpty() )
8879 depends << mParentSchemaParameterName;
8885 return mParentConnectionParameterName;
8890 mParentConnectionParameterName =
name;
8895 return mParentSchemaParameterName;
8900 mParentSchemaParameterName =
name;
8906 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8907 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
8908 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
8915 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8916 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
8917 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
8925 QString def = definition;
8927 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
8928 const QRegularExpressionMatch m = re.match( def );
8931 connection = m.captured( 1 ).trimmed();
8932 if ( connection == QLatin1String(
"none" ) )
8934 schema = m.captured( 2 ).trimmed();
8935 if ( schema == QLatin1String(
"none" ) )
8937 def = m.captured( 3 );
8945 return mAllowNewTableNames;
8958 const QVariant &defaultValue,
bool optional )
8972 if ( !var.isValid() )
8980 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
8993 if ( qobject_cast< QgsPointCloudLayer * >( qvariant_cast<QObject *>( var ) ) )
8996 if ( var.type() != QVariant::String || var.toString().isEmpty() )
9014 if ( !val.isValid() )
9015 return QStringLiteral(
"None" );
9017 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
9021 p.insert(
name(), val );
9052 const QVariant &defaultValue,
bool optional )
9065 if ( !var.isValid() )
9073 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
9086 if ( qobject_cast< QgsAnnotationLayer * >( qvariant_cast<QObject *>( var ) ) )
9089 if ( var.type() != QVariant::String || var.toString().isEmpty() )
9107 if ( !val.isValid() )
9108 return QStringLiteral(
"None" );
9110 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
9114 p.insert(
name(), val );
9147 QVariant var = input;
9148 if ( !var.isValid() )
9156 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9162 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
9175 if ( var.type() != QVariant::String )
9178 if ( var.toString().isEmpty() )
9186 if ( !value.isValid() )
9187 return QStringLiteral(
"None" );
9189 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
9190 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9192 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9201 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9217 return lOriginalProvider->defaultPointCloudFileExtension();
9221 return p->defaultPointCloudFileExtension();
9232 QStringList filters;
9233 for (
const QString &ext : exts )
9235 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9237 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9244 return lOriginalProvider->supportedOutputPointCloudLayerExtensions();
9248 return p->supportedOutputPointCloudLayerExtensions();
9253 return QStringList() << ext;
9268 , mParentLayerParameterName( parentLayerParameterName )
9269 , mAllowMultiple( allowMultiple )
9270 , mDefaultToAllAttributes( defaultToAllAttributes )
9290 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
9295 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
9297 if ( !mAllowMultiple )
9303 else if ( input.type() == QVariant::String )
9305 if ( input.toString().isEmpty() )
9308 const QStringList parts = input.toString().split(
';' );
9309 if ( parts.count() > 1 && !mAllowMultiple )
9314 if ( input.toString().isEmpty() )
9322 if ( !value.isValid() )
9323 return QStringLiteral(
"None" );
9325 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
9326 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9328 if ( value.type() == QVariant::List )
9331 const auto constToList = value.toList();
9332 for (
const QVariant &val : constToList )
9336 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9338 else if ( value.type() == QVariant::StringList )
9341 const auto constToStringList = value.toStringList();
9342 for (
const QString &s : constToStringList )
9346 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9354 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
9356 code += QLatin1String(
"optional " );
9357 code += QLatin1String(
"attribute " );
9359 if ( mAllowMultiple )
9360 code += QLatin1String(
"multiple " );
9362 if ( mDefaultToAllAttributes )
9363 code += QLatin1String(
"default_to_all_attributes " );
9365 code += mParentLayerParameterName +
' ';
9368 return code.trimmed();
9373 switch ( outputType )
9377 QString code = QStringLiteral(
"QgsProcessingParameterPointCloudAttribute('%1', %2" )
9380 code += QLatin1String(
", optional=True" );
9382 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
9383 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
9387 if ( mDefaultToAllAttributes )
9388 code += QLatin1String(
", defaultToAllAttributes=True" );
9400 QStringList depends;
9401 if ( !mParentLayerParameterName.isEmpty() )
9402 depends << mParentLayerParameterName;
9408 return mParentLayerParameterName;
9418 return mAllowMultiple;
9428 return mDefaultToAllAttributes;
9433 mDefaultToAllAttributes = enabled;
9439 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
9440 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
9441 map.insert( QStringLiteral(
"default_to_all_attributes" ), mDefaultToAllAttributes );
9448 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
9449 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
9450 mDefaultToAllAttributes = map.value( QStringLiteral(
"default_to_all_attributes" ) ).toBool();
9459 QString def = definition;
9461 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
9464 def = def.mid( 8 ).trimmed();
9467 if ( def.startsWith( QLatin1String(
"default_to_all_attributes" ), Qt::CaseInsensitive ) )
9470 def = def.mid( 25 ).trimmed();
9473 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
9474 const QRegularExpressionMatch m = re.match( def );
9477 parent = m.captured( 1 ).trimmed();
9478 def = m.captured( 2 );
9505 QVariant var = input;
9506 if ( !var.isValid() )
9514 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9520 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
9533 if ( var.type() != QVariant::String )
9536 if ( var.toString().isEmpty() )
9544 if ( !value.isValid() )
9545 return QStringLiteral(
"None" );
9547 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
9548 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9550 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9559 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9579 QStringList filters;
9580 for (
const QString &ext : exts )
9582 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9584 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9590 return QStringList() << ext;
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.
TemporalUnit
Temporal units.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
WkbType
The WKB type describes the number of dimensions a geometry has.
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.
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
QString toWkt(WktVariant variant=WKT1_GDAL, 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.
InvalidGeometryCheck
Handling of features with invalid geometries.
@ GeometryNoCheck
No invalid geometry checking.
@ GeometryAbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
@ GeometrySkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
An interface for objects which accept features via addFeature(s) methods.
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 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.
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.
QString source() const
Returns the source for the layer.
QgsCoordinateReferenceSystem crs
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
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,...
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 ...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
Flags flags
Flags which dictate source behavior.
bool selectedFeaturesOnly
true if only selected features in the source should be used by algorithms.
QgsFeatureRequest::InvalidGeometryCheck geometryCheck
Geometry check method to apply to this source.
QgsProperty source
Source definition.
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...
@ FlagCreateIndividualOutputPerInputFeature
If set, every feature processed from this source will be placed into its own individually created out...
@ FlagOverrideDefaultGeometryCheck
If set, the default geometry check method (as dictated by QgsProcessingContext) will be overridden fo...
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::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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
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 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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
A 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...
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 asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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.
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::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.
@ DateTime
Datetime values.
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.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable 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.
QgsProcessingParameterDateTime(const QString &name, const QString &description=QString(), Type type=DateTime, const QVariant &defaultValue=QVariant(), bool optional=false, const QDateTime &minValue=QDateTime(), const QDateTime &maxValue=QDateTime())
Constructor for QgsProcessingParameterDateTime.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Type dataType() const
Returns the acceptable data type for the parameter.
void setDataType(Type type)
Sets the acceptable data type for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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.
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...
virtual QStringList valueAsStringList(const QVariant &value, QgsProcessingContext &context, bool &ok) const
Returns a string list version of the parameter input value (if possible).
Flags mFlags
Parameter flags.
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.
virtual QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString mName
Parameter name.
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...
@ FlagOptional
Parameter is optional.
QString mDescription
Parameter description.
virtual QString type() const =0
Unique parameter type name.
Flags flags() const
Returns any flags associated with the parameter.
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.
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.
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 asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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::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...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
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.
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 asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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.
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.
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.
QgsProcessing::SourceType dataType() const
Returns the layer type for 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.
QgsProcessingParameterFeatureSink(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true, bool supportsAppend=false)
Constructor for QgsProcessingParameterFeatureSink.
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.
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the sinks associated with the parameter.
bool supportsAppend() const
Returns true if the sink supports appending features to an existing table.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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.
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.
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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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 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 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.
QgsProcessingParameterField(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), DataType type=Any, bool allowMultiple=false, bool optional=false, bool defaultToAllFields=false)
Constructor for QgsProcessingParameterField.
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 setDataType(DataType type)
Sets the acceptable data type for the field.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
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.
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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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 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 setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
DataType
Field data types.
@ DateTime
Accepts datetime fields.
@ Numeric
Accepts numeric fields.
@ Binary
Accepts binary fields, since QGIS 3.34.
@ String
Accepts string fields.
@ Boolean
Accepts boolean fields, since QGIS 3.34.
DataType dataType() const
Returns the acceptable data type for the field.
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::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 asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter.
static QgsProcessingParameterFile * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition, Behavior behavior=File)
Creates a new parameter using the definition from a script code.
Behavior
Parameter behavior.
@ Folder
Parameter is a folder.
@ File
Parameter is a single file.
Behavior behavior() const
Returns the parameter behavior (e.g.
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.
QgsProcessingParameterFile(const QString &name, const QString &description=QString(), Behavior behavior=File, const QString &extension=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &fileFilter=QString())
Constructor for QgsProcessingParameterFile.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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 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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::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.
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.
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 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 asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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 asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString type() const override
Unique parameter type name.
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::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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
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.
QgsProcessingParameterMultipleLayers(const QString &name, const QString &description=QString(), QgsProcessing::SourceType layerType=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMultipleLayers.
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.
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...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
void setLayerType(QgsProcessing::SourceType type)
Sets the layer type for layers acceptable by the parameter.
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.
QgsProcessing::SourceType layerType() const
Returns the layer type for layers acceptable by the parameter.
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
Double/float values.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
double maximum() const
Returns the maximum value acceptable by the parameter.
QgsProcessingParameterNumber(const QString &name, const QString &description=QString(), Type type=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(Type type)
Sets the acceptable data type for the parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Type dataType() const
Returns the acceptable data type 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.
static QString typeName()
Returns the type name for the parameter class.
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 ...
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.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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::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.
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
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::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
void setDataType(QgsProcessingParameterNumber::Type dataType)
Sets the acceptable data type for the range.
QgsProcessingParameterRange(const QString &name, const QString &description=QString(), QgsProcessingParameterNumber::Type type=QgsProcessingParameterNumber::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...
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::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 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::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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 ...
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...
QgsProcessing::SourceType dataType() const
Returns the layer type for this created vector layer.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the created vector layer.
QgsProcessingParameterVectorDestination(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterVectorDestination.
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.
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...
A vector layer (with or without geometry) parameter for processing algorithms.
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...
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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 normalizeLayerSource(const QString &source)
Normalizes a layer source string for safe comparison across different operating system environments.
static QString encodeProviderKeyAndUri(const QString &providerKey, const QString &uri)
Encodes a provider key and layer uri to a single string, for use with decodeProviderKeyAndUri()
LayerHint
Layer type hints.
@ Annotation
Annotation layer type, since QGIS 3.22.
@ Vector
Vector layer type.
@ VectorTile
Vector tile layer type, since QGIS 3.32.
@ Mesh
Mesh layer type, since QGIS 3.6.
@ Raster
Raster layer type.
@ UnknownType
Unknown layer type.
@ PointCloud
Point cloud layer type, since QGIS 3.22.
static QgsProcessingFeatureSource * variantToSource(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a new feature source.
static QString variantToPythonLiteral(const QVariant &value)
Converts a variant to a Python literal.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
static QString convertToCompatibleFormatAndLayerName(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, QString &layerName, long long featureLimit=-1, const QString &filterExpression=QString())
Converts a source vector layer to a file path and layer name of a vector layer of compatible format.
static QString convertToCompatibleFormat(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, long long featureLimit=-1, const QString &filterExpression=QString())
Converts a source vector layer to a file path of a vector layer of compatible format.
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, Qgis::WkbType geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), QgsRemappingSinkDefinition *remappingDefinition=nullptr)
Creates a feature sink ready for adding features.
static QString defaultRasterExtension()
Returns the default raster extension to use, in the absence of all other constraints (e....
static QString defaultVectorTileExtension()
Returns the default vector tile extension to use, in the absence of all other constraints (e....
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags=QgsProcessing::LayerOptionsFlags())
Interprets a string as a map layer within the supplied context.
static QString defaultPointCloudExtension()
Returns the default point cloud extension to use, in the absence of all other constraints (e....
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.
SourceType
Data source types enum.
@ TypePlugin
Plugin layers.
@ TypeVectorLine
Vector line layers.
@ TypeMapLayer
Any map layer type (raster, vector, mesh, point cloud, annotation or plugin layer)
@ TypeVectorPolygon
Vector polygon layers.
@ TypeFile
Files (i.e. non map layer sources, such as text files)
@ TypeAnnotation
Annotation layers.
@ TypePointCloud
Point cloud layers.
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ TypeRaster
Raster layers.
@ TypeVectorTile
Vector tile layers.
@ TypeVectorPoint
Vector point layers.
@ TypeVectorAnyGeometry
Any vector layer with geometry.
@ SkipIndexGeneration
Do not generate index when creating a layer. Makes sense only for point cloud layers.
static QString sourceTypeToString(SourceType type)
Converts a source type to a string representation.
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.
@ ExpressionBasedProperty
Expression based property (QgsExpressionBasedProperty)
@ StaticProperty
Static property (QgsStaticProperty)
@ FieldBasedProperty
Field based property (QgsFieldBasedProperty)
@ InvalidProperty
Invalid (not set) property.
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.
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.
Type propertyType() const
Returns the property type.
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)
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