41#include <QRegularExpression>
49 map.insert( QStringLiteral(
"feature_limit" ),
featureLimit );
51 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
flags ) );
52 map.insert( QStringLiteral(
"geometry_check" ),
static_cast< int >(
geometryCheck ) );
60 featureLimit = map.value( QStringLiteral(
"feature_limit" ), -1 ).toLongLong();
62 flags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ), 0 ).toInt() );
75 mRemappingDefinition = definition;
82 map.insert( QStringLiteral(
"create_options" ),
createOptions );
84 map.insert( QStringLiteral(
"remapping" ), QVariant::fromValue( mRemappingDefinition ) );
91 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
92 if ( map.contains( QStringLiteral(
"remapping" ) ) )
99 mUseRemapping =
false;
107 && mUseRemapping == other.mUseRemapping && mRemappingDefinition == other.mRemappingDefinition;
112 return !( *
this == other );
117 const QVariant val = parameters.value( name );
118 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
137 QVariant val = value;
138 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
141 if ( !val.isValid() )
150 return destParam->generateTemporaryDestination( &context );
153 return val.toString();
169 const QVariant val = value;
170 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
173 if ( val.isValid() && !val.toString().isEmpty() )
177 return val.toString();
197 QVariant val = value;
198 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
202 const double res = val.toDouble( &ok );
208 return val.toDouble();
224 QVariant val = value;
225 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
229 double dbl = val.toDouble( &ok );
234 dbl = val.toDouble( &ok );
241 const double round = std::round( dbl );
242 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
247 return static_cast< int >( std::round( dbl ) );
256 return QList< int >();
264 return QList< int >();
266 QList< int > resultList;
267 const QVariant val = value;
270 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
272 else if ( val.type() == QVariant::List )
274 const QVariantList list = val.toList();
275 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
276 resultList << it->toInt();
280 const QStringList parts = val.toString().split(
';' );
281 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
282 resultList << it->toInt();
286 if ( resultList.isEmpty() )
291 if ( definition->
defaultValue().type() == QVariant::List )
293 const QVariantList list = definition->
defaultValue().toList();
294 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
295 resultList << it->toInt();
299 const QStringList parts = definition->
defaultValue().toString().split(
';' );
300 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
301 resultList << it->toInt();
322 QVariant val = value;
323 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
326 QDateTime d = val.toDateTime();
327 if ( !d.isValid() && val.type() == QVariant::String )
329 d = QDateTime::fromString( val.toString() );
336 d = val.toDateTime();
338 if ( !d.isValid() && val.type() == QVariant::String )
340 d = QDateTime::fromString( val.toString() );
359 QVariant val = value;
360 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
363 QDate d = val.toDate();
364 if ( !d.isValid() && val.type() == QVariant::String )
366 d = QDate::fromString( val.toString() );
375 if ( !d.isValid() && val.type() == QVariant::String )
377 d = QDate::fromString( val.toString() );
396 QVariant val = value;
397 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
402 if ( val.type() == QVariant::DateTime )
403 d = val.toDateTime().time();
407 if ( !d.isValid() && val.type() == QVariant::String )
409 d = QTime::fromString( val.toString() );
418 if ( !d.isValid() && val.type() == QVariant::String )
420 d = QTime::fromString( val.toString() );
441 if ( enumDef && val >= enumDef->
options().size() )
461 QVariantList resultList;
462 const QVariant val = value;
463 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
465 else if ( val.type() == QVariant::List )
467 const auto constToList = val.toList();
468 for (
const QVariant &var : constToList )
471 else if ( val.type() == QVariant::String )
473 const auto constSplit = val.toString().split(
',' );
474 for (
const QString &var : constSplit )
480 if ( resultList.isEmpty() )
481 return QList< int >();
483 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
487 if ( definition->
defaultValue().type() == QVariant::List )
489 const auto constToList = definition->
defaultValue().toList();
490 for (
const QVariant &var : constToList )
493 else if ( definition->
defaultValue().type() == QVariant::String )
495 const auto constSplit = definition->
defaultValue().toString().split(
',' );
496 for (
const QString &var : constSplit )
505 const auto constResultList = resultList;
506 for (
const QVariant &var : constResultList )
508 const int resInt = var.toInt();
509 if ( !enumDef || resInt < enumDef->options().size() )
532 if ( enumText.isEmpty() || !enumDef->
options().contains( enumText ) )
541 return QStringList();
549 return QStringList();
551 const QVariant val = value;
553 QStringList enumValues;
555 std::function< void(
const QVariant &var ) > processVariant;
556 processVariant = [ &enumValues, &context, &definition, &processVariant ](
const QVariant & var )
558 if ( var.type() == QVariant::List )
560 const auto constToList = var.toList();
561 for (
const QVariant &listVar : constToList )
563 processVariant( listVar );
566 else if ( var.type() == QVariant::StringList )
568 const auto constToStringList = var.toStringList();
569 for (
const QString &s : constToStringList )
574 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
578 const QStringList parts = var.toString().split(
',' );
579 for (
const QString &s : parts )
586 processVariant( val );
592 const QStringList options = enumDef->
options();
593 const QSet<QString> subtraction = QSet<QString>( enumValues.begin(), enumValues.end() ).subtract( QSet<QString>( options.begin(), options.end() ) );
595 if ( enumValues.isEmpty() || !subtraction.isEmpty() )
628 const QVariant val = value;
629 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
631 else if ( val.isValid() )
644 const QVariant val = value;
645 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
647 else if ( val.isValid() )
655 QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
656 const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
661 val = parameters.value( definition->
name() );
664 return parameterAsSink( definition, val, fields, geometryType,
crs, context, destinationIdentifier, sinkFlags, createOptions, datasourceOptions, layerOptions );
667QgsFeatureSink *
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 )
669 QVariantMap options = createOptions;
670 QVariant val = value;
675 bool useRemapDefinition =
false;
676 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
687 useRemapDefinition =
true;
693 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
697 else if ( !val.isValid() || val.toString().isEmpty() )
713 dest = val.toString();
718 dest = destParam->generateTemporaryDestination( &context );
721 if ( dest.isEmpty() )
724 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType,
crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition :
nullptr ) );
725 destinationIdentifier = dest;
727 if ( destinationProject )
729 if ( destName.isEmpty() && definition )
735 outputName = definition->
name();
739 return sink.release();
763 QVariant val = parameters.value( definition->
name() );
765 bool selectedFeaturesOnly =
false;
766 long long featureLimit = -1;
767 QString filterExpression;
768 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
777 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
784 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
790 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
795 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
799 else if ( !val.isValid() || val.toString().isEmpty() )
805 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
811 layerRef = val.toString();
816 if ( layerRef.isEmpty() )
828 compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit, filterExpression );
831 compatibleFormats, preferredFormat, context, feedback, featureLimit, filterExpression );
841 QString *destLayer = layerName;
856 return parameterAsLayer( definition, parameters.value( definition->
name() ), context, layerHint, flags );
864 QVariant val = value;
865 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
870 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
875 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
887 if ( !val.isValid() || val.toString().isEmpty() )
893 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
898 QString layerRef = val.toString();
899 if ( layerRef.isEmpty() )
902 if ( layerRef.isEmpty() )
933 val = parameters.value( definition->
name() );
940 QVariant val = value;
944 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
954 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
958 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
965 dest = val.toString();
970 dest = destParam->generateTemporaryDestination( &context );
973 if ( destinationProject )
976 if ( destName.isEmpty() && definition )
981 outputName = definition->
name();
1004 val = parameters.value( definition->
name() );
1011 QVariant val = value;
1013 if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1021 if ( definition && val.userType() == QMetaType::type(
"QgsProperty" ) )
1025 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
1032 dest = val.toString();
1037 dest = destParam->generateTemporaryDestination( &context );
1057 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
1082 QVariant val = value;
1084 if ( val.userType() == QMetaType::type(
"QgsRectangle" ) )
1088 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1094 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1113 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1119 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1132 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1135 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1138 rectText = val.toString();
1140 if ( rectText.isEmpty() && !layer )
1143 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1144 const QRegularExpressionMatch match = rx.match( rectText );
1145 if ( match.hasMatch() )
1147 bool xMinOk =
false;
1148 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1149 bool xMaxOk =
false;
1150 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1151 bool yMinOk =
false;
1152 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1153 bool yMaxOk =
false;
1154 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1155 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1206 QVariant val = parameters.value( definition->
name() );
1208 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1214 g = g.densifyByCount( 20 );
1228 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1234 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1247 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1250 rectText = val.toString();
1252 if ( !rectText.isEmpty() )
1254 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1255 const QRegularExpressionMatch match = rx.match( rectText );
1256 if ( match.hasMatch() )
1258 bool xMinOk =
false;
1259 const double xMin = match.captured( 1 ).toDouble( &xMinOk );
1260 bool xMaxOk =
false;
1261 const double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1262 bool yMinOk =
false;
1263 const double yMin = match.captured( 3 ).toDouble( &yMinOk );
1264 bool yMaxOk =
false;
1265 const double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1266 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1292 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1321 const QVariant val = parameters.value( definition->
name() );
1327 QVariant val = value;
1328 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1337 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1343 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1355 QString valueAsString;
1356 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1359 valueAsString = val.toString();
1361 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1363 const QRegularExpressionMatch match = rx.match( valueAsString );
1364 if ( match.hasMatch() )
1371 if ( val.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
1377 else if ( val.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1390 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1391 return layer->crs();
1393 return layer->crs();
1395 if (
auto *lProject = context.
project() )
1396 return lProject->crs();
1414 const QVariant val = value;
1415 if ( val.userType() == QMetaType::type(
"QgsPointXY" ) )
1419 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1425 if ( val.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1444 if ( pointText.isEmpty() )
1447 if ( pointText.isEmpty() )
1450 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1453 const QRegularExpressionMatch match = rx.match( valueAsString );
1454 if ( match.hasMatch() )
1457 const double x = match.captured( 1 ).toDouble( &xOk );
1459 const double y = match.captured( 2 ).toDouble( &yOk );
1487 const QVariant val = parameters.value( definition->
name() );
1493 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1502 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1505 const QRegularExpressionMatch match = rx.match( valueAsString );
1506 if ( match.hasMatch() )
1513 if (
auto *lProject = context.
project() )
1514 return lProject->crs();
1532 const QVariant val = value;
1533 if ( val.userType() == QMetaType::type(
"QgsGeometry" ) )
1538 if ( val.userType() == QMetaType::type(
"QgsPointXY" ) )
1543 if ( val.userType() == QMetaType::type(
"QgsRectangle" ) )
1548 if ( val.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1566 if ( val.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1572 g = g.densifyByCount( 20 );
1586 if ( val.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
1605 if ( valueAsString.isEmpty() )
1608 if ( valueAsString.isEmpty() )
1611 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1613 const QRegularExpressionMatch match = rx.match( valueAsString );
1614 if ( match.hasMatch() )
1641 const QVariant val = parameters.value( definition->
name() );
1647 if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
1656 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
1665 if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
1675 const QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1678 const QRegularExpressionMatch match = rx.match( valueAsString );
1679 if ( match.hasMatch() )
1686 if (
auto *lProject = context.
project() )
1687 return lProject->crs();
1698 if ( fileText.isEmpty() )
1709 if ( fileText.isEmpty() )
1717 return QVariantList();
1725 return QVariantList();
1727 QString resultString;
1728 const QVariant val = value;
1729 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1731 else if ( val.type() == QVariant::List )
1732 return val.toList();
1734 resultString = val.toString();
1736 if ( resultString.isEmpty() )
1739 if ( definition->
defaultValue().type() == QVariant::List )
1745 QVariantList result;
1746 const auto constSplit = resultString.split(
',' );
1749 for (
const QString &s : constSplit )
1751 number = s.toDouble( &ok );
1752 result << ( ok ? QVariant( number ) : s );
1761 return QList<QgsMapLayer *>();
1769 return QList<QgsMapLayer *>();
1771 const QVariant val = value;
1772 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1774 return QList<QgsMapLayer *>() << layer;
1777 QList<QgsMapLayer *> layers;
1779 std::function< void(
const QVariant &var ) > processVariant;
1780 processVariant = [ &layers, &context, &definition, flags, &processVariant](
const QVariant & var )
1782 if ( var.type() == QVariant::List )
1784 const auto constToList = var.toList();
1785 for (
const QVariant &listVar : constToList )
1787 processVariant( listVar );
1790 else if ( var.type() == QVariant::StringList )
1792 const auto constToStringList = var.toStringList();
1793 for (
const QString &s : constToStringList )
1795 processVariant( s );
1798 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
1800 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
1804 const QVariant sink = fromVar.
sink;
1805 if ( sink.userType() == QMetaType::type(
"QgsProperty" ) )
1810 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1822 processVariant( val );
1824 if ( layers.isEmpty() )
1827 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->
defaultValue() ) ) )
1831 else if ( definition->
defaultValue().type() == QVariant::List )
1833 const auto constToList = definition->
defaultValue().toList();
1834 for (
const QVariant &var : constToList )
1836 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1842 processVariant( var );
1856 return QStringList();
1858 const QVariant val = value;
1862 std::function< void(
const QVariant &var ) > processVariant;
1863 processVariant = [ &
files, &context, &definition, &processVariant ](
const QVariant & var )
1865 if ( var.type() == QVariant::List )
1867 const auto constToList = var.toList();
1868 for (
const QVariant &listVar : constToList )
1870 processVariant( listVar );
1873 else if ( var.type() == QVariant::StringList )
1875 const auto constToStringList = var.toStringList();
1876 for (
const QString &s : constToStringList )
1878 processVariant( s );
1881 else if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
1885 files << var.toString();
1889 processVariant( val );
1891 if (
files.isEmpty() )
1902 return QStringList();
1910 return QList<double>();
1918 return QList<double>();
1920 QStringList resultStringList;
1921 const QVariant val = value;
1923 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
1925 else if ( val.type() == QVariant::List )
1927 const auto constToList = val.toList();
1928 for (
const QVariant &var : constToList )
1929 resultStringList << var.toString();
1932 resultStringList << val.toString();
1934 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1936 resultStringList.clear();
1938 if ( definition->
defaultValue().type() == QVariant::List )
1940 const auto constToList = definition->
defaultValue().toList();
1941 for (
const QVariant &var : constToList )
1942 resultStringList << var.toString();
1945 resultStringList << definition->
defaultValue().toString();
1948 if ( resultStringList.size() == 1 )
1950 resultStringList = resultStringList.at( 0 ).split(
',' );
1953 if ( resultStringList.size() < 2 )
1954 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1956 QList< double > result;
1958 double n = resultStringList.at( 0 ).toDouble( &ok );
1962 result << std::numeric_limits<double>::quiet_NaN() ;
1964 n = resultStringList.at( 1 ).toDouble( &ok );
1968 result << std::numeric_limits<double>::quiet_NaN() ;
1976 return QStringList();
1989 return QStringList();
1997 return QStringList();
1999 QStringList resultStringList;
2000 const QVariant val = value;
2001 if ( val.isValid() )
2003 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
2005 else if ( val.type() == QVariant::List )
2007 const auto constToList = val.toList();
2008 for (
const QVariant &var : constToList )
2009 resultStringList << var.toString();
2011 else if ( val.type() == QVariant::StringList )
2013 resultStringList = val.toStringList();
2016 resultStringList.append( val.toString().split(
';' ) );
2019 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
2021 resultStringList.clear();
2025 if ( definition->
defaultValue().type() == QVariant::List )
2027 const auto constToList = definition->
defaultValue().toList();
2028 for (
const QVariant &var : constToList )
2029 resultStringList << var.toString();
2031 else if ( definition->
defaultValue().type() == QVariant::StringList )
2033 resultStringList = definition->
defaultValue().toStringList();
2036 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
2040 return resultStringList;
2054 if ( layoutName.isEmpty() )
2106 QVariant val = value;
2107 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
2111 if ( val.type() == QVariant::Color )
2113 QColor
c = val.value< QColor >();
2115 if ( !colorParam->opacityEnabled() )
2123 if ( definition->
defaultValue().type() == QVariant::Color )
2129 if ( colorText.isEmpty() )
2132 bool containsAlpha =
false;
2135 if (
c.isValid() && !colorParam->opacityEnabled() )
2207 const QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
2208 const QString name = map.value( QStringLiteral(
"name" ) ).toString();
2209 std::unique_ptr< QgsProcessingParameterDefinition > def;
2286 def.reset( paramType->
create( name ) );
2292 def->fromVariantMap( map );
2293 return def.release();
2298 QString desc = name;
2299 desc.replace(
'_',
' ' );
2305 bool isOptional =
false;
2309 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2314 if ( type == QLatin1String(
"boolean" ) )
2316 else if ( type == QLatin1String(
"crs" ) )
2318 else if ( type == QLatin1String(
"layer" ) )
2320 else if ( type == QLatin1String(
"extent" ) )
2322 else if ( type == QLatin1String(
"point" ) )
2324 else if ( type == QLatin1String(
"geometry" ) )
2326 else if ( type == QLatin1String(
"file" ) )
2328 else if ( type == QLatin1String(
"folder" ) )
2330 else if ( type == QLatin1String(
"matrix" ) )
2332 else if ( type == QLatin1String(
"multiple" ) )
2334 else if ( type == QLatin1String(
"number" ) )
2336 else if ( type == QLatin1String(
"distance" ) )
2338 else if ( type == QLatin1String(
"duration" ) )
2340 else if ( type == QLatin1String(
"scale" ) )
2342 else if ( type == QLatin1String(
"range" ) )
2344 else if ( type == QLatin1String(
"raster" ) )
2346 else if ( type == QLatin1String(
"enum" ) )
2348 else if ( type == QLatin1String(
"string" ) )
2350 else if ( type == QLatin1String(
"authcfg" ) )
2352 else if ( type == QLatin1String(
"expression" ) )
2354 else if ( type == QLatin1String(
"field" ) )
2356 else if ( type == QLatin1String(
"vector" ) )
2358 else if ( type == QLatin1String(
"source" ) )
2360 else if ( type == QLatin1String(
"sink" ) )
2362 else if ( type == QLatin1String(
"vectordestination" ) )
2364 else if ( type == QLatin1String(
"rasterdestination" ) )
2366 else if ( type == QLatin1String(
"pointclouddestination" ) )
2368 else if ( type == QLatin1String(
"filedestination" ) )
2370 else if ( type == QLatin1String(
"folderdestination" ) )
2372 else if ( type == QLatin1String(
"band" ) )
2374 else if ( type == QLatin1String(
"mesh" ) )
2376 else if ( type == QLatin1String(
"layout" ) )
2378 else if ( type == QLatin1String(
"layoutitem" ) )
2380 else if ( type == QLatin1String(
"color" ) )
2382 else if ( type == QLatin1String(
"coordinateoperation" ) )
2384 else if ( type == QLatin1String(
"maptheme" ) )
2386 else if ( type == QLatin1String(
"datetime" ) )
2388 else if ( type == QLatin1String(
"providerconnection" ) )
2390 else if ( type == QLatin1String(
"databaseschema" ) )
2392 else if ( type == QLatin1String(
"databasetable" ) )
2394 else if ( type == QLatin1String(
"pointcloud" ) )
2396 else if ( type == QLatin1String(
"annotation" ) )
2398 else if ( type == QLatin1String(
"attribute" ) )
2400 else if ( type == QLatin1String(
"vectortiledestination" ) )
2406bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2408 const thread_local QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
2409 QRegularExpressionMatch m = re.match( code );
2410 if ( !m.hasMatch() )
2413 name = m.captured( 1 );
2414 QString tokens = m.captured( 2 );
2415 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
2418 tokens.remove( 0, 8 );
2425 tokens = tokens.trimmed();
2427 const thread_local QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2428 m = re2.match( tokens );
2429 if ( !m.hasMatch() )
2431 type = tokens.toLower().trimmed();
2436 type = m.captured( 1 ).toLower().trimmed();
2437 definition = m.captured( 2 );
2448 , mDescription( description )
2450 , mDefault( defaultValue )
2451 , mFlags( optional ? FlagOptional : 0 )
2456 if ( !input.isValid() && !
mDefault.isValid() )
2459 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
2460 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
2468 if ( !value.isValid() )
2469 return QStringLiteral(
"None" );
2471 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2472 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2484 if ( !value.isValid() )
2488 if ( value.type() == QVariant::Type::Map )
2490 const QVariantMap sourceMap = value.toMap();
2491 QVariantMap resultMap;
2492 for (
auto it = sourceMap.constBegin(); it != sourceMap.constEnd(); it++ )
2498 else if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList )
2500 const QVariantList sourceList = value.toList();
2501 QVariantList resultList;
2502 resultList.reserve( sourceList.size() );
2503 for (
const QVariant &v : sourceList )
2511 switch ( value.userType() )
2514 case QMetaType::Bool:
2515 case QMetaType::Char:
2516 case QMetaType::Int:
2517 case QMetaType::Double:
2518 case QMetaType::Float:
2519 case QMetaType::LongLong:
2520 case QMetaType::ULongLong:
2521 case QMetaType::UInt:
2522 case QMetaType::ULong:
2523 case QMetaType::UShort:
2530 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2540 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"field" ), prop.
field() }} );
2542 return QVariantMap( {{QStringLiteral(
"type" ), QStringLiteral(
"data_defined" )}, {QStringLiteral(
"expression" ), prop.
expressionString() }} );
2547 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2557 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2565 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2574 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2586 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2601 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2607 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2614 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2621 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2626 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2628 const QColor fromVar = value.value< QColor >();
2629 if ( !fromVar.isValid() )
2632 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2634 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2636 const QDateTime fromVar = value.toDateTime();
2637 if ( !fromVar.isValid() )
2640 return fromVar.toString( Qt::ISODate );
2642 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2644 const QDate fromVar = value.toDate();
2645 if ( !fromVar.isValid() )
2648 return fromVar.toString( Qt::ISODate );
2650 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2652 const QTime fromVar = value.toTime();
2653 if ( !fromVar.isValid() )
2656 return fromVar.toString( Qt::ISODate );
2663 p.insert(
name(), value );
2667 if ( !source.isEmpty() )
2674 if ( value.userType() == QMetaType::QString )
2679 Q_ASSERT_X(
false,
"QgsProcessingParameterDefinition::valueAsJsonObject", QStringLiteral(
"unsupported variant type %1" ).arg(
QMetaType::typeName( value.userType() ) ).toLocal8Bit() );
2692 if ( !value.isValid() )
2695 switch ( value.userType() )
2698 case QMetaType::Bool:
2699 case QMetaType::Char:
2700 case QMetaType::Int:
2701 case QMetaType::Double:
2702 case QMetaType::Float:
2703 case QMetaType::LongLong:
2704 case QMetaType::ULongLong:
2705 case QMetaType::UInt:
2706 case QMetaType::ULong:
2707 case QMetaType::UShort:
2708 return value.toString();
2714 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
2724 return QStringLiteral(
"field:%1" ).arg( prop.
field() );
2731 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
2741 else if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
2749 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
2757 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
2769 else if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
2784 else if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
2790 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
2797 else if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
2802 else if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
2807 else if ( value.userType() == QMetaType::type(
"QColor" ) )
2809 const QColor fromVar = value.value< QColor >();
2810 if ( !fromVar.isValid() )
2813 return QStringLiteral(
"rgba( %1, %2, %3, %4 )" ).arg( fromVar.red() ).arg( fromVar.green() ).arg( fromVar.blue() ).arg( QString::number( fromVar.alphaF(),
'f', 2 ) );
2815 else if ( value.userType() == QMetaType::type(
"QDateTime" ) )
2817 const QDateTime fromVar = value.toDateTime();
2818 if ( !fromVar.isValid() )
2821 return fromVar.toString( Qt::ISODate );
2823 else if ( value.userType() == QMetaType::type(
"QDate" ) )
2825 const QDate fromVar = value.toDate();
2826 if ( !fromVar.isValid() )
2829 return fromVar.toString( Qt::ISODate );
2831 else if ( value.userType() == QMetaType::type(
"QTime" ) )
2833 const QTime fromVar = value.toTime();
2834 if ( !fromVar.isValid() )
2837 return fromVar.toString( Qt::ISODate );
2844 p.insert(
name(), value );
2848 if ( !source.isEmpty() )
2855 if ( value.userType() == QMetaType::QString )
2856 return value.toString();
2861 return value.toString();
2867 if ( !value.isValid( ) )
2868 return QStringList();
2870 if ( value.type() == QVariant::Type::List || value.type() == QVariant::Type::StringList )
2872 const QVariantList sourceList = value.toList();
2873 QStringList resultList;
2874 resultList.reserve( sourceList.size() );
2875 for (
const QVariant &v : sourceList )
2884 return QStringList();
2896 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2898 code += QLatin1String(
"optional " );
2899 code +=
type() +
' ';
2901 return code.trimmed();
2909 switch ( outputType )
2913 QString code = t->className() + QStringLiteral(
"('%1', %2" )
2916 code += QLatin1String(
", optional=True" );
2932 map.insert( QStringLiteral(
"parameter_type" ),
type() );
2933 map.insert( QStringLiteral(
"name" ),
mName );
2934 map.insert( QStringLiteral(
"description" ),
mDescription );
2935 map.insert( QStringLiteral(
"help" ),
mHelp );
2936 map.insert( QStringLiteral(
"default" ),
mDefault );
2937 map.insert( QStringLiteral(
"defaultGui" ),
mGuiDefault );
2938 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
mFlags ) );
2939 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
2945 mName = map.value( QStringLiteral(
"name" ) ).toString();
2946 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
2947 mHelp = map.value( QStringLiteral(
"help" ) ).toString();
2948 mDefault = map.value( QStringLiteral(
"default" ) );
2949 mGuiDefault = map.value( QStringLiteral(
"defaultGui" ) );
2950 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
2951 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
2967 QString text = QStringLiteral(
"<p><b>%1</b></p>" ).arg(
description() );
2968 if ( !
help().isEmpty() )
2970 text += QStringLiteral(
"<p>%1</p>" ).arg(
help() );
2972 text += QStringLiteral(
"<p>%1</p>" ).arg( QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
2987 if ( !val.isValid() )
2988 return QStringLiteral(
"None" );
2990 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
2992 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
2997 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2999 code += QLatin1String(
"optional " );
3000 code +=
type() +
' ';
3001 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
3002 return code.trimmed();
3023 if ( !input.isValid() )
3026 if ( input.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
3030 else if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3034 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3039 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3045 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3048 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3056 if ( !value.isValid() )
3057 return QStringLiteral(
"None" );
3059 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
3062 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
3067 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3068 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3071 p.insert(
name(), value );
3108 if ( !input.isValid() )
3111 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3116 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3121 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3139 if ( !val.isValid() )
3140 return QStringLiteral(
"None" );
3142 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
3146 p.insert(
name(), val );
3166 for (
const QString &raster : rasters )
3168 if ( !vectors.contains( raster ) )
3172 for (
const QString &mesh : meshFilters )
3174 if ( !vectors.contains( mesh ) )
3178 for (
const QString &pointCloud : pointCloudFilters )
3180 if ( !vectors.contains( pointCloud ) )
3181 vectors << pointCloud;
3183 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
3184 std::sort( vectors.begin(), vectors.end() );
3186 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QLatin1String(
";;" ) );
3196 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3198 code += QLatin1String(
"optional " );
3199 code += QLatin1String(
"layer " );
3206 code += QLatin1String(
"hasgeometry " );
3210 code += QLatin1String(
"point " );
3214 code += QLatin1String(
"line " );
3218 code += QLatin1String(
"polygon " );
3222 code += QLatin1String(
"raster " );
3226 code += QLatin1String(
"mesh " );
3230 code += QLatin1String(
"plugin " );
3234 code += QLatin1String(
"pointcloud " );
3238 code += QLatin1String(
"annotation " );
3244 return code.trimmed();
3250 QString def = definition;
3253 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
3256 def = def.mid( 12 );
3259 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
3265 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
3271 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
3277 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
3283 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
3289 else if ( def.startsWith( QLatin1String(
"plugin" ), Qt::CaseInsensitive ) )
3295 else if ( def.startsWith( QLatin1String(
"pointcloud" ), Qt::CaseInsensitive ) )
3298 def = def.mid( 11 );
3301 else if ( def.startsWith( QLatin1String(
"annotation" ), Qt::CaseInsensitive ) )
3304 def = def.mid( 11 );
3315 switch ( outputType )
3319 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', %2" )
3322 code += QLatin1String(
", optional=True" );
3329 QStringList options;
3333 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
3337 code += QLatin1Char(
')' );
3354 map.insert( QStringLiteral(
"data_types" ), types );
3362 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3363 for (
const QVariant &val : values )
3383 if ( !input.isValid() )
3386 if ( input.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
3390 else if ( input.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
3395 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3400 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3405 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3409 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3416 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3419 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3428 const thread_local QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
3429 const QRegularExpressionMatch match = rx.match( input.toString() );
3430 if ( match.hasMatch() )
3432 bool xMinOk =
false;
3433 ( void )match.captured( 1 ).toDouble( &xMinOk );
3434 bool xMaxOk =
false;
3435 ( void )match.captured( 2 ).toDouble( &xMaxOk );
3436 bool yMinOk =
false;
3437 ( void )match.captured( 3 ).toDouble( &yMinOk );
3438 bool yMaxOk =
false;
3439 ( void )match.captured( 4 ).toDouble( &yMaxOk );
3440 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
3450 if ( !value.isValid() )
3451 return QStringLiteral(
"None" );
3453 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3454 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3456 if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
3464 else if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3472 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3477 const QString wkt = g.
asWkt();
3478 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3483 p.insert(
name(), value );
3519 if ( !input.isValid() )
3522 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3527 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3531 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3535 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3540 if ( input.type() == QVariant::String )
3542 if ( input.toString().isEmpty() )
3546 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
3548 const QRegularExpressionMatch match = rx.match( input.toString() );
3549 if ( match.hasMatch() )
3552 ( void )match.captured( 1 ).toDouble( &xOk );
3554 ( void )match.captured( 2 ).toDouble( &yOk );
3563 if ( !value.isValid() )
3564 return QStringLiteral(
"None" );
3566 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3567 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3569 if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
3575 else if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3582 else if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3587 const QString wkt = g.
asWkt();
3588 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3601 const QVariant &defaultValue,
bool optional,
const QList<int> &geometryTypes,
bool allowMultipart )
3603 mGeomTypes( geometryTypes ),
3604 mAllowMultipart( allowMultipart )
3616 if ( !input.isValid() )
3619 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3624 const bool anyTypeAllowed = mGeomTypes.isEmpty() || mGeomTypes.contains(
static_cast< int >( Qgis::GeometryType::Unknown ) );
3626 if ( input.userType() == QMetaType::type(
"QgsGeometry" ) )
3628 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( input.value<
QgsGeometry>().
type() ) ) ) &&
3629 ( mAllowMultipart || !input.value<
QgsGeometry>().isMultipart() );
3632 if ( input.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3638 if ( input.userType() == QMetaType::type(
"QgsPointXY" ) )
3640 return anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( Qgis::GeometryType::Point ) );
3643 if ( input.userType() == QMetaType::type(
"QgsRectangle" ) )
3645 return anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( Qgis::GeometryType::Polygon ) );
3648 if ( input.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3650 return anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( Qgis::GeometryType::Point ) );
3653 if ( input.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3655 return anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( Qgis::GeometryType::Polygon ) );
3658 if ( input.type() == QVariant::String )
3660 if ( input.toString().isEmpty() )
3665 const thread_local QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3667 const QRegularExpressionMatch match = rx.match( input.toString() );
3668 if ( match.hasMatch() )
3673 return ( anyTypeAllowed || mGeomTypes.contains(
static_cast< int >( g.
type() ) ) ) && ( mAllowMultipart || !g.
isMultipart() );
3693 if ( !value.isValid() )
3694 return QStringLiteral(
"None" );
3696 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
3699 if ( value.userType() == QMetaType::type(
"QgsGeometry" ) )
3706 if ( value.userType() == QMetaType::type(
"QgsReferencedGeometry" ) )
3713 if ( value.userType() == QMetaType::type(
"QgsPointXY" ) )
3720 if ( value.userType() == QMetaType::type(
"QgsReferencedPointXY" ) )
3727 if ( value.userType() == QMetaType::type(
"QgsRectangle" ) )
3734 if ( value.userType() == QMetaType::type(
"QgsReferencedRectangle" ) )
3746 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3748 code += QLatin1String(
"optional " );
3749 code +=
type() +
' ';
3751 for (
const int type : mGeomTypes )
3755 case Qgis::GeometryType::Point:
3756 code += QLatin1String(
"point " );
3759 case Qgis::GeometryType::Line:
3760 code += QLatin1String(
"line " );
3763 case Qgis::GeometryType::Polygon:
3764 code += QLatin1String(
"polygon " );
3768 code += QLatin1String(
"unknown " );
3774 return code.trimmed();
3779 switch ( outputType )
3783 QString code = QStringLiteral(
"QgsProcessingParameterGeometry('%1', %2" )
3786 code += QLatin1String(
", optional=True" );
3788 if ( !mGeomTypes.empty() )
3794 case Qgis::GeometryType::Point:
3795 return QStringLiteral(
"PointGeometry" );
3797 case Qgis::GeometryType::Line:
3798 return QStringLiteral(
"LineGeometry" );
3800 case Qgis::GeometryType::Polygon:
3801 return QStringLiteral(
"PolygonGeometry" );
3803 case Qgis::GeometryType::Unknown:
3804 return QStringLiteral(
"UnknownGeometry" );
3806 case Qgis::GeometryType::Null:
3807 return QStringLiteral(
"NullGeometry" );
3812 QStringList options;
3813 options.reserve( mGeomTypes.size() );
3814 for (
const int type : mGeomTypes )
3816 options << QStringLiteral(
" QgsWkbTypes.%1" ).arg( geomTypeToString(
static_cast<Qgis::GeometryType>(
type ) ) );
3818 code += QStringLiteral(
", geometryTypes=[%1 ]" ).arg( options.join(
',' ) );
3821 if ( ! mAllowMultipart )
3823 code += QLatin1String(
", allowMultipart=False" );
3838 for (
const int type : mGeomTypes )
3842 map.insert( QStringLiteral(
"geometrytypes" ), types );
3843 map.insert( QStringLiteral(
"multipart" ), mAllowMultipart );
3851 const QVariantList values = map.value( QStringLiteral(
"geometrytypes" ) ).toList();
3852 for (
const QVariant &val : values )
3854 mGeomTypes << val.toInt();
3856 mAllowMultipart = map.value( QStringLiteral(
"multipart" ) ).toBool();
3867 , mBehavior( behavior )
3868 , mExtension( fileFilter.isEmpty() ? extension : QString() )
3869 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
3881 if ( !input.isValid() )
3884 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
3889 const QString
string = input.toString().trimmed();
3891 if ( input.type() != QVariant::String ||
string.isEmpty() )
3894 switch ( mBehavior )
3898 if ( !mExtension.isEmpty() )
3900 return string.endsWith( mExtension, Qt::CaseInsensitive );
3902 else if ( !mFileFilter.isEmpty() )
3920 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3922 code += QLatin1String(
"optional " );
3923 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
3925 return code.trimmed();
3930 switch ( outputType )
3935 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', %2" )
3938 code += QLatin1String(
", optional=True" );
3939 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
3940 if ( !mExtension.isEmpty() )
3941 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
3942 if ( !mFileFilter.isEmpty() )
3943 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
3954 switch ( mBehavior )
3958 if ( !mFileFilter.isEmpty() )
3959 return mFileFilter != QObject::tr(
"All files (*.*)" ) ? mFileFilter + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" ) : mFileFilter;
3960 else if ( !mExtension.isEmpty() )
3961 return QObject::tr(
"%1 files" ).arg( mExtension.toUpper() ) + QStringLiteral(
" (*." ) + mExtension.toLower() + QStringLiteral(
");;" ) + QObject::tr(
"All files (*.*)" );
3963 return QObject::tr(
"All files (*.*)" );
3975 mFileFilter.clear();
3985 mFileFilter = filter;
3992 map.insert( QStringLiteral(
"behavior" ), mBehavior );
3993 map.insert( QStringLiteral(
"extension" ), mExtension );
3994 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
4001 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
4002 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
4003 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
4014 , mHeaders( headers )
4015 , mNumberRows( numberRows )
4016 , mFixedNumberRows( fixedNumberRows )
4028 if ( !input.isValid() )
4031 if ( input.type() == QVariant::String )
4033 if ( input.toString().isEmpty() )
4037 else if ( input.type() == QVariant::List )
4039 if ( input.toList().isEmpty() )
4043 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
4053 if ( !value.isValid() )
4054 return QStringLiteral(
"None" );
4056 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4057 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4060 p.insert(
name(), value );
4068 switch ( outputType )
4072 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', %2" )
4075 code += QLatin1String(
", optional=True" );
4076 code += QStringLiteral(
", numberRows=%1" ).arg( mNumberRows );
4077 code += QStringLiteral(
", hasFixedNumberRows=%1" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4080 headers.reserve( mHeaders.size() );
4081 for (
const QString &h : mHeaders )
4083 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
4115 return mFixedNumberRows;
4120 mFixedNumberRows = fixedNumberRows;
4126 map.insert( QStringLiteral(
"headers" ), mHeaders );
4127 map.insert( QStringLiteral(
"rows" ), mNumberRows );
4128 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
4135 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
4136 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
4137 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
4148 , mLayerType( layerType )
4160 if ( !input.isValid() )
4165 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
4171 if ( input.type() == QVariant::String )
4173 if ( input.toString().isEmpty() )
4176 if ( mMinimumNumberInputs > 1 )
4187 else if ( input.type() == QVariant::List )
4189 if ( input.toList().count() < mMinimumNumberInputs )
4192 if ( mMinimumNumberInputs > input.toList().count() )
4200 const auto constToList = input.toList();
4201 for (
const QVariant &v : constToList )
4203 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
4212 else if ( input.type() == QVariant::StringList )
4214 if ( input.toStringList().count() < mMinimumNumberInputs )
4217 if ( mMinimumNumberInputs > input.toStringList().count() )
4225 const auto constToStringList = input.toStringList();
4226 for (
const QString &v : constToStringList )
4239 if ( !value.isValid() )
4240 return QStringLiteral(
"None" );
4242 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4243 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4248 if ( value.type() == QVariant::StringList )
4250 const QStringList list = value.toStringList();
4251 parts.reserve( list.count() );
4252 for (
const QString &v : list )
4255 else if ( value.type() == QVariant::List )
4257 const QVariantList list = value.toList();
4258 parts.reserve( list.count() );
4259 for (
const QVariant &v : list )
4262 if ( !parts.isEmpty() )
4263 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4268 p.insert(
name(), value );
4270 if ( !list.isEmpty() )
4273 parts.reserve( list.count() );
4278 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4297 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4299 code += QLatin1String(
"optional " );
4300 switch ( mLayerType )
4303 code += QLatin1String(
"multiple raster" );
4307 code += QLatin1String(
"multiple file" );
4311 code += QLatin1String(
"multiple vector" );
4315 if (
mDefault.type() == QVariant::List )
4318 const auto constToList =
mDefault.toList();
4319 for (
const QVariant &var : constToList )
4321 parts << var.toString();
4323 code += parts.join(
',' );
4325 else if (
mDefault.type() == QVariant::StringList )
4327 code +=
mDefault.toStringList().join(
',' );
4333 return code.trimmed();
4338 switch ( outputType )
4342 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', %2" )
4345 code += QLatin1String(
", optional=True" );
4349 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
4360 switch ( mLayerType )
4363 return QObject::tr(
"All files (*.*)" );
4402 return mMinimumNumberInputs;
4414 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
4415 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
4423 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
4429 QString
type = definition;
4431 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
4432 const QRegularExpressionMatch m = re.match( definition );
4435 type = m.captured( 1 ).toLower().trimmed();
4436 defaultVal = m.captured( 2 );
4439 if (
type == QLatin1String(
"vector" ) )
4441 else if (
type == QLatin1String(
"raster" ) )
4443 else if (
type == QLatin1String(
"file" ) )
4456 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
4467 QVariant input = value;
4468 if ( !input.isValid() )
4476 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4482 const double res = input.toDouble( &ok );
4486 return !( res < mMin || res > mMax );
4491 if ( !value.isValid() )
4492 return QStringLiteral(
"None" );
4494 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4495 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4497 return value.toString();
4504 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
4505 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
4506 if ( mMax < std::numeric_limits<double>::max() )
4507 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
4509 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
4510 const QString extra = parts.join( QLatin1String(
"<br />" ) );
4511 if ( !extra.isEmpty() )
4512 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
4518 switch ( outputType )
4522 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', %2" )
4525 code += QLatin1String(
", optional=True" );
4527 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4529 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
4530 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
4531 if ( mMax != std::numeric_limits<double>::max() )
4532 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
4574 map.insert( QStringLiteral(
"min" ), mMin );
4575 map.insert( QStringLiteral(
"max" ), mMax );
4576 map.insert( QStringLiteral(
"data_type" ), mDataType );
4583 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
4584 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
4585 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
4592 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4609 if ( !input.isValid() )
4612 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4617 if ( input.type() == QVariant::String )
4619 const QStringList list = input.toString().split(
',' );
4620 if ( list.count() != 2 )
4623 list.at( 0 ).toDouble( &ok );
4625 list.at( 1 ).toDouble( &ok2 );
4630 else if ( input.type() == QVariant::List )
4632 if ( input.toList().count() != 2 )
4636 input.toList().at( 0 ).toDouble( &ok );
4638 input.toList().at( 1 ).toDouble( &ok2 );
4649 if ( !value.isValid() )
4650 return QStringLiteral(
"None" );
4652 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4653 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4656 p.insert(
name(), value );
4659 QStringList stringParts;
4660 const auto constParts = parts;
4661 for (
const double v : constParts )
4663 stringParts << QString::number( v );
4665 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
4670 switch ( outputType )
4674 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', %2" )
4677 code += QLatin1String(
", optional=True" );
4679 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
QgsProcessingParameterNumber::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4702 map.insert( QStringLiteral(
"data_type" ), mDataType );
4716 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4732 if ( !input.isValid() )
4735 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4740 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4743 if ( input.type() != QVariant::String || input.toString().isEmpty() )
4761 if ( !val.isValid() )
4762 return QStringLiteral(
"None" );
4764 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
4768 p.insert(
name(), val );
4796 , mOptions( options )
4797 , mAllowMultiple( allowMultiple )
4798 , mUsesStaticStrings( usesStaticStrings )
4810 QVariant input = value;
4811 if ( !input.isValid() )
4819 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
4824 if ( mUsesStaticStrings )
4826 if ( input.type() == QVariant::List )
4828 if ( !mAllowMultiple )
4831 const QVariantList values = input.toList();
4835 for (
const QVariant &val : values )
4837 if ( !mOptions.contains( val.toString() ) )
4843 else if ( input.type() == QVariant::StringList )
4845 if ( !mAllowMultiple )
4848 const QStringList values = input.toStringList();
4853 if ( values.count() > 1 && !mAllowMultiple )
4856 for (
const QString &val : values )
4858 if ( !mOptions.contains( val ) )
4863 else if ( input.type() == QVariant::String )
4865 const QStringList parts = input.toString().split(
',' );
4866 if ( parts.count() > 1 && !mAllowMultiple )
4869 const auto constParts = parts;
4870 for (
const QString &part : constParts )
4872 if ( !mOptions.contains( part ) )
4880 if ( input.type() == QVariant::List )
4882 if ( !mAllowMultiple )
4885 const QVariantList values = input.toList();
4889 for (
const QVariant &val : values )
4892 const int res = val.toInt( &ok );
4895 else if ( res < 0 || res >= mOptions.count() )
4901 else if ( input.type() == QVariant::String )
4903 const QStringList parts = input.toString().split(
',' );
4904 if ( parts.count() > 1 && !mAllowMultiple )
4907 const auto constParts = parts;
4908 for (
const QString &part : constParts )
4911 const int res = part.toInt( &ok );
4914 else if ( res < 0 || res >= mOptions.count() )
4919 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
4922 const int res = input.toInt( &ok );
4925 else if ( res >= 0 && res < mOptions.count() )
4935 if ( !value.isValid() )
4936 return QStringLiteral(
"None" );
4938 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
4939 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4941 if ( mUsesStaticStrings )
4943 if ( value.type() == QVariant::List || value.type() == QVariant::StringList )
4946 const QStringList constList = value.toStringList();
4947 for (
const QString &val : constList )
4951 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4953 else if ( value.type() == QVariant::String )
4956 const QStringList constList = value.toString().split(
',' );
4957 if ( constList.count() > 1 )
4959 for (
const QString &val : constList )
4963 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4971 if ( value.type() == QVariant::List )
4974 const auto constToList = value.toList();
4975 for (
const QVariant &val : constToList )
4977 parts << QString::number( static_cast< int >( val.toDouble() ) );
4979 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4981 else if ( value.type() == QVariant::String )
4983 const QStringList parts = value.toString().split(
',' );
4984 if ( parts.count() > 1 )
4986 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4990 return QString::number(
static_cast< int >( value.toDouble() ) );
4996 if ( !value.isValid() )
4999 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5002 if ( mUsesStaticStrings )
5008 if ( value.type() == QVariant::List )
5011 const QVariantList toList = value.toList();
5012 parts.reserve( toList.size() );
5013 for (
const QVariant &val : toList )
5015 parts << mOptions.value(
static_cast< int >( val.toDouble() ) );
5017 return parts.join(
',' );
5019 else if ( value.type() == QVariant::String )
5021 const QStringList parts = value.toString().split(
',' );
5022 QStringList comments;
5023 if ( parts.count() > 1 )
5025 for (
const QString &part : parts )
5028 const int val = part.toInt( &ok );
5030 comments << mOptions.value( val );
5032 return comments.join(
',' );
5036 return mOptions.value(
static_cast< int >( value.toDouble() ) );
5042 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5044 code += QLatin1String(
"optional " );
5045 code += QLatin1String(
"enum " );
5047 if ( mAllowMultiple )
5048 code += QLatin1String(
"multiple " );
5050 if ( mUsesStaticStrings )
5051 code += QLatin1String(
"static " );
5053 code += mOptions.join(
';' ) +
' ';
5056 return code.trimmed();
5061 switch ( outputType )
5065 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', %2" )
5068 code += QLatin1String(
", optional=True" );
5071 options.reserve( mOptions.size() );
5072 for (
const QString &o : mOptions )
5074 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
5076 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5078 code += QStringLiteral(
", usesStaticStrings=%1" ).arg( mUsesStaticStrings ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5101 return mAllowMultiple;
5111 return mUsesStaticStrings;
5122 map.insert( QStringLiteral(
"options" ), mOptions );
5123 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5124 map.insert( QStringLiteral(
"uses_static_strings" ), mUsesStaticStrings );
5131 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
5132 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5133 mUsesStaticStrings = map.value( QStringLiteral(
"uses_static_strings" ) ).toBool();
5140 QString def = definition;
5142 bool multiple =
false;
5143 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5149 bool staticStrings =
false;
5150 if ( def.startsWith( QLatin1String(
"static" ), Qt::CaseInsensitive ) )
5152 staticStrings =
true;
5156 const thread_local QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
5157 const QRegularExpressionMatch m = re.match( def );
5158 QString values = def;
5161 values = m.captured( 1 ).trimmed();
5162 defaultVal = m.captured( 2 );
5170 , mMultiLine( multiLine )
5183 return QStringLiteral(
"None" );
5185 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5186 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5188 const QString s = value.toString();
5194 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5196 code += QLatin1String(
"optional " );
5197 code += QLatin1String(
"string " );
5200 code += QLatin1String(
"long " );
5203 return code.trimmed();
5208 switch ( outputType )
5212 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', %2" )
5215 code += QLatin1String(
", optional=True" );
5216 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5239 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
5246 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
5252 QString def = definition;
5254 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
5260 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5262 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5266 if ( def == QLatin1String(
"None" ) )
5289 if ( !value.isValid() )
5290 return QStringLiteral(
"None" );
5292 const QString s = value.toString();
5298 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5300 code += QLatin1String(
"optional " );
5301 code += QLatin1String(
"authcfg " );
5304 return code.trimmed();
5309 QString def = definition;
5311 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
5313 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
5317 if ( def == QLatin1String(
"None" ) )
5330 , mParentLayerParameterName( parentLayerParameterName )
5331 , mExpressionType( type )
5343 if ( !value.isValid() )
5344 return QStringLiteral(
"None" );
5346 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5347 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5349 const QString s = value.toString();
5355 QStringList depends;
5356 if ( !mParentLayerParameterName.isEmpty() )
5357 depends << mParentLayerParameterName;
5363 switch ( outputType )
5367 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', %2" )
5370 code += QLatin1String(
", optional=True" );
5372 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5379 code += QLatin1String(
", type=Qgis.ExpressionType.PointCloud)" );
5383 code += QLatin1Char(
')' );
5393 return mParentLayerParameterName;
5403 return mExpressionType;
5414 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5415 map.insert( QStringLiteral(
"expression_type" ),
static_cast< int >( mExpressionType ) );
5422 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5423 mExpressionType =
static_cast< Qgis::ExpressionType >( map.value( QStringLiteral(
"expression_type" ) ).toInt() );
5452 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5465 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
5468 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5486 if ( !val.isValid() )
5487 return QStringLiteral(
"None" );
5489 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
5493 p.insert(
name(), val );
5511 switch ( outputType )
5515 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', %2" )
5518 code += QLatin1String(
", optional=True" );
5522 QStringList options;
5525 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
5559 map.insert( QStringLiteral(
"data_types" ), types );
5567 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
5568 for (
const QVariant &val : values )
5581 const QVariant &defaultValue,
bool optional )
5599 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5612 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
5615 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5633 if ( !val.isValid() )
5634 return QStringLiteral(
"None" );
5636 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
5640 p.insert(
name(), val );
5668 , mParentLayerParameterName( parentLayerParameterName )
5670 , mAllowMultiple( allowMultiple )
5671 , mDefaultToAllFields( defaultToAllFields )
5684 if ( !input.isValid() )
5687 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
5692 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
5694 if ( !mAllowMultiple )
5700 else if ( input.type() == QVariant::String )
5702 if ( input.toString().isEmpty() )
5705 const QStringList parts = input.toString().split(
';' );
5706 if ( parts.count() > 1 && !mAllowMultiple )
5711 if ( input.toString().isEmpty() )
5719 if ( !value.isValid() )
5720 return QStringLiteral(
"None" );
5722 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
5723 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5725 if ( value.type() == QVariant::List )
5728 const auto constToList = value.toList();
5729 for (
const QVariant &val : constToList )
5733 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5735 else if ( value.type() == QVariant::StringList )
5738 const auto constToStringList = value.toStringList();
5739 for (
const QString &s : constToStringList )
5743 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5751 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5753 code += QLatin1String(
"optional " );
5754 code += QLatin1String(
"field " );
5756 switch ( mDataType )
5759 code += QLatin1String(
"numeric " );
5763 code += QLatin1String(
"string " );
5767 code += QLatin1String(
"datetime " );
5774 if ( mAllowMultiple )
5775 code += QLatin1String(
"multiple " );
5777 if ( mDefaultToAllFields )
5778 code += QLatin1String(
"default_to_all_fields " );
5780 code += mParentLayerParameterName +
' ';
5783 return code.trimmed();
5788 switch ( outputType )
5792 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', %2" )
5795 code += QLatin1String(
", optional=True" );
5798 switch ( mDataType )
5801 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
5805 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
5809 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
5813 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
5816 code += QStringLiteral(
", type=%1" ).arg(
dataType );
5818 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5819 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5823 if ( mDefaultToAllFields )
5824 code += QLatin1String(
", defaultToAllFields=True" );
5836 QStringList depends;
5837 if ( !mParentLayerParameterName.isEmpty() )
5838 depends << mParentLayerParameterName;
5844 return mParentLayerParameterName;
5864 return mAllowMultiple;
5874 return mDefaultToAllFields;
5879 mDefaultToAllFields = enabled;
5885 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5886 map.insert( QStringLiteral(
"data_type" ), mDataType );
5887 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5888 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
5895 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5896 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
5897 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5898 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
5908 QString def = definition;
5910 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
5915 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
5920 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
5926 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5929 def = def.mid( 8 ).trimmed();
5932 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
5935 def = def.mid( 21 ).trimmed();
5938 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
5939 const QRegularExpressionMatch m = re.match( def );
5942 parent = m.captured( 1 ).trimmed();
5943 def = m.captured( 2 );
5968 QVariant var = input;
5969 if ( !var.isValid() )
5972 if ( var.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
5977 else if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
5984 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
5996 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
6001 if ( var.type() != QVariant::String || var.toString().isEmpty() )
6019 if ( !value.isValid() )
6020 return QStringLiteral(
"None" );
6022 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6025 if ( value.userType() == QMetaType::type(
"QgsProcessingFeatureSourceDefinition" ) )
6028 QString geometryCheckString;
6032 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
6036 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
6040 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
6046 if ( fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagOverrideDefaultGeometryCheck )
6047 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
6048 if ( fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagCreateIndividualOutputPerInputFeature )
6049 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
6050 if ( !
flags.empty() )
6051 flagString =
flags.join( QLatin1String(
" | " ) );
6058 layerString = layer->source();
6065 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6066 geometryCheckString,
6078 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression(%1), selectedFeaturesOnly=%2, featureLimit=%3%4%6, geometryCheck=%5)" )
6082 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
6083 geometryCheckString,
6092 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
6097 QString layerString = value.toString();
6101 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
6118 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6120 code += QLatin1String(
"optional " );
6121 code += QLatin1String(
"source " );
6128 code += QLatin1String(
"point " );
6132 code += QLatin1String(
"line " );
6136 code += QLatin1String(
"polygon " );
6143 return code.trimmed();
6148 switch ( outputType )
6152 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', %2" )
6155 code += QLatin1String(
", optional=True" );
6159 QStringList options;
6163 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
6180 : mDataTypes( types )
6193 map.insert( QStringLiteral(
"data_types" ), types );
6201 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
6202 for (
const QVariant &val : values )
6212 QString def = definition;
6215 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6221 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6227 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6242 , mSupportsAppend( supportsAppend )
6253 QVariant var = input;
6254 if ( !var.isValid() )
6257 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6263 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6276 if ( var.type() != QVariant::String )
6279 if ( var.toString().isEmpty() )
6287 if ( !value.isValid() )
6288 return QStringLiteral(
"None" );
6290 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6291 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6293 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6302 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6311 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6313 code += QLatin1String(
"optional " );
6314 code += QLatin1String(
"sink " );
6316 switch ( mDataType )
6319 code += QLatin1String(
"point " );
6323 code += QLatin1String(
"line " );
6327 code += QLatin1String(
"polygon " );
6331 code += QLatin1String(
"table " );
6339 return code.trimmed();
6351 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6355 return p->defaultVectorFileExtension(
hasGeometry() );
6365 return QStringLiteral(
"dbf" );
6372 switch ( outputType )
6376 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', %2" )
6379 code += QLatin1String(
", optional=True" );
6383 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6384 if ( mSupportsAppend )
6385 code += QLatin1String(
", supportsAppend=True" );
6398 QStringList filters;
6399 for (
const QString &ext : exts )
6401 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6403 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6412 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6414 return lOriginalProvider->supportedOutputTableExtensions();
6419 return p->supportedOutputVectorLayerExtensions();
6421 return p->supportedOutputTableExtensions();
6436 switch ( mDataType )
6466 map.insert( QStringLiteral(
"data_type" ), mDataType );
6467 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
6475 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
6482 return QStringLiteral(
"memory:%1" ).arg(
description() );
6490 QString def = definition;
6491 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6496 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6501 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6506 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
6517 return mSupportsAppend;
6537 QVariant var = input;
6538 if ( !var.isValid() )
6541 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6547 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6560 if ( var.type() != QVariant::String )
6563 if ( var.toString().isEmpty() )
6571 if ( !value.isValid() )
6572 return QStringLiteral(
"None" );
6574 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6575 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6577 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6586 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6602 return lOriginalProvider->defaultRasterFileExtension();
6606 return p->defaultRasterFileExtension();
6617 QStringList filters;
6618 for (
const QString &ext : exts )
6620 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6622 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6629 return lOriginalProvider->supportedOutputRasterLayerExtensions();
6633 return p->supportedOutputRasterLayerExtensions();
6649 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
6661 QVariant var = input;
6662 if ( !var.isValid() )
6665 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6671 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6684 if ( var.type() != QVariant::String )
6687 if ( var.toString().isEmpty() )
6697 if ( !value.isValid() )
6698 return QStringLiteral(
"None" );
6700 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
6701 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6703 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6712 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6721 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
6733 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
6734 return QStringLiteral(
"file" );
6737 const thread_local QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
6738 const QRegularExpressionMatch match = rx.match( mFileFilter );
6739 if ( !match.hasMatch() )
6740 return QStringLiteral(
"file" );
6742 return match.captured( 1 );
6747 switch ( outputType )
6751 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', %2" )
6754 code += QLatin1String(
", optional=True" );
6758 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6770 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
6786 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
6793 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
6814 QVariant var = input;
6815 if ( !var.isValid() )
6818 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6831 if ( var.type() != QVariant::String )
6834 if ( var.toString().isEmpty() )
6857 , mCreateByDefault( createByDefault )
6865 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
6866 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
6873 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
6874 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
6880 switch ( outputType )
6887 QString code = t->className() + QStringLiteral(
"('%1', %2" )
6890 code += QLatin1String(
", optional=True" );
6892 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6907 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
6914 const thread_local QRegularExpression rx( QStringLiteral(
"[.]" ) );
6915 QString sanitizedName =
name();
6916 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
6931 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
6940 return mCreateByDefault;
6962 QVariant var = input;
6963 if ( !var.isValid() )
6966 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
6972 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
6985 if ( var.type() != QVariant::String )
6988 if ( var.toString().isEmpty() )
6996 if ( !value.isValid() )
6997 return QStringLiteral(
"None" );
6999 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7000 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7002 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
7011 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
7020 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7022 code += QLatin1String(
"optional " );
7023 code += QLatin1String(
"vectorDestination " );
7025 switch ( mDataType )
7028 code += QLatin1String(
"point " );
7032 code += QLatin1String(
"line " );
7036 code += QLatin1String(
"polygon " );
7044 return code.trimmed();
7056 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
7060 return p->defaultVectorFileExtension(
hasGeometry() );
7070 return QStringLiteral(
"dbf" );
7077 switch ( outputType )
7081 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', %2" )
7084 code += QLatin1String(
", optional=True" );
7088 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7101 QStringList filters;
7102 for (
const QString &ext : exts )
7104 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
7106 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
7114 return lOriginalProvider->supportedOutputVectorLayerExtensions();
7116 return lOriginalProvider->supportedOutputTableExtensions();
7121 return p->supportedOutputVectorLayerExtensions();
7123 return p->supportedOutputTableExtensions();
7138 switch ( mDataType )
7168 map.insert( QStringLiteral(
"data_type" ), mDataType );
7182 QString def = definition;
7183 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
7188 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
7193 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
7204 , mParentLayerParameterName( parentLayerParameterName )
7205 , mAllowMultiple( allowMultiple )
7217 if ( !input.isValid() )
7220 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
7225 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
7227 if ( !mAllowMultiple )
7236 const double res = input.toInt( &ok );
7246 return mAllowMultiple;
7256 if ( !value.isValid() )
7257 return QStringLiteral(
"None" );
7259 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7260 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7262 if ( value.type() == QVariant::List )
7265 const QVariantList values = value.toList();
7266 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7268 parts << QString::number( static_cast< int >( it->toDouble() ) );
7270 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7272 else if ( value.type() == QVariant::StringList )
7275 const QStringList values = value.toStringList();
7276 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
7278 parts << QString::number( static_cast< int >( it->toDouble() ) );
7280 return parts.join(
',' ).prepend(
'[' ).append(
']' );
7283 return value.toString();
7288 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7290 code += QLatin1String(
"optional " );
7291 code += QLatin1String(
"band " );
7293 if ( mAllowMultiple )
7294 code += QLatin1String(
"multiple " );
7296 code += mParentLayerParameterName +
' ';
7299 return code.trimmed();
7304 QStringList depends;
7305 if ( !mParentLayerParameterName.isEmpty() )
7306 depends << mParentLayerParameterName;
7312 switch ( outputType )
7316 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', %2" )
7319 code += QLatin1String(
", optional=True" );
7321 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
7322 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7334 return mParentLayerParameterName;
7345 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
7346 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
7353 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
7354 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
7361 QString def = definition;
7364 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
7367 def = def.mid( 8 ).trimmed();
7370 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7371 const QRegularExpressionMatch m = re.match( def );
7374 parent = m.captured( 1 ).trimmed();
7375 def = m.captured( 2 );
7392 , mParentParameterName( parentParameterName )
7409 QStringList depends;
7410 if ( !mParentParameterName.isEmpty() )
7411 depends << mParentParameterName;
7417 switch ( outputType )
7421 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', %2" )
7424 code += QLatin1String(
", optional=True" );
7426 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
7428 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7429 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7430 if (
maximum() != std::numeric_limits<double>::max() )
7431 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7442 return mParentParameterName;
7453 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
7454 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7461 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
7462 mDefaultUnit =
static_cast< Qgis::DistanceUnit>( map.value( QStringLiteral(
"default_unit" ),
static_cast< int >( Qgis::DistanceUnit::Unknown ) ).toInt() );
7488 switch ( outputType )
7492 QString code = QStringLiteral(
"QgsProcessingParameterDuration('%1', %2" )
7495 code += QLatin1String(
", optional=True" );
7497 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
7498 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
7499 if (
maximum() != std::numeric_limits<double>::max() )
7500 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
7512 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
7519 mDefaultUnit =
static_cast< Qgis::TemporalUnit>( map.value( QStringLiteral(
"default_unit" ),
static_cast< int >( Qgis::TemporalUnit::Days ) ).toInt() );
7546 switch ( outputType )
7550 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', %2" )
7553 code += QLatin1String(
", optional=True" );
7565 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
7585 return QStringLiteral(
"None" );
7587 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7588 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7590 const QString s = value.toString();
7596 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7598 code += QLatin1String(
"optional " );
7599 code += QLatin1String(
"layout " );
7602 return code.trimmed();
7607 switch ( outputType )
7611 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', %2" )
7614 code += QLatin1String(
", optional=True" );
7625 QString def = definition;
7627 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7629 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7633 if ( def == QLatin1String(
"None" ) )
7646 , mParentLayoutParameterName( parentLayoutParameterName )
7647 , mItemType( itemType )
7660 return QStringLiteral(
"None" );
7662 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7663 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7665 const QString s = value.toString();
7671 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7673 code += QLatin1String(
"optional " );
7674 code += QLatin1String(
"layoutitem " );
7675 if ( mItemType >= 0 )
7676 code += QString::number( mItemType ) +
' ';
7678 code += mParentLayoutParameterName +
' ';
7681 return code.trimmed();
7686 switch ( outputType )
7690 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', %2" )
7693 code += QLatin1String(
", optional=True" );
7695 if ( mItemType >= 0 )
7696 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
7698 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
7711 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
7712 map.insert( QStringLiteral(
"item_type" ), mItemType );
7719 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
7720 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
7726 QStringList depends;
7727 if ( !mParentLayoutParameterName.isEmpty() )
7728 depends << mParentLayoutParameterName;
7735 QString def = definition;
7737 const thread_local QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
7738 const QRegularExpressionMatch m = re.match( def );
7741 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
7742 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
7743 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
7756 return mParentLayoutParameterName;
7761 mParentLayoutParameterName =
name;
7780 , mAllowOpacity( opacityEnabled )
7793 return QStringLiteral(
"None" );
7795 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7796 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7798 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
7799 return QStringLiteral(
"QColor()" );
7801 if ( value.canConvert< QColor >() )
7803 const QColor
c = value.value< QColor >();
7804 if ( !mAllowOpacity ||
c.alpha() == 255 )
7805 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
7807 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
7810 const QString s = value.toString();
7816 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7818 code += QLatin1String(
"optional " );
7819 code += QLatin1String(
"color " );
7821 if ( mAllowOpacity )
7822 code += QLatin1String(
"withopacity " );
7825 return code.trimmed();
7830 switch ( outputType )
7834 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', %2" )
7837 code += QLatin1String(
", optional=True" );
7839 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7851 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
7854 if ( !input.isValid() )
7857 if ( input.type() == QVariant::Color )
7861 else if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
7866 if ( input.type() != QVariant::String || input.toString().isEmpty() )
7869 bool containsAlpha =
false;
7876 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
7883 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
7889 return mAllowOpacity;
7894 mAllowOpacity = enabled;
7899 QString def = definition;
7901 bool allowOpacity =
false;
7902 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
7904 allowOpacity =
true;
7905 def = def.mid( 12 );
7908 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7910 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7914 if ( def == QLatin1String(
"None" ) )
7925 , mSourceParameterName( sourceCrsParameterName )
7926 , mDestParameterName( destinationCrsParameterName )
7927 , mSourceCrs( staticSourceCrs )
7928 , mDestCrs( staticDestinationCrs )
7941 return QStringLiteral(
"None" );
7943 if ( value.userType() == QMetaType::type(
"QgsCoordinateReferenceSystem" ) )
7946 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
7951 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
7952 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7955 p.insert(
name(), value );
7960 const QString s = value.toString();
7966 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7968 code += QLatin1String(
"optional " );
7969 code += QLatin1String(
"coordinateoperation " );
7972 return code.trimmed();
7977 switch ( outputType )
7982 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', %2" )
7985 code += QLatin1String(
", optional=True" );
7986 if ( !mSourceParameterName.isEmpty() )
7987 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg(
valueAsPythonString( mSourceParameterName,
c ) );
7988 if ( !mDestParameterName.isEmpty() )
7989 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg(
valueAsPythonString( mDestParameterName,
c ) );
7991 if ( mSourceCrs.isValid() )
7993 if ( mDestCrs.isValid() )
7994 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg(
valueAsPythonString( mDestCrs,
c ) );
8006 if ( !mSourceParameterName.isEmpty() )
8007 res << mSourceParameterName;
8008 if ( !mDestParameterName.isEmpty() )
8009 res << mDestParameterName;
8016 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
8017 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
8018 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
8019 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
8026 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
8027 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
8028 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
8029 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
8035 QString def = definition;
8037 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8039 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8043 if ( def == QLatin1String(
"None" ) )
8068 if ( !input.isValid() && !
mDefault.isValid() )
8071 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8072 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8080 if ( !value.isValid() )
8081 return QStringLiteral(
"None" );
8083 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8084 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8091 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8093 code += QLatin1String(
"optional " );
8094 code += QLatin1String(
"maptheme " );
8097 return code.trimmed();
8102 switch ( outputType )
8106 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', %2" )
8109 code += QLatin1String(
", optional=True" );
8134 QString def = definition;
8135 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8137 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8159 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
8161 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
8172 QVariant input = value;
8173 if ( !input.isValid() )
8181 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
8186 if ( input.type() != QVariant::DateTime && input.type() != QVariant::Date && input.type() != QVariant::Time && input.type() != QVariant::String )
8189 if ( ( input.type() == QVariant::DateTime || input.type() == QVariant::Date ) && mDataType ==
Time )
8192 if ( input.type() == QVariant::String )
8194 const QString s = input.toString();
8198 input = QDateTime::fromString( s, Qt::ISODate );
8199 if ( mDataType ==
Time )
8201 if ( !input.toDateTime().isValid() )
8202 input = QTime::fromString( s );
8204 input = input.toDateTime().time();
8208 if ( mDataType !=
Time )
8210 const QDateTime res = input.toDateTime();
8211 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
8215 const QTime res = input.toTime();
8216 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
8222 if ( !value.isValid() )
8223 return QStringLiteral(
"None" );
8225 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8226 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8228 if ( value.type() == QVariant::DateTime )
8230 const QDateTime dt = value.toDateTime();
8231 if ( !dt.isValid() )
8232 return QStringLiteral(
"QDateTime()" );
8234 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
8235 .arg( dt.date().month() )
8236 .arg( dt.date().day() )
8237 .arg( dt.time().hour() )
8238 .arg( dt.time().minute() )
8239 .arg( dt.time().second() );
8241 else if ( value.type() == QVariant::Date )
8243 const QDate dt = value.toDate();
8244 if ( !dt.isValid() )
8245 return QStringLiteral(
"QDate()" );
8247 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
8251 else if ( value.type() == QVariant::Time )
8253 const QTime dt = value.toTime();
8254 if ( !dt.isValid() )
8255 return QStringLiteral(
"QTime()" );
8257 return QStringLiteral(
"QTime(%4, %5, %6)" )
8260 .arg( dt.second() );
8262 return value.toString();
8269 if ( mMin.isValid() )
8270 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
8271 if ( mMax.isValid() )
8272 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
8274 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
DateTime ?
mDefault.toDateTime().toString( Qt::ISODate ) :
8275 ( mDataType ==
Date ?
mDefault.toDate().toString( Qt::ISODate ) :
mDefault.toTime( ).toString() ) );
8276 const QString extra = parts.join( QLatin1String(
"<br />" ) );
8277 if ( !extra.isEmpty() )
8278 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
8284 switch ( outputType )
8288 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', %2" )
8291 code += QLatin1String(
", optional=True" );
8293 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
DateTime ? QStringLiteral(
"QgsProcessingParameterDateTime.DateTime" )
8294 : mDataType ==
Date ? QStringLiteral(
"QgsProcessingParameterDateTime.Date" )
8295 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
8298 if ( mMin.isValid() )
8300 if ( mMax.isValid() )
8342 map.insert( QStringLiteral(
"min" ), mMin );
8343 map.insert( QStringLiteral(
"max" ), mMax );
8344 map.insert( QStringLiteral(
"data_type" ), mDataType );
8351 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
8352 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
8353 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
8360 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
8371 , mProviderId( provider )
8384 if ( !input.isValid() && !
mDefault.isValid() )
8387 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8388 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8396 if ( !value.isValid() )
8397 return QStringLiteral(
"None" );
8399 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8400 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8407 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8409 code += QLatin1String(
"optional " );
8410 code += QLatin1String(
"providerconnection " );
8411 code += mProviderId +
' ';
8414 return code.trimmed();
8419 switch ( outputType )
8423 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', %2, '%3'" )
8426 code += QLatin1String(
", optional=True" );
8440 map.insert( QStringLiteral(
"provider" ), mProviderId );
8447 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
8453 QString def = definition;
8455 if ( def.contains(
' ' ) )
8457 provider = def.left( def.indexOf(
' ' ) );
8458 def = def.mid( def.indexOf(
' ' ) + 1 );
8466 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
8468 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
8486 , mParentConnectionParameterName( parentLayerParameterName )
8499 if ( !input.isValid() && !
mDefault.isValid() )
8502 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8503 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8511 if ( !value.isValid() )
8512 return QStringLiteral(
"None" );
8514 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8515 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8522 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8524 code += QLatin1String(
"optional " );
8525 code += QLatin1String(
"databaseschema " );
8527 code += mParentConnectionParameterName +
' ';
8530 return code.trimmed();
8535 switch ( outputType )
8539 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', %2" )
8542 code += QLatin1String(
", optional=True" );
8544 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8558 QStringList depends;
8559 if ( !mParentConnectionParameterName.isEmpty() )
8560 depends << mParentConnectionParameterName;
8566 return mParentConnectionParameterName;
8571 mParentConnectionParameterName =
name;
8577 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8584 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8591 QString def = definition;
8593 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
8594 const QRegularExpressionMatch m = re.match( def );
8597 parent = m.captured( 1 ).trimmed();
8598 def = m.captured( 2 );
8614 const QString &connectionParameterName,
8615 const QString &schemaParameterName,
8616 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
8618 , mParentConnectionParameterName( connectionParameterName )
8619 , mParentSchemaParameterName( schemaParameterName )
8620 , mAllowNewTableNames( allowNewTableNames )
8633 if ( !input.isValid() && !
mDefault.isValid() )
8636 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
8637 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
8645 if ( !value.isValid() )
8646 return QStringLiteral(
"None" );
8648 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8649 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
8656 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
8658 code += QLatin1String(
"optional " );
8659 code += QLatin1String(
"databasetable " );
8661 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
8662 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
8665 return code.trimmed();
8670 switch ( outputType )
8674 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', %2" )
8677 code += QLatin1String(
", optional=True" );
8679 if ( mAllowNewTableNames )
8680 code += QLatin1String(
", allowNewTableNames=True" );
8682 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
8683 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
8697 QStringList depends;
8698 if ( !mParentConnectionParameterName.isEmpty() )
8699 depends << mParentConnectionParameterName;
8700 if ( !mParentSchemaParameterName.isEmpty() )
8701 depends << mParentSchemaParameterName;
8707 return mParentConnectionParameterName;
8712 mParentConnectionParameterName =
name;
8717 return mParentSchemaParameterName;
8722 mParentSchemaParameterName =
name;
8728 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
8729 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
8730 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
8737 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
8738 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
8739 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
8747 QString def = definition;
8749 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
8750 const QRegularExpressionMatch m = re.match( def );
8753 connection = m.captured( 1 ).trimmed();
8754 if ( connection == QLatin1String(
"none" ) )
8756 schema = m.captured( 2 ).trimmed();
8757 if ( schema == QLatin1String(
"none" ) )
8759 def = m.captured( 3 );
8767 return mAllowNewTableNames;
8780 const QVariant &defaultValue,
bool optional )
8797 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
8810 if ( qobject_cast< QgsPointCloudLayer * >( qvariant_cast<QObject *>( var ) ) )
8813 if ( var.type() != QVariant::String || var.toString().isEmpty() )
8831 if ( !val.isValid() )
8832 return QStringLiteral(
"None" );
8834 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
8838 p.insert(
name(), val );
8869 const QVariant &defaultValue,
bool optional )
8886 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
8899 if ( qobject_cast< QgsAnnotationLayer * >( qvariant_cast<QObject *>( var ) ) )
8902 if ( var.type() != QVariant::String || var.toString().isEmpty() )
8920 if ( !val.isValid() )
8921 return QStringLiteral(
"None" );
8923 if ( val.userType() == QMetaType::type(
"QgsProperty" ) )
8927 p.insert(
name(), val );
8960 QVariant var = input;
8961 if ( !var.isValid() )
8964 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
8970 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
8983 if ( var.type() != QVariant::String )
8986 if ( var.toString().isEmpty() )
8994 if ( !value.isValid() )
8995 return QStringLiteral(
"None" );
8997 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
8998 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9000 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9009 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9025 return lOriginalProvider->defaultPointCloudFileExtension();
9029 return p->defaultPointCloudFileExtension();
9040 QStringList filters;
9041 for (
const QString &ext : exts )
9043 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9045 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9052 return lOriginalProvider->supportedOutputPointCloudLayerExtensions();
9056 return p->supportedOutputPointCloudLayerExtensions();
9061 return QStringList() << ext;
9076 , mParentLayerParameterName( parentLayerParameterName )
9077 , mAllowMultiple( allowMultiple )
9078 , mDefaultToAllAttributes( defaultToAllAttributes )
9089 if ( !input.isValid() )
9092 if ( input.userType() == QMetaType::type(
"QgsProperty" ) )
9097 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
9099 if ( !mAllowMultiple )
9105 else if ( input.type() == QVariant::String )
9107 if ( input.toString().isEmpty() )
9110 const QStringList parts = input.toString().split(
';' );
9111 if ( parts.count() > 1 && !mAllowMultiple )
9116 if ( input.toString().isEmpty() )
9124 if ( !value.isValid() )
9125 return QStringLiteral(
"None" );
9127 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
9128 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9130 if ( value.type() == QVariant::List )
9133 const auto constToList = value.toList();
9134 for (
const QVariant &val : constToList )
9138 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9140 else if ( value.type() == QVariant::StringList )
9143 const auto constToStringList = value.toStringList();
9144 for (
const QString &s : constToStringList )
9148 return parts.join(
',' ).prepend(
'[' ).append(
']' );
9156 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
9158 code += QLatin1String(
"optional " );
9159 code += QLatin1String(
"attribute " );
9161 if ( mAllowMultiple )
9162 code += QLatin1String(
"multiple " );
9164 if ( mDefaultToAllAttributes )
9165 code += QLatin1String(
"default_to_all_attributes " );
9167 code += mParentLayerParameterName +
' ';
9170 return code.trimmed();
9175 switch ( outputType )
9179 QString code = QStringLiteral(
"QgsProcessingParameterPointCloudAttribute('%1', %2" )
9182 code += QLatin1String(
", optional=True" );
9184 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
9185 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
9189 if ( mDefaultToAllAttributes )
9190 code += QLatin1String(
", defaultToAllAttributes=True" );
9202 QStringList depends;
9203 if ( !mParentLayerParameterName.isEmpty() )
9204 depends << mParentLayerParameterName;
9210 return mParentLayerParameterName;
9220 return mAllowMultiple;
9230 return mDefaultToAllAttributes;
9235 mDefaultToAllAttributes = enabled;
9241 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
9242 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
9243 map.insert( QStringLiteral(
"default_to_all_attributes" ), mDefaultToAllAttributes );
9250 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
9251 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
9252 mDefaultToAllAttributes = map.value( QStringLiteral(
"default_to_all_attributes" ) ).toBool();
9261 QString def = definition;
9263 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
9266 def = def.mid( 8 ).trimmed();
9269 if ( def.startsWith( QLatin1String(
"default_to_all_attributes" ), Qt::CaseInsensitive ) )
9272 def = def.mid( 25 ).trimmed();
9275 const thread_local QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
9276 const QRegularExpressionMatch m = re.match( def );
9279 parent = m.captured( 1 ).trimmed();
9280 def = m.captured( 2 );
9307 QVariant var = input;
9308 if ( !var.isValid() )
9311 if ( var.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9317 if ( var.userType() == QMetaType::type(
"QgsProperty" ) )
9330 if ( var.type() != QVariant::String )
9333 if ( var.toString().isEmpty() )
9341 if ( !value.isValid() )
9342 return QStringLiteral(
"None" );
9344 if ( value.userType() == QMetaType::type(
"QgsProperty" ) )
9345 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
9347 if ( value.userType() == QMetaType::type(
"QgsProcessingOutputLayerDefinition" ) )
9356 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
9376 QStringList filters;
9377 for (
const QString &ext : exts )
9379 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
9381 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
9387 return QStringList() << ext;
ExpressionType
Expression types.
@ Qgis
Native QGIS expression.
@ PointCloud
Point cloud expression.
DistanceUnit
Units of distance.
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...
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
static QgsGeometry fromRect(const QgsRectangle &rect) SIP_HOLDGIL
Creates a new geometry from a QgsRectangle.
bool isMultipart() const SIP_HOLDGIL
Returns true if WKB of the geometry is of WKBMulti* type.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
static QgsGeometry fromPointXY(const QgsPointXY &point) SIP_HOLDGIL
Creates a new geometry from a QgsPointXY object.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QString lastError() const SIP_HOLDGIL
Returns an error string referring to the last error encountered either when this geometry was created...
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
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.
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...
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.
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.
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.
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.
@ String
Accepts string fields.
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 yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
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.
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.
CORE_EXPORT const QStringList files(const QString &zip)
Returns the list of files within a zip file.
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