40 #include <QRegularExpression>
48 map.insert( QStringLiteral(
"feature_limit" ),
featureLimit );
49 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
flags ) );
50 map.insert( QStringLiteral(
"geometry_check" ),
static_cast< int >(
geometryCheck ) );
58 featureLimit = map.value( QStringLiteral(
"feature_limit" ), -1 ).toLongLong();
59 flags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ), 0 ).toInt() );
72 mRemappingDefinition = definition;
79 map.insert( QStringLiteral(
"create_options" ),
createOptions );
81 map.insert( QStringLiteral(
"remapping" ), QVariant::fromValue( mRemappingDefinition ) );
88 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
89 if ( map.contains( QStringLiteral(
"remapping" ) ) )
96 mUseRemapping =
false;
104 && mUseRemapping == other.mUseRemapping && mRemappingDefinition == other.mRemappingDefinition;
109 return !( *
this == other );
114 QVariant val = parameters.value( name );
134 QVariant val = value;
138 if ( !val.isValid() )
147 return destParam->generateTemporaryDestination();
150 return val.toString();
166 QVariant val = value;
170 if ( val.isValid() && !val.toString().isEmpty() )
174 return val.toString();
194 QVariant val = value;
199 double res = val.toDouble( &ok );
205 return val.toDouble();
221 QVariant val = value;
226 double dbl = val.toDouble( &ok );
231 dbl = val.toDouble( &ok );
238 double round = std::round( dbl );
239 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
244 return static_cast< int >( std::round( dbl ) );
253 return QList< int >();
261 return QList< int >();
263 QList< int > resultList;
264 QVariant val = value;
269 else if ( val.type() == QVariant::List )
271 QVariantList list = val.toList();
272 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
273 resultList << it->toInt();
277 QStringList parts = val.toString().split(
';' );
278 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
279 resultList << it->toInt();
283 if ( ( resultList.isEmpty() || resultList.at( 0 ) == 0 ) )
289 if ( definition->
defaultValue().type() == QVariant::List )
291 QVariantList list = definition->
defaultValue().toList();
292 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
293 resultList << it->toInt();
297 QStringList parts = definition->
defaultValue().toString().split(
';' );
298 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
299 resultList << it->toInt();
320 QVariant val = value;
324 QDateTime d = val.toDateTime();
325 if ( !d.isValid() && val.type() == QVariant::String )
327 d = QDateTime::fromString( val.toString() );
334 d = val.toDateTime();
336 if ( !d.isValid() && val.type() == QVariant::String )
338 d = QDateTime::fromString( val.toString() );
357 QVariant val = value;
361 QDate d = val.toDate();
362 if ( !d.isValid() && val.type() == QVariant::String )
364 d = QDate::fromString( val.toString() );
373 if ( !d.isValid() && val.type() == QVariant::String )
375 d = QDate::fromString( val.toString() );
394 QVariant val = value;
400 if ( val.type() == QVariant::DateTime )
401 d = val.toDateTime().time();
405 if ( !d.isValid() && val.type() == QVariant::String )
407 d = QTime::fromString( val.toString() );
416 if ( !d.isValid() && val.type() == QVariant::String )
418 d = QTime::fromString( val.toString() );
439 if ( enumDef && val >= enumDef->
options().size() )
459 QVariantList resultList;
460 QVariant val = value;
463 else if ( val.type() == QVariant::List )
465 const auto constToList = val.toList();
466 for (
const QVariant &var : constToList )
469 else if ( val.type() == QVariant::String )
471 const auto constSplit = val.toString().split(
',' );
472 for (
const QString &var : constSplit )
478 if ( resultList.isEmpty() )
479 return QList< int >();
481 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
485 if ( definition->
defaultValue().type() == QVariant::List )
487 const auto constToList = definition->
defaultValue().toList();
488 for (
const QVariant &var : constToList )
491 else if ( definition->
defaultValue().type() == QVariant::String )
493 const auto constSplit = definition->
defaultValue().toString().split(
',' );
494 for (
const QString &var : constSplit )
503 const auto constResultList = resultList;
504 for (
const QVariant &var : constResultList )
506 int resInt = var.toInt();
507 if ( !enumDef || resInt < enumDef->options().size() )
530 if ( enumText.isEmpty() || !enumDef->
options().contains( enumText ) )
539 return QStringList();
547 return QStringList();
549 QVariant val = value;
551 QStringList enumValues;
553 std::function< void(
const QVariant &var ) > processVariant;
554 processVariant = [ &enumValues, &context, &definition, &processVariant ](
const QVariant & var )
556 if ( var.type() == QVariant::List )
558 const auto constToList = var.toList();
559 for (
const QVariant &listVar : constToList )
561 processVariant( listVar );
564 else if ( var.type() == QVariant::StringList )
566 const auto constToStringList = var.toStringList();
567 for (
const QString &s : constToStringList )
576 const QStringList parts = var.toString().split(
',' );
577 for (
const QString &s : parts )
584 processVariant( val );
590 #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
591 QSet<QString> subtraction = enumValues.toSet().subtract( enumDef->
options().toSet() );
593 const QStringList options = enumDef->
options();
594 QSet<QString> subtraction = QSet<QString>( enumValues.begin(), enumValues.end() ).subtract( QSet<QString>( options.begin(), options.end() ) );
597 if ( enumValues.isEmpty() || !subtraction.isEmpty() )
629 QVariant val = value;
632 else if ( val.isValid() )
645 QVariant val = value;
648 else if ( val.isValid() )
656 QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
657 const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
662 val = parameters.value( definition->
name() );
665 return parameterAsSink( definition, val, fields, geometryType,
crs, context, destinationIdentifier, sinkFlags, createOptions, datasourceOptions, layerOptions );
668 QgsFeatureSink *
QgsProcessingParameters::parameterAsSink(
const QgsProcessingParameterDefinition *definition,
const QVariant &value,
const QgsFields &fields,
QgsWkbTypes::Type geometryType,
const QgsCoordinateReferenceSystem &
crs,
QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
670 QVariantMap options = createOptions;
671 QVariant val = value;
676 bool useRemapDefinition =
false;
688 useRemapDefinition =
true;
698 else if ( !val.isValid() || val.toString().isEmpty() )
714 dest = val.toString();
719 dest = destParam->generateTemporaryDestination();
722 if ( dest.isEmpty() )
725 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType,
crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition :
nullptr ) );
726 destinationIdentifier = dest;
728 if ( destinationProject )
730 if ( destName.isEmpty() && definition )
736 outputName = definition->
name();
740 return sink.release();
764 QVariant val = parameters.value( definition->
name() );
766 bool selectedFeaturesOnly =
false;
767 long long featureLimit = -1;
789 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
798 else if ( !val.isValid() || val.toString().isEmpty() )
804 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
810 layerRef = val.toString();
815 if ( layerRef.isEmpty() )
827 compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit );
830 compatibleFormats, preferredFormat, context, feedback, featureLimit );
840 QString *destLayer = layerName;
855 return parameterAsLayer( definition, parameters.value( definition->
name() ), context, layerHint );
863 QVariant val = value;
869 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
886 if ( !val.isValid() || val.toString().isEmpty() )
892 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
897 QString layerRef = val.toString();
898 if ( layerRef.isEmpty() )
901 if ( layerRef.isEmpty() )
932 val = parameters.value( definition->
name() );
939 QVariant val = value;
957 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
964 dest = val.toString();
969 dest = destParam->generateTemporaryDestination();
972 if ( destinationProject )
975 if ( destName.isEmpty() && definition )
980 outputName = definition->
name();
999 val = parameters.value( definition->
name() );
1006 QVariant val = value;
1016 if ( definition && val.canConvert<
QgsProperty>() )
1020 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
1027 dest = val.toString();
1032 dest = destParam->generateTemporaryDestination();
1052 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
1077 QVariant val = value;
1126 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1132 rectText = val.toString();
1134 if ( rectText.isEmpty() && !layer )
1137 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1138 QRegularExpressionMatch match = rx.match( rectText );
1139 if ( match.hasMatch() )
1141 bool xMinOk =
false;
1142 double xMin = match.captured( 1 ).toDouble( &xMinOk );
1143 bool xMaxOk =
false;
1144 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1145 bool yMinOk =
false;
1146 double yMin = match.captured( 3 ).toDouble( &yMinOk );
1147 bool yMaxOk =
false;
1148 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1149 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1198 QVariant val = parameters.value( definition->
name() );
1206 g = g.densifyByCount( 20 );
1242 rectText = val.toString();
1244 if ( !rectText.isEmpty() )
1246 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1247 QRegularExpressionMatch match = rx.match( rectText );
1248 if ( match.hasMatch() )
1250 bool xMinOk =
false;
1251 double xMin = match.captured( 1 ).toDouble( &xMinOk );
1252 bool xMaxOk =
false;
1253 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1254 bool yMinOk =
false;
1255 double yMin = match.captured( 3 ).toDouble( &yMinOk );
1256 bool yMaxOk =
false;
1257 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1258 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1284 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1313 QVariant val = parameters.value( definition->
name() );
1319 QVariant val = value;
1347 QString valueAsString;
1351 valueAsString = val.toString();
1353 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1355 QRegularExpressionMatch match = rx.match( valueAsString );
1356 if ( match.hasMatch() )
1382 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1383 return layer->crs();
1385 return layer->crs();
1387 if (
auto *lProject = context.
project() )
1388 return lProject->crs();
1406 QVariant val = value;
1436 if ( pointText.isEmpty() )
1439 if ( pointText.isEmpty() )
1442 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1445 QRegularExpressionMatch match = rx.match( valueAsString );
1446 if ( match.hasMatch() )
1449 double x = match.captured( 1 ).toDouble( &xOk );
1451 double y = match.captured( 2 ).toDouble( &yOk );
1479 QVariant val = parameters.value( definition->
name() );
1494 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1497 QRegularExpressionMatch match = rx.match( valueAsString );
1498 if ( match.hasMatch() )
1505 if (
auto *lProject = context.
project() )
1506 return lProject->crs();
1524 QVariant val = value;
1564 g = g.densifyByCount( 20 );
1597 if ( valueAsString.isEmpty() )
1600 if ( valueAsString.isEmpty() )
1603 QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1605 QRegularExpressionMatch match = rx.match( valueAsString );
1606 if ( match.hasMatch() )
1633 QVariant val = parameters.value( definition->
name() );
1667 QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1670 QRegularExpressionMatch match = rx.match( valueAsString );
1671 if ( match.hasMatch() )
1678 if (
auto *lProject = context.
project() )
1679 return lProject->crs();
1690 if ( fileText.isEmpty() )
1701 if ( fileText.isEmpty() )
1709 return QVariantList();
1717 return QVariantList();
1719 QString resultString;
1720 QVariant val = value;
1723 else if ( val.type() == QVariant::List )
1724 return val.toList();
1726 resultString = val.toString();
1728 if ( resultString.isEmpty() )
1731 if ( definition->
defaultValue().type() == QVariant::List )
1737 QVariantList result;
1738 const auto constSplit = resultString.split(
',' );
1739 for (
const QString &s : constSplit )
1748 return QList<QgsMapLayer *>();
1756 return QList<QgsMapLayer *>();
1758 QVariant val = value;
1759 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1761 return QList<QgsMapLayer *>() << layer;
1764 QList<QgsMapLayer *> layers;
1766 std::function< void(
const QVariant &var ) > processVariant;
1767 processVariant = [ &layers, &context, &definition, &processVariant ](
const QVariant & var )
1769 if ( var.type() == QVariant::List )
1771 const auto constToList = var.toList();
1772 for (
const QVariant &listVar : constToList )
1774 processVariant( listVar );
1777 else if ( var.type() == QVariant::StringList )
1779 const auto constToStringList = var.toStringList();
1780 for (
const QString &s : constToStringList )
1782 processVariant( s );
1791 QVariant sink = fromVar.
sink;
1797 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1809 processVariant( val );
1811 if ( layers.isEmpty() )
1814 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->
defaultValue() ) ) )
1818 else if ( definition->
defaultValue().type() == QVariant::List )
1820 const auto constToList = definition->
defaultValue().toList();
1821 for (
const QVariant &var : constToList )
1823 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1829 processVariant( var );
1843 return QStringList();
1845 QVariant val = value;
1849 std::function< void(
const QVariant &var ) > processVariant;
1850 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1852 if ( var.type() == QVariant::List )
1854 const auto constToList = var.toList();
1855 for (
const QVariant &listVar : constToList )
1857 processVariant( listVar );
1860 else if ( var.type() == QVariant::StringList )
1862 const auto constToStringList = var.toStringList();
1863 for (
const QString &s : constToStringList )
1865 processVariant( s );
1872 files << var.toString();
1876 processVariant( val );
1878 if ( files.isEmpty() )
1889 return QStringList();
1897 return QList<double>();
1905 return QList<double>();
1907 QStringList resultStringList;
1908 QVariant val = value;
1912 else if ( val.type() == QVariant::List )
1914 const auto constToList = val.toList();
1915 for (
const QVariant &var : constToList )
1916 resultStringList << var.toString();
1919 resultStringList << val.toString();
1921 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1923 resultStringList.clear();
1925 if ( definition->
defaultValue().type() == QVariant::List )
1927 const auto constToList = definition->
defaultValue().toList();
1928 for (
const QVariant &var : constToList )
1929 resultStringList << var.toString();
1932 resultStringList << definition->
defaultValue().toString();
1935 if ( resultStringList.size() == 1 )
1937 resultStringList = resultStringList.at( 0 ).split(
',' );
1940 if ( resultStringList.size() < 2 )
1941 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1943 QList< double > result;
1945 double n = resultStringList.at( 0 ).toDouble( &ok );
1949 result << std::numeric_limits<double>::quiet_NaN() ;
1951 n = resultStringList.at( 1 ).toDouble( &ok );
1955 result << std::numeric_limits<double>::quiet_NaN() ;
1963 return QStringList();
1965 QStringList resultStringList;
1972 return QStringList();
1974 QStringList resultStringList;
1975 QVariant val = value;
1976 if ( val.isValid() )
1980 else if ( val.type() == QVariant::List )
1982 const auto constToList = val.toList();
1983 for (
const QVariant &var : constToList )
1984 resultStringList << var.toString();
1986 else if ( val.type() == QVariant::StringList )
1988 resultStringList = val.toStringList();
1991 resultStringList.append( val.toString().split(
';' ) );
1994 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
1996 resultStringList.clear();
2000 if ( definition->
defaultValue().type() == QVariant::List )
2002 const auto constToList = definition->
defaultValue().toList();
2003 for (
const QVariant &var : constToList )
2004 resultStringList << var.toString();
2006 else if ( definition->
defaultValue().type() == QVariant::StringList )
2008 resultStringList = definition->
defaultValue().toStringList();
2011 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
2015 return resultStringList;
2029 if ( layoutName.isEmpty() )
2081 QVariant val = value;
2086 if ( val.type() == QVariant::Color )
2088 QColor
c = val.value< QColor >();
2090 if ( !colorParam->opacityEnabled() )
2098 if ( definition->
defaultValue().type() == QVariant::Color )
2104 if ( colorText.isEmpty() )
2107 bool containsAlpha =
false;
2110 if (
c.isValid() && !colorParam->opacityEnabled() )
2162 QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
2163 QString name = map.value( QStringLiteral(
"name" ) ).toString();
2164 std::unique_ptr< QgsProcessingParameterDefinition > def;
2231 def.reset( paramType->
create( name ) );
2237 def->fromVariantMap( map );
2238 return def.release();
2243 QString desc = name;
2244 desc.replace(
'_',
' ' );
2250 bool isOptional =
false;
2254 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2259 if ( type == QLatin1String(
"boolean" ) )
2261 else if ( type == QLatin1String(
"crs" ) )
2263 else if ( type == QLatin1String(
"layer" ) )
2265 else if ( type == QLatin1String(
"extent" ) )
2267 else if ( type == QLatin1String(
"point" ) )
2269 else if ( type == QLatin1String(
"geometry" ) )
2271 else if ( type == QLatin1String(
"file" ) )
2273 else if ( type == QLatin1String(
"folder" ) )
2275 else if ( type == QLatin1String(
"matrix" ) )
2277 else if ( type == QLatin1String(
"multiple" ) )
2279 else if ( type == QLatin1String(
"number" ) )
2281 else if ( type == QLatin1String(
"distance" ) )
2283 else if ( type == QLatin1String(
"scale" ) )
2285 else if ( type == QLatin1String(
"range" ) )
2287 else if ( type == QLatin1String(
"raster" ) )
2289 else if ( type == QLatin1String(
"enum" ) )
2291 else if ( type == QLatin1String(
"string" ) )
2293 else if ( type == QLatin1String(
"authcfg" ) )
2295 else if ( type == QLatin1String(
"expression" ) )
2297 else if ( type == QLatin1String(
"field" ) )
2299 else if ( type == QLatin1String(
"vector" ) )
2301 else if ( type == QLatin1String(
"source" ) )
2303 else if ( type == QLatin1String(
"sink" ) )
2305 else if ( type == QLatin1String(
"vectordestination" ) )
2307 else if ( type == QLatin1String(
"rasterdestination" ) )
2309 else if ( type == QLatin1String(
"filedestination" ) )
2311 else if ( type == QLatin1String(
"folderdestination" ) )
2313 else if ( type == QLatin1String(
"band" ) )
2315 else if ( type == QLatin1String(
"mesh" ) )
2317 else if ( type == QLatin1String(
"layout" ) )
2319 else if ( type == QLatin1String(
"layoutitem" ) )
2321 else if ( type == QLatin1String(
"color" ) )
2323 else if ( type == QLatin1String(
"coordinateoperation" ) )
2325 else if ( type == QLatin1String(
"maptheme" ) )
2327 else if ( type == QLatin1String(
"datetime" ) )
2329 else if ( type == QLatin1String(
"providerconnection" ) )
2331 else if ( type == QLatin1String(
"databaseschema" ) )
2333 else if ( type == QLatin1String(
"databasetable" ) )
2339 bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2341 QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
2342 QRegularExpressionMatch m = re.match( code );
2343 if ( !m.hasMatch() )
2346 name = m.captured( 1 );
2347 QString tokens = m.captured( 2 );
2348 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
2351 tokens.remove( 0, 8 );
2358 tokens = tokens.trimmed();
2360 QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2361 m = re2.match( tokens );
2362 if ( !m.hasMatch() )
2364 type = tokens.toLower().trimmed();
2369 type = m.captured( 1 ).toLower().trimmed();
2370 definition = m.captured( 2 );
2381 , mDescription( description )
2383 , mDefault( defaultValue )
2384 , mFlags( optional ? FlagOptional : 0 )
2389 if ( !input.isValid() && !
mDefault.isValid() )
2392 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
2393 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
2401 if ( !value.isValid() )
2402 return QStringLiteral(
"None" );
2405 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2412 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2414 code += QLatin1String(
"optional " );
2415 code +=
type() +
' ';
2417 return code.trimmed();
2425 switch ( outputType )
2429 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
2431 code += QLatin1String(
", optional=True" );
2447 map.insert( QStringLiteral(
"parameter_type" ),
type() );
2448 map.insert( QStringLiteral(
"name" ),
mName );
2449 map.insert( QStringLiteral(
"description" ),
mDescription );
2450 map.insert( QStringLiteral(
"help" ),
mHelp );
2451 map.insert( QStringLiteral(
"default" ),
mDefault );
2452 map.insert( QStringLiteral(
"defaultGui" ),
mGuiDefault );
2453 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
mFlags ) );
2454 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
2460 mName = map.value( QStringLiteral(
"name" ) ).toString();
2461 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
2462 mHelp = map.value( QStringLiteral(
"help" ) ).toString();
2463 mDefault = map.value( QStringLiteral(
"default" ) );
2464 mGuiDefault = map.value( QStringLiteral(
"defaultGui" ) );
2465 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
2466 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
2482 QString text = QStringLiteral(
"<p><b>%1</b></p>" ).arg(
description() );
2483 if ( !
help().isEmpty() )
2485 text += QStringLiteral(
"<p>%1</p>" ).arg(
help() );
2487 text += QStringLiteral(
"<p>%1</p>" ).arg( QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
2502 if ( !val.isValid() )
2503 return QStringLiteral(
"None" );
2507 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
2512 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2514 code += QLatin1String(
"optional " );
2515 code +=
type() +
' ';
2516 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
2517 return code.trimmed();
2538 if ( !input.isValid() )
2560 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2563 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2571 if ( !value.isValid() )
2572 return QStringLiteral(
"None" );
2577 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
2583 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2586 p.insert(
name(), value );
2613 if ( !input.isValid() )
2621 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2626 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2644 if ( !val.isValid() )
2645 return QStringLiteral(
"None" );
2651 p.insert(
name(), val );
2661 for (
const QString &raster : rasters )
2663 if ( !vectors.contains( raster ) )
2667 for (
const QString &mesh : meshFilters )
2669 if ( !vectors.contains( mesh ) )
2672 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
2673 std::sort( vectors.begin(), vectors.end() );
2675 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QLatin1String(
";;" ) );
2685 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2687 code += QLatin1String(
"optional " );
2688 code += QLatin1String(
"layer " );
2695 code += QLatin1String(
"hasgeometry " );
2699 code += QLatin1String(
"point " );
2703 code += QLatin1String(
"line " );
2707 code += QLatin1String(
"polygon " );
2711 code += QLatin1String(
"raster " );
2715 code += QLatin1String(
"mesh " );
2721 return code.trimmed();
2727 QString def = definition;
2730 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
2733 def = def.mid( 12 );
2736 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
2742 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
2748 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
2754 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
2760 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
2774 switch ( outputType )
2778 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', '%2'" ).arg(
name(),
description() );
2780 code += QLatin1String(
", optional=True" );
2787 QStringList options;
2791 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
2795 code += QLatin1Char(
')' );
2812 map.insert( QStringLiteral(
"data_types" ), types );
2820 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
2821 for (
const QVariant &val : values )
2841 if ( !input.isValid() )
2874 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2877 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2886 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
2887 QRegularExpressionMatch match = rx.match( input.toString() );
2888 if ( match.hasMatch() )
2890 bool xMinOk =
false;
2891 ( void )match.captured( 1 ).toDouble( &xMinOk );
2892 bool xMaxOk =
false;
2893 ( void )match.captured( 2 ).toDouble( &xMaxOk );
2894 bool yMinOk =
false;
2895 ( void )match.captured( 3 ).toDouble( &yMinOk );
2896 bool yMaxOk =
false;
2897 ( void )match.captured( 4 ).toDouble( &yMaxOk );
2898 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
2908 if ( !value.isValid() )
2909 return QStringLiteral(
"None" );
2912 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2935 const QString wkt = g.
asWkt();
2936 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
2941 p.insert(
name(), value );
2967 if ( !input.isValid() )
2988 if ( input.type() == QVariant::String )
2990 if ( input.toString().isEmpty() )
2994 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
2996 QRegularExpressionMatch match = rx.match( input.toString() );
2997 if ( match.hasMatch() )
3000 ( void )match.captured( 1 ).toDouble( &xOk );
3002 ( void )match.captured( 2 ).toDouble( &yOk );
3011 if ( !value.isValid() )
3012 return QStringLiteral(
"None" );
3015 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3035 const QString wkt = g.
asWkt();
3036 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
3049 const QVariant &defaultValue,
bool optional,
const QList<int> &geometryTypes )
3051 mGeomTypes( geometryTypes )
3063 if ( !input.isValid() )
3075 return anyTypeAllowed || mGeomTypes.contains( input.value<
QgsGeometry>().
type() );
3103 if ( input.type() == QVariant::String )
3105 if ( input.toString().isEmpty() )
3110 QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3112 QRegularExpressionMatch match = rx.match( input.toString() );
3113 if ( match.hasMatch() )
3118 return anyTypeAllowed || mGeomTypes.contains( g.
type() );
3138 if ( !value.isValid() )
3139 return QStringLiteral(
"None" );
3191 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3193 code += QLatin1String(
"optional " );
3194 code +=
type() +
' ';
3196 for (
int type : mGeomTypes )
3201 code += QLatin1String(
"point " );
3205 code += QLatin1String(
"line " );
3209 code += QLatin1String(
"polygon " );
3213 code += QLatin1String(
"unknown" );
3219 return code.trimmed();
3224 switch ( outputType )
3228 QString code = QStringLiteral(
"QgsProcessingParameterGeometry('%1', '%2'" ).arg(
name(),
description() );
3230 code += QLatin1String(
", optional=True" );
3232 if ( !mGeomTypes.empty() )
3239 return QStringLiteral(
"PointGeometry" );
3242 return QStringLiteral(
"LineGeometry" );
3245 return QStringLiteral(
"PolygonGeometry" );
3248 return QStringLiteral(
"UnknownGeometry" );
3251 return QStringLiteral(
"NullGeometry" );
3256 QStringList options;
3257 options.reserve( mGeomTypes.size() );
3258 for (
int type : mGeomTypes )
3262 code += QStringLiteral(
", geometryTypes=[%1 ]" ).arg( options.join(
',' ) );
3277 for (
int type : mGeomTypes )
3281 map.insert( QStringLiteral(
"geometrytypes" ), types );
3289 const QVariantList values = map.value( QStringLiteral(
"geometrytypes" ) ).toList();
3290 for (
const QVariant &val : values )
3292 mGeomTypes << val.toInt();
3304 , mBehavior( behavior )
3305 , mExtension( fileFilter.isEmpty() ? extension : QString() )
3306 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
3318 if ( !input.isValid() )
3326 QString
string = input.toString().trimmed();
3328 if ( input.type() != QVariant::String ||
string.isEmpty() )
3331 switch ( mBehavior )
3335 if ( !mExtension.isEmpty() )
3337 return string.endsWith( mExtension, Qt::CaseInsensitive );
3339 else if ( !mFileFilter.isEmpty() )
3342 return test == string;
3358 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3360 code += QLatin1String(
"optional " );
3361 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
3363 return code.trimmed();
3368 switch ( outputType )
3373 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', '%2'" ).arg(
name(),
description() );
3375 code += QLatin1String(
", optional=True" );
3376 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
3377 if ( !mExtension.isEmpty() )
3378 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
3379 if ( !mFileFilter.isEmpty() )
3380 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
3391 switch ( mBehavior )
3395 if ( !mFileFilter.isEmpty() )
3396 return mFileFilter != QObject::tr(
"All files (*.*)" ) ? mFileFilter + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" ) : mFileFilter;
3397 else if ( !mExtension.isEmpty() )
3398 return QObject::tr(
"%1 files" ).arg( mExtension.toUpper() ) + QStringLiteral(
" (*." ) + mExtension.toLower() + QStringLiteral(
");;" ) + QObject::tr(
"All files (*.*)" );
3400 return QObject::tr(
"All files (*.*)" );
3412 mFileFilter.clear();
3422 mFileFilter = filter;
3429 map.insert( QStringLiteral(
"behavior" ), mBehavior );
3430 map.insert( QStringLiteral(
"extension" ), mExtension );
3431 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
3438 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
3439 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
3440 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
3451 , mHeaders( headers )
3452 , mNumberRows( numberRows )
3453 , mFixedNumberRows( fixedNumberRows )
3465 if ( !input.isValid() )
3468 if ( input.type() == QVariant::String )
3470 if ( input.toString().isEmpty() )
3474 else if ( input.type() == QVariant::List )
3476 if ( input.toList().isEmpty() )
3480 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
3490 if ( !value.isValid() )
3491 return QStringLiteral(
"None" );
3494 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3497 p.insert(
name(), value );
3501 const auto constList = list;
3502 for (
const QVariant &v : constList )
3504 if ( v.type() == QVariant::List )
3507 const auto constToList = v.toList();
3508 for (
const QVariant &v2 : constToList )
3510 if ( v2.isNull() || !v2.isValid() )
3511 parts2 << QStringLiteral(
"None" );
3512 else if ( v2.toString().isEmpty() )
3513 parts2 << QStringLiteral(
"''" );
3515 parts2 << v2.toString();
3517 parts << parts2.join(
',' ).prepend(
'[' ).append(
']' );
3521 if ( v.isNull() || !v.isValid() )
3522 parts << QStringLiteral(
"None" );
3523 else if ( v.toString().isEmpty() )
3524 parts << QStringLiteral(
"''" );
3526 parts << v.toString();
3530 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3535 switch ( outputType )
3539 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', '%2'" ).arg(
name(),
description() );
3541 code += QLatin1String(
", optional=True" );
3542 code += QStringLiteral(
", numberRows=" ).arg( mNumberRows );
3543 code += QStringLiteral(
", hasFixedNumberRows=" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
3546 headers.reserve( mHeaders.size() );
3547 for (
const QString &h : mHeaders )
3549 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
3581 return mFixedNumberRows;
3586 mFixedNumberRows = fixedNumberRows;
3592 map.insert( QStringLiteral(
"headers" ), mHeaders );
3593 map.insert( QStringLiteral(
"rows" ), mNumberRows );
3594 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
3601 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
3602 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
3603 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
3614 , mLayerType( layerType )
3626 if ( !input.isValid() )
3631 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3637 if ( input.type() == QVariant::String )
3639 if ( input.toString().isEmpty() )
3642 if ( mMinimumNumberInputs > 1 )
3653 else if ( input.type() == QVariant::List )
3655 if ( input.toList().count() < mMinimumNumberInputs )
3658 if ( mMinimumNumberInputs > input.toList().count() )
3666 const auto constToList = input.toList();
3667 for (
const QVariant &v : constToList )
3669 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
3678 else if ( input.type() == QVariant::StringList )
3680 if ( input.toStringList().count() < mMinimumNumberInputs )
3683 if ( mMinimumNumberInputs > input.toStringList().count() )
3691 const auto constToStringList = input.toStringList();
3692 for (
const QString &v : constToStringList )
3705 if ( !value.isValid() )
3706 return QStringLiteral(
"None" );
3709 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3714 if ( value.type() == QVariant::StringList )
3716 const QStringList list = value.toStringList();
3717 parts.reserve( list.count() );
3718 for (
const QString &v : list )
3721 else if ( value.type() == QVariant::List )
3723 const QVariantList list = value.toList();
3724 parts.reserve( list.count() );
3725 for (
const QVariant &v : list )
3728 if ( !parts.isEmpty() )
3729 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3734 p.insert(
name(), value );
3736 if ( !list.isEmpty() )
3739 parts.reserve( list.count() );
3744 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3753 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3755 code += QLatin1String(
"optional " );
3756 switch ( mLayerType )
3759 code += QLatin1String(
"multiple raster" );
3763 code += QLatin1String(
"multiple file" );
3767 code += QLatin1String(
"multiple vector" );
3771 if (
mDefault.type() == QVariant::List )
3774 const auto constToList =
mDefault.toList();
3775 for (
const QVariant &var : constToList )
3777 parts << var.toString();
3779 code += parts.join(
',' );
3781 else if (
mDefault.type() == QVariant::StringList )
3783 code +=
mDefault.toStringList().join(
',' );
3789 return code.trimmed();
3794 switch ( outputType )
3798 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', '%2'" ).arg(
name(),
description() );
3800 code += QLatin1String(
", optional=True" );
3804 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
3816 switch ( mLayerType )
3819 return QObject::tr(
"All files (*.*)" );
3852 return mMinimumNumberInputs;
3864 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
3865 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
3873 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
3879 QString
type = definition;
3881 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
3882 QRegularExpressionMatch m = re.match( definition );
3885 type = m.captured( 1 ).toLower().trimmed();
3886 defaultVal = m.captured( 2 );
3889 if (
type == QLatin1String(
"vector" ) )
3891 else if (
type == QLatin1String(
"raster" ) )
3893 else if (
type == QLatin1String(
"file" ) )
3906 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
3917 QVariant input = value;
3918 if ( !input.isValid() )
3932 double res = input.toDouble( &ok );
3936 return !( res < mMin || res > mMax );
3941 if ( !value.isValid() )
3942 return QStringLiteral(
"None" );
3945 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3947 return value.toString();
3954 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
3955 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
3956 if ( mMax < std::numeric_limits<double>::max() )
3957 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
3959 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
3960 QString extra = parts.join( QLatin1String(
"<br />" ) );
3961 if ( !extra.isEmpty() )
3962 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
3968 switch ( outputType )
3972 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', '%2'" ).arg(
name(),
description() );
3974 code += QLatin1String(
", optional=True" );
3976 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
3978 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
3979 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
3980 if ( mMax != std::numeric_limits<double>::max() )
3981 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
4023 map.insert( QStringLiteral(
"min" ), mMin );
4024 map.insert( QStringLiteral(
"max" ), mMax );
4025 map.insert( QStringLiteral(
"data_type" ), mDataType );
4032 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
4033 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
4034 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
4041 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4058 if ( !input.isValid() )
4066 if ( input.type() == QVariant::String )
4068 QStringList list = input.toString().split(
',' );
4069 if ( list.count() != 2 )
4072 list.at( 0 ).toDouble( &ok );
4074 list.at( 1 ).toDouble( &ok2 );
4079 else if ( input.type() == QVariant::List )
4081 if ( input.toList().count() != 2 )
4085 input.toList().at( 0 ).toDouble( &ok );
4087 input.toList().at( 1 ).toDouble( &ok2 );
4098 if ( !value.isValid() )
4099 return QStringLiteral(
"None" );
4102 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4105 p.insert(
name(), value );
4108 QStringList stringParts;
4109 const auto constParts = parts;
4110 for (
double v : constParts )
4112 stringParts << QString::number( v );
4114 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
4119 switch ( outputType )
4123 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', '%2'" ).arg(
name(),
description() );
4125 code += QLatin1String(
", optional=True" );
4127 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
QgsProcessingParameterNumber::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4150 map.insert( QStringLiteral(
"data_type" ), mDataType );
4164 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4180 if ( !input.isValid() )
4188 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4191 if ( input.type() != QVariant::String || input.toString().isEmpty() )
4209 if ( !val.isValid() )
4210 return QStringLiteral(
"None" );
4216 p.insert(
name(), val );
4234 , mOptions( options )
4235 , mAllowMultiple( allowMultiple )
4236 , mUsesStaticStrings( usesStaticStrings )
4248 QVariant input = value;
4249 if ( !input.isValid() )
4262 if ( mUsesStaticStrings )
4264 if ( input.type() == QVariant::List )
4266 if ( !mAllowMultiple )
4269 const QVariantList values = input.toList();
4273 for (
const QVariant &val : values )
4275 if ( !mOptions.contains( val.toString() ) )
4281 else if ( input.type() == QVariant::StringList )
4283 if ( !mAllowMultiple )
4286 const QStringList values = input.toStringList();
4291 if ( values.count() > 1 && !mAllowMultiple )
4294 for (
const QString &val : values )
4296 if ( !mOptions.contains( val ) )
4301 else if ( input.type() == QVariant::String )
4303 QStringList parts = input.toString().split(
',' );
4304 if ( parts.count() > 1 && !mAllowMultiple )
4307 const auto constParts = parts;
4308 for (
const QString &part : constParts )
4310 if ( !mOptions.contains( part ) )
4318 if ( input.type() == QVariant::List )
4320 if ( !mAllowMultiple )
4323 const QVariantList values = input.toList();
4327 for (
const QVariant &val : values )
4330 int res = val.toInt( &ok );
4333 else if ( res < 0 || res >= mOptions.count() )
4339 else if ( input.type() == QVariant::String )
4341 QStringList parts = input.toString().split(
',' );
4342 if ( parts.count() > 1 && !mAllowMultiple )
4345 const auto constParts = parts;
4346 for (
const QString &part : constParts )
4349 int res = part.toInt( &ok );
4352 else if ( res < 0 || res >= mOptions.count() )
4357 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
4360 int res = input.toInt( &ok );
4363 else if ( res >= 0 && res < mOptions.count() )
4373 if ( !value.isValid() )
4374 return QStringLiteral(
"None" );
4377 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4379 if ( mUsesStaticStrings )
4381 if ( value.type() == QVariant::StringList )
4384 const QStringList constList = value.toStringList();
4385 for (
const QString &val : constList )
4389 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4391 else if ( value.type() == QVariant::String )
4394 const QStringList constList = value.toString().split(
',' );
4395 if ( constList.count() > 1 )
4397 for (
const QString &val : constList )
4401 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4409 if ( value.type() == QVariant::List )
4412 const auto constToList = value.toList();
4413 for (
const QVariant &val : constToList )
4415 parts << QString::number( static_cast< int >( val.toDouble() ) );
4417 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4419 else if ( value.type() == QVariant::String )
4421 QStringList parts = value.toString().split(
',' );
4422 if ( parts.count() > 1 )
4424 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4428 return QString::number(
static_cast< int >( value.toDouble() ) );
4434 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4436 code += QLatin1String(
"optional " );
4437 code += QLatin1String(
"enum " );
4439 if ( mAllowMultiple )
4440 code += QLatin1String(
"multiple " );
4442 if ( mUsesStaticStrings )
4443 code += QLatin1String(
"static " );
4445 code += mOptions.join(
';' ) +
' ';
4448 return code.trimmed();
4453 switch ( outputType )
4457 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', '%2'" ).arg(
name(),
description() );
4459 code += QLatin1String(
", optional=True" );
4462 options.reserve( mOptions.size() );
4463 for (
const QString &o : mOptions )
4465 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
4467 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4469 code += QStringLiteral(
", usesStaticStrings=%1" ).arg( mUsesStaticStrings ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4492 return mAllowMultiple;
4502 return mUsesStaticStrings;
4513 map.insert( QStringLiteral(
"options" ), mOptions );
4514 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
4515 map.insert( QStringLiteral(
"uses_static_strings" ), mUsesStaticStrings );
4522 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
4523 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
4524 mUsesStaticStrings = map.value( QStringLiteral(
"uses_static_strings" ) ).toBool();
4531 QString def = definition;
4533 bool multiple =
false;
4534 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
4540 bool staticStrings =
false;
4541 if ( def.startsWith( QLatin1String(
"static" ), Qt::CaseInsensitive ) )
4543 staticStrings =
true;
4547 QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
4548 QRegularExpressionMatch m = re.match( def );
4549 QString values = def;
4552 values = m.captured( 1 ).trimmed();
4553 defaultVal = m.captured( 2 );
4561 , mMultiLine( multiLine )
4573 if ( !value.isValid() || value.isNull() )
4574 return QStringLiteral(
"None" );
4577 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4579 QString s = value.toString();
4585 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4587 code += QLatin1String(
"optional " );
4588 code += QLatin1String(
"string " );
4591 code += QLatin1String(
"long " );
4594 return code.trimmed();
4599 switch ( outputType )
4603 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', '%2'" ).arg(
name(),
description() );
4605 code += QLatin1String(
", optional=True" );
4606 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4629 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
4636 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
4642 QString def = definition;
4644 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
4650 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
4652 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
4656 if ( def == QLatin1String(
"None" ) )
4679 if ( !value.isValid() )
4680 return QStringLiteral(
"None" );
4682 QString s = value.toString();
4688 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4690 code += QLatin1String(
"optional " );
4691 code += QLatin1String(
"authcfg " );
4694 return code.trimmed();
4699 QString def = definition;
4701 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
4703 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
4707 if ( def == QLatin1String(
"None" ) )
4720 , mParentLayerParameterName( parentLayerParameterName )
4732 if ( !value.isValid() )
4733 return QStringLiteral(
"None" );
4736 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4738 QString s = value.toString();
4744 QStringList depends;
4745 if ( !mParentLayerParameterName.isEmpty() )
4746 depends << mParentLayerParameterName;
4752 switch ( outputType )
4756 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', '%2'" ).arg(
name(),
description() );
4758 code += QLatin1String(
", optional=True" );
4760 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
4772 return mParentLayerParameterName;
4783 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
4790 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
4831 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
4834 if ( var.type() != QVariant::String || var.toString().isEmpty() )
4852 if ( !val.isValid() )
4853 return QStringLiteral(
"None" );
4859 p.insert(
name(), val );
4867 switch ( outputType )
4871 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', '%2'" ).arg(
name(),
description() );
4873 code += QLatin1String(
", optional=True" );
4877 QStringList options;
4880 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
4914 map.insert( QStringLiteral(
"data_types" ), types );
4922 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
4923 for (
const QVariant &val : values )
4936 const QString &description,
4937 const QVariant &defaultValue,
4969 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
4972 if ( var.type() != QVariant::String || var.toString().isEmpty() )
4990 if ( !val.isValid() )
4991 return QStringLiteral(
"None" );
4997 p.insert(
name(), val );
5015 , mParentLayerParameterName( parentLayerParameterName )
5017 , mAllowMultiple( allowMultiple )
5018 , mDefaultToAllFields( defaultToAllFields )
5031 if ( !input.isValid() )
5039 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
5041 if ( !mAllowMultiple )
5047 else if ( input.type() == QVariant::String )
5049 if ( input.toString().isEmpty() )
5052 QStringList parts = input.toString().split(
';' );
5053 if ( parts.count() > 1 && !mAllowMultiple )
5058 if ( input.toString().isEmpty() )
5066 if ( !value.isValid() )
5067 return QStringLiteral(
"None" );
5070 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5072 if ( value.type() == QVariant::List )
5075 const auto constToList = value.toList();
5076 for (
const QVariant &val : constToList )
5080 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5082 else if ( value.type() == QVariant::StringList )
5085 const auto constToStringList = value.toStringList();
5086 for ( QString s : constToStringList )
5090 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5098 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5100 code += QLatin1String(
"optional " );
5101 code += QLatin1String(
"field " );
5103 switch ( mDataType )
5106 code += QLatin1String(
"numeric " );
5110 code += QLatin1String(
"string " );
5114 code += QLatin1String(
"datetime " );
5121 if ( mAllowMultiple )
5122 code += QLatin1String(
"multiple " );
5124 if ( mDefaultToAllFields )
5125 code += QLatin1String(
"default_to_all_fields " );
5127 code += mParentLayerParameterName +
' ';
5130 return code.trimmed();
5135 switch ( outputType )
5139 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', '%2'" ).arg(
name(),
description() );
5141 code += QLatin1String(
", optional=True" );
5144 switch ( mDataType )
5147 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
5151 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
5155 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
5159 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
5162 code += QStringLiteral(
", type=%1" ).arg(
dataType );
5164 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5165 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5169 if ( mDefaultToAllFields )
5170 code += QLatin1String(
", defaultToAllFields=True" );
5182 QStringList depends;
5183 if ( !mParentLayerParameterName.isEmpty() )
5184 depends << mParentLayerParameterName;
5190 return mParentLayerParameterName;
5210 return mAllowMultiple;
5220 return mDefaultToAllFields;
5225 mDefaultToAllFields = enabled;
5231 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5232 map.insert( QStringLiteral(
"data_type" ), mDataType );
5233 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5234 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
5241 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5242 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
5243 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5244 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
5254 QString def = definition;
5256 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
5261 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
5266 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
5272 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5275 def = def.mid( 8 ).trimmed();
5278 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
5281 def = def.mid( 21 ).trimmed();
5284 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
5285 QRegularExpressionMatch m = re.match( def );
5288 parent = m.captured( 1 ).trimmed();
5289 def = m.captured( 2 );
5314 QVariant var = input;
5315 if ( !var.isValid() )
5342 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
5347 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5365 if ( !value.isValid() )
5366 return QStringLiteral(
"None" );
5369 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5374 QString geometryCheckString;
5378 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
5382 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
5386 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
5392 if ( fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagOverrideDefaultGeometryCheck )
5393 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
5394 if ( fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagCreateIndividualOutputPerInputFeature )
5395 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
5396 if ( !
flags.empty() )
5397 flagString =
flags.join( QLatin1String(
" | " ) );
5404 layerString = layer->source();
5408 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition('%1', selectedFeaturesOnly=%2, featureLimit=%3%4, geometryCheck=%5)" ).arg( layerString,
5411 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
5412 geometryCheckString );
5423 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression('%1'), selectedFeaturesOnly=%2, featureLimit=%3%4, geometryCheck=%5)" )
5427 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
5428 geometryCheckString );
5432 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
source.
asExpression() );
5436 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
5441 QString layerString = value.toString();
5445 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
5452 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5454 code += QLatin1String(
"optional " );
5455 code += QLatin1String(
"source " );
5462 code += QLatin1String(
"point " );
5466 code += QLatin1String(
"line " );
5470 code += QLatin1String(
"polygon " );
5477 return code.trimmed();
5482 switch ( outputType )
5486 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', '%2'" ).arg(
name(),
description() );
5488 code += QLatin1String(
", optional=True" );
5492 QStringList options;
5496 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
5513 : mDataTypes( types )
5526 map.insert( QStringLiteral(
"data_types" ), types );
5534 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
5535 for (
const QVariant &val : values )
5545 QString def = definition;
5548 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
5554 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
5560 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
5575 , mSupportsAppend( supportsAppend )
5586 QVariant var = input;
5587 if ( !var.isValid() )
5609 if ( var.type() != QVariant::String )
5612 if ( var.toString().isEmpty() )
5620 if ( !value.isValid() )
5621 return QStringLiteral(
"None" );
5624 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5635 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
5644 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5646 code += QLatin1String(
"optional " );
5647 code += QLatin1String(
"sink " );
5649 switch ( mDataType )
5652 code += QLatin1String(
"point " );
5656 code += QLatin1String(
"line " );
5660 code += QLatin1String(
"polygon " );
5664 code += QLatin1String(
"table " );
5672 return code.trimmed();
5684 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
5688 return p->defaultVectorFileExtension(
hasGeometry() );
5698 return QStringLiteral(
"dbf" );
5705 switch ( outputType )
5709 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', '%2'" ).arg(
name(),
description() );
5711 code += QLatin1String(
", optional=True" );
5715 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5716 if ( mSupportsAppend )
5717 code += QLatin1String(
", supportsAppend=True" );
5730 QStringList filters;
5731 for (
const QString &ext : exts )
5733 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
5735 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
5744 return lOriginalProvider->supportedOutputVectorLayerExtensions();
5746 return lOriginalProvider->supportedOutputTableExtensions();
5751 return p->supportedOutputVectorLayerExtensions();
5753 return p->supportedOutputTableExtensions();
5768 switch ( mDataType )
5794 map.insert( QStringLiteral(
"data_type" ), mDataType );
5795 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
5803 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
5810 return QStringLiteral(
"memory:%1" ).arg(
description() );
5818 QString def = definition;
5819 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
5824 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
5829 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
5834 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
5845 return mSupportsAppend;
5865 QVariant var = input;
5866 if ( !var.isValid() )
5888 if ( var.type() != QVariant::String )
5891 if ( var.toString().isEmpty() )
5899 if ( !value.isValid() )
5900 return QStringLiteral(
"None" );
5903 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5914 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
5930 return lOriginalProvider->defaultRasterFileExtension();
5934 return p->defaultRasterFileExtension();
5945 QStringList filters;
5946 for (
const QString &ext : exts )
5948 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
5950 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
5957 return lOriginalProvider->supportedOutputRasterLayerExtensions();
5961 return p->supportedOutputRasterLayerExtensions();
5977 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
5989 QVariant var = input;
5990 if ( !var.isValid() )
6012 if ( var.type() != QVariant::String )
6015 if ( var.toString().isEmpty() )
6025 if ( !value.isValid() )
6026 return QStringLiteral(
"None" );
6029 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6040 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6049 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
6061 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
6062 return QStringLiteral(
"file" );
6065 QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
6066 QRegularExpressionMatch match = rx.match( mFileFilter );
6067 if ( !match.hasMatch() )
6068 return QStringLiteral(
"file" );
6070 return match.captured( 1 );
6075 switch ( outputType )
6079 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', '%2'" ).arg(
name(),
description() );
6081 code += QLatin1String(
", optional=True" );
6085 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6097 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
6113 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
6120 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
6141 QVariant var = input;
6142 if ( !var.isValid() )
6158 if ( var.type() != QVariant::String )
6161 if ( var.toString().isEmpty() )
6184 , mCreateByDefault( createByDefault )
6192 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
6193 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
6200 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
6201 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
6207 switch ( outputType )
6214 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
6216 code += QLatin1String(
", optional=True" );
6218 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6233 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
6240 QRegularExpression rx( QStringLiteral(
"[.]" ) );
6241 QString sanitizedName =
name();
6242 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
6257 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
6266 return mCreateByDefault;
6288 QVariant var = input;
6289 if ( !var.isValid() )
6311 if ( var.type() != QVariant::String )
6314 if ( var.toString().isEmpty() )
6322 if ( !value.isValid() )
6323 return QStringLiteral(
"None" );
6326 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6337 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6346 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6348 code += QLatin1String(
"optional " );
6349 code += QLatin1String(
"vectorDestination " );
6351 switch ( mDataType )
6354 code += QLatin1String(
"point " );
6358 code += QLatin1String(
"line " );
6362 code += QLatin1String(
"polygon " );
6370 return code.trimmed();
6382 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6386 return p->defaultVectorFileExtension(
hasGeometry() );
6396 return QStringLiteral(
"dbf" );
6403 switch ( outputType )
6407 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', '%2'" ).arg(
name(),
description() );
6409 code += QLatin1String(
", optional=True" );
6413 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6426 QStringList filters;
6427 for (
const QString &ext : exts )
6429 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6431 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6439 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6441 return lOriginalProvider->supportedOutputTableExtensions();
6446 return p->supportedOutputVectorLayerExtensions();
6448 return p->supportedOutputTableExtensions();
6463 switch ( mDataType )
6489 map.insert( QStringLiteral(
"data_type" ), mDataType );
6503 QString def = definition;
6504 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6509 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6514 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6525 , mParentLayerParameterName( parentLayerParameterName )
6526 , mAllowMultiple( allowMultiple )
6538 if ( !input.isValid() )
6546 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
6548 if ( !mAllowMultiple )
6557 double res = input.toInt( &ok );
6567 return mAllowMultiple;
6577 if ( !value.isValid() )
6578 return QStringLiteral(
"None" );
6581 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6583 if ( value.type() == QVariant::List )
6586 QVariantList values = value.toList();
6587 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
6589 parts << QString::number( static_cast< int >( it->toDouble() ) );
6591 return parts.join(
',' ).prepend(
'[' ).append(
']' );
6593 else if ( value.type() == QVariant::StringList )
6596 QStringList values = value.toStringList();
6597 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
6599 parts << QString::number( static_cast< int >( it->toDouble() ) );
6601 return parts.join(
',' ).prepend(
'[' ).append(
']' );
6604 return value.toString();
6609 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6611 code += QLatin1String(
"optional " );
6612 code += QLatin1String(
"band " );
6614 if ( mAllowMultiple )
6615 code += QLatin1String(
"multiple " );
6617 code += mParentLayerParameterName +
' ';
6620 return code.trimmed();
6625 QStringList depends;
6626 if ( !mParentLayerParameterName.isEmpty() )
6627 depends << mParentLayerParameterName;
6633 switch ( outputType )
6637 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', '%2'" ).arg(
name(),
description() );
6639 code += QLatin1String(
", optional=True" );
6641 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
6642 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6654 return mParentLayerParameterName;
6665 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
6666 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
6673 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
6674 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
6681 QString def = definition;
6684 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
6687 def = def.mid( 8 ).trimmed();
6690 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
6691 QRegularExpressionMatch m = re.match( def );
6694 parent = m.captured( 1 ).trimmed();
6695 def = m.captured( 2 );
6712 , mParentParameterName( parentParameterName )
6729 QStringList depends;
6730 if ( !mParentParameterName.isEmpty() )
6731 depends << mParentParameterName;
6737 switch ( outputType )
6741 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', '%2'" ).arg(
name(),
description() );
6743 code += QLatin1String(
", optional=True" );
6745 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
6747 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
6748 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
6749 if (
maximum() != std::numeric_limits<double>::max() )
6750 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
6761 return mParentParameterName;
6772 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
6773 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
6780 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
6808 switch ( outputType )
6812 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', '%2'" ).arg(
name(),
description() );
6814 code += QLatin1String(
", optional=True" );
6826 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
6845 if ( !value.isValid() || value.isNull() )
6846 return QStringLiteral(
"None" );
6849 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6851 QString s = value.toString();
6857 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6859 code += QLatin1String(
"optional " );
6860 code += QLatin1String(
"layout " );
6863 return code.trimmed();
6868 switch ( outputType )
6872 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', '%2'" ).arg(
name(),
description() );
6874 code += QLatin1String(
", optional=True" );
6885 QString def = definition;
6887 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
6889 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
6893 if ( def == QLatin1String(
"None" ) )
6906 , mParentLayoutParameterName( parentLayoutParameterName )
6907 , mItemType( itemType )
6919 if ( !value.isValid() || value.isNull() )
6920 return QStringLiteral(
"None" );
6923 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6925 QString s = value.toString();
6931 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6933 code += QLatin1String(
"optional " );
6934 code += QLatin1String(
"layoutitem " );
6935 if ( mItemType >= 0 )
6936 code += QString::number( mItemType ) +
' ';
6938 code += mParentLayoutParameterName +
' ';
6941 return code.trimmed();
6946 switch ( outputType )
6950 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', '%2'" ).arg(
name(),
description() );
6952 code += QLatin1String(
", optional=True" );
6954 if ( mItemType >= 0 )
6955 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
6957 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
6970 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
6971 map.insert( QStringLiteral(
"item_type" ), mItemType );
6978 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
6979 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
6985 QStringList depends;
6986 if ( !mParentLayoutParameterName.isEmpty() )
6987 depends << mParentLayoutParameterName;
6994 QString def = definition;
6996 QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
6997 QRegularExpressionMatch m = re.match( def );
7000 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
7001 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
7002 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
7015 return mParentLayoutParameterName;
7020 mParentLayoutParameterName =
name;
7039 , mAllowOpacity( opacityEnabled )
7051 if ( !value.isValid() || value.isNull() )
7052 return QStringLiteral(
"None" );
7055 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7057 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
7058 return QStringLiteral(
"QColor()" );
7060 if ( value.canConvert< QColor >() )
7062 QColor
c = value.value< QColor >();
7063 if ( !mAllowOpacity ||
c.alpha() == 255 )
7064 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
7066 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
7069 QString s = value.toString();
7075 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7077 code += QLatin1String(
"optional " );
7078 code += QLatin1String(
"color " );
7080 if ( mAllowOpacity )
7081 code += QLatin1String(
"withopacity " );
7084 return code.trimmed();
7089 switch ( outputType )
7093 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', '%2'" ).arg(
name(),
description() );
7095 code += QLatin1String(
", optional=True" );
7097 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
7109 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
7112 if ( !input.isValid() )
7115 if ( input.type() == QVariant::Color )
7124 if ( input.type() != QVariant::String || input.toString().isEmpty() )
7127 bool containsAlpha =
false;
7134 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
7141 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
7147 return mAllowOpacity;
7152 mAllowOpacity = enabled;
7157 QString def = definition;
7159 bool allowOpacity =
false;
7160 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
7162 allowOpacity =
true;
7163 def = def.mid( 12 );
7166 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7168 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7172 if ( def == QLatin1String(
"None" ) )
7183 , mSourceParameterName( sourceCrsParameterName )
7184 , mDestParameterName( destinationCrsParameterName )
7185 , mSourceCrs( staticSourceCrs )
7186 , mDestCrs( staticDestinationCrs )
7198 if ( !value.isValid() || value.isNull() )
7199 return QStringLiteral(
"None" );
7204 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
7210 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7213 p.insert(
name(), value );
7218 QString s = value.toString();
7224 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7226 code += QLatin1String(
"optional " );
7227 code += QLatin1String(
"coordinateoperation " );
7230 return code.trimmed();
7235 switch ( outputType )
7240 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', '%2'" ).arg(
name(),
description() );
7242 code += QLatin1String(
", optional=True" );
7243 if ( !mSourceParameterName.isEmpty() )
7244 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg(
valueAsPythonString( mSourceParameterName,
c ) );
7245 if ( !mDestParameterName.isEmpty() )
7246 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg(
valueAsPythonString( mDestParameterName,
c ) );
7248 if ( mSourceCrs.isValid() )
7250 if ( mDestCrs.isValid() )
7251 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg(
valueAsPythonString( mDestCrs,
c ) );
7263 if ( !mSourceParameterName.isEmpty() )
7264 res << mSourceParameterName;
7265 if ( !mDestParameterName.isEmpty() )
7266 res << mDestParameterName;
7273 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
7274 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
7275 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
7276 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
7283 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
7284 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
7285 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
7286 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
7292 QString def = definition;
7294 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7296 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7300 if ( def == QLatin1String(
"None" ) )
7325 if ( !input.isValid() && !
mDefault.isValid() )
7328 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7329 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7337 if ( !value.isValid() )
7338 return QStringLiteral(
"None" );
7341 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7348 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7350 code += QLatin1String(
"optional " );
7351 code += QLatin1String(
"maptheme " );
7354 return code.trimmed();
7359 switch ( outputType )
7363 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', '%2'" ).arg(
name(),
description() );
7365 code += QLatin1String(
", optional=True" );
7392 QString def = definition;
7393 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7395 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7417 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
7419 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
7430 QVariant input = value;
7431 if ( !input.isValid() )
7444 if ( input.type() != QVariant::DateTime && input.type() != QVariant::Date && input.type() != QVariant::Time && input.type() != QVariant::String )
7447 if ( ( input.type() == QVariant::DateTime || input.type() == QVariant::Date ) && mDataType ==
Time )
7450 if ( input.type() == QVariant::String )
7452 QString s = input.toString();
7456 input = QDateTime::fromString( s, Qt::ISODate );
7457 if ( mDataType ==
Time )
7459 if ( !input.toDateTime().isValid() )
7460 input = QTime::fromString( s );
7462 input = input.toDateTime().time();
7466 if ( mDataType !=
Time )
7468 QDateTime res = input.toDateTime();
7469 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
7473 QTime res = input.toTime();
7474 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
7480 if ( !value.isValid() )
7481 return QStringLiteral(
"None" );
7484 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7486 if ( value.type() == QVariant::DateTime )
7488 const QDateTime dt = value.toDateTime();
7489 if ( !dt.isValid() )
7490 return QStringLiteral(
"QDateTime()" );
7492 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
7493 .arg( dt.date().month() )
7494 .arg( dt.date().day() )
7495 .arg( dt.time().hour() )
7496 .arg( dt.time().minute() )
7497 .arg( dt.time().second() );
7499 else if ( value.type() == QVariant::Date )
7501 const QDate dt = value.toDate();
7502 if ( !dt.isValid() )
7503 return QStringLiteral(
"QDate()" );
7505 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
7509 else if ( value.type() == QVariant::Time )
7511 const QTime dt = value.toTime();
7512 if ( !dt.isValid() )
7513 return QStringLiteral(
"QTime()" );
7515 return QStringLiteral(
"QTime(%4, %5, %6)" )
7518 .arg( dt.second() );
7520 return value.toString();
7527 if ( mMin.isValid() )
7528 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
7529 if ( mMax.isValid() )
7530 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
7532 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
DateTime ?
mDefault.toDateTime().toString( Qt::ISODate ) :
7533 ( mDataType ==
Date ?
mDefault.toDate().toString( Qt::ISODate ) :
mDefault.toTime( ).toString() ) );
7534 QString extra = parts.join( QLatin1String(
"<br />" ) );
7535 if ( !extra.isEmpty() )
7536 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
7542 switch ( outputType )
7546 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', '%2'" ).arg(
name(),
description() );
7548 code += QLatin1String(
", optional=True" );
7550 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
DateTime ? QStringLiteral(
"QgsProcessingParameterDateTime.DateTime" )
7551 : mDataType ==
Date ? QStringLiteral(
"QgsProcessingParameterDateTime.Date" )
7552 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
7555 if ( mMin.isValid() )
7557 if ( mMax.isValid() )
7599 map.insert( QStringLiteral(
"min" ), mMin );
7600 map.insert( QStringLiteral(
"max" ), mMax );
7601 map.insert( QStringLiteral(
"data_type" ), mDataType );
7608 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
7609 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
7610 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
7617 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
7628 , mProviderId( provider )
7641 if ( !input.isValid() && !
mDefault.isValid() )
7644 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7645 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7653 if ( !value.isValid() )
7654 return QStringLiteral(
"None" );
7657 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7664 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7666 code += QLatin1String(
"optional " );
7667 code += QLatin1String(
"providerconnection " );
7668 code += mProviderId +
' ';
7671 return code.trimmed();
7676 switch ( outputType )
7680 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', '%2', '%3'" ).arg(
name(),
description(), mProviderId );
7682 code += QLatin1String(
", optional=True" );
7696 map.insert( QStringLiteral(
"provider" ), mProviderId );
7703 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
7711 QString def = definition;
7713 if ( def.contains(
' ' ) )
7715 provider = def.left( def.indexOf(
' ' ) );
7716 def = def.mid( def.indexOf(
' ' ) + 1 );
7724 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7726 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7744 , mParentConnectionParameterName( parentLayerParameterName )
7757 if ( !input.isValid() && !
mDefault.isValid() )
7760 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7761 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7769 if ( !value.isValid() )
7770 return QStringLiteral(
"None" );
7773 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7780 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7782 code += QLatin1String(
"optional " );
7783 code += QLatin1String(
"databaseschema " );
7785 code += mParentConnectionParameterName +
' ';
7788 return code.trimmed();
7793 switch ( outputType )
7797 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', '%2'" ).arg(
name(),
description() );
7799 code += QLatin1String(
", optional=True" );
7801 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
7815 QStringList depends;
7816 if ( !mParentConnectionParameterName.isEmpty() )
7817 depends << mParentConnectionParameterName;
7823 return mParentConnectionParameterName;
7828 mParentConnectionParameterName =
name;
7834 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
7841 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
7848 QString def = definition;
7850 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7851 QRegularExpressionMatch m = re.match( def );
7854 parent = m.captured( 1 ).trimmed();
7855 def = m.captured( 2 );
7871 const QString &connectionParameterName,
7872 const QString &schemaParameterName,
7873 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
7875 , mParentConnectionParameterName( connectionParameterName )
7876 , mParentSchemaParameterName( schemaParameterName )
7877 , mAllowNewTableNames( allowNewTableNames )
7890 if ( !input.isValid() && !
mDefault.isValid() )
7893 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7894 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7902 if ( !value.isValid() )
7903 return QStringLiteral(
"None" );
7906 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7913 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7915 code += QLatin1String(
"optional " );
7916 code += QLatin1String(
"databasetable " );
7918 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
7919 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
7922 return code.trimmed();
7927 switch ( outputType )
7931 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', '%2'" ).arg(
name(),
description() );
7933 code += QLatin1String(
", optional=True" );
7935 if ( mAllowNewTableNames )
7936 code += QLatin1String(
", allowNewTableNames=True" );
7938 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
7939 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
7953 QStringList depends;
7954 if ( !mParentConnectionParameterName.isEmpty() )
7955 depends << mParentConnectionParameterName;
7956 if ( !mParentSchemaParameterName.isEmpty() )
7957 depends << mParentSchemaParameterName;
7963 return mParentConnectionParameterName;
7968 mParentConnectionParameterName =
name;
7973 return mParentSchemaParameterName;
7978 mParentSchemaParameterName =
name;
7984 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
7985 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
7986 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
7993 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
7994 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
7995 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
8003 QString def = definition;
8005 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
8006 QRegularExpressionMatch m = re.match( def );
8009 connection = m.captured( 1 ).trimmed();
8010 if ( connection == QLatin1String(
"none" ) )
8012 schema = m.captured( 2 ).trimmed();
8013 if ( schema == QLatin1String(
"none" ) )
8015 def = m.captured( 3 );
8023 return mAllowNewTableNames;
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QString authid() const
Returns the authority identifier for the CRS.
@ 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 QString addExtensionFromFilter(const QString &fileName, const QString &filter)
Ensures that a fileName ends with an extension from the specified filter string.
A geometry is the spatial representation of a feature.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
static QgsGeometry fromRect(const QgsRectangle &rect) SIP_HOLDGIL
Creates a new geometry from a QgsRectangle.
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
static QgsGeometry fromPointXY(const QgsPointXY &point) SIP_HOLDGIL
Creates a new geometry from a QgsPointXY object.
QgsWkbTypes::GeometryType type
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...
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
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
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::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
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.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
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.
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.
virtual QString generateTemporaryDestination() const
Generates a temporary destination value for this parameter.
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.
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.
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 raster layer output for processing algorithms.
A vector layer output for processing algorithms.
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.
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.
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.
QVariant defaultValue() const
Returns the default value for the parameter.
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...
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.
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.
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.
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.
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...
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.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QgsProcessingParameterExpression(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false)
Constructor for QgsProcessingParameterExpression.
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.
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.
A feature sink output for processing algorithms.
QString generateTemporaryDestination() 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 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.
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...
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.
QgsProcessingParameterGeometry(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QList< int > &geometryTypes=QList< int >())
Constructor for QgsProcessingParameterGeometry.
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 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.
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.
QgsProcessingParameterMeshLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMeshLayer.
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.
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 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 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.
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.
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.
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.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of map layers.
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 QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
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 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 QgsMapLayer * parameterAsLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingUtils::LayerHint layerHint=QgsProcessingUtils::LayerHint::UnknownType)
Evaluates the parameter with matching definition to a map layer.
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 QgsFeatureSink * parameterAsSink(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsFields &fields, QgsWkbTypes::Type 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 bool parameterAsBoolean(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
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 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 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 convertToCompatibleFormat(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, long long featureLimit=-1)
Converts a source vector layer to a file path of a vector layer of compatible format.
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 normalizeLayerSource(const QString &source)
Normalizes a layer source string for safe comparison across different operating system environments.
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type 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 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.
@ Vector
Vector layer type.
@ Mesh
Mesh layer type, since QGIS 3.6.
@ Raster
Raster layer type.
@ UnknownType
Unknown layer type.
static QString generateTempFilename(const QString &basename)
Returns a temporary filename for a given file, putting it into a temporary folder (creating that fold...
static QgsProcessingFeatureSource * variantToSource(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a new feature source.
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)
Converts a source vector layer to a file path and layer name of a vector layer of compatible format.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType)
Interprets a string as a map layer within the supplied context.
static QString defaultRasterExtension()
Returns the default raster 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.
@ TypeVectorLine
Vector line layers.
@ TypeMapLayer
Any map layer type (raster or vector or mesh)
@ TypeVectorPolygon
Vector polygon layers.
@ TypeFile
Files (i.e. non map layer sources, such as text files)
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ TypeRaster
Raster layers.
@ TypeVectorPoint
Vector point layers.
@ TypeVectorAnyGeometry
Any vector layer with geometry.
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,...
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.
@ StaticProperty
Static property (QgsStaticProperty)
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
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.
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.
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,...
DistanceUnit
Units of distance.
@ DistanceUnknownUnit
Unknown distance unit.
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.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Type
The WKB type describes the number of dimensions a geometry has.
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.
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