QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
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,
565 const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
570 val = parameters.value( definition->
name() );
573 return parameterAsSink( definition, val, fields, geometryType,
crs, context, destinationIdentifier, sinkFlags, createOptions, datasourceOptions, layerOptions );
576 QgsFeatureSink *
QgsProcessingParameters::parameterAsSink(
const QgsProcessingParameterDefinition *definition,
const QVariant &value,
const QgsFields &fields,
QgsWkbTypes::Type geometryType,
const QgsCoordinateReferenceSystem &
crs,
QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags,
const QVariantMap &createOptions,
const QStringList &datasourceOptions,
const QStringList &layerOptions )
578 QVariantMap options = createOptions;
579 QVariant val = value;
584 bool useRemapDefinition =
false;
596 useRemapDefinition =
true;
606 else if ( !val.isValid() || val.toString().isEmpty() )
622 dest = val.toString();
627 dest = destParam->generateTemporaryDestination();
630 if ( dest.isEmpty() )
633 std::unique_ptr< QgsFeatureSink > sink(
QgsProcessingUtils::createFeatureSink( dest, context, fields, geometryType,
crs, options, datasourceOptions, layerOptions, sinkFlags, useRemapDefinition ? &remapDefinition :
nullptr ) );
634 destinationIdentifier = dest;
636 if ( destinationProject )
638 if ( destName.isEmpty() && definition )
644 outputName = definition->
name();
648 return sink.release();
672 QVariant val = parameters.value( definition->
name() );
674 bool selectedFeaturesOnly =
false;
675 long long featureLimit = -1;
697 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
706 else if ( !val.isValid() || val.toString().isEmpty() )
712 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
718 layerRef = val.toString();
723 if ( layerRef.isEmpty() )
735 compatibleFormats, preferredFormat, context, feedback, *layerName, featureLimit );
738 compatibleFormats, preferredFormat, context, feedback, featureLimit );
748 QString *destLayer = layerName;
764 return parameterAsLayer( definition, parameters.value( definition->
name() ), context, layerHint );
772 QVariant val = value;
778 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
795 if ( !val.isValid() || val.toString().isEmpty() )
801 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
806 QString layerRef = val.toString();
807 if ( layerRef.isEmpty() )
810 if ( layerRef.isEmpty() )
841 val = parameters.value( definition->
name() );
848 QVariant val = value;
866 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
873 dest = val.toString();
878 dest = destParam->generateTemporaryDestination();
881 if ( destinationProject )
884 if ( destName.isEmpty() && definition )
889 outputName = definition->
name();
908 val = parameters.value( definition->
name() );
915 QVariant val = value;
929 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
936 dest = val.toString();
941 dest = destParam->generateTemporaryDestination();
986 QVariant val = value;
1035 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1041 rectText = val.toString();
1043 if ( rectText.isEmpty() && !layer )
1046 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1047 QRegularExpressionMatch match = rx.match( rectText );
1048 if ( match.hasMatch() )
1050 bool xMinOk =
false;
1051 double xMin = match.captured( 1 ).toDouble( &xMinOk );
1052 bool xMaxOk =
false;
1053 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1054 bool yMinOk =
false;
1055 double yMin = match.captured( 3 ).toDouble( &yMinOk );
1056 bool yMaxOk =
false;
1057 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1058 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1107 QVariant val = parameters.value( definition->
name() );
1115 g = g.densifyByCount( 20 );
1151 rectText = val.toString();
1153 if ( !rectText.isEmpty() )
1155 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1156 QRegularExpressionMatch match = rx.match( rectText );
1157 if ( match.hasMatch() )
1159 bool xMinOk =
false;
1160 double xMin = match.captured( 1 ).toDouble( &xMinOk );
1161 bool xMaxOk =
false;
1162 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
1163 bool yMinOk =
false;
1164 double yMin = match.captured( 3 ).toDouble( &yMinOk );
1165 bool yMaxOk =
false;
1166 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
1167 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1193 QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) );
1222 QVariant val = parameters.value( definition->
name() );
1228 QVariant val = value;
1256 QString valueAsString;
1260 valueAsString = val.toString();
1262 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1264 QRegularExpressionMatch match = rx.match( valueAsString );
1265 if ( match.hasMatch() )
1291 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1292 return layer->crs();
1294 return layer->crs();
1296 if (
auto *lProject = context.
project() )
1297 return lProject->crs();
1315 QVariant val = value;
1345 if ( pointText.isEmpty() )
1348 if ( pointText.isEmpty() )
1351 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1354 QRegularExpressionMatch match = rx.match( valueAsString );
1355 if ( match.hasMatch() )
1358 double x = match.captured( 1 ).toDouble( &xOk );
1360 double y = match.captured( 2 ).toDouble( &yOk );
1388 QVariant val = parameters.value( definition->
name() );
1403 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1406 QRegularExpressionMatch match = rx.match( valueAsString );
1407 if ( match.hasMatch() )
1414 if (
auto *lProject = context.
project() )
1415 return lProject->crs();
1433 QVariant val = value;
1473 g = g.densifyByCount( 20 );
1506 if ( valueAsString.isEmpty() )
1509 if ( valueAsString.isEmpty() )
1512 QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1514 QRegularExpressionMatch match = rx.match( valueAsString );
1515 if ( match.hasMatch() )
1543 QVariant val = parameters.value( definition->
name() );
1577 QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
1580 QRegularExpressionMatch match = rx.match( valueAsString );
1581 if ( match.hasMatch() )
1588 if (
auto *lProject = context.
project() )
1589 return lProject->crs();
1603 if ( fileText.isEmpty() )
1614 if ( fileText.isEmpty() )
1622 return QVariantList();
1630 return QVariantList();
1632 QString resultString;
1633 QVariant val = value;
1636 else if ( val.type() == QVariant::List )
1637 return val.toList();
1639 resultString = val.toString();
1641 if ( resultString.isEmpty() )
1644 if ( definition->
defaultValue().type() == QVariant::List )
1650 QVariantList result;
1651 const auto constSplit = resultString.split(
',' );
1652 for (
const QString &s : constSplit )
1661 return QList<QgsMapLayer *>();
1669 return QList<QgsMapLayer *>();
1671 QVariant val = value;
1672 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1674 return QList<QgsMapLayer *>() << layer;
1677 QList<QgsMapLayer *> layers;
1679 std::function< void(
const QVariant &var ) > processVariant;
1680 processVariant = [ &layers, &context, &definition, &processVariant ](
const QVariant & var )
1682 if ( var.type() == QVariant::List )
1684 const auto constToList = var.toList();
1685 for (
const QVariant &listVar : constToList )
1687 processVariant( listVar );
1690 else if ( var.type() == QVariant::StringList )
1692 const auto constToStringList = var.toStringList();
1693 for (
const QString &s : constToStringList )
1695 processVariant( s );
1699 processVariant( var.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1704 QVariant sink = fromVar.
sink;
1707 processVariant( sink.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1710 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1722 processVariant( val );
1724 if ( layers.isEmpty() )
1727 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->defaultValue() ) ) )
1731 else if ( definition->defaultValue().type() == QVariant::List )
1733 const auto constToList = definition->defaultValue().toList();
1734 for (
const QVariant &var : constToList )
1736 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1742 processVariant( var );
1747 processVariant( definition->defaultValue() );
1756 return QStringList();
1758 QVariant val = value;
1762 std::function< void(
const QVariant &var ) > processVariant;
1763 processVariant = [ &files, &context, &definition, &processVariant ](
const QVariant & var )
1765 if ( var.type() == QVariant::List )
1767 const auto constToList = var.toList();
1768 for (
const QVariant &listVar : constToList )
1770 processVariant( listVar );
1773 else if ( var.type() == QVariant::StringList )
1775 const auto constToStringList = var.toStringList();
1776 for (
const QString &s : constToStringList )
1778 processVariant( s );
1782 processVariant( var.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1785 files << var.toString();
1789 processVariant( val );
1791 if ( files.isEmpty() )
1793 processVariant( definition->defaultValue() );
1802 return QStringList();
1810 return QList<double>();
1818 return QList<double>();
1820 QStringList resultStringList;
1821 QVariant val = value;
1825 else if ( val.type() == QVariant::List )
1827 const auto constToList = val.toList();
1828 for (
const QVariant &var : constToList )
1829 resultStringList << var.toString();
1832 resultStringList << val.toString();
1834 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1836 resultStringList.clear();
1838 if ( definition->
defaultValue().type() == QVariant::List )
1840 const auto constToList = definition->
defaultValue().toList();
1841 for (
const QVariant &var : constToList )
1842 resultStringList << var.toString();
1845 resultStringList << definition->
defaultValue().toString();
1848 if ( resultStringList.size() == 1 )
1850 resultStringList = resultStringList.at( 0 ).split(
',' );
1853 if ( resultStringList.size() < 2 )
1854 return QList< double >() << std::numeric_limits<double>::quiet_NaN() << std::numeric_limits<double>::quiet_NaN() ;
1856 QList< double > result;
1858 double n = resultStringList.at( 0 ).toDouble( &ok );
1862 result << std::numeric_limits<double>::quiet_NaN() ;
1864 n = resultStringList.at( 1 ).toDouble( &ok );
1868 result << std::numeric_limits<double>::quiet_NaN() ;
1876 return QStringList();
1878 QStringList resultStringList;
1885 return QStringList();
1887 QStringList resultStringList;
1888 QVariant val = value;
1889 if ( val.isValid() )
1893 else if ( val.type() == QVariant::List )
1895 const auto constToList = val.toList();
1896 for (
const QVariant &var : constToList )
1897 resultStringList << var.toString();
1899 else if ( val.type() == QVariant::StringList )
1901 resultStringList = val.toStringList();
1904 resultStringList.append( val.toString().split(
';' ) );
1907 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
1909 resultStringList.clear();
1913 if ( definition->
defaultValue().type() == QVariant::List )
1915 const auto constToList = definition->
defaultValue().toList();
1916 for (
const QVariant &var : constToList )
1917 resultStringList << var.toString();
1919 else if ( definition->
defaultValue().type() == QVariant::StringList )
1921 resultStringList = definition->
defaultValue().toStringList();
1924 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
1928 return resultStringList;
1942 if ( layoutName.isEmpty() )
1994 QVariant val = value;
1999 if ( val.type() == QVariant::Color )
2001 QColor
c = val.value< QColor >();
2003 if ( !colorParam->opacityEnabled() )
2011 if ( definition->
defaultValue().type() == QVariant::Color )
2017 if ( colorText.isEmpty() )
2020 bool containsAlpha =
false;
2023 if (
c.isValid() && !colorParam->opacityEnabled() )
2075 QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
2076 QString name = map.value( QStringLiteral(
"name" ) ).toString();
2077 std::unique_ptr< QgsProcessingParameterDefinition > def;
2144 def.reset( paramType->
create( name ) );
2150 def->fromVariantMap( map );
2151 return def.release();
2156 QString desc = name;
2157 desc.replace(
'_',
' ' );
2163 bool isOptional =
false;
2167 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
2172 if ( type == QLatin1String(
"boolean" ) )
2174 else if ( type == QLatin1String(
"crs" ) )
2176 else if ( type == QLatin1String(
"layer" ) )
2178 else if ( type == QLatin1String(
"extent" ) )
2180 else if ( type == QLatin1String(
"point" ) )
2182 else if ( type == QLatin1String(
"geometry" ) )
2184 else if ( type == QLatin1String(
"file" ) )
2186 else if ( type == QLatin1String(
"folder" ) )
2188 else if ( type == QLatin1String(
"matrix" ) )
2190 else if ( type == QLatin1String(
"multiple" ) )
2192 else if ( type == QLatin1String(
"number" ) )
2194 else if ( type == QLatin1String(
"distance" ) )
2196 else if ( type == QLatin1String(
"scale" ) )
2198 else if ( type == QLatin1String(
"range" ) )
2200 else if ( type == QLatin1String(
"raster" ) )
2202 else if ( type == QLatin1String(
"enum" ) )
2204 else if ( type == QLatin1String(
"string" ) )
2206 else if ( type == QLatin1String(
"authcfg" ) )
2208 else if ( type == QLatin1String(
"expression" ) )
2210 else if ( type == QLatin1String(
"field" ) )
2212 else if ( type == QLatin1String(
"vector" ) )
2214 else if ( type == QLatin1String(
"source" ) )
2216 else if ( type == QLatin1String(
"sink" ) )
2218 else if ( type == QLatin1String(
"vectordestination" ) )
2220 else if ( type == QLatin1String(
"rasterdestination" ) )
2222 else if ( type == QLatin1String(
"filedestination" ) )
2224 else if ( type == QLatin1String(
"folderdestination" ) )
2226 else if ( type == QLatin1String(
"band" ) )
2228 else if ( type == QLatin1String(
"mesh" ) )
2230 else if ( type == QLatin1String(
"layout" ) )
2232 else if ( type == QLatin1String(
"layoutitem" ) )
2234 else if ( type == QLatin1String(
"color" ) )
2236 else if ( type == QLatin1String(
"coordinateoperation" ) )
2238 else if ( type == QLatin1String(
"maptheme" ) )
2240 else if ( type == QLatin1String(
"datetime" ) )
2242 else if ( type == QLatin1String(
"providerconnection" ) )
2244 else if ( type == QLatin1String(
"databaseschema" ) )
2246 else if ( type == QLatin1String(
"databasetable" ) )
2252 bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
2254 QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
2255 QRegularExpressionMatch m = re.match( code );
2256 if ( !m.hasMatch() )
2259 name = m.captured( 1 );
2260 QString tokens = m.captured( 2 );
2261 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
2264 tokens.remove( 0, 8 );
2271 tokens = tokens.trimmed();
2273 QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2274 m = re2.match( tokens );
2275 if ( !m.hasMatch() )
2277 type = tokens.toLower().trimmed();
2282 type = m.captured( 1 ).toLower().trimmed();
2283 definition = m.captured( 2 );
2294 , mDescription( description )
2296 , mDefault( defaultValue )
2297 , mFlags( optional ? FlagOptional : 0 )
2302 if ( !input.isValid() && !
mDefault.isValid() )
2305 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
2306 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
2314 if ( !value.isValid() )
2315 return QStringLiteral(
"None" );
2318 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2325 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2327 code += QLatin1String(
"optional " );
2328 code +=
type() +
' ';
2330 return code.trimmed();
2338 switch ( outputType )
2342 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
2344 code += QLatin1String(
", optional=True" );
2360 map.insert( QStringLiteral(
"parameter_type" ),
type() );
2361 map.insert( QStringLiteral(
"name" ),
mName );
2362 map.insert( QStringLiteral(
"description" ),
mDescription );
2363 map.insert( QStringLiteral(
"help" ),
mHelp );
2364 map.insert( QStringLiteral(
"default" ),
mDefault );
2365 map.insert( QStringLiteral(
"flags" ),
static_cast< int >(
mFlags ) );
2366 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
2372 mName = map.value( QStringLiteral(
"name" ) ).toString();
2373 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
2374 mHelp = map.value( QStringLiteral(
"help" ) ).toString();
2375 mDefault = map.value( QStringLiteral(
"default" ) );
2376 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
2377 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
2393 QString text = QStringLiteral(
"<p><b>%1</b></p>" ).arg(
description() );
2394 if ( !
help().isEmpty() )
2396 text += QStringLiteral(
"<p>%1</p>" ).arg(
help() );
2398 text += QStringLiteral(
"<p>%1</p>" ).arg( QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
2413 if ( !val.isValid() )
2414 return QStringLiteral(
"None" );
2418 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
2423 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2425 code += QLatin1String(
"optional " );
2426 code +=
type() +
' ';
2427 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
2428 return code.trimmed();
2449 if ( !input.isValid() )
2471 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2474 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2482 if ( !value.isValid() )
2483 return QStringLiteral(
"None" );
2488 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
2494 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2497 p.insert(
name(), value );
2524 if ( !input.isValid() )
2532 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2537 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2555 if ( !val.isValid() )
2556 return QStringLiteral(
"None" );
2562 p.insert(
name(), val );
2572 for (
const QString &raster : rasters )
2574 if ( !vectors.contains( raster ) )
2578 for (
const QString &mesh : meshFilters )
2580 if ( !vectors.contains( mesh ) )
2583 vectors.removeAll( QObject::tr(
"All files (*.*)" ) );
2584 std::sort( vectors.begin(), vectors.end() );
2586 return QObject::tr(
"All files (*.*)" ) + QStringLiteral(
";;" ) + vectors.join( QLatin1String(
";;" ) );
2596 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2598 code += QLatin1String(
"optional " );
2599 code += QLatin1String(
"layer " );
2606 code += QLatin1String(
"hasgeometry " );
2610 code += QLatin1String(
"point " );
2614 code += QLatin1String(
"line " );
2618 code += QLatin1String(
"polygon " );
2622 code += QLatin1String(
"raster " );
2626 code += QLatin1String(
"mesh " );
2632 return code.trimmed();
2638 QString def = definition;
2641 if ( def.startsWith( QLatin1String(
"hasgeometry" ), Qt::CaseInsensitive ) )
2644 def = def.mid( 12 );
2647 else if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
2653 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
2659 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
2665 else if ( def.startsWith( QLatin1String(
"raster" ), Qt::CaseInsensitive ) )
2671 else if ( def.startsWith( QLatin1String(
"mesh" ), Qt::CaseInsensitive ) )
2685 switch ( outputType )
2689 QString code = QStringLiteral(
"QgsProcessingParameterMapLayer('%1', '%2'" ).arg(
name(),
description() );
2691 code += QLatin1String(
", optional=True" );
2698 QStringList options;
2702 code += QStringLiteral(
", types=[%1])" ).arg( options.join(
',' ) );
2706 code += QLatin1Char(
')' );
2723 map.insert( QStringLiteral(
"data_types" ), types );
2731 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
2732 for (
const QVariant &val : values )
2752 if ( !input.isValid() )
2785 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2788 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2797 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
2798 QRegularExpressionMatch match = rx.match( input.toString() );
2799 if ( match.hasMatch() )
2801 bool xMinOk =
false;
2802 ( void )match.captured( 1 ).toDouble( &xMinOk );
2803 bool xMaxOk =
false;
2804 ( void )match.captured( 2 ).toDouble( &xMaxOk );
2805 bool yMinOk =
false;
2806 ( void )match.captured( 3 ).toDouble( &yMinOk );
2807 bool yMaxOk =
false;
2808 ( void )match.captured( 4 ).toDouble( &yMaxOk );
2809 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
2819 if ( !value.isValid() )
2820 return QStringLiteral(
"None" );
2823 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2846 const QString wkt = g.
asWkt();
2847 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
2852 p.insert(
name(), value );
2878 if ( !input.isValid() )
2899 if ( input.type() == QVariant::String )
2901 if ( input.toString().isEmpty() )
2905 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
2907 QRegularExpressionMatch match = rx.match( input.toString() );
2908 if ( match.hasMatch() )
2911 ( void )match.captured( 1 ).toDouble( &xOk );
2913 ( void )match.captured( 2 ).toDouble( &yOk );
2922 if ( !value.isValid() )
2923 return QStringLiteral(
"None" );
2926 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2946 const QString wkt = g.
asWkt();
2947 return QStringLiteral(
"QgsGeometry.fromWkt('%1')" ).arg( wkt );
2960 const QVariant &defaultValue,
bool optional,
const QList<int> &geometryTypes )
2962 mGeomTypes( geometryTypes )
2974 if ( !input.isValid() )
2986 return anyTypeAllowed || mGeomTypes.contains( input.value<
QgsGeometry>().
type() );
3014 if ( input.type() == QVariant::String )
3016 if ( input.toString().isEmpty() )
3021 QRegularExpression rx( QStringLiteral(
"^\\s*(?:CRS=(.*);)?(.*?)$" ) );
3023 QRegularExpressionMatch match = rx.match( input.toString() );
3024 if ( match.hasMatch() )
3029 return anyTypeAllowed || mGeomTypes.contains( g.
type() );
3049 if ( !value.isValid() )
3050 return QStringLiteral(
"None" );
3102 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3104 code += QLatin1String(
"optional " );
3105 code +=
type() +
' ';
3107 for (
int type : mGeomTypes )
3112 code += QLatin1String(
"point " );
3116 code += QLatin1String(
"line " );
3120 code += QLatin1String(
"polygon " );
3124 code += QLatin1String(
"unknown" );
3130 return code.trimmed();
3135 switch ( outputType )
3139 QString code = QStringLiteral(
"QgsProcessingParameterGeometry('%1', '%2'" ).arg(
name(),
description() );
3141 code += QLatin1String(
", optional=True" );
3143 if ( !mGeomTypes.empty() )
3150 return QStringLiteral(
"PointGeometry" );
3153 return QStringLiteral(
"LineGeometry" );
3156 return QStringLiteral(
"PolygonGeometry" );
3159 return QStringLiteral(
"UnknownGeometry" );
3162 return QStringLiteral(
"NullGeometry" );
3167 QStringList options;
3168 options.reserve( mGeomTypes.size() );
3169 for (
int type : mGeomTypes )
3173 code += QStringLiteral(
", geometryTypes=[%1 ]" ).arg( options.join(
',' ) );
3188 for (
int type : mGeomTypes )
3192 map.insert( QStringLiteral(
"geometrytypes" ), types );
3200 const QVariantList values = map.value( QStringLiteral(
"geometrytypes" ) ).toList();
3201 for (
const QVariant &val : values )
3203 mGeomTypes << val.toInt();
3215 , mBehavior( behavior )
3216 , mExtension( fileFilter.isEmpty() ? extension : QString() )
3217 , mFileFilter( fileFilter.isEmpty() && extension.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
3229 if ( !input.isValid() )
3237 QString
string = input.toString().trimmed();
3239 if ( input.type() != QVariant::String ||
string.isEmpty() )
3242 switch ( mBehavior )
3246 if ( !mExtension.isEmpty() )
3248 return string.endsWith( mExtension, Qt::CaseInsensitive );
3250 else if ( !mFileFilter.isEmpty() )
3253 return test == string;
3269 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3271 code += QLatin1String(
"optional " );
3272 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
3274 return code.trimmed();
3279 switch ( outputType )
3284 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', '%2'" ).arg(
name(),
description() );
3286 code += QLatin1String(
", optional=True" );
3287 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
3288 if ( !mExtension.isEmpty() )
3289 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
3290 if ( !mFileFilter.isEmpty() )
3291 code += QStringLiteral(
", fileFilter='%1'" ).arg( mFileFilter );
3303 mFileFilter.clear();
3313 mFileFilter = filter;
3320 map.insert( QStringLiteral(
"behavior" ), mBehavior );
3321 map.insert( QStringLiteral(
"extension" ), mExtension );
3322 map.insert( QStringLiteral(
"filefilter" ), mFileFilter );
3329 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
3330 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
3331 mFileFilter = map.value( QStringLiteral(
"filefilter" ) ).toString();
3342 , mHeaders( headers )
3343 , mNumberRows( numberRows )
3344 , mFixedNumberRows( fixedNumberRows )
3356 if ( !input.isValid() )
3359 if ( input.type() == QVariant::String )
3361 if ( input.toString().isEmpty() )
3365 else if ( input.type() == QVariant::List )
3367 if ( input.toList().isEmpty() )
3371 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
3381 if ( !value.isValid() )
3382 return QStringLiteral(
"None" );
3385 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3388 p.insert(
name(), value );
3392 const auto constList = list;
3393 for (
const QVariant &v : constList )
3395 if ( v.type() == QVariant::List )
3398 const auto constToList = v.toList();
3399 for (
const QVariant &v2 : constToList )
3401 if ( v2.isNull() || !v2.isValid() )
3402 parts2 << QStringLiteral(
"None" );
3403 else if ( v2.toString().isEmpty() )
3404 parts2 << QStringLiteral(
"''" );
3406 parts2 << v2.toString();
3408 parts << parts2.join(
',' ).prepend(
'[' ).append(
']' );
3412 if ( v.isNull() || !v.isValid() )
3413 parts << QStringLiteral(
"None" );
3414 else if ( v.toString().isEmpty() )
3415 parts << QStringLiteral(
"''" );
3417 parts << v.toString();
3421 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3426 switch ( outputType )
3430 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', '%2'" ).arg(
name(),
description() );
3432 code += QLatin1String(
", optional=True" );
3433 code += QStringLiteral(
", numberRows=" ).arg( mNumberRows );
3434 code += QStringLiteral(
", hasFixedNumberRows=" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
3437 headers.reserve( mHeaders.size() );
3438 for (
const QString &h : mHeaders )
3440 code += QStringLiteral(
", headers=[%1]" ).arg(
headers.join(
',' ) );
3472 return mFixedNumberRows;
3477 mFixedNumberRows = fixedNumberRows;
3483 map.insert( QStringLiteral(
"headers" ), mHeaders );
3484 map.insert( QStringLiteral(
"rows" ), mNumberRows );
3485 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
3492 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
3493 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
3494 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
3505 , mLayerType( layerType )
3517 if ( !input.isValid() )
3522 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
3528 if ( input.type() == QVariant::String )
3530 if ( input.toString().isEmpty() )
3533 if ( mMinimumNumberInputs > 1 )
3544 else if ( input.type() == QVariant::List )
3546 if ( input.toList().count() < mMinimumNumberInputs )
3549 if ( mMinimumNumberInputs > input.toList().count() )
3557 const auto constToList = input.toList();
3558 for (
const QVariant &v : constToList )
3560 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
3569 else if ( input.type() == QVariant::StringList )
3571 if ( input.toStringList().count() < mMinimumNumberInputs )
3574 if ( mMinimumNumberInputs > input.toStringList().count() )
3582 const auto constToStringList = input.toStringList();
3583 for (
const QString &v : constToStringList )
3596 if ( !value.isValid() )
3597 return QStringLiteral(
"None" );
3600 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3605 if ( value.type() == QVariant::StringList )
3607 const QStringList list = value.toStringList();
3608 parts.reserve( list.count() );
3609 for (
const QString &v : list )
3612 else if ( value.type() == QVariant::List )
3614 const QVariantList list = value.toList();
3615 parts.reserve( list.count() );
3616 for (
const QVariant &v : list )
3619 if ( !parts.isEmpty() )
3620 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3625 p.insert(
name(), value );
3627 if ( !list.isEmpty() )
3630 parts.reserve( list.count() );
3635 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3644 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3646 code += QLatin1String(
"optional " );
3647 switch ( mLayerType )
3650 code += QLatin1String(
"multiple raster" );
3654 code += QLatin1String(
"multiple file" );
3658 code += QLatin1String(
"multiple vector" );
3662 if (
mDefault.type() == QVariant::List )
3665 const auto constToList =
mDefault.toList();
3666 for (
const QVariant &var : constToList )
3668 parts << var.toString();
3670 code += parts.join(
',' );
3672 else if (
mDefault.type() == QVariant::StringList )
3674 code +=
mDefault.toStringList().join(
',' );
3680 return code.trimmed();
3685 switch ( outputType )
3689 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', '%2'" ).arg(
name(),
description() );
3691 code += QLatin1String(
", optional=True" );
3695 code += QStringLiteral(
", layerType=%1" ).arg(
layerType );
3707 switch ( mLayerType )
3710 return QObject::tr(
"All files (*.*)" );
3743 return mMinimumNumberInputs;
3755 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
3756 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
3764 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
3770 QString
type = definition;
3772 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
3773 QRegularExpressionMatch m = re.match( definition );
3776 type = m.captured( 1 ).toLower().trimmed();
3777 defaultVal = m.captured( 2 );
3780 if (
type == QLatin1String(
"vector" ) )
3782 else if (
type == QLatin1String(
"raster" ) )
3784 else if (
type == QLatin1String(
"file" ) )
3797 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
3808 QVariant input = value;
3809 if ( !input.isValid() )
3823 double res = input.toDouble( &ok );
3827 return !( res < mMin || res > mMax );
3832 if ( !value.isValid() )
3833 return QStringLiteral(
"None" );
3836 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3838 return value.toString();
3845 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
3846 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
3847 if ( mMax < std::numeric_limits<double>::max() )
3848 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
3850 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
3851 QString extra = parts.join( QLatin1String(
"<br />" ) );
3852 if ( !extra.isEmpty() )
3853 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
3859 switch ( outputType )
3863 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', '%2'" ).arg(
name(),
description() );
3865 code += QLatin1String(
", optional=True" );
3867 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
3869 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
3870 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
3871 if ( mMax != std::numeric_limits<double>::max() )
3872 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
3914 map.insert( QStringLiteral(
"min" ), mMin );
3915 map.insert( QStringLiteral(
"max" ), mMax );
3916 map.insert( QStringLiteral(
"data_type" ), mDataType );
3923 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
3924 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
3925 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
3932 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
3949 if ( !input.isValid() )
3957 if ( input.type() == QVariant::String )
3959 QStringList list = input.toString().split(
',' );
3960 if ( list.count() != 2 )
3963 list.at( 0 ).toDouble( &ok );
3965 list.at( 1 ).toDouble( &ok2 );
3970 else if ( input.type() == QVariant::List )
3972 if ( input.toList().count() != 2 )
3976 input.toList().at( 0 ).toDouble( &ok );
3978 input.toList().at( 1 ).toDouble( &ok2 );
3989 if ( !value.isValid() )
3990 return QStringLiteral(
"None" );
3993 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3996 p.insert(
name(), value );
3999 QStringList stringParts;
4000 const auto constParts = parts;
4001 for (
double v : constParts )
4003 stringParts << QString::number( v );
4005 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
4010 switch ( outputType )
4014 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', '%2'" ).arg(
name(),
description() );
4016 code += QLatin1String(
", optional=True" );
4018 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
QgsProcessingParameterNumber::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
4041 map.insert( QStringLiteral(
"data_type" ), mDataType );
4055 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
4071 if ( !input.isValid() )
4079 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
4082 if ( input.type() != QVariant::String || input.toString().isEmpty() )
4100 if ( !val.isValid() )
4101 return QStringLiteral(
"None" );
4107 p.insert(
name(), val );
4125 , mOptions( options )
4126 , mAllowMultiple( allowMultiple )
4138 QVariant input = value;
4139 if ( !input.isValid() )
4152 if ( input.type() == QVariant::List )
4154 if ( !mAllowMultiple )
4157 const QVariantList values = input.toList();
4161 for (
const QVariant &val : values )
4164 int res = val.toInt( &ok );
4167 else if ( res < 0 || res >= mOptions.count() )
4173 else if ( input.type() == QVariant::String )
4175 QStringList parts = input.toString().split(
',' );
4176 if ( parts.count() > 1 && !mAllowMultiple )
4179 const auto constParts = parts;
4180 for (
const QString &part : constParts )
4183 int res = part.toInt( &ok );
4186 else if ( res < 0 || res >= mOptions.count() )
4191 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
4194 int res = input.toInt( &ok );
4197 else if ( res >= 0 && res < mOptions.count() )
4205 if ( !value.isValid() )
4206 return QStringLiteral(
"None" );
4209 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4211 if ( value.type() == QVariant::List )
4214 const auto constToList = value.toList();
4215 for (
const QVariant &val : constToList )
4217 parts << QString::number( static_cast< int >( val.toDouble() ) );
4219 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4221 else if ( value.type() == QVariant::String )
4223 QStringList parts = value.toString().split(
',' );
4224 if ( parts.count() > 1 )
4226 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4230 return QString::number(
static_cast< int >( value.toDouble() ) );
4235 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4237 code += QLatin1String(
"optional " );
4238 code += QLatin1String(
"enum " );
4240 if ( mAllowMultiple )
4241 code += QLatin1String(
"multiple " );
4243 code += mOptions.join(
';' ) +
' ';
4246 return code.trimmed();
4251 switch ( outputType )
4255 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', '%2'" ).arg(
name(),
description() );
4257 code += QLatin1String(
", optional=True" );
4260 options.reserve( mOptions.size() );
4261 for (
const QString &o : mOptions )
4263 code += QStringLiteral(
", options=[%1]" ).arg(
options.join(
',' ) );
4265 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4287 return mAllowMultiple;
4298 map.insert( QStringLiteral(
"options" ), mOptions );
4299 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
4306 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
4307 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
4314 bool multiple =
false;
4315 QString def = definition;
4316 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
4322 QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
4323 QRegularExpressionMatch m = re.match( def );
4324 QString values = def;
4327 values = m.captured( 1 ).trimmed();
4328 defaultVal = m.captured( 2 );
4336 , mMultiLine( multiLine )
4348 if ( !value.isValid() || value.isNull() )
4349 return QStringLiteral(
"None" );
4352 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4354 QString s = value.toString();
4360 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4362 code += QLatin1String(
"optional " );
4363 code += QLatin1String(
"string " );
4366 code += QLatin1String(
"long " );
4369 return code.trimmed();
4374 switch ( outputType )
4378 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', '%2'" ).arg(
name(),
description() );
4380 code += QLatin1String(
", optional=True" );
4381 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4404 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
4411 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
4417 QString def = definition;
4419 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
4425 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
4427 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
4431 if ( def == QLatin1String(
"None" ) )
4454 if ( !value.isValid() )
4455 return QStringLiteral(
"None" );
4457 QString s = value.toString();
4463 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4465 code += QLatin1String(
"optional " );
4466 code += QLatin1String(
"authcfg " );
4469 return code.trimmed();
4474 QString def = definition;
4476 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
4478 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
4482 if ( def == QLatin1String(
"None" ) )
4495 , mParentLayerParameterName( parentLayerParameterName )
4507 if ( !value.isValid() )
4508 return QStringLiteral(
"None" );
4511 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4513 QString s = value.toString();
4519 QStringList depends;
4520 if ( !mParentLayerParameterName.isEmpty() )
4521 depends << mParentLayerParameterName;
4527 switch ( outputType )
4531 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', '%2'" ).arg(
name(),
description() );
4533 code += QLatin1String(
", optional=True" );
4535 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
4547 return mParentLayerParameterName;
4558 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
4565 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
4606 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
4609 if ( var.type() != QVariant::String || var.toString().isEmpty() )
4627 if ( !val.isValid() )
4628 return QStringLiteral(
"None" );
4634 p.insert(
name(), val );
4642 switch ( outputType )
4646 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', '%2'" ).arg(
name(),
description() );
4648 code += QLatin1String(
", optional=True" );
4652 QStringList options;
4655 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
4689 map.insert( QStringLiteral(
"data_types" ), types );
4697 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
4698 for (
const QVariant &val : values )
4711 const QString &description,
4712 const QVariant &defaultValue,
4744 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
4747 if ( var.type() != QVariant::String || var.toString().isEmpty() )
4765 if ( !val.isValid() )
4766 return QStringLiteral(
"None" );
4772 p.insert(
name(), val );
4790 , mParentLayerParameterName( parentLayerParameterName )
4792 , mAllowMultiple( allowMultiple )
4793 , mDefaultToAllFields( defaultToAllFields )
4806 if ( !input.isValid() )
4814 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
4816 if ( !mAllowMultiple )
4822 else if ( input.type() == QVariant::String )
4824 if ( input.toString().isEmpty() )
4827 QStringList parts = input.toString().split(
';' );
4828 if ( parts.count() > 1 && !mAllowMultiple )
4833 if ( input.toString().isEmpty() )
4841 if ( !value.isValid() )
4842 return QStringLiteral(
"None" );
4845 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4847 if ( value.type() == QVariant::List )
4850 const auto constToList = value.toList();
4851 for (
const QVariant &val : constToList )
4855 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4857 else if ( value.type() == QVariant::StringList )
4860 const auto constToStringList = value.toStringList();
4861 for ( QString s : constToStringList )
4865 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4873 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4875 code += QLatin1String(
"optional " );
4876 code += QLatin1String(
"field " );
4878 switch ( mDataType )
4881 code += QLatin1String(
"numeric " );
4885 code += QLatin1String(
"string " );
4889 code += QLatin1String(
"datetime " );
4896 if ( mAllowMultiple )
4897 code += QLatin1String(
"multiple " );
4899 if ( mDefaultToAllFields )
4900 code += QLatin1String(
"default_to_all_fields " );
4902 code += mParentLayerParameterName +
' ';
4905 return code.trimmed();
4910 switch ( outputType )
4914 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', '%2'" ).arg(
name(),
description() );
4916 code += QLatin1String(
", optional=True" );
4919 switch ( mDataType )
4922 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
4926 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
4930 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
4934 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
4937 code += QStringLiteral(
", type=%1" ).arg(
dataType );
4939 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
4940 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4944 if ( mDefaultToAllFields )
4945 code += QLatin1String(
", defaultToAllFields=True" );
4957 QStringList depends;
4958 if ( !mParentLayerParameterName.isEmpty() )
4959 depends << mParentLayerParameterName;
4965 return mParentLayerParameterName;
4985 return mAllowMultiple;
4995 return mDefaultToAllFields;
5000 mDefaultToAllFields = enabled;
5006 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5007 map.insert( QStringLiteral(
"data_type" ), mDataType );
5008 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5009 map.insert( QStringLiteral(
"default_to_all_fields" ), mDefaultToAllFields );
5016 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5017 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
5018 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5019 mDefaultToAllFields = map.value( QStringLiteral(
"default_to_all_fields" ) ).toBool();
5029 QString def = definition;
5031 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
5036 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
5041 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
5047 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5050 def = def.mid( 8 ).trimmed();
5053 if ( def.startsWith( QLatin1String(
"default_to_all_fields" ), Qt::CaseInsensitive ) )
5056 def = def.mid( 21 ).trimmed();
5059 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
5060 QRegularExpressionMatch m = re.match( def );
5063 parent = m.captured( 1 ).trimmed();
5064 def = m.captured( 2 );
5089 QVariant var = input;
5090 if ( !var.isValid() )
5117 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
5122 if ( var.type() != QVariant::String || var.toString().isEmpty() )
5140 if ( !value.isValid() )
5141 return QStringLiteral(
"None" );
5144 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5149 QString geometryCheckString;
5153 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryNoCheck" );
5157 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometrySkipInvalid" );
5161 geometryCheckString = QStringLiteral(
"QgsFeatureRequest.GeometryAbortOnInvalid" );
5167 if ( fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagOverrideDefaultGeometryCheck )
5168 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagOverrideDefaultGeometryCheck" );
5169 if ( fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagCreateIndividualOutputPerInputFeature )
5170 flags << QStringLiteral(
"QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature" );
5171 if ( !
flags.empty() )
5172 flagString =
flags.join( QLatin1String(
" | " ) );
5179 layerString = layer->source();
5183 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition('%1', selectedFeaturesOnly=%2, featureLimit=%3%4, geometryCheck=%5)" ).arg( layerString,
5186 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
5187 geometryCheckString );
5198 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression('%1'), selectedFeaturesOnly=%2, featureLimit=%3%4, geometryCheck=%5)" )
5202 flagString.isEmpty() ? QString() : ( QStringLiteral(
", flags=%1" ).arg( flagString ) ),
5203 geometryCheckString );
5207 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
source.
asExpression() );
5211 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
5216 QString layerString = value.toString();
5220 layerString = layer->providerType() != QLatin1String(
"ogr" ) && layer->providerType() != QLatin1String(
"gdal" ) && layer->providerType() != QLatin1String(
"mdal" ) ?
QgsProcessingUtils::encodeProviderKeyAndUri( layer->providerType(), layer->source() ) : layer->source();
5227 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5229 code += QLatin1String(
"optional " );
5230 code += QLatin1String(
"source " );
5237 code += QLatin1String(
"point " );
5241 code += QLatin1String(
"line " );
5245 code += QLatin1String(
"polygon " );
5252 return code.trimmed();
5257 switch ( outputType )
5261 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', '%2'" ).arg(
name(),
description() );
5263 code += QLatin1String(
", optional=True" );
5267 QStringList options;
5271 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
5288 : mDataTypes( types )
5301 map.insert( QStringLiteral(
"data_types" ), types );
5309 const QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
5310 for (
const QVariant &val : values )
5320 QString def = definition;
5323 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
5329 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
5335 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
5350 , mSupportsAppend( supportsAppend )
5361 QVariant var = input;
5362 if ( !var.isValid() )
5384 if ( var.type() != QVariant::String )
5387 if ( var.toString().isEmpty() )
5395 if ( !value.isValid() )
5396 return QStringLiteral(
"None" );
5399 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5410 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
5419 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5421 code += QLatin1String(
"optional " );
5422 code += QLatin1String(
"sink " );
5424 switch ( mDataType )
5427 code += QLatin1String(
"point " );
5431 code += QLatin1String(
"line " );
5435 code += QLatin1String(
"polygon " );
5439 code += QLatin1String(
"table " );
5447 return code.trimmed();
5459 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
5463 return p->defaultVectorFileExtension(
hasGeometry() );
5473 return QStringLiteral(
"dbf" );
5480 switch ( outputType )
5484 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', '%2'" ).arg(
name(),
description() );
5486 code += QLatin1String(
", optional=True" );
5490 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5491 if ( mSupportsAppend )
5492 code += QLatin1String(
", supportsAppend=True" );
5505 QStringList filters;
5506 for (
const QString &ext : exts )
5508 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
5510 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
5519 return lOriginalProvider->supportedOutputVectorLayerExtensions();
5521 return lOriginalProvider->supportedOutputTableExtensions();
5526 return p->supportedOutputVectorLayerExtensions();
5528 return p->supportedOutputTableExtensions();
5543 switch ( mDataType )
5569 map.insert( QStringLiteral(
"data_type" ), mDataType );
5570 map.insert( QStringLiteral(
"supports_append" ), mSupportsAppend );
5578 mSupportsAppend = map.value( QStringLiteral(
"supports_append" ), false ).toBool();
5585 return QStringLiteral(
"memory:%1" ).arg(
description() );
5593 QString def = definition;
5594 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
5599 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
5604 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
5609 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
5620 return mSupportsAppend;
5640 QVariant var = input;
5641 if ( !var.isValid() )
5663 if ( var.type() != QVariant::String )
5666 if ( var.toString().isEmpty() )
5674 if ( !value.isValid() )
5675 return QStringLiteral(
"None" );
5678 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5689 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
5705 return lOriginalProvider->defaultRasterFileExtension();
5709 return p->defaultRasterFileExtension();
5720 QStringList filters;
5721 for (
const QString &ext : exts )
5723 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
5725 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
5732 return lOriginalProvider->supportedOutputRasterLayerExtensions();
5736 return p->supportedOutputRasterLayerExtensions();
5752 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
5764 QVariant var = input;
5765 if ( !var.isValid() )
5787 if ( var.type() != QVariant::String )
5790 if ( var.toString().isEmpty() )
5800 if ( !value.isValid() )
5801 return QStringLiteral(
"None" );
5804 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5815 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
5824 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
5836 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
5837 return QStringLiteral(
"file" );
5840 QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
5841 QRegularExpressionMatch match = rx.match( mFileFilter );
5842 if ( !match.hasMatch() )
5843 return QStringLiteral(
"file" );
5845 return match.captured( 1 );
5850 switch ( outputType )
5854 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', '%2'" ).arg(
name(),
description() );
5856 code += QLatin1String(
", optional=True" );
5860 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5872 return (
fileFilter().isEmpty() ? QString() :
fileFilter() + QStringLiteral(
";;" ) ) + QObject::tr(
"All files (*.*)" );
5888 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
5895 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
5916 QVariant var = input;
5917 if ( !var.isValid() )
5933 if ( var.type() != QVariant::String )
5936 if ( var.toString().isEmpty() )
5959 , mCreateByDefault( createByDefault )
5967 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
5968 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
5975 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
5976 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
5982 switch ( outputType )
5989 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
5991 code += QLatin1String(
", optional=True" );
5993 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6008 return QObject::tr(
"Default extension" ) + QStringLiteral(
" (*." ) +
defaultFileExtension() +
')';
6015 QRegularExpression rx( QStringLiteral(
"[.]" ) );
6016 QString sanitizedName =
name();
6017 sanitizedName.replace( rx, QStringLiteral(
"_" ) );
6032 return lOriginalProvider->isSupportedOutputValue( value,
this, context, error );
6041 return mCreateByDefault;
6063 QVariant var = input;
6064 if ( !var.isValid() )
6086 if ( var.type() != QVariant::String )
6089 if ( var.toString().isEmpty() )
6097 if ( !value.isValid() )
6098 return QStringLiteral(
"None" );
6101 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6112 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
6121 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6123 code += QLatin1String(
"optional " );
6124 code += QLatin1String(
"vectorDestination " );
6126 switch ( mDataType )
6129 code += QLatin1String(
"point " );
6133 code += QLatin1String(
"line " );
6137 code += QLatin1String(
"polygon " );
6145 return code.trimmed();
6157 return lOriginalProvider->defaultVectorFileExtension(
hasGeometry() );
6161 return p->defaultVectorFileExtension(
hasGeometry() );
6171 return QStringLiteral(
"dbf" );
6178 switch ( outputType )
6182 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', '%2'" ).arg(
name(),
description() );
6184 code += QLatin1String(
", optional=True" );
6188 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6201 QStringList filters;
6202 for (
const QString &ext : exts )
6204 filters << QObject::tr(
"%1 files (*.%2)" ).arg( ext.toUpper(), ext.toLower() );
6206 return filters.join( QLatin1String(
";;" ) ) + QStringLiteral(
";;" ) + QObject::tr(
"All files (*.*)" );
6214 return lOriginalProvider->supportedOutputVectorLayerExtensions();
6216 return lOriginalProvider->supportedOutputTableExtensions();
6221 return p->supportedOutputVectorLayerExtensions();
6223 return p->supportedOutputTableExtensions();
6238 switch ( mDataType )
6264 map.insert( QStringLiteral(
"data_type" ), mDataType );
6278 QString def = definition;
6279 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
6284 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
6289 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
6300 , mParentLayerParameterName( parentLayerParameterName )
6301 , mAllowMultiple( allowMultiple )
6313 if ( !input.isValid() )
6321 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
6323 if ( !mAllowMultiple )
6332 double res = input.toInt( &ok );
6342 return mAllowMultiple;
6352 if ( !value.isValid() )
6353 return QStringLiteral(
"None" );
6356 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6358 if ( value.type() == QVariant::List )
6361 QVariantList values = value.toList();
6362 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
6364 parts << QString::number( static_cast< int >( it->toDouble() ) );
6366 return parts.join(
',' ).prepend(
'[' ).append(
']' );
6368 else if ( value.type() == QVariant::StringList )
6371 QStringList values = value.toStringList();
6372 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
6374 parts << QString::number( static_cast< int >( it->toDouble() ) );
6376 return parts.join(
',' ).prepend(
'[' ).append(
']' );
6379 return value.toString();
6384 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6386 code += QLatin1String(
"optional " );
6387 code += QLatin1String(
"band " );
6389 if ( mAllowMultiple )
6390 code += QLatin1String(
"multiple " );
6392 code += mParentLayerParameterName +
' ';
6395 return code.trimmed();
6400 QStringList depends;
6401 if ( !mParentLayerParameterName.isEmpty() )
6402 depends << mParentLayerParameterName;
6408 switch ( outputType )
6412 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', '%2'" ).arg(
name(),
description() );
6414 code += QLatin1String(
", optional=True" );
6416 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
6417 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6429 return mParentLayerParameterName;
6440 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
6441 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
6448 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
6449 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
6456 QString def = definition;
6459 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
6462 def = def.mid( 8 ).trimmed();
6465 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
6466 QRegularExpressionMatch m = re.match( def );
6469 parent = m.captured( 1 ).trimmed();
6470 def = m.captured( 2 );
6487 , mParentParameterName( parentParameterName )
6504 QStringList depends;
6505 if ( !mParentParameterName.isEmpty() )
6506 depends << mParentParameterName;
6512 switch ( outputType )
6516 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', '%2'" ).arg(
name(),
description() );
6518 code += QLatin1String(
", optional=True" );
6520 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
6522 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
6523 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
6524 if (
maximum() != std::numeric_limits<double>::max() )
6525 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
6536 return mParentParameterName;
6547 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
6548 map.insert( QStringLiteral(
"default_unit" ),
static_cast< int >( mDefaultUnit ) );
6555 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
6583 switch ( outputType )
6587 QString code = QStringLiteral(
"QgsProcessingParameterScale('%1', '%2'" ).arg(
name(),
description() );
6589 code += QLatin1String(
", optional=True" );
6601 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
6620 if ( !value.isValid() || value.isNull() )
6621 return QStringLiteral(
"None" );
6624 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6626 QString s = value.toString();
6632 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6634 code += QLatin1String(
"optional " );
6635 code += QLatin1String(
"layout " );
6638 return code.trimmed();
6643 switch ( outputType )
6647 QString code = QStringLiteral(
"QgsProcessingParameterLayout('%1', '%2'" ).arg(
name(),
description() );
6649 code += QLatin1String(
", optional=True" );
6660 QString def = definition;
6662 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
6664 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
6668 if ( def == QLatin1String(
"None" ) )
6681 , mParentLayoutParameterName( parentLayoutParameterName )
6682 , mItemType( itemType )
6694 if ( !value.isValid() || value.isNull() )
6695 return QStringLiteral(
"None" );
6698 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6700 QString s = value.toString();
6706 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6708 code += QLatin1String(
"optional " );
6709 code += QLatin1String(
"layoutitem " );
6710 if ( mItemType >= 0 )
6711 code += QString::number( mItemType ) +
' ';
6713 code += mParentLayoutParameterName +
' ';
6716 return code.trimmed();
6721 switch ( outputType )
6725 QString code = QStringLiteral(
"QgsProcessingParameterLayoutItem('%1', '%2'" ).arg(
name(),
description() );
6727 code += QLatin1String(
", optional=True" );
6729 if ( mItemType >= 0 )
6730 code += QStringLiteral(
", itemType=%1" ).arg( mItemType );
6732 code += QStringLiteral(
", parentLayoutParameterName='%1'" ).arg( mParentLayoutParameterName );
6745 map.insert( QStringLiteral(
"parent_layout" ), mParentLayoutParameterName );
6746 map.insert( QStringLiteral(
"item_type" ), mItemType );
6753 mParentLayoutParameterName = map.value( QStringLiteral(
"parent_layout" ) ).toString();
6754 mItemType = map.value( QStringLiteral(
"item_type" ) ).toInt();
6760 QStringList depends;
6761 if ( !mParentLayoutParameterName.isEmpty() )
6762 depends << mParentLayoutParameterName;
6769 QString def = definition;
6771 QRegularExpression re( QStringLiteral(
"(\\d+)?\\s*(.*?)\\s+(.*)$" ) );
6772 QRegularExpressionMatch m = re.match( def );
6775 itemType = m.captured( 1 ).trimmed().isEmpty() ? -1 : m.captured( 1 ).trimmed().toInt();
6776 parent = m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ).trimmed() : m.captured( 2 ).trimmed();
6777 def = !m.captured( 2 ).trimmed().isEmpty() ? m.captured( 3 ) : QString();
6790 return mParentLayoutParameterName;
6795 mParentLayoutParameterName =
name;
6814 , mAllowOpacity( opacityEnabled )
6826 if ( !value.isValid() || value.isNull() )
6827 return QStringLiteral(
"None" );
6830 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6832 if ( value.canConvert< QColor >() && !value.value< QColor >().isValid() )
6833 return QStringLiteral(
"QColor()" );
6835 if ( value.canConvert< QColor >() )
6837 QColor
c = value.value< QColor >();
6838 if ( !mAllowOpacity ||
c.alpha() == 255 )
6839 return QStringLiteral(
"QColor(%1, %2, %3)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() );
6841 return QStringLiteral(
"QColor(%1, %2, %3, %4)" ).arg(
c.red() ).arg(
c.green() ).arg(
c.blue() ).arg(
c.alpha() );
6844 QString s = value.toString();
6850 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
6852 code += QLatin1String(
"optional " );
6853 code += QLatin1String(
"color " );
6855 if ( mAllowOpacity )
6856 code += QLatin1String(
"withopacity " );
6859 return code.trimmed();
6864 switch ( outputType )
6868 QString code = QStringLiteral(
"QgsProcessingParameterColor('%1', '%2'" ).arg(
name(),
description() );
6870 code += QLatin1String(
", optional=True" );
6872 code += QStringLiteral(
", opacityEnabled=%1" ).arg( mAllowOpacity ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
6884 if ( !input.isValid() && (
mDefault.isValid() && ( !
mDefault.toString().isEmpty() ||
mDefault.value< QColor >().isValid() ) ) )
6887 if ( !input.isValid() )
6890 if ( input.type() == QVariant::Color )
6899 if ( input.type() != QVariant::String || input.toString().isEmpty() )
6902 bool containsAlpha =
false;
6909 map.insert( QStringLiteral(
"opacityEnabled" ), mAllowOpacity );
6916 mAllowOpacity = map.value( QStringLiteral(
"opacityEnabled" ) ).toBool();
6922 return mAllowOpacity;
6927 mAllowOpacity = enabled;
6932 QString def = definition;
6934 bool allowOpacity =
false;
6935 if ( def.startsWith( QLatin1String(
"withopacity" ), Qt::CaseInsensitive ) )
6937 allowOpacity =
true;
6938 def = def.mid( 12 );
6941 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
6943 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
6947 if ( def == QLatin1String(
"None" ) )
6958 , mSourceParameterName( sourceCrsParameterName )
6959 , mDestParameterName( destinationCrsParameterName )
6960 , mSourceCrs( staticSourceCrs )
6961 , mDestCrs( staticDestinationCrs )
6973 if ( !value.isValid() || value.isNull() )
6974 return QStringLiteral(
"None" );
6979 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
6985 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
6988 p.insert(
name(), value );
6993 QString s = value.toString();
6999 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7001 code += QLatin1String(
"optional " );
7002 code += QLatin1String(
"coordinateoperation " );
7005 return code.trimmed();
7010 switch ( outputType )
7015 QString code = QStringLiteral(
"QgsProcessingParameterCoordinateOperation('%1', '%2'" ).arg(
name(),
description() );
7017 code += QLatin1String(
", optional=True" );
7018 if ( !mSourceParameterName.isEmpty() )
7019 code += QStringLiteral(
", sourceCrsParameterName=%1" ).arg(
valueAsPythonString( mSourceParameterName,
c ) );
7020 if ( !mDestParameterName.isEmpty() )
7021 code += QStringLiteral(
", destinationCrsParameterName=%1" ).arg(
valueAsPythonString( mDestParameterName,
c ) );
7023 if ( mSourceCrs.isValid() )
7025 if ( mDestCrs.isValid() )
7026 code += QStringLiteral(
", staticDestinationCrs=%1" ).arg(
valueAsPythonString( mDestCrs,
c ) );
7038 if ( !mSourceParameterName.isEmpty() )
7039 res << mSourceParameterName;
7040 if ( !mDestParameterName.isEmpty() )
7041 res << mDestParameterName;
7048 map.insert( QStringLiteral(
"source_crs_parameter_name" ), mSourceParameterName );
7049 map.insert( QStringLiteral(
"dest_crs_parameter_name" ), mDestParameterName );
7050 map.insert( QStringLiteral(
"static_source_crs" ), mSourceCrs );
7051 map.insert( QStringLiteral(
"static_dest_crs" ), mDestCrs );
7058 mSourceParameterName = map.value( QStringLiteral(
"source_crs_parameter_name" ) ).toString();
7059 mDestParameterName = map.value( QStringLiteral(
"dest_crs_parameter_name" ) ).toString();
7060 mSourceCrs = map.value( QStringLiteral(
"static_source_crs" ) );
7061 mDestCrs = map.value( QStringLiteral(
"static_dest_crs" ) );
7067 QString def = definition;
7069 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7071 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7075 if ( def == QLatin1String(
"None" ) )
7100 if ( !input.isValid() && !
mDefault.isValid() )
7103 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7104 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7112 if ( !value.isValid() )
7113 return QStringLiteral(
"None" );
7116 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7123 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7125 code += QLatin1String(
"optional " );
7126 code += QLatin1String(
"maptheme " );
7129 return code.trimmed();
7134 switch ( outputType )
7138 QString code = QStringLiteral(
"QgsProcessingParameterMapTheme('%1', '%2'" ).arg(
name(),
description() );
7140 code += QLatin1String(
", optional=True" );
7167 QString def = definition;
7168 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7170 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7192 if ( mMin.isValid() && mMax.isValid() && mMin >= mMax )
7194 QgsMessageLog::logMessage( QObject::tr(
"Invalid datetime parameter \"%1\": min value %2 is >= max value %3!" ).arg(
name, mMin.toString(), mMax.toString() ), QObject::tr(
"Processing" ) );
7205 QVariant input = value;
7206 if ( !input.isValid() )
7219 if ( input.type() != QVariant::DateTime && input.type() != QVariant::Date && input.type() != QVariant::Time && input.type() != QVariant::String )
7222 if ( ( input.type() == QVariant::DateTime || input.type() == QVariant::Date ) && mDataType ==
Time )
7225 if ( input.type() == QVariant::String )
7227 QString s = input.toString();
7231 input = QDateTime::fromString( s, Qt::ISODate );
7232 if ( mDataType ==
Time )
7234 if ( !input.toDateTime().isValid() )
7235 input = QTime::fromString( s );
7237 input = input.toDateTime().time();
7241 if ( mDataType !=
Time )
7243 QDateTime res = input.toDateTime();
7244 return res.isValid() && ( res >= mMin || !mMin.isValid() ) && ( res <= mMax || !mMax.isValid() );
7248 QTime res = input.toTime();
7249 return res.isValid() && ( res >= mMin.time() || !mMin.isValid() ) && ( res <= mMax.time() || !mMax.isValid() );
7255 if ( !value.isValid() )
7256 return QStringLiteral(
"None" );
7259 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7261 if ( value.type() == QVariant::DateTime )
7263 const QDateTime dt = value.toDateTime();
7264 if ( !dt.isValid() )
7265 return QStringLiteral(
"QDateTime()" );
7267 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" ).arg( dt.date().year() )
7268 .arg( dt.date().month() )
7269 .arg( dt.date().day() )
7270 .arg( dt.time().hour() )
7271 .arg( dt.time().minute() )
7272 .arg( dt.time().second() );
7274 else if ( value.type() == QVariant::Date )
7276 const QDate dt = value.toDate();
7277 if ( !dt.isValid() )
7278 return QStringLiteral(
"QDate()" );
7280 return QStringLiteral(
"QDate(%1, %2, %3)" ).arg( dt.year() )
7284 else if ( value.type() == QVariant::Time )
7286 const QTime dt = value.toTime();
7287 if ( !dt.isValid() )
7288 return QStringLiteral(
"QTime()" );
7290 return QStringLiteral(
"QTime(%4, %5, %6)" )
7293 .arg( dt.second() );
7295 return value.toString();
7302 if ( mMin.isValid() )
7303 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin.toString( Qt::ISODate ) );
7304 if ( mMax.isValid() )
7305 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax.toString( Qt::ISODate ) );
7307 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
DateTime ?
mDefault.toDateTime().toString( Qt::ISODate ) :
7308 ( mDataType ==
Date ?
mDefault.toDate().toString( Qt::ISODate ) :
mDefault.toTime( ).toString() ) );
7309 QString extra = parts.join( QLatin1String(
"<br />" ) );
7310 if ( !extra.isEmpty() )
7311 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
7317 switch ( outputType )
7321 QString code = QStringLiteral(
"QgsProcessingParameterDateTime('%1', '%2'" ).arg(
name(),
description() );
7323 code += QLatin1String(
", optional=True" );
7325 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
DateTime ? QStringLiteral(
"QgsProcessingParameterDateTime.DateTime" )
7326 : mDataType ==
Date ? QStringLiteral(
"QgsProcessingParameterDateTime.Date" )
7327 : QStringLiteral(
"QgsProcessingParameterDateTime.Time" ) );
7330 if ( mMin.isValid() )
7332 if ( mMax.isValid() )
7374 map.insert( QStringLiteral(
"min" ), mMin );
7375 map.insert( QStringLiteral(
"max" ), mMax );
7376 map.insert( QStringLiteral(
"data_type" ), mDataType );
7383 mMin = map.value( QStringLiteral(
"min" ) ).toDateTime();
7384 mMax = map.value( QStringLiteral(
"max" ) ).toDateTime();
7385 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
7392 : ( definition.toLower().trimmed() == QLatin1String(
"none" ) ? QVariant() : definition ), isOptional );
7403 , mProviderId( provider )
7416 if ( !input.isValid() && !
mDefault.isValid() )
7419 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7420 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7428 if ( !value.isValid() )
7429 return QStringLiteral(
"None" );
7432 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7439 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7441 code += QLatin1String(
"optional " );
7442 code += QLatin1String(
"providerconnection " );
7443 code += mProviderId +
' ';
7446 return code.trimmed();
7451 switch ( outputType )
7455 QString code = QStringLiteral(
"QgsProcessingParameterProviderConnection('%1', '%2', '%3'" ).arg(
name(),
description(), mProviderId );
7457 code += QLatin1String(
", optional=True" );
7471 map.insert( QStringLiteral(
"provider" ), mProviderId );
7478 mProviderId = map.value( QStringLiteral(
"provider" ) ).toString();
7486 QString def = definition;
7488 if ( def.contains(
' ' ) )
7490 provider = def.left( def.indexOf(
' ' ) );
7491 def = def.mid( def.indexOf(
' ' ) + 1 );
7499 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
7501 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
7519 , mParentConnectionParameterName( parentLayerParameterName )
7532 if ( !input.isValid() && !
mDefault.isValid() )
7535 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7536 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7544 if ( !value.isValid() )
7545 return QStringLiteral(
"None" );
7548 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7555 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7557 code += QLatin1String(
"optional " );
7558 code += QLatin1String(
"databaseschema " );
7560 code += mParentConnectionParameterName +
' ';
7563 return code.trimmed();
7568 switch ( outputType )
7572 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseSchema('%1', '%2'" ).arg(
name(),
description() );
7574 code += QLatin1String(
", optional=True" );
7576 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
7590 QStringList depends;
7591 if ( !mParentConnectionParameterName.isEmpty() )
7592 depends << mParentConnectionParameterName;
7598 return mParentConnectionParameterName;
7603 mParentConnectionParameterName =
name;
7609 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
7616 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
7623 QString def = definition;
7625 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
7626 QRegularExpressionMatch m = re.match( def );
7629 parent = m.captured( 1 ).trimmed();
7630 def = m.captured( 2 );
7646 const QString &connectionParameterName,
7647 const QString &schemaParameterName,
7648 const QVariant &defaultValue,
bool optional,
bool allowNewTableNames )
7650 , mParentConnectionParameterName( connectionParameterName )
7651 , mParentSchemaParameterName( schemaParameterName )
7652 , mAllowNewTableNames( allowNewTableNames )
7665 if ( !input.isValid() && !
mDefault.isValid() )
7668 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
7669 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
7677 if ( !value.isValid() )
7678 return QStringLiteral(
"None" );
7681 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
7688 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
7690 code += QLatin1String(
"optional " );
7691 code += QLatin1String(
"databasetable " );
7693 code += ( mParentConnectionParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentConnectionParameterName ) +
' ';
7694 code += ( mParentSchemaParameterName.isEmpty() ? QStringLiteral(
"none" ) : mParentSchemaParameterName ) +
' ';
7697 return code.trimmed();
7702 switch ( outputType )
7706 QString code = QStringLiteral(
"QgsProcessingParameterDatabaseTable('%1', '%2'" ).arg(
name(),
description() );
7708 code += QLatin1String(
", optional=True" );
7710 if ( mAllowNewTableNames )
7711 code += QLatin1String(
", allowNewTableNames=True" );
7713 code += QStringLiteral(
", connectionParameterName='%1'" ).arg( mParentConnectionParameterName );
7714 code += QStringLiteral(
", schemaParameterName='%1'" ).arg( mParentSchemaParameterName );
7728 QStringList depends;
7729 if ( !mParentConnectionParameterName.isEmpty() )
7730 depends << mParentConnectionParameterName;
7731 if ( !mParentSchemaParameterName.isEmpty() )
7732 depends << mParentSchemaParameterName;
7738 return mParentConnectionParameterName;
7743 mParentConnectionParameterName =
name;
7748 return mParentSchemaParameterName;
7753 mParentSchemaParameterName =
name;
7759 map.insert( QStringLiteral(
"mParentConnectionParameterName" ), mParentConnectionParameterName );
7760 map.insert( QStringLiteral(
"mParentSchemaParameterName" ), mParentSchemaParameterName );
7761 map.insert( QStringLiteral(
"mAllowNewTableNames" ), mAllowNewTableNames );
7768 mParentConnectionParameterName = map.value( QStringLiteral(
"mParentConnectionParameterName" ) ).toString();
7769 mParentSchemaParameterName = map.value( QStringLiteral(
"mParentSchemaParameterName" ) ).toString();
7770 mAllowNewTableNames = map.value( QStringLiteral(
"mAllowNewTableNames" ),
false ).toBool();
7778 QString def = definition;
7780 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*+)\\b\\s*(.*)$" ) );
7781 QRegularExpressionMatch m = re.match( def );
7784 connection = m.captured( 1 ).trimmed();
7785 if ( connection == QLatin1String(
"none" ) )
7787 schema = m.captured( 2 ).trimmed();
7788 if ( schema == QLatin1String(
"none" ) )
7790 def = m.captured( 3 );
7798 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.
A table (matrix) parameter for processing algorithms.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString lastError() const SIP_HOLDGIL
Returns an error string referring to the last error encountered either when this geometry was created...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString mHelp
Parameter help.
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...
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), QgsRemappingSinkDefinition *remappingDefinition=nullptr)
Creates a feature sink ready for adding features.
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.
QgsProcessingParameterGeometry(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QList< int > &geometryTypes=QList< int >())
Constructor for QgsProcessingParameterGeometry.
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.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
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.
Defines the parameters used to remap features when creating a QgsRemappingProxyFeatureSink.
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...
static QgsGeometry parameterAsGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a geometry.
A numeric parameter for processing algorithms.
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...
A QgsRectangle with associated coordinate reference system.
@ 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.
Base class for providing feedback from a processing algorithm.
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.
@ WKT_PREFERRED
Preferred format, matching the most recent WKT ISO standard. Currently an alias to WKT2_2019,...
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...
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
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.
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.
A map theme parameter for processing algorithms, allowing users to select an existing map theme from ...
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.
Container of fields for a vector layer.
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
A file output for processing algorithms.
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.
A vector layer output for processing algorithms.
static QgsGeometry fromPointXY(const QgsPointXY &point) SIP_HOLDGIL
Creates a new geometry from a QgsPointXY object.
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.
Abstract base class for processing providers.
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.
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.
A QgsGeometry with associated coordinate reference system.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
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...
Can be inherited by parameters which require limits to their acceptable data types.
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.
Base class for the definition of processing parameters.
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...
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.
An input feature source (such as vector layers) parameter for processing algorithms.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm.
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.
A map layer parameter for processing algorithms.
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...
A parameter for processing algorithms which accepts multiple map layers.
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.
A rectangle specified with double values.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
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.
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.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
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.
A string parameter for authentication configuration ID values.
A color parameter for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
A database table name parameter for processing algorithms, allowing users to select from existing dat...
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.
A feature sink output for processing algorithms.
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
Base class for all parameter definitions which represent file or layer destinations,...
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.
Base class for the definition of processing outputs.
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.
Encapsulates settings relating to a feature source input to a processing algorithm.
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
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.
A double numeric parameter for map scale values.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
A numeric range parameter for processing algorithms.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Custom exception class for Coordinate Reference System related exceptions.
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.
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.
A mesh layer parameter for processing algorithms.
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.
A coordinate reference system parameter for processing algorithms.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static 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.
Contains information about the context in which a processing algorithm is executed.
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.
A geometry parameter for processing algorithms.
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
static QgsProcessingParameterGeometry * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
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.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
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.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
@ 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.
A print layout item parameter, allowing users to select a particular item from a print layout.
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.
A string parameter for processing algorithms.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString help() const
Returns the help 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...
QgsProcessingParameterMeshLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMeshLayer.
@ DateTime
Accepts datetime fields.
A rectangular map extent parameter for processing algorithms.
QString type() const override
Unique parameter type name.
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...
QString toWkt(WktVariant variant=WKT1_GDAL, bool multiline=false, int indentationWidth=4) const
Returns a WKT representation of this CRS.
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.
A raster layer parameter for processing algorithms.
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".
A data provider connection parameter for processing algorithms, allowing users to select from availab...
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.
An input file or folder parameter for processing algorithms.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
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.
A vector layer (with or without geometry) parameter for processing algorithms.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Base class for graphical items within a QgsLayout.
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
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.
Represents a raster layer.
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.
static QgsCoordinateReferenceSystem parameterAsGeometryCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with a geometry parameter value.
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 QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
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.
This class represents a coordinate reference system (CRS).
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
A print layout parameter, allowing users to select a print layout.
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.
A vector layer destination parameter, for specifying the destination path for a vector layer created ...
A database schema parameter for processing algorithms, allowing users to select from existing schemas...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString type() const override
Unique parameter type name.
A QgsPointXY with associated coordinate reference system.
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.
A double numeric parameter for distance values.
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.
A point parameter for processing algorithms.
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.
A class to represent a 2D point.
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 type() const override
Unique parameter type name.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
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.
static QgsReferencedGeometry fromReferencedRect(const QgsReferencedRectangle &rectangle)
Construct a new QgsReferencedGeometry from referenced rectangle.
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.
A boolean parameter for processing algorithms.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
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...
A datetime (or pure date or time) parameter for processing algorithms.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Abstract base class for processing algorithms.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
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
A geometry is the spatial representation of a feature.
bool hasFixedNumberRows() const
Returns whether the table has a fixed number of rows.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A raster layer output for processing algorithms.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
Represents a vector layer which manages a vector based data sets.
An expression parameter for processing algorithms.
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,...
Base class for all map layer types.
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.
static QgsGeometry fromRect(const QgsRectangle &rect) SIP_HOLDGIL
Creates a new geometry from a QgsRectangle.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString type() const override
Unique parameter type name.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource,...
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...
static QgsReferencedGeometry fromReferencedPointXY(const QgsReferencedPointXY &point)
Construct a new QgsReferencedGeometry from referenced point.
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)
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.
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.
QString createFileFilter() const override
This method needs to be reimplemented in all classes which implement this interface and return a file...
A raster band parameter for Processing algorithms.
@ 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.
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 QgsProcessingParameterFeatureSource * 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 parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
static QgsFeatureSink * parameterAsSink(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList())
Evaluates the parameter with matching definition to a feature sink.
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.
const QgsLayoutManager * layoutManager() const
Returns the project's layout manager, which manages print layouts, atlases and reports within the pro...
Interface for master layout type objects, such as print layouts and reports.
An enum based parameter for processing algorithms, allowing for selection from predefined values.
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.
A HTML file output for processing algorithms.
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.
QgsProcessingParameterDefinition(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &help=QString())
Constructor for QgsProcessingParameterDefinition.
A coordinate operation parameter for processing algorithms, for selection between available coordinat...
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.
Class for parsing and evaluation of expressions (formerly called "search strings").
@ 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.
QgsWkbTypes::GeometryType type
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.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
A folder output for processing algorithms.
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.
Custom exception class for processing related exceptions.
A vector layer or feature source field parameter for processing algorithms.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
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.
An interface for objects which accept features via addFeature(s) methods.
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.
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.
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.
A folder destination parameter, for specifying the destination path for a folder created by the algor...
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...