QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
47 map.insert( QStringLiteral(
"feature_limit" ),
featureLimit );
48 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
flags ) );
49 map.insert( QStringLiteral(
"geometry_check" ),
static_cast< int >(
geometryCheck ) );
57 featureLimit = map.value( QStringLiteral(
"feature_limit" ), -1 ).toLongLong();
58 flags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ), 0 ).toInt() );
71 mRemappingDefinition = definition;
78 map.insert( QStringLiteral(
"create_options" ),
createOptions );
80 map.insert( QStringLiteral(
"remapping" ), QVariant::fromValue( mRemappingDefinition ) );
87 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
88 if ( map.contains( QStringLiteral(
"remapping" ) ) )
95 mUseRemapping =
false;
103 && mUseRemapping == other.mUseRemapping && mRemappingDefinition == other.mRemappingDefinition;
108 return !( *
this == other );
113 QVariant val = parameters.value( name );
133 QVariant val = value;
137 if ( !val.isValid() )
146 return destParam->generateTemporaryDestination();
149 return val.toString();
165 QVariant val = value;
169 if ( val.isValid() && !val.toString().isEmpty() )
173 return val.toString();
193 QVariant val = value;
198 double res = val.toDouble( &ok );
204 return val.toDouble();
220 QVariant val = value;
225 double dbl = val.toDouble( &ok );
230 dbl = val.toDouble( &ok );
237 double round = std::round( dbl );
238 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
243 return static_cast< int >( std::round( dbl ) );
252 return QList< int >();
260 return QList< int >();
262 QList< int > resultList;
263 QVariant val = value;
268 else if ( val.type() == QVariant::List )
270 QVariantList list = val.toList();
271 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
272 resultList << it->toInt();
276 QStringList parts = val.toString().split(
';' );
277 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
278 resultList << it->toInt();
282 if ( ( resultList.isEmpty() || resultList.at( 0 ) == 0 ) )
288 if ( definition->
defaultValue().type() == QVariant::List )
290 QVariantList list = definition->
defaultValue().toList();
291 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
292 resultList << it->toInt();
296 QStringList parts = definition->
defaultValue().toString().split(
';' );
297 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
298 resultList << it->toInt();
319 QVariant val = value;
323 QDateTime d = val.toDateTime();
324 if ( !d.isValid() && val.type() == QVariant::String )
326 d = QDateTime::fromString( val.toString() );
333 d = val.toDateTime();
335 if ( !d.isValid() && val.type() == QVariant::String )
337 d = QDateTime::fromString( val.toString() );
356 QVariant val = value;
360 QDate d = val.toDate();
361 if ( !d.isValid() && val.type() == QVariant::String )
363 d = QDate::fromString( val.toString() );
372 if ( !d.isValid() && val.type() == QVariant::String )
374 d = QDate::fromString( val.toString() );
393 QVariant val = value;
399 if ( val.type() == QVariant::DateTime )
400 d = val.toDateTime().time();
404 if ( !d.isValid() && val.type() == QVariant::String )
406 d = QTime::fromString( val.toString() );
415 if ( !d.isValid() && val.type() == QVariant::String )
417 d = QTime::fromString( val.toString() );
438 if ( enumDef && val >= enumDef->
options().size() )
458 QVariantList resultList;
459 QVariant val = value;
462 else if ( val.type() == QVariant::List )
464 const auto constToList = val.toList();
465 for (
const QVariant &var : constToList )
468 else if ( val.type() == QVariant::String )
470 const auto constSplit = val.toString().split(
',' );
471 for (
const QString &var : constSplit )
477 if ( resultList.isEmpty() )
478 return QList< int >();
480 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
484 if ( definition->
defaultValue().type() == QVariant::List )
486 const auto constToList = definition->
defaultValue().toList();
487 for (
const QVariant &var : constToList )
490 else if ( definition->
defaultValue().type() == QVariant::String )
492 const auto constSplit = definition->
defaultValue().toString().split(
',' );
493 for (
const QString &var : constSplit )
502 const auto constResultList = resultList;
503 for (
const QVariant &var : constResultList )
505 int resInt = var.toInt();
506 if ( !enumDef || resInt < enumDef->options().size() )
537 QVariant val = value;
540 else if ( val.isValid() )
553 QVariant val = value;
556 else if ( val.isValid() )
564 QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags )
569 val = parameters.value( definition->
name() );
572 return parameterAsSink( definition, val, fields, geometryType,
crs, context, destinationIdentifier, sinkFlags );
577 QVariant val = value;
581 QVariantMap createOptions;
583 bool useRemapDefinition =
false;
595 useRemapDefinition =
true;
605 else if ( !val.isValid() || val.toString().isEmpty() )
621 dest = val.toString();
626 dest = destParam->generateTemporaryDestination();
629 if ( dest.isEmpty() )
632 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType,
crs, createOptions, sinkFlags, useRemapDefinition ? &remapDefinition :
nullptr ) );
633 destinationIdentifier = dest;
635 if ( destinationProject )
637 if ( destName.isEmpty() && definition )
643 outputName = definition->
name();
647 return sink.release();
671 QVariant val = parameters.value( definition->
name() );
673 bool selectedFeaturesOnly =
false;
674 long long featureLimit = -1;
696 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
705 else if ( !val.isValid() || val.toString().isEmpty() )
711 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
717 layerRef = val.toString();
722 if ( layerRef.isEmpty() )
734 compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit );
737 compatibleFormats, preferredFormat, context, feedback, featureLimit );
747 QString *destLayer = layerName;
763 return parameterAsLayer( definition, parameters.value( definition->
name() ), context, layerHint );
771 QVariant val = value;
777 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
794 if ( !val.isValid() || val.toString().isEmpty() )
800 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
805 QString layerRef = val.toString();
806 if ( layerRef.isEmpty() )
809 if ( layerRef.isEmpty() )
840 val = parameters.value( definition->
name() );
847 QVariant val = value;
865 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
872 dest = val.toString();
877 dest = destParam->generateTemporaryDestination();
880 if ( destinationProject )
883 if ( destName.isEmpty() && definition )
888 outputName = definition->
name();
907 val = parameters.value( definition->
name() );
914 QVariant val = value;
928 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
935 dest = val.toString();
940 dest = destParam->generateTemporaryDestination();
985 QVariant val = value;
1034 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1040 rectText = val.toString();
1042 if ( rectText.isEmpty() && !layer )
1045 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1046 QRegularExpressionMatch match = rx.match( rectText );
1047 if ( match.hasMatch() )
1049 bool xMinOk =
false;
1050 double xMin = match.captured( 1 ).toDouble( &xMinOk );
1051 bool xMaxOk =
false;
1052 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1053 bool yMinOk =
false;
1054 double yMin = match.captured( 3 ).toDouble( &yMinOk );
1055 bool yMaxOk =
false;
1056 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1057 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1106 QVariant val = parameters.value( definition->
name() );
1114 g = g.densifyByCount( 20 );
1150 rectText = val.toString();
1152 if ( !rectText.isEmpty() )
1154 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1155 QRegularExpressionMatch match = rx.match( rectText );
1156 if ( match.hasMatch() )
1158 bool xMinOk =
false;
1159 double xMin = match.captured( 1 ).toDouble( &xMinOk );
1160 bool xMaxOk =
false;
1161 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1162 bool yMinOk =
false;
1163 double yMin = match.captured( 3 ).toDouble( &yMinOk );
1164 bool yMaxOk =
false;
1165 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1166 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1192 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1221 QVariant val = parameters.value( definition->
name() );
1227 QVariant val = value;
1255 QString valueAsString;
1259 valueAsString = val.toString();
1261 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1263 QRegularExpressionMatch match = rx.match( valueAsString );
1264 if ( match.hasMatch() )
1290 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1291 return layer->crs();
1293 return layer->crs();
1314 QVariant val = value;
1344 if ( pointText.isEmpty() )
1347 if ( pointText.isEmpty() )
1350 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1353 QRegularExpressionMatch match = rx.match( valueAsString );
1354 if ( match.hasMatch() )
1357 double x = match.captured( 1 ).toDouble( &xOk );
1359 double y = match.captured( 2 ).toDouble( &yOk );
1387 QVariant val = parameters.value( definition->
name() );
1402 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1405 QRegularExpressionMatch match = rx.match( valueAsString );
1406 if ( match.hasMatch() )
1425 if ( fileText.isEmpty() )
1436 if ( fileText.isEmpty() )
1444 return QVariantList();
1452 return QVariantList();
1454 QString resultString;
1455 QVariant val = value;
1458 else if ( val.type() == QVariant::List )
1459 return val.toList();
1461 resultString = val.toString();
1463 if ( resultString.isEmpty() )
1466 if ( definition->
defaultValue().type() == QVariant::List )
1472 QVariantList result;
1473 const auto constSplit = resultString.split(
',' );
1474 for (
const QString &s : constSplit )
1483 return QList<QgsMapLayer *>();
1491 return QList<QgsMapLayer *>();
1493 QVariant val = value;
1494 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1496 return QList<QgsMapLayer *>() << layer;
1499 QList<QgsMapLayer *> layers;
1501 std::function< void(
const QVariant &var ) > processVariant;
1502 processVariant = [ &layers, &context, &definition, &processVariant ](
const QVariant & var )
1504 if ( var.type() == QVariant::List )
1506 const auto constToList = var.toList();
1507 for (
const QVariant &listVar : constToList )
1509 processVariant( listVar );
1512 else if ( var.type() == QVariant::StringList )
1514 const auto constToStringList = var.toStringList();
1515 for (
const QString &s : constToStringList )
1517 processVariant( s );
1521 processVariant( var.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1526 QVariant sink = fromVar.
sink;
1529 processVariant( sink.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1532 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1544 processVariant( val );
1546 if ( layers.isEmpty() )
1549 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->defaultValue() ) ) )
1553 else if ( definition->defaultValue().type() == QVariant::List )
1555 const auto constToList = definition->defaultValue().toList();
1556 for (
const QVariant &var : constToList )
1558 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1564 processVariant( var );
1569 processVariant( definition->defaultValue() );
1578 return QStringList();
1580 QVariant val = value;
1584 std::function< void(
const QVariant &var ) > processVariant;
1585 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1587 if ( var.type() == QVariant::List )
1589 const auto constToList = var.toList();
1590 for (
const QVariant &listVar : constToList )
1592 processVariant( listVar );
1595 else if ( var.type() == QVariant::StringList )
1597 const auto constToStringList = var.toStringList();
1598 for (
const QString &s : constToStringList )
1600 processVariant( s );
1604 processVariant( var.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1607 files << var.toString();
1611 processVariant( val );
1613 if ( files.isEmpty() )
1615 processVariant( definition->defaultValue() );
1624 return QStringList();
1632 return QList<double>();
1640 return QList<double>();
1642 QStringList resultStringList;
1643 QVariant val = value;
1647 else if ( val.type() == QVariant::List )
1649 const auto constToList = val.toList();
1650 for (
const QVariant &var : constToList )
1651 resultStringList << var.toString();
1654 resultStringList << val.toString();
1656 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1658 resultStringList.clear();
1660 if ( definition->
defaultValue().type() == QVariant::List )
1662 const auto constToList = definition->
defaultValue().toList();
1663 for (
const QVariant &var : constToList )
1664 resultStringList << var.toString();
1667 resultStringList << definition->
defaultValue().toString();
1670 if ( resultStringList.size() == 1 )
1672 resultStringList = resultStringList.at( 0 ).split(
',' );
1675 if ( resultStringList.size() < 2 )
1676 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1678 QList< double > result;
1680 double n = resultStringList.at( 0 ).toDouble( &ok );
1684 result << std::numeric_limits<double>::quiet_NaN() ;
1686 n = resultStringList.at( 1 ).toDouble( &ok );
1690 result << std::numeric_limits<double>::quiet_NaN() ;
1698 return QStringList();
1700 QStringList resultStringList;
1707 return QStringList();
1709 QStringList resultStringList;
1710 QVariant val = value;
1711 if ( val.isValid() )
1715 else if ( val.type() == QVariant::List )
1717 const auto constToList = val.toList();
1718 for (
const QVariant &var : constToList )
1719 resultStringList << var.toString();
1721 else if ( val.type() == QVariant::StringList )
1723 resultStringList = val.toStringList();
1726 resultStringList.append( val.toString().split(
';' ) );
1729 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
1731 resultStringList.clear();
1735 if ( definition->
defaultValue().type() == QVariant::List )
1737 const auto constToList = definition->
defaultValue().toList();
1738 for (
const QVariant &var : constToList )
1739 resultStringList << var.toString();
1741 else if ( definition->
defaultValue().type() == QVariant::StringList )
1743 resultStringList = definition->
defaultValue().toStringList();
1746 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
1750 return resultStringList;
1764 if ( layoutName.isEmpty() )
1816 QVariant val = value;
1821 if ( val.type() == QVariant::Color )
1823 QColor
c = val.value< QColor >();
1825 if ( !colorParam->opacityEnabled() )
1833 if ( definition->
defaultValue().type() == QVariant::Color )
1839 if ( colorText.isEmpty() )
1842 bool containsAlpha =
false;
1845 if (
c.isValid() && !colorParam->opacityEnabled() )
1897 QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
1898 QString name = map.value( QStringLiteral(
"name" ) ).toString();
1899 std::unique_ptr< QgsProcessingParameterDefinition > def;
1966 def.reset( paramType->
create( name ) );
1972 def->fromVariantMap( map );
1973 return def.release();
1978 QString desc = name;
1979 desc.replace(
'_',
' ' );
1985 bool isOptional =
false;
1989 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
1994 if ( type == QStringLiteral(
"boolean" ) )
1996 else if ( type == QStringLiteral(
"crs" ) )
1998 else if ( type == QStringLiteral(
"layer" ) )
2000 else if ( type == QStringLiteral(
"extent" ) )
2002 else if ( type == QStringLiteral(
"point" ) )
2004 else if ( type == QStringLiteral(
"file" ) )
2006 else if ( type == QStringLiteral(
"folder" ) )
2008 else if ( type == QStringLiteral(
"matrix" ) )
2010 else if ( type == QStringLiteral(
"multiple" ) )
2012 else if ( type == QStringLiteral(
"number" ) )
2014 else if ( type == QStringLiteral(
"distance" ) )
2016 else if ( type == QStringLiteral(
"scale" ) )
2018 else if ( type == QStringLiteral(
"range" ) )
2020 else if ( type == QStringLiteral(
"raster" ) )
2022 else if ( type == QStringLiteral(
"enum" ) )
2024 else if ( type == QStringLiteral(
"string" ) )
2026 else if ( type == QStringLiteral(
"authcfg" ) )
2028 else if ( type == QStringLiteral(
"expression" ) )
2030 else if ( type == QStringLiteral(
"field" ) )
2032 else if ( type == QStringLiteral(
"vector" ) )
2034 else if ( type == QStringLiteral(
"source" ) )
2036 else if ( type == QStringLiteral(
"sink" ) )
2038 else if ( type == QStringLiteral(
"vectordestination" ) )
2040 else if ( type == QStringLiteral(
"rasterdestination" ) )
2042 else if ( type == QStringLiteral(
"filedestination" ) )
2044 else if ( type == QStringLiteral(
"folderdestination" ) )
2046 else if ( type == QStringLiteral(
"band" ) )
2048 else if ( type == QStringLiteral(
"mesh" ) )
2050 else if ( type == QStringLiteral(
"layout" ) )
2052 else if ( type == QStringLiteral(
"layoutitem" ) )
2054 else if ( type == QStringLiteral(
"color" ) )
2056 else if ( type == QStringLiteral(
"coordinateoperation" ) )
2058 else if ( type == QStringLiteral(
"maptheme" ) )
2060 else if ( type == QStringLiteral(
"datetime" ) )
2062 else if ( type == QStringLiteral(
"providerconnection" ) )
2064 else if ( type == QStringLiteral(
"databaseschema" ) )
2066 else if ( type == QStringLiteral(
"databasetable" ) )
2072 bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2074 QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
2075 QRegularExpressionMatch m = re.match( code );
2076 if ( !m.hasMatch() )
2079 name = m.captured( 1 );
2080 QString tokens = m.captured( 2 );
2081 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
2084 tokens.remove( 0, 8 );
2091 tokens = tokens.trimmed();
2093 QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2094 m = re2.match( tokens );
2095 if ( !m.hasMatch() )
2097 type = tokens.toLower().trimmed();
2102 type = m.captured( 1 ).toLower().trimmed();
2103 definition = m.captured( 2 );
2114 , mDescription( description )
2115 , mDefault( defaultValue )
2116 , mFlags( optional ? FlagOptional : 0 )
2121 if ( !input.isValid() && !
mDefault.isValid() )
2124 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
2125 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
2133 if ( !value.isValid() )
2134 return QStringLiteral(
"None" );
2137 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2144 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2146 code += QStringLiteral(
"optional " );
2147 code +=
type() +
' ';
2149 return code.trimmed();
2157 switch ( outputType )
2161 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
2163 code += QStringLiteral(
", optional=True" );
2179 map.insert( QStringLiteral(
"parameter_type" ),
type() );
2180 map.insert( QStringLiteral(
"name" ),
mName );
2181 map.insert( QStringLiteral(
"description" ),
mDescription );
2182 map.insert( QStringLiteral(
"default" ),
mDefault );
2183 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
mFlags ) );
2184 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
2190 mName = map.value( QStringLiteral(
"name" ) ).toString();
2191 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
2192 mDefault = map.value( QStringLiteral(
"default" ) );
2193 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
2194 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
2210 return QStringLiteral(
"<p><b>%1</b></p><p>%2</p>" ).arg(
2212 QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
2226 if ( !val.isValid() )
2227 return QStringLiteral(
"None" );
2231 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
2236 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2238 code += QStringLiteral(
"optional " );
2239 code +=
type() +
' ';
2240 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
2241 return code.trimmed();
2262 if ( !input.isValid() )
2284 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2287 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2295 if ( !value.isValid() )
2296 return QStringLiteral(
"None" );
2301 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
2307 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2310 p.insert(
name(), value );
2337 if ( !input.isValid() )
2345 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2350 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2368 if ( !val.isValid() )
2369 return QStringLiteral(
"None" );
2375 p.insert(
name(), val );
2385 for (
const QString &raster : rasters )
2387 if ( !vectors.contains( raster ) )
2391 for (
const QString &mesh : meshFilters )
2393 if ( !vectors.contains( mesh ) )
2396 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
2397 std::sort( vectors.begin(), vectors.end() );
2399 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QStringLiteral(
";;" ) );
2409 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2411 code += QStringLiteral(
"optional " );
2412 code += QStringLiteral(
"layer " );
2419 code += QStringLiteral(
"hasgeometry " );
2423 code += QStringLiteral(
"point " );
2427 code += QStringLiteral(
"line " );
2431 code += QStringLiteral(
"polygon " );
2435 code += QStringLiteral(
"raster " );
2439 code += QStringLiteral(
"mesh " );
2445 return code.trimmed();
2451 QString def = definition;
2454 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
2457 def = def.mid( 12 );
2460 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
2466 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
2472 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
2478 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
2484 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
2498 switch ( outputType )
2502 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', '%2'" ).arg(
name(),
description() );
2504 code += QStringLiteral(
", optional=True" );
2511 QStringList options;
2515 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
2519 code += QStringLiteral(
")" );
2536 map.insert( QStringLiteral(
"data_types" ), types );
2544 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
2545 for (
const QVariant &val : values )
2565 if ( !input.isValid() )
2598 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2601 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2610 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
2611 QRegularExpressionMatch match = rx.match( input.toString() );
2612 if ( match.hasMatch() )
2614 bool xMinOk =
false;
2615 ( void )match.captured( 1 ).toDouble( &xMinOk );
2616 bool xMaxOk =
false;
2617 ( void )match.captured( 2 ).toDouble( &xMaxOk );
2618 bool yMinOk =
false;
2619 ( void )match.captured( 3 ).toDouble( &yMinOk );
2620 bool yMaxOk =
false;
2621 ( void )match.captured( 4 ).toDouble( &yMaxOk );
2622 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
2632 if ( !value.isValid() )
2633 return QStringLiteral(
"None" );
2636 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2659 const QString wkt = g.
asWkt();
2660 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
2665 p.insert(
name(), value );
2691 if ( !input.isValid() )
2712 if ( input.type() == QVariant::String )
2714 if ( input.toString().isEmpty() )
2718 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
2720 QRegularExpressionMatch match = rx.match( input.toString() );
2721 if ( match.hasMatch() )
2724 ( void )match.captured( 1 ).toDouble( &xOk );
2726 ( void )match.captured( 2 ).toDouble( &yOk );
2735 if ( !value.isValid() )
2736 return QStringLiteral(
"None" );
2739 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2759 const QString wkt = g.
asWkt();
2760 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
2774 , mBehavior( behavior )
2775 , mExtension( fileFilter.isEmpty() ? extension : QString() )
2776 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
2788 if ( !input.isValid() )
2796 QString
string = input.toString().trimmed();
2798 if ( input.type() != QVariant::String ||
string.isEmpty() )
2801 switch ( mBehavior )
2805 if ( !mExtension.isEmpty() )
2807 return string.endsWith( mExtension, Qt::CaseInsensitive );
2809 else if ( !mFileFilter.isEmpty() )
2812 return test == string;
2828 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2830 code += QStringLiteral(
"optional " );
2831 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
2833 return code.trimmed();
2838 switch ( outputType )
2843 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', '%2'" ).arg(
name(),
description() );
2845 code += QStringLiteral(
", optional=True" );
2846 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
2847 if ( !mExtension.isEmpty() )
2848 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
2849 if ( !mFileFilter.isEmpty() )
2850 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
2862 mFileFilter.clear();
2872 mFileFilter = filter;
2879 map.insert( QStringLiteral(
"behavior" ), mBehavior );
2880 map.insert( QStringLiteral(
"extension" ), mExtension );
2881 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
2888 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
2889 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
2890 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
2901 , mHeaders( headers )
2902 , mNumberRows( numberRows )
2903 , mFixedNumberRows( fixedNumberRows )
2915 if ( !input.isValid() )
2918 if ( input.type() == QVariant::String )
2920 if ( input.toString().isEmpty() )
2924 else if ( input.type() == QVariant::List )
2926 if ( input.toList().isEmpty() )
2930 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
2940 if ( !value.isValid() )
2941 return QStringLiteral(
"None" );
2944 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2947 p.insert(
name(), value );
2951 const auto constList = list;
2952 for (
const QVariant &v : constList )
2954 if ( v.type() == QVariant::List )
2957 const auto constToList = v.toList();
2958 for (
const QVariant &v2 : constToList )
2960 if ( v2.isNull() || !v2.isValid() )
2961 parts2 << QStringLiteral(
"None" );
2962 else if ( v2.toString().isEmpty() )
2963 parts2 << QStringLiteral(
"''" );
2965 parts2 << v2.toString();
2967 parts << parts2.join(
',' ).prepend(
'[' ).append(
']' );
2971 if ( v.isNull() || !v.isValid() )
2972 parts << QStringLiteral(
"None" );
2973 else if ( v.toString().isEmpty() )
2974 parts << QStringLiteral(
"''" );
2976 parts << v.toString();
2980 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2985 switch ( outputType )
2989 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', '%2'" ).arg(
name(),
description() );
2991 code += QStringLiteral(
", optional=True" );
2992 code += QStringLiteral(
", numberRows=" ).arg( mNumberRows );
2993 code += QStringLiteral(
", hasFixedNumberRows=" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
2996 headers.reserve( mHeaders.size() );
2997 for (
const QString &h : mHeaders )
2999 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
3031 return mFixedNumberRows;
3036 mFixedNumberRows = fixedNumberRows;
3042 map.insert( QStringLiteral(
"headers" ), mHeaders );
3043 map.insert( QStringLiteral(
"rows" ), mNumberRows );
3044 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
3051 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
3052 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
3053 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
3064 , mLayerType( layerType )
3076 if ( !input.isValid() )
3081 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3087 if ( input.type() == QVariant::String )
3089 if ( input.toString().isEmpty() )
3092 if ( mMinimumNumberInputs > 1 )
3103 else if ( input.type() == QVariant::List )
3105 if ( input.toList().count() < mMinimumNumberInputs )
3108 if ( mMinimumNumberInputs > input.toList().count() )
3116 const auto constToList = input.toList();
3117 for (
const QVariant &v : constToList )
3119 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
3128 else if ( input.type() == QVariant::StringList )
3130 if ( input.toStringList().count() < mMinimumNumberInputs )
3133 if ( mMinimumNumberInputs > input.toStringList().count() )
3141 const auto constToStringList = input.toStringList();
3142 for (
const QString &v : constToStringList )
3155 if ( !value.isValid() )
3156 return QStringLiteral(
"None" );
3159 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3164 if ( value.type() == QVariant::StringList )
3166 const QStringList list = value.toStringList();
3167 parts.reserve( list.count() );
3168 for (
const QString &v : list )
3171 else if ( value.type() == QVariant::List )
3173 const QVariantList list = value.toList();
3174 parts.reserve( list.count() );
3175 for (
const QVariant &v : list )
3178 if ( !parts.isEmpty() )
3179 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3184 p.insert(
name(), value );
3186 if ( !list.isEmpty() )
3189 parts.reserve( list.count() );
3194 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3203 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3205 code += QStringLiteral(
"optional " );
3206 switch ( mLayerType )
3209 code += QStringLiteral(
"multiple raster" );
3213 code += QStringLiteral(
"multiple file" );
3217 code += QStringLiteral(
"multiple vector" );
3221 if (
mDefault.type() == QVariant::List )
3224 const auto constToList =
mDefault.toList();
3225 for (
const QVariant &var : constToList )
3227 parts << var.toString();
3229 code += parts.join(
',' );
3231 else if (
mDefault.type() == QVariant::StringList )
3233 code +=
mDefault.toStringList().join(
',' );
3239 return code.trimmed();
3244 switch ( outputType )
3248 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', '%2'" ).arg(
name(),
description() );
3250 code += QStringLiteral(
", optional=True" );
3254 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
3266 switch ( mLayerType )
3269 return QObject::tr(
"All files (*.*)" );
3302 return mMinimumNumberInputs;
3314 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
3315 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
3323 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
3329 QString
type = definition;
3331 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
3332 QRegularExpressionMatch m = re.match( definition );
3335 type = m.captured( 1 ).toLower().trimmed();
3336 defaultVal = m.captured( 2 );
3339 if (
type == QStringLiteral(
"vector" ) )
3341 else if (
type == QStringLiteral(
"raster" ) )
3343 else if (
type == QStringLiteral(
"file" ) )
3356 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
3367 QVariant input = value;
3368 if ( !input.isValid() )
3382 double res = input.toDouble( &ok );
3386 return !( res < mMin || res > mMax );
3391 if ( !value.isValid() )
3392 return QStringLiteral(
"None" );
3395 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3397 return value.toString();
3404 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
3405 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
3406 if ( mMax < std::numeric_limits<double>::max() )
3407 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
3409 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
3410 QString extra = parts.join( QStringLiteral(
"<br />" ) );
3411 if ( !extra.isEmpty() )
3412 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
3418 switch ( outputType )
3422 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', '%2'" ).arg(
name(),
description() );
3424 code += QStringLiteral(
", optional=True" );
3426 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
3428 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
3429 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
3430 if ( mMax != std::numeric_limits<double>::max() )
3431 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
3473 map.insert( QStringLiteral(
"min" ), mMin );
3474 map.insert( QStringLiteral(
"max" ), mMax );
3475 map.insert( QStringLiteral(
"data_type" ), mDataType );
3482 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
3483 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
3484 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
3491 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
3508 if ( !input.isValid() )
3516 if ( input.type() == QVariant::String )
3518 QStringList list = input.toString().split(
',' );
3519 if ( list.count() != 2 )
3522 list.at( 0 ).toDouble( &ok );
3524 list.at( 1 ).toDouble( &ok2 );
3529 else if ( input.type() == QVariant::List )
3531 if ( input.toList().count() != 2 )
3535 input.toList().at( 0 ).toDouble( &ok );
3537 input.toList().at( 1 ).toDouble( &ok2 );
3548 if ( !value.isValid() )
3549 return QStringLiteral(
"None" );
3552 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3555 p.insert(
name(), value );
3558 QStringList stringParts;
3559 const auto constParts = parts;
3560 for (
double v : constParts )
3562 stringParts << QString::number( v );
3564 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
3569 switch ( outputType )
3573 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', '%2'" ).arg(
name(),
description() );
3575 code += QStringLiteral(
", optional=True" );
3577 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
QgsProcessingParameterNumber::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
3600 map.insert( QStringLiteral(
"data_type" ), mDataType );
3614 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
3630 if ( !input.isValid() )
3638 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
3641 if ( input.type() != QVariant::String || input.toString().isEmpty() )
3659 if ( !val.isValid() )
3660 return QStringLiteral(
"None" );
3666 p.insert(
name(), val );
3684 , mOptions( options )
3685 , mAllowMultiple( allowMultiple )
3697 QVariant input = value;
3698 if ( !input.isValid() )
3711 if ( input.type() == QVariant::List )
3713 if ( !mAllowMultiple )
3716 const QVariantList values = input.toList();
3720 for (
const QVariant &val : values )
3723 int res = val.toInt( &ok );
3726 else if ( res < 0 || res >= mOptions.count() )
3732 else if ( input.type() == QVariant::String )
3734 QStringList parts = input.toString().split(
',' );
3735 if ( parts.count() > 1 && !mAllowMultiple )
3738 const auto constParts = parts;
3739 for (
const QString &part : constParts )
3742 int res = part.toInt( &ok );
3745 else if ( res < 0 || res >= mOptions.count() )
3750 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
3753 int res = input.toInt( &ok );
3756 else if ( res >= 0 && res < mOptions.count() )
3764 if ( !value.isValid() )
3765 return QStringLiteral(
"None" );
3768 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3770 if ( value.type() == QVariant::List )
3773 const auto constToList = value.toList();
3774 for (
const QVariant &val : constToList )
3776 parts << QString::number( static_cast< int >( val.toDouble() ) );
3778 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3780 else if ( value.type() == QVariant::String )
3782 QStringList parts = value.toString().split(
',' );
3783 if ( parts.count() > 1 )
3785 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3789 return QString::number(
static_cast< int >( value.toDouble() ) );
3794 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3796 code += QStringLiteral(
"optional " );
3797 code += QStringLiteral(
"enum " );
3799 if ( mAllowMultiple )
3800 code += QStringLiteral(
"multiple " );
3802 code += mOptions.join(
';' ) +
' ';
3805 return code.trimmed();
3810 switch ( outputType )
3814 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', '%2'" ).arg(
name(),
description() );
3816 code += QStringLiteral(
", optional=True" );
3819 options.reserve( mOptions.size() );
3820 for (
const QString &o : mOptions )
3822 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
3824 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
3846 return mAllowMultiple;
3857 map.insert( QStringLiteral(
"options" ), mOptions );
3858 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
3865 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
3866 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
3873 bool multiple =
false;
3874 QString def = definition;
3875 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
3881 QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
3882 QRegularExpressionMatch m = re.match( def );
3883 QString values = def;
3886 values = m.captured( 1 ).trimmed();
3887 defaultVal = m.captured( 2 );
3895 , mMultiLine( multiLine )
3907 if ( !value.isValid() || value.isNull() )
3908 return QStringLiteral(
"None" );
3911 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3913 QString s = value.toString();
3919 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3921 code += QStringLiteral(
"optional " );
3922 code += QStringLiteral(
"string " );
3925 code += QStringLiteral(
"long " );
3928 return code.trimmed();
3933 switch ( outputType )
3937 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', '%2'" ).arg(
name(),
description() );
3939 code += QStringLiteral(
", optional=True" );
3940 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
3963 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
3970 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
3976 QString def = definition;
3978 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
3984 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
3986 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
3990 if ( def == QStringLiteral(
"None" ) )
4013 if ( !value.isValid() )
4014 return QStringLiteral(
"None" );
4016 QString s = value.toString();
4022 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4024 code += QStringLiteral(
"optional " );
4025 code += QStringLiteral(
"authcfg " );
4028 return code.trimmed();
4033 QString def = definition;
4035 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
4037 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
4041 if ( def == QStringLiteral(
"None" ) )
4054 , mParentLayerParameterName( parentLayerParameterName )
4066 if ( !value.isValid() )
4067 return QStringLiteral(
"None" );
4070 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4072 QString s = value.toString();
4078 QStringList depends;
4079 if ( !mParentLayerParameterName.isEmpty() )
4080 depends << mParentLayerParameterName;
4086 switch ( outputType )
4090 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', '%2'" ).arg(
name(),
description() );
4092 code += QStringLiteral(
", optional=True" );
4094 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
4106 return mParentLayerParameterName;
4117 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
4124 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
4165 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
4168 if ( var.type() != QVariant::String || var.toString().isEmpty() )
4186 if ( !val.isValid() )
4187 return QStringLiteral(
"None" );
4193 p.insert(
name(), val );
4201 switch ( outputType )
4205 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', '%2'" ).arg(
name(),
description() );
4207 code += QStringLiteral(
", optional=True" );
4211 QStringList options;
4214 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
4248 map.insert( QStringLiteral(
"data_types" ), types );
4256 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
4257 for (
const QVariant &val : values )
4270 const QString &description,
4271 const QVariant &defaultValue,
4303 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
4306 if ( var.type() != QVariant::String || var.toString().isEmpty() )
4324 if ( !val.isValid() )
4325 return QStringLiteral(
"None" );
4331 p.insert(
name(), val );
4349 , mParentLayerParameterName( parentLayerParameterName )
4351 , mAllowMultiple( allowMultiple )
4352 , mDefaultToAllFields( defaultToAllFields )
4365 if ( !input.isValid() )
4373 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
4375 if ( !mAllowMultiple )
4381 else if ( input.type() == QVariant::String )
4383 if ( input.toString().isEmpty() )
4386 QStringList parts = input.toString().split(
';' );
4387 if ( parts.count() > 1 && !mAllowMultiple )
4392 if ( input.toString().isEmpty() )
4400 if ( !value.isValid() )
4401 return QStringLiteral(
"None" );
4404 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4406 if ( value.type() == QVariant::List )
4409 const auto constToList = value.toList();
4410 for (
const QVariant &val : constToList )
4414 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4416 else if ( value.type() == QVariant::StringList )
4419 const auto constToStringList = value.toStringList();
4420 for ( QString s : constToStringList )
4424 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4432 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4434 code += QStringLiteral(
"optional " );
4435 code += QStringLiteral(
"field " );
4437 switch ( mDataType )
4440 code += QStringLiteral(
"numeric " );
4444 code += QStringLiteral(
"string " );
4448 code += QStringLiteral(
"datetime " );
4455 if ( mAllowMultiple )
4456 code += QStringLiteral(
"multiple " );
4458 if ( mDefaultToAllFields )
4459 code += QStringLiteral(
"default_to_all_fields " );
4461 code += mParentLayerParameterName +
' ';
4464 return code.trimmed();
4469 switch ( outputType )
4473 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', '%2'" ).arg(
name(),
description() );
4475 code += QStringLiteral(
", optional=True" );
4478 switch ( mDataType )
4481 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
4485 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
4489 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
4493 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
4496 code += QStringLiteral(
", type=%1" ).arg(
dataType );
4498 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
4499 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4503 if ( mDefaultToAllFields )
4504 code += QStringLiteral(
", defaultToAllFields=True" );
4516 QStringList depends;
4517 if ( !mParentLayerParameterName.isEmpty() )
4518 depends << mParentLayerParameterName;
4524 return mParentLayerParameterName;
4544 return mAllowMultiple;
4554 return mDefaultToAllFields;
4559 mDefaultToAllFields = enabled;
4565 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
4566 map.insert( QStringLiteral(
"data_type" ), mDataType );
4567 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
4568 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
4575 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
4576 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
4577 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
4578 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
4588 QString def = definition;
4590 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
4595 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
4600 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
4606 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
4609 def = def.mid( 8 ).trimmed();
4612 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
4615 def = def.mid( 21 ).trimmed();
4618 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
4619 QRegularExpressionMatch m = re.match( def );
4622 parent = m.captured( 1 ).trimmed();
4623 def = m.captured( 2 );
4648 QVariant var = input;
4649 if ( !var.isValid() )
4676 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
4681 if ( var.type() != QVariant::String || var.toString().isEmpty() )
4699 if ( !value.isValid() )
4700 return QStringLiteral(
"None" );
4703 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4708 QString geometryCheckString;
4712 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
4716 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
4720 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
4726 if ( fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagOverrideDefaultGeometryCheck )
4727 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
4728 if ( fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagCreateIndividualOutputPerInputFeature )
4729 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
4730 if ( !
flags.empty() )
4731 flagString =
flags.join( QStringLiteral(
" | " ) );
4738 layerString = layer->source();
4742 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition('%1', selectedFeaturesOnly=%2, featureLimit=%3%4, geometryCheck=%5)" ).arg( layerString,
4745 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
4746 geometryCheckString );
4757 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression('%1'), selectedFeaturesOnly=%2, featureLimit=%3%4, geometryCheck=%5)" )
4761 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
4762 geometryCheckString );
4766 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
source.
asExpression() );
4770 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
4775 QString layerString = value.toString();
4779 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
4786 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4788 code += QStringLiteral(
"optional " );
4789 code += QStringLiteral(
"source " );
4796 code += QStringLiteral(
"point " );
4800 code += QStringLiteral(
"line " );
4804 code += QStringLiteral(
"polygon " );
4811 return code.trimmed();
4816 switch ( outputType )
4820 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', '%2'" ).arg(
name(),
description() );
4822 code += QStringLiteral(
", optional=True" );
4826 QStringList options;
4830 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
4847 : mDataTypes( types )
4860 map.insert( QStringLiteral(
"data_types" ), types );
4868 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
4869 for (
const QVariant &val : values )
4879 QString def = definition;
4882 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
4888 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
4894 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
4909 , mSupportsAppend( supportsAppend )
4920 QVariant var = input;
4921 if ( !var.isValid() )
4943 if ( var.type() != QVariant::String )
4946 if ( var.toString().isEmpty() )
4954 if ( !value.isValid() )
4955 return QStringLiteral(
"None" );
4958 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4969 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4978 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4980 code += QStringLiteral(
"optional " );
4981 code += QStringLiteral(
"sink " );
4983 switch ( mDataType )
4986 code += QStringLiteral(
"point " );
4990 code += QStringLiteral(
"line " );
4994 code += QStringLiteral(
"polygon " );
4998 code += QStringLiteral(
"table " );
5006 return code.trimmed();
5022 return p->defaultVectorFileExtension(
hasGeometry() );
5032 return QStringLiteral(
"dbf" );
5039 switch ( outputType )
5043 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', '%2'" ).arg(
name(),
description() );
5045 code += QStringLiteral(
", optional=True" );
5049 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5050 if ( mSupportsAppend )
5051 code += QStringLiteral(
", supportsAppend=True" );
5064 QStringList filters;
5065 for (
const QString &ext : exts )
5067 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
5069 return filters.join( QStringLiteral(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
5085 return p->supportedOutputVectorLayerExtensions();
5087 return p->supportedOutputTableExtensions();
5102 switch ( mDataType )
5128 map.insert( QStringLiteral(
"data_type" ), mDataType );
5129 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
5137 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
5144 return QStringLiteral(
"memory:%1" ).arg(
description() );
5152 QString def = definition;
5153 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
5158 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
5163 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
5168 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
5179 return mSupportsAppend;
5199 QVariant var = input;
5200 if ( !var.isValid() )
5222 if ( var.type() != QVariant::String )
5225 if ( var.toString().isEmpty() )
5233 if ( !value.isValid() )
5234 return QStringLiteral(
"None" );
5237 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5248 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
5268 return p->defaultRasterFileExtension();
5279 QStringList filters;
5280 for (
const QString &ext : exts )
5282 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
5284 return filters.join( QStringLiteral(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
5295 return p->supportedOutputRasterLayerExtensions();
5311 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
5323 QVariant var = input;
5324 if ( !var.isValid() )
5346 if ( var.type() != QVariant::String )
5349 if ( var.toString().isEmpty() )
5359 if ( !value.isValid() )
5360 return QStringLiteral(
"None" );
5363 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5374 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
5383 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
5395 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
5396 return QStringLiteral(
"file" );
5399 QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
5400 QRegularExpressionMatch match = rx.match( mFileFilter );
5401 if ( !match.hasMatch() )
5402 return QStringLiteral(
"file" );
5404 return match.captured( 1 );
5409 switch ( outputType )
5413 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', '%2'" ).arg(
name(),
description() );
5415 code += QStringLiteral(
", optional=True" );
5419 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5431 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
5447 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
5454 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
5475 QVariant var = input;
5476 if ( !var.isValid() )
5492 if ( var.type() != QVariant::String )
5495 if ( var.toString().isEmpty() )
5518 , mCreateByDefault( createByDefault )
5526 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
5527 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
5534 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
5535 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
5541 switch ( outputType )
5548 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
5550 code += QStringLiteral(
", optional=True" );
5552 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5567 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
5574 QRegularExpression rx( QStringLiteral(
"[.]" ) );
5575 QString sanitizedName =
name();
5576 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
5600 return mCreateByDefault;
5622 QVariant var = input;
5623 if ( !var.isValid() )
5645 if ( var.type() != QVariant::String )
5648 if ( var.toString().isEmpty() )
5656 if ( !value.isValid() )
5657 return QStringLiteral(
"None" );
5660 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5671 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
5680 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5682 code += QStringLiteral(
"optional " );
5683 code += QStringLiteral(
"vectorDestination " );
5685 switch ( mDataType )
5688 code += QStringLiteral(
"point " );
5692 code += QStringLiteral(
"line " );
5696 code += QStringLiteral(
"polygon " );
5704 return code.trimmed();
5720 return p->defaultVectorFileExtension(
hasGeometry() );
5730 return QStringLiteral(
"dbf" );
5737 switch ( outputType )
5741 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', '%2'" ).arg(
name(),
description() );
5743 code += QStringLiteral(
", optional=True" );
5747 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5760 QStringList filters;
5761 for (
const QString &ext : exts )
5763 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
5765 return filters.join( QStringLiteral(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
5780 return p->supportedOutputVectorLayerExtensions();
5782 return p->supportedOutputTableExtensions();
5797 switch ( mDataType )
5823 map.insert( QStringLiteral(
"data_type" ), mDataType );
5837 QString def = definition;
5838 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
5843 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
5848 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
5859 , mParentLayerParameterName( parentLayerParameterName )
5860 , mAllowMultiple( allowMultiple )
5872 if ( !input.isValid() )
5880 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
5882 if ( !mAllowMultiple )
5891 double res = input.toInt( &ok );
5901 return mAllowMultiple;
5911 if ( !value.isValid() )
5912 return QStringLiteral(
"None" );
5915 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5917 if ( value.type() == QVariant::List )
5920 QVariantList values = value.toList();
5921 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
5923 parts << QString::number( static_cast< int >( it->toDouble() ) );
5925 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5927 else if ( value.type() == QVariant::StringList )
5930 QStringList values = value.toStringList();
5931 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
5933 parts << QString::number( static_cast< int >( it->toDouble() ) );
5935 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5938 return value.toString();
5943 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5945 code += QStringLiteral(
"optional " );
5946 code += QStringLiteral(
"band " );
5948 if ( mAllowMultiple )
5949 code += QStringLiteral(
"multiple " );
5951 code += mParentLayerParameterName +
' ';
5954 return code.trimmed();
5959 QStringList depends;
5960 if ( !mParentLayerParameterName.isEmpty() )
5961 depends << mParentLayerParameterName;
5967 switch ( outputType )
5971 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', '%2'" ).arg(
name(),
description() );
5973 code += QStringLiteral(
", optional=True" );
5975 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5976 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5988 return mParentLayerParameterName;
5999 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
6000 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
6007 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
6008 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
6015 QString def = definition;
6018 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
6021 def = def.mid( 8 ).trimmed();
6024 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
6025 QRegularExpressionMatch m = re.match( def );
6028 parent = m.captured( 1 ).trimmed();
6029 def = m.captured( 2 );
6046 , mParentParameterName( parentParameterName )
6063 QStringList depends;
6064 if ( !mParentParameterName.isEmpty() )
6065 depends << mParentParameterName;
6071 switch ( outputType )
6075 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', '%2'" ).arg(
name(),
description() );
6077 code += QStringLiteral(
", optional=True" );
6079 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
6081 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
6082 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
6083 if (
maximum() != std::numeric_limits<double>::max() )
6084 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
6095 return mParentParameterName;
6106 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
6107 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
6114 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
6142 switch ( outputType )
6146 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', '%2'" ).arg(
name(),
description() );
6148 code += QStringLiteral(
", optional=True" );
6160 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
6179 if ( !value.isValid() || value.isNull() )
6180 return QStringLiteral(
"None" );
6183 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6185 QString s = value.toString();
6191 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6193 code += QStringLiteral(
"optional " );
6194 code += QStringLiteral(
"layout " );
6197 return code.trimmed();
6202 switch ( outputType )
6206 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', '%2'" ).arg(
name(),
description() );
6208 code += QStringLiteral(
", optional=True" );
6219 QString def = definition;
6221 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
6223 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
6227 if ( def == QStringLiteral(
"None" ) )
6240 , mParentLayoutParameterName( parentLayoutParameterName )
6241 , mItemType( itemType )
6253 if ( !value.isValid() || value.isNull() )
6254 return QStringLiteral(
"None" );
6257 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6259 QString s = value.toString();
6265 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6267 code += QStringLiteral(
"optional " );
6268 code += QStringLiteral(
"layoutitem " );
6269 if ( mItemType >= 0 )
6270 code += QString::number( mItemType ) +
' ';
6272 code += mParentLayoutParameterName +
' ';
6275 return code.trimmed();
6280 switch ( outputType )
6284 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', '%2'" ).arg(
name(),
description() );
6286 code += QStringLiteral(
", optional=True" );
6288 if ( mItemType >= 0 )
6289 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
6291 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
6304 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
6305 map.insert( QStringLiteral(
"item_type" ), mItemType );
6312 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
6313 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
6319 QStringList depends;
6320 if ( !mParentLayoutParameterName.isEmpty() )
6321 depends << mParentLayoutParameterName;
6328 QString def = definition;
6330 QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
6331 QRegularExpressionMatch m = re.match( def );
6334 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
6335 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
6336 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
6349 return mParentLayoutParameterName;
6354 mParentLayoutParameterName =
name;
6373 , mAllowOpacity( opacityEnabled )
6385 if ( !value.isValid() || value.isNull() )
6386 return QStringLiteral(
"None" );
6389 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6391 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
6392 return QStringLiteral(
"QColor()" );
6394 if ( value.canConvert< QColor >() )
6396 QColor
c = value.value< QColor >();
6397 if ( !mAllowOpacity ||
c.alpha() == 255 )
6398 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
6400 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
6403 QString s = value.toString();
6409 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6411 code += QStringLiteral(
"optional " );
6412 code += QStringLiteral(
"color " );
6414 if ( mAllowOpacity )
6415 code += QStringLiteral(
"withopacity " );
6418 return code.trimmed();
6423 switch ( outputType )
6427 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', '%2'" ).arg(
name(),
description() );
6429 code += QStringLiteral(
", optional=True" );
6431 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6443 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
6446 if ( !input.isValid() )
6449 if ( input.type() == QVariant::Color )
6458 if ( input.type() != QVariant::String || input.toString().isEmpty() )
6461 bool containsAlpha =
false;
6468 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
6475 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
6481 return mAllowOpacity;
6486 mAllowOpacity = enabled;
6491 QString def = definition;
6493 bool allowOpacity =
false;
6494 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
6496 allowOpacity =
true;
6497 def = def.mid( 12 );
6500 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
6502 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
6506 if ( def == QStringLiteral(
"None" ) )
6517 , mSourceParameterName( sourceCrsParameterName )
6518 , mDestParameterName( destinationCrsParameterName )
6519 , mSourceCrs( staticSourceCrs )
6520 , mDestCrs( staticDestinationCrs )
6532 if ( !value.isValid() || value.isNull() )
6533 return QStringLiteral(
"None" );
6538 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
6544 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6547 p.insert(
name(), value );
6552 QString s = value.toString();
6558 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6560 code += QStringLiteral(
"optional " );
6561 code += QStringLiteral(
"coordinateoperation " );
6564 return code.trimmed();
6569 switch ( outputType )
6574 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', '%2'" ).arg(
name(),
description() );
6576 code += QStringLiteral(
", optional=True" );
6577 if ( !mSourceParameterName.isEmpty() )
6578 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg(
valueAsPythonString( mSourceParameterName,
c ) );
6579 if ( !mDestParameterName.isEmpty() )
6580 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg(
valueAsPythonString( mDestParameterName,
c ) );
6582 if ( mSourceCrs.isValid() )
6584 if ( mDestCrs.isValid() )
6585 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg(
valueAsPythonString( mDestCrs,
c ) );
6597 if ( !mSourceParameterName.isEmpty() )
6598 res << mSourceParameterName;
6599 if ( !mDestParameterName.isEmpty() )
6600 res << mDestParameterName;
6607 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
6608 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
6609 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
6610 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
6617 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
6618 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
6619 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
6620 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
6626 QString def = definition;
6628 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
6630 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
6634 if ( def == QStringLiteral(
"None" ) )
6659 if ( !input.isValid() && !
mDefault.isValid() )
6662 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
6663 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
6671 if ( !value.isValid() )
6672 return QStringLiteral(
"None" );
6675 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6682 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6684 code += QStringLiteral(
"optional " );
6685 code += QStringLiteral(
"maptheme " );
6688 return code.trimmed();
6693 switch ( outputType )
6697 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', '%2'" ).arg(
name(),
description() );
6699 code += QStringLiteral(
", optional=True" );
6726 QString def = definition;
6727 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
6729 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
6751 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
6753 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
6764 QVariant input = value;
6765 if ( !input.isValid() )
6778 if ( input.type() != QVariant::DateTime && input.type() != QVariant::Date && input.type() != QVariant::Time && input.type() != QVariant::String )
6781 if ( ( input.type() == QVariant::DateTime || input.type() == QVariant::Date ) && mDataType ==
Time )
6784 if ( input.type() == QVariant::String )
6786 QString s = input.toString();
6790 input = QDateTime::fromString( s, Qt::ISODate );
6791 if ( mDataType ==
Time )
6793 if ( !input.toDateTime().isValid() )
6794 input = QTime::fromString( s );
6796 input = input.toDateTime().time();
6800 if ( mDataType !=
Time )
6802 QDateTime res = input.toDateTime();
6803 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
6807 QTime res = input.toTime();
6808 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
6814 if ( !value.isValid() )
6815 return QStringLiteral(
"None" );
6818 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6820 if ( value.type() == QVariant::DateTime )
6822 const QDateTime dt = value.toDateTime();
6823 if ( !dt.isValid() )
6824 return QStringLiteral(
"QDateTime()" );
6826 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
6827 .arg( dt.date().month() )
6828 .arg( dt.date().day() )
6829 .arg( dt.time().hour() )
6830 .arg( dt.time().minute() )
6831 .arg( dt.time().second() );
6833 else if ( value.type() == QVariant::Date )
6835 const QDate dt = value.toDate();
6836 if ( !dt.isValid() )
6837 return QStringLiteral(
"QDate()" );
6839 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
6843 else if ( value.type() == QVariant::Time )
6845 const QTime dt = value.toTime();
6846 if ( !dt.isValid() )
6847 return QStringLiteral(
"QTime()" );
6849 return QStringLiteral(
"QTime(%4, %5, %6)" )
6852 .arg( dt.second() );
6854 return value.toString();
6861 if ( mMin.isValid() )
6862 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
6863 if ( mMax.isValid() )
6864 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
6866 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
DateTime ?
mDefault.toDateTime().toString( Qt::ISODate ) :
6867 ( mDataType ==
Date ?
mDefault.toDate().toString( Qt::ISODate ) :
mDefault.toTime( ).toString() ) );
6868 QString extra = parts.join( QStringLiteral(
"<br />" ) );
6869 if ( !extra.isEmpty() )
6870 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
6876 switch ( outputType )
6880 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', '%2'" ).arg(
name(),
description() );
6882 code += QStringLiteral(
", optional=True" );
6884 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
DateTime ? QStringLiteral(
"QgsProcessingParameterDateTime.DateTime" )
6885 : mDataType ==
Date ? QStringLiteral(
"QgsProcessingParameterDateTime.Date" )
6886 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
6889 if ( mMin.isValid() )
6891 if ( mMax.isValid() )
6933 map.insert( QStringLiteral(
"min" ), mMin );
6934 map.insert( QStringLiteral(
"max" ), mMax );
6935 map.insert( QStringLiteral(
"data_type" ), mDataType );
6942 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
6943 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
6944 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
6951 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
6962 , mProviderId( provider )
6975 if ( !input.isValid() && !
mDefault.isValid() )
6978 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
6979 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
6987 if ( !value.isValid() )
6988 return QStringLiteral(
"None" );
6991 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6998 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7000 code += QStringLiteral(
"optional " );
7001 code += QStringLiteral(
"providerconnection " );
7002 code += mProviderId +
' ';
7005 return code.trimmed();
7010 switch ( outputType )
7014 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', '%2', '%3'" ).arg(
name(),
description(), mProviderId );
7016 code += QStringLiteral(
", optional=True" );
7030 map.insert( QStringLiteral(
"provider" ), mProviderId );
7037 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
7045 QString def = definition;
7047 if ( def.contains(
' ' ) )
7049 provider = def.left( def.indexOf(
' ' ) );
7050 def = def.mid( def.indexOf(
' ' ) + 1 );
7058 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7060 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7078 , mParentConnectionParameterName( parentLayerParameterName )
7091 if ( !input.isValid() && !
mDefault.isValid() )
7094 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7095 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7103 if ( !value.isValid() )
7104 return QStringLiteral(
"None" );
7107 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7114 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7116 code += QStringLiteral(
"optional " );
7117 code += QStringLiteral(
"databaseschema " );
7119 code += mParentConnectionParameterName +
' ';
7122 return code.trimmed();
7127 switch ( outputType )
7131 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', '%2'" ).arg(
name(),
description() );
7133 code += QStringLiteral(
", optional=True" );
7135 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
7149 QStringList depends;
7150 if ( !mParentConnectionParameterName.isEmpty() )
7151 depends << mParentConnectionParameterName;
7157 return mParentConnectionParameterName;
7162 mParentConnectionParameterName =
name;
7168 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
7175 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
7182 QString def = definition;
7184 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7185 QRegularExpressionMatch m = re.match( def );
7188 parent = m.captured( 1 ).trimmed();
7189 def = m.captured( 2 );
7205 const QString &connectionParameterName,
7206 const QString &schemaParameterName,
7207 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
7209 , mParentConnectionParameterName( connectionParameterName )
7210 , mParentSchemaParameterName( schemaParameterName )
7211 , mAllowNewTableNames( allowNewTableNames )
7224 if ( !input.isValid() && !
mDefault.isValid() )
7227 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7228 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7236 if ( !value.isValid() )
7237 return QStringLiteral(
"None" );
7240 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7247 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7249 code += QStringLiteral(
"optional " );
7250 code += QStringLiteral(
"databasetable " );
7252 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
7253 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
7256 return code.trimmed();
7261 switch ( outputType )
7265 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', '%2'" ).arg(
name(),
description() );
7267 code += QStringLiteral(
", optional=True" );
7269 if ( mAllowNewTableNames )
7270 code += QStringLiteral(
", allowNewTableNames=True" );
7272 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
7273 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
7287 QStringList depends;
7288 if ( !mParentConnectionParameterName.isEmpty() )
7289 depends << mParentConnectionParameterName;
7290 if ( !mParentSchemaParameterName.isEmpty() )
7291 depends << mParentSchemaParameterName;
7297 return mParentConnectionParameterName;
7302 mParentConnectionParameterName =
name;
7307 return mParentSchemaParameterName;
7312 mParentSchemaParameterName =
name;
7318 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
7319 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
7320 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
7327 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
7328 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
7329 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
7337 QString def = definition;
7339 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
7340 QRegularExpressionMatch m = re.match( def );
7343 connection = m.captured( 1 ).trimmed();
7344 if ( connection == QLatin1String(
"none" ) )
7346 schema = m.captured( 2 ).trimmed();
7347 if ( schema == QLatin1String(
"none" ) )
7349 def = m.captured( 3 );
7357 return mAllowNewTableNames;
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.
QString parentParameterName() const
Returns the name of the parent parameter, or an empty string if this is not set.
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 selectedFeaturesOnly
true if only selected features in the source should be used by 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.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QgsCoordinateReferenceSystem crs
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...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
virtual QgsProcessingParameterDefinition * create(const QString &name) const =0
Creates a new parameter of this type.
void setItemType(int type)
Sets the acceptable item type, or -1 if any item type is allowed.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
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...
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.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
@ Double
Double/float values.
@ String
Accepts string fields.
DataType
Field data types.
static QString defaultVectorExtension()
Returns the default vector extension to use, in the absence of all other constraints (e....
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...
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.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
void setParentParameterName(const QString &parentParameterName)
Sets the name of the parent layer parameter.
static QString parameterAsConnectionName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a connection name string.
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
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.
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QString type() const override
Unique parameter type name.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
@ Numeric
Accepts numeric fields.
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...
QgsProcessingParameterRasterLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRasterLayer.
QString type() const override
Unique parameter type name.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
A store for object properties.
void setMinimum(const QDateTime &minimum)
Sets the minimum value acceptable by the parameter.
void setDataType(Type type)
Sets the acceptable data type for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
@ GeometryAbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
static QgsProcessingFeatureSource * variantToSource(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a new feature source.
QString parentConnectionParameterName() const
Returns the name of the parent connection parameter, or an empty string if this is not set.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString type() const override
Unique parameter type name.
QgsProcessingAlgorithm * mAlgorithm
Pointer to algorithm which owns this parameter.
bool multiLine() const
Returns true if the parameter allows multiline strings.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
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 fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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...
QgsProject * project() const
Returns the project in which the algorithm is being executed.
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...
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QString type() const override
Unique parameter type name.
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...
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...
@ DistanceUnknownUnit
Unknown distance unit.
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.
void setExtension(const QString &extension)
Sets a file extension for the parameter.
QString description() const
Returns the description for the parameter.
int numberRows() const
Returns the fixed number of rows in the table.
QgsLayoutItem * itemById(const QString &id) const
Returns a layout item given its id.
QgsProcessingProvider * originalProvider() const
Original (source) provider which this parameter has been derived from.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
void setAllowNewTableNames(bool allowed)
Sets whether the parameter allows users to enter names for a new (non-existing) tables.
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 QgsProcessingParameterVectorLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
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.
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.
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.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QString parameterAsDatabaseTableName(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database table name.
QString parentSchemaParameterName() const
Returns the name of the parent schema parameter, or an empty string if this is not set.
QgsProcessingParameterMapTheme(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMapTheme.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
const QgsCoordinateReferenceSystem & crs
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static QStringList parameterAsFields(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of fields.
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.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Flags flags() const
Returns any flags associated with the parameter.
QVariantMap mMetadata
Freeform metadata for parameter. Mostly used by widget wrappers to customize their appearance and beh...
QgsProcessingParameterExtent(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterExtent.
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.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QgsProcessingDestinationParameter(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingDestinationParameter.
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.
void setCreateByDefault(bool createByDefault)
Sets whether the destination should be created by default.
@ Folder
Parameter is a folder.
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 setDefaultToAllFields(bool enabled)
Sets whether a parameter which allows multiple selections (see allowMultiple()) should automatically ...
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
@ TypeVectorPolygon
Vector polygon layers.
void setMultiLine(bool multiLine)
Sets whether the parameter allows multiline strings.
static QString normalizeLayerSource(const QString &source)
Normalizes a layer source string for safe comparison across different operating system environments.
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.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
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.
QgsProcessing::SourceType dataType() const
Returns the layer type for sinks associated with the parameter.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
QgsProcessing::SourceType layerType() const
Returns the layer type for layers acceptable by the parameter.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static 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.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QgsProcessingParameterAuthConfig(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterAuthConfig.
bool isValid() const
Checks if this expression is valid.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
static QString typeName()
Returns the type name for the parameter class.
virtual QStringList supportedOutputTableExtensions() const
Returns a list of the table (geometry-less vector layers) file extensions supported by this provider.
static QDate parameterAsDate(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static date value.
virtual bool isSupportedOutputValue(const QVariant &value, QgsProcessingContext &context, QString &error) const
Tests whether a value is a supported value for this parameter.
QgsProcessingParameterExpression(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false)
Constructor for QgsProcessingParameterExpression.
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like 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...
int minimumNumberInputs() const
Returns the minimum number of layers required for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterMapLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterMapLayer.
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...
QgsProcessingParameterEnum(const QString &name, const QString &description=QString(), const QStringList &options=QStringList(), bool allowMultiple=false, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterEnum.
Flags flags
Flags which dictate source behavior.
virtual QString fileMeshFilters() const
Returns mesh file filter string.
static QString typeName()
Returns the type name for the parameter class.
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.
QgsProcessingParameterLimitedDataTypes(const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterLimitedDataTypes, with a list of acceptable data types.
@ TypeVectorLine
Vector line layers.
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.
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...
Type
The WKB type describes the number of dimensions a geometry has.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
void setNumberRows(int rows)
Sets the fixed number of rows in the table.
void setParentLayoutParameterName(const QString &name)
Sets the name of the parent layout parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString sourceTypeToString(SourceType type)
Converts a source type to a string representation.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsFeatureRequest::InvalidGeometryCheck geometryCheck
Geometry check method to apply to this source.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
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 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 createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
LayerHint
Layer type hints.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
InvalidGeometryCheck
Handling of features with invalid geometries.
@ GeometrySkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
Type propertyType() const
Returns the property type.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString encodeProviderKeyAndUri(const QString &providerKey, const QString &uri)
Encodes a provider key and layer uri to a single string, for use with decodeProviderKeyAndUri()
DistanceUnit
Units of distance.
bool loadVariant(const QVariant &property)
Loads this property from a QVariantMap, wrapped in a QVariant.
static QString typeName()
Returns the type name for the parameter class.
void setSupportsAppend(bool supportsAppend)
Sets whether the sink supports appending features to an existing table.
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.
void setMinimumNumberInputs(int minimum)
Sets the minimum number of layers required for the parameter.
@ TypeVectorPoint
Vector point layers.
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
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.
@ PrintLayout
Individual print layout (QgsPrintLayout)
bool defaultToAllFields() const
Returns whether a parameter which allows multiple selections (see allowMultiple()) should automatical...
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 parameterAsSchema(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a database schema name.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
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.
QgsProperty source
Source 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 createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
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.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
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...
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
static QgsProcessingParameterDefinition * parameterFromVariantMap(const QVariantMap &map)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied variant map.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
QVariantMap toVariantMap() const override
Saves 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.
void setDataType(QgsProcessingParameterNumber::Type dataType)
Sets the acceptable data type for the range.
@ Raster
Raster layer type.
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
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.
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())
Evaluates the parameter with matching definition to a feature sink.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
Makes metadata of processing parameters available.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
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.
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
Type dataType() const
Returns the acceptable data type for the parameter.
static QString typeName()
Returns the type name for the parameter class.
@ Mesh
Mesh layer type, since QGIS 3.6.
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 createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
@ File
Parameter is a single file.
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the sinks associated with the parameter.
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.
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
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.
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...
QString generateTemporaryDestination() const override
Generates a temporary destination value for this parameter.
static QString parameterAsFile(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file/folder name.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool loadVariant(const QVariantMap &map)
Loads this output layer definition from a QVariantMap, wrapped in a QVariant.
virtual QgsMasterLayoutInterface::Type layoutType() const =0
Returns the master layout type.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of map layers.
QStringList options() const
Returns the list of acceptable options for the parameter.
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 hasGeometry() const
Returns true if sink is likely to include geometries.
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.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
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 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.
QgsProcessingParameterRasterDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterRasterDestination.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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 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 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...
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...
QgsProcessing::SourceType dataType() const
Returns the layer type for this created vector layer.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
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.
void setRemappingDefinition(const QgsRemappingSinkDefinition &definition)
Sets the remapping definition to use when adding features to the output layer.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static 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...
Print layout, a QgsLayout subclass for static or atlas-based layouts.
@ TypeMapLayer
Any map layer type (raster or vector or mesh)
QVariant toVariant() const
Saves this property to a QVariantMap, wrapped in a QVariant.
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...
@ PythonQgsProcessingAlgorithmSubclass
Full Python QgsProcessingAlgorithm subclass.
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.
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.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
void setLayerType(QgsProcessing::SourceType type)
Sets the layer type for layers acceptable by the parameter.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this provider.
QVariant toVariant() const
Saves this output layer definition to a QVariantMap, wrapped in a QVariant.
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
virtual bool fromVariantMap(const QVariantMap &map)
Restores this parameter to a QVariantMap.
static QStringList supportedFormatExtensions(RasterFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats.
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.
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 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 QgsProcessingParameterDatabaseTable * 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 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.
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...
bool allowMultiple() const
Returns whether multiple band selections are permitted.
@ DateTime
Datetime values.
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.
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.
static QString typeName()
Returns the type name for the parameter class.
Flags mFlags
Parameter flags.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QString typeName()
Returns the type name for the parameter class.
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
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 QDateTime parameterAsDateTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static datetime value.
void setParentSchemaParameterName(const QString &name)
Sets the name of the parent schema parameter.
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.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
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.
virtual QString toolTip() const
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
bool operator==(const QgsProcessingOutputLayerDefinition &other) const
void setAllowMultiple(bool allowMultiple)
Sets whether multiple band selections are permitted.
QString type() const override
Unique parameter type name.
QString mDescription
Parameter description.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
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.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
bool fromVariantMap(const QVariantMap &map) override
Restores 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...
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QString extension() const
Returns any specified file extension for the parameter.
QgsProcessingAlgorithm * algorithm() const
Returns a pointer to the algorithm which owns this parameter.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
virtual QgsRectangle extent() const
Returns the extent of the layer.
static bool parameterAsBoolean(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
void setHasFixedNumberRows(bool hasFixedNumberRows)
Sets whether the table has a fixed number of rows.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
@ TypeRaster
Raster layers.
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 name() const
Returns the name of the parameter.
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 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...
bool hasGeometry() const
Returns true if the created layer is likely to include geometries.
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...
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.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterScale(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterScale.
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.
void setDataType(DataType type)
Sets the acceptable data type for the field.
QgsRemappingSinkDefinition remappingDefinition() const
Returns the output remapping definition, if useRemapping() is true.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
@ TypeVectorAnyGeometry
Any vector layer with geometry.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString authid() const
Returns the authority identifier for the CRS.
virtual QString fileRasterFilters() const
Returns raster file filter string.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
double maximum() const
Returns the maximum value acceptable by 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.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
static QList< int > parameterAsInts(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of integer values.
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.
@ DateTime
Accepts datetime fields.
QString type() const override
Unique parameter type name.
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported by this provider.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterMultipleLayers * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString 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.
QgsProcessingParameterType * parameterType(const QString &id) const
Returns the parameter type registered for id.
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.
QStringList headers() const
Returns a list of column headers (if set).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
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.
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.
static QgsPrintLayout * parameterAsLayout(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a print layout.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value.
static QStringList supportedFormatExtensions(VectorFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats, e.g "shp", "gpkg".
void setDataTypes(const QList< int > &types)
Sets the geometry types for sources acceptable by the parameter.
static const QString TEMPORARY_OUTPUT
Constant used to indicate that a Processing algorithm output should be a temporary layer/file.
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.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
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.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QList< int > dataTypes() const
Returns the geometry types for sources 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...
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...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Base class for graphical items within a QgsLayout.
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.
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.
static QStringList parameterAsFileList(const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of files (for QgsProcessingParameterMultip...
QString type() const override
Unique parameter type name.
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 checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Details for layers to load into projects.
bool allowNewTableNames() const
Returns true if the parameter allows users to enter names for a new (non-existing) tables.
virtual QString defaultFileExtension() const =0
Returns the default file extension for destination file paths associated with this parameter.
QgsMasterLayoutInterface * layoutByName(const QString &name) const
Returns the layout with a matching name, or nullptr if no matching layouts were found.
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.
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.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterScale * 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...
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QString type() const override
Unique parameter type name.
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 parentLayerParameterName() const
Returns the name of the parent layer 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 QgsProcessingParameterDefinition * parameterFromScriptCode(const QString &code)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied script code st...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterBoolean(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterBoolean.
QgsProcessingParameterMultipleLayers(const QString &name, const QString &description=QString(), QgsProcessing::SourceType layerType=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMultipleLayers.
int itemType() const
Returns 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...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString parameterAsCompatibleSourceLayerPathInternal(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingFeedback *feedback, QString *layerName)
void setHeaders(const QStringList &headers)
Sets the list of column headers.
static QgsMeshLayer * parameterAsMeshLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition and value to a mesh layer.
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...
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.
QgsProcessingParameterDistance * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString mName
Parameter name.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
QString source() const
Returns the source for the layer.
@ Vector
Vector layer type.
void setParentConnectionParameterName(const QString &name)
Sets the name of the parent connection parameter.
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.
double minimum() const
Returns the minimum value acceptable by the parameter.
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...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Type dataType() const
Returns the acceptable data type for the parameter.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
QgsProcessingParameterColor(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool opacityEnabled=true, bool optional=false)
Constructor for QgsProcessingParameterColor.
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 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...
QgsProcessingParameterPoint(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterPoint.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
QVariantMap createOptions
Map of optional sink/layer creation options, which are passed to the underlying provider when creatin...
QString type() const override
Unique parameter type name.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
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.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
bool supportsNonFileBasedOutput() const
Returns true if the destination parameter supports non filed-based outputs, such as memory layers or ...
static QString generateTempFilename(const QString &basename)
Returns a temporary filename for a given file, putting it into a temporary folder (creating that fold...
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.
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...
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 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.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
void setMaximum(double maximum)
Sets the maximum 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.
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.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
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
bool hasFixedNumberRows() const
Returns whether the table has a fixed number of rows.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString createAllMapLayerFileFilter()
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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 createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
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...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
QgsProcessingParameterString(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool multiLine=false, bool optional=false)
Constructor for QgsProcessingParameterString.
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,...
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 QString parameterAsOutputLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output layer destination.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
void setParentConnectionParameterName(const QString &name)
Sets the name of the parent connection parameter.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QString typeName()
Returns the type name for the parameter class.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsExpressionContext & expressionContext()
Returns the expression context.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
virtual QString asScriptCode() const
Returns the parameter definition encoded in a string which can be used within a Processing script.
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.
void setAllowMultiple(bool allowMultiple)
Sets whether the parameter allows multiple selected values.
QgsProcessingParameterFolderDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFolderDestination.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
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.
QString type() const override
Unique parameter type name.
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.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterRange(const QString &name, const QString &description=QString(), QgsProcessingParameterNumber::Type type=QgsProcessingParameterNumber::Integer, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRange.
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 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...
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported for this parameter.
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).
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...
static QString typeName()
Returns the type name for the parameter class.
void setMaximum(const QDateTime &maximum)
Sets the maximum value acceptable by the parameter.
@ TypeFile
Files (i.e. non map layer sources, such as text files)
QgsProcessingParameterDefinition(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterDefinition.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
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...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
@ GeometryNoCheck
No invalid geometry checking.
QList< int > mDataTypes
List of acceptable data types for the parameter.
QString fileFilter() const
Returns the file filter string for file destinations compatible 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...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
void setOpacityEnabled(bool enabled)
Sets whether the parameter allows opacity control.
QString type() const override
Unique parameter type name.
QVariant mDefault
Default value for parameter.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
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...
virtual QString fileVectorFilters() const
Returns vector file filter string.
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 typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QVariant staticValue() const
Returns the current static value for the property.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
static QString parameterAsFileOutput(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file based output destination.
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 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.
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.
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), QgsRemappingSinkDefinition *remappingDefinition=nullptr)
Creates a feature sink ready for adding features.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
QString parentLayoutParameterName() const
Returns the name of the parent layout parameter, or an empty string if this is not set.
QgsProcessingProvider * provider() const
Returns a pointer to the provider for the algorithm which owns this parameter.
QgsProcessingParameterCrs(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCrs.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
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 ...
virtual QString type() const =0
Unique parameter type name.
Interface for master layout type objects, such as print layouts and reports.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProperty sink
Sink/layer 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...
bool createByDefault() const
Returns true if the destination should be created by default.
QString destinationName
Name to use for sink if it's to be loaded into a destination project.
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.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
@ FlagOptional
Parameter is optional.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
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.
QVariant defaultValue() const
Returns the default value for the parameter.
static QString descriptionFromName(const QString &name)
Creates an autogenerated parameter description from a parameter name.
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
@ StaticProperty
Static property (QgsStaticProperty)
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
PythonOutputType
Available Python output types.
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...
DataType dataType() const
Returns the acceptable data type for the field.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
Behavior behavior() const
Returns the parameter behavior (e.g.
QgsProcessingParameterLayout(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterLayout.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
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.
virtual QString defaultVectorFileExtension(bool hasGeometry=true) const
Returns the default file extension to use for vector outputs created by the provider.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter.
static QString defaultRasterExtension()
Returns the default raster extension to use, in the absence of all other constraints (e....
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
void setOptions(const QStringList &options)
Sets the list of acceptable options for the parameter.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QString typeName()
Returns the type name for the parameter class.
bool operator!=(const QgsProcessingOutputLayerDefinition &other) const
SourceType
Data source types enum.
QgsCoordinateReferenceSystem crs
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 isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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.
bool loadVariant(const QVariantMap &map)
Loads this source definition from a QVariantMap, wrapped in a QVariant.
static QTime parameterAsTime(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static time value.
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.
bool useRemapping() const
Returns true if the output uses a remapping 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...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
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 QgsProcessingParameterLayout * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
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.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
void setMinimum(double minimum)
Sets the minimum value acceptable by the parameter.
virtual QString generateTemporaryDestination() const
Generates a temporary destination value for this parameter.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script.
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the created vector layer.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
QVariant toVariant() const
Saves this source definition to a QVariantMap, wrapped in a QVariant.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString typeName()
Returns the type name for the parameter class.
QDateTime maximum() const
Returns the maximum value acceptable by the parameter.
virtual QString defaultRasterFileExtension() const
Returns the default file extension to use for raster outputs created by the provider.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Behavior
Parameter behavior.
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 opacityEnabled() const
Returns true if the parameter allows opacity control.
static QString addExtensionFromFilter(const QString &fileName, const QString &filter)
Ensures that a fileName ends with an extension from the specified filter string.
QgsProject * destinationProject
Destination project.
@ UnknownType
Unknown layer type.
QgsProcessingParameterVectorLayer(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterVectorLayer.
QgsProcessingParameterFeatureSource(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFeatureSource.
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 parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
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.
QDateTime minimum() const
Returns 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...