42 map.insert( QStringLiteral(
"create_options" ),
createOptions );
49 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
55 QVariant val = parameters.value( name );
67 return parameterAsString( definition, parameters.value( definition->
name() ), context );
88 return destParam->generateTemporaryDestination();
91 return val.toString();
99 return parameterAsExpression( definition, parameters.value( definition->
name() ), context );
107 QVariant val = value;
111 if ( val.isValid() && !val.toString().isEmpty() )
115 return val.toString();
127 return parameterAsDouble( definition, parameters.value( definition->
name() ), context );
135 QVariant val = value;
140 double res = val.toDouble( &ok );
146 return val.toDouble();
154 return parameterAsInt( definition, parameters.value( definition->
name() ), context );
162 QVariant val = value;
167 double dbl = val.toDouble( &ok );
172 dbl = val.toDouble( &ok );
179 double round = std::round( dbl );
180 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
185 return static_cast< int >( std::round( dbl ) );
194 return QList< int >();
196 return parameterAsInts( definition, parameters.value( definition->
name() ), context );
202 return QList< int >();
204 QList< int > resultList;
205 QVariant val = value;
210 else if ( val.type() == QVariant::List )
212 QVariantList list = val.toList();
213 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
214 resultList << it->toInt();
218 QStringList parts = val.toString().split(
';' );
219 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
220 resultList << it->toInt();
224 if ( ( resultList.isEmpty() || resultList.at( 0 ) == 0 ) )
230 if ( definition->
defaultValue().type() == QVariant::List )
232 QVariantList list = definition->
defaultValue().toList();
233 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
234 resultList << it->toInt();
238 QStringList parts = definition->
defaultValue().toString().split(
';' );
239 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
240 resultList << it->toInt();
253 return parameterAsEnum( definition, parameters.value( definition->
name() ), context );
261 int val = parameterAsInt( definition, value, context );
263 if ( enumDef && val >= enumDef->
options().size() )
275 return parameterAsEnums( definition, parameters.value( definition->
name() ), context );
283 QVariantList resultList;
284 QVariant val = value;
287 else if ( val.type() == QVariant::List )
289 Q_FOREACH (
const QVariant &var, val.toList() )
292 else if ( val.type() == QVariant::String )
294 Q_FOREACH (
const QString &var, val.toString().split(
',' ) )
300 if ( resultList.isEmpty() )
301 return QList< int >();
303 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
307 if ( definition->
defaultValue().type() == QVariant::List )
309 Q_FOREACH (
const QVariant &var, definition->
defaultValue().toList() )
312 else if ( definition->
defaultValue().type() == QVariant::String )
314 Q_FOREACH (
const QString &var, definition->
defaultValue().toString().split(
',' ) )
323 Q_FOREACH (
const QVariant &var, resultList )
325 int resInt = var.toInt();
326 if ( !enumDef || resInt < enumDef->options().size() )
339 return parameterAsBool( definition, parameters.value( definition->
name() ), context );
349 QVariant val = value;
352 else if ( val.isValid() )
360 QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags )
365 val = parameters.value( definition->
name() );
368 return parameterAsSink( definition, val, fields, geometryType, crs, context, destinationIdentifier, sinkFlags );
373 QVariant val = value;
394 else if ( !val.isValid() || val.toString().isEmpty() )
406 dest = val.toString();
411 dest = destParam->generateTemporaryDestination();
414 if ( dest.isEmpty() )
418 destinationIdentifier = dest;
420 if ( destinationProject )
422 if ( destName.isEmpty() && definition )
428 outputName = definition->
name();
432 return sink.release();
440 return parameterAsSource( definition, parameters.value( definition->
name() ), context );
456 QVariant val = parameters.value( definition->
name() );
458 bool selectedFeaturesOnly =
false;
479 vl = qobject_cast<
QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
488 else if ( !val.isValid() || val.toString().isEmpty() )
494 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
500 layerRef = val.toString();
505 if ( layerRef.isEmpty() )
516 compatibleFormats, preferredFormat, context, feedback );
525 return parameterAsLayer( definition, parameters.value( definition->
name() ), context );
533 QVariant val = value;
539 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
556 if ( !val.isValid() || val.toString().isEmpty() )
562 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
567 QString layerRef = val.toString();
568 if ( layerRef.isEmpty() )
571 if ( layerRef.isEmpty() )
579 return qobject_cast<
QgsRasterLayer *>( parameterAsLayer( definition, parameters, context ) );
584 return qobject_cast<
QgsRasterLayer *>( parameterAsLayer( definition, value, context ) );
589 return qobject_cast<
QgsMeshLayer *>( parameterAsLayer( definition, parameters, context ) );
594 return qobject_cast<
QgsMeshLayer *>( parameterAsLayer( definition, value, context ) );
602 val = parameters.value( definition->
name() );
604 return parameterAsOutputLayer( definition, val, context );
609 QVariant val = value;
629 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
636 dest = val.toString();
641 dest = destParam->generateTemporaryDestination();
644 if ( destinationProject )
647 if ( destName.isEmpty() && definition )
652 outputName = definition->
name();
671 val = parameters.value( definition->
name() );
673 return parameterAsFileOutput( definition, val, context );
678 QVariant val = value;
692 else if ( !val.isValid() || val.toString().isEmpty() )
699 dest = val.toString();
704 dest = destParam->generateTemporaryDestination();
711 return qobject_cast<
QgsVectorLayer *>( parameterAsLayer( definition, parameters, context ) );
716 return qobject_cast<
QgsVectorLayer *>( parameterAsLayer( definition, value, context ) );
724 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
732 QVariant val = value;
758 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
764 if ( !val.isValid() )
770 QString crsText = val.toString();
771 if ( crsText.isEmpty() )
774 if ( crsText.isEmpty() )
778 if ( context.
project() && crsText.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
797 return parameterAsExtent( definition, parameters.value( definition->
name() ), context, crs );
805 QVariant val = value;
854 rectText = val.toString();
856 if ( rectText.isEmpty() && !layer )
859 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
860 QRegularExpressionMatch match = rx.match( rectText );
861 if ( match.hasMatch() )
864 double xMin = match.captured( 1 ).toDouble( &xMinOk );
866 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
868 double yMin = match.captured( 3 ).toDouble( &yMinOk );
870 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
871 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
875 if ( crs.
isValid() && rectCrs.isValid() && crs != rectCrs )
920 QVariant val = parameters.value( definition->
name() );
928 g = g.densifyByCount( 20 );
964 rectText = val.toString();
966 if ( !rectText.isEmpty() )
968 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
969 QRegularExpressionMatch match = rx.match( rectText );
970 if ( match.hasMatch() )
973 double xMin = match.captured( 1 ).toDouble( &xMinOk );
975 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
977 double yMin = match.captured( 3 ).toDouble( &yMinOk );
979 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
980 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
985 if ( crs.
isValid() && rectCrs.isValid() && crs != rectCrs )
987 g = g.densifyByCount( 20 );
1035 QVariant val = parameters.value( definition->
name() );
1064 QString valueAsString;
1068 valueAsString = val.toString();
1070 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1072 QRegularExpressionMatch match = rx.match( valueAsString );
1073 if ( match.hasMatch() )
1099 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1100 return layer->crs();
1102 return layer->crs();
1115 return parameterAsPoint( definition, parameters.value( definition->
name() ), context, crs );
1123 QVariant val = value;
1146 QString pointText = parameterAsString( definition, value, context );
1147 if ( pointText.isEmpty() )
1150 if ( pointText.isEmpty() )
1153 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1155 QString valueAsString = parameterAsString( definition, value, context );
1156 QRegularExpressionMatch match = rx.match( valueAsString );
1157 if ( match.hasMatch() )
1160 double x = match.captured( 1 ).toDouble( &xOk );
1162 double y = match.captured( 2 ).toDouble( &yOk );
1169 if ( crs.
isValid() && pointCrs.isValid() && crs != pointCrs )
1190 QVariant val = parameters.value( definition->
name() );
1201 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1203 QString valueAsString = parameterAsString( definition, parameters, context );
1204 QRegularExpressionMatch match = rx.match( valueAsString );
1205 if ( match.hasMatch() )
1223 QString fileText = parameterAsString( definition, parameters, context );
1224 if ( fileText.isEmpty() )
1234 QString fileText = parameterAsString( definition, value, context );
1235 if ( fileText.isEmpty() )
1243 return QVariantList();
1245 return parameterAsMatrix( definition, parameters.value( definition->
name() ), context );
1251 return QVariantList();
1253 QString resultString;
1254 QVariant val = value;
1257 else if ( val.type() == QVariant::List )
1258 return val.toList();
1260 resultString = val.toString();
1262 if ( resultString.isEmpty() )
1265 if ( definition->
defaultValue().type() == QVariant::List )
1271 QVariantList result;
1272 Q_FOREACH (
const QString &s, resultString.split(
',' ) )
1281 return QList<QgsMapLayer *>();
1283 return parameterAsLayerList( definition, parameters.value( definition->
name() ), context );
1289 return QList<QgsMapLayer *>();
1291 QVariant val = value;
1292 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1294 return QList<QgsMapLayer *>() << layer;
1297 QList<QgsMapLayer *> layers;
1299 std::function< void( const QVariant &var ) > processVariant;
1300 processVariant = [ &layers, &context, &definition, &processVariant ](
const QVariant & var )
1302 if ( var.type() == QVariant::List )
1304 Q_FOREACH (
const QVariant &listVar, var.toList() )
1306 processVariant( listVar );
1309 else if ( var.type() == QVariant::StringList )
1311 Q_FOREACH (
const QString &s, var.toStringList() )
1313 processVariant( s );
1317 processVariant( var.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1325 processVariant( sink.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1328 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1340 processVariant( val );
1342 if ( layers.isEmpty() )
1345 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->defaultValue() ) ) )
1349 else if ( definition->defaultValue().type() == QVariant::List )
1351 Q_FOREACH (
const QVariant &var, definition->defaultValue().toList() )
1353 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1359 processVariant( var );
1364 processVariant( definition->defaultValue() );
1373 return QList<double>();
1375 return parameterAsRange( definition, parameters.value( definition->
name() ), context );
1381 return QList<double>();
1383 QStringList resultStringList;
1384 QVariant val = value;
1387 else if ( val.type() == QVariant::List )
1389 Q_FOREACH (
const QVariant &var, val.toList() )
1390 resultStringList << var.toString();
1393 resultStringList << val.toString();
1395 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1397 resultStringList.clear();
1399 if ( definition->
defaultValue().type() == QVariant::List )
1401 Q_FOREACH (
const QVariant &var, definition->
defaultValue().toList() )
1402 resultStringList << var.toString();
1405 resultStringList << definition->
defaultValue().toString();
1408 if ( resultStringList.size() == 1 )
1410 resultStringList = resultStringList.at( 0 ).split(
',' );
1413 if ( resultStringList.size() < 2 )
1414 return QList< double >() << 0.0 << 0.0;
1416 return QList< double >() << resultStringList.at( 0 ).toDouble() << resultStringList.at( 1 ).toDouble();
1422 return QStringList();
1424 QStringList resultStringList;
1425 return parameterAsFields( definition, parameters.value( definition->
name() ), context );
1431 return QStringList();
1433 QStringList resultStringList;
1434 QVariant val = value;
1435 if ( val.isValid() )
1439 else if ( val.type() == QVariant::List )
1441 Q_FOREACH (
const QVariant &var, val.toList() )
1442 resultStringList << var.toString();
1445 resultStringList.append( val.toString().split(
';' ) );
1448 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
1450 resultStringList.clear();
1454 if ( definition->
defaultValue().type() == QVariant::List )
1456 Q_FOREACH (
const QVariant &var, definition->
defaultValue().toList() )
1457 resultStringList << var.toString();
1460 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
1464 return resultStringList;
1469 QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
1470 QString name = map.value( QStringLiteral(
"name" ) ).toString();
1471 std::unique_ptr< QgsProcessingParameterDefinition > def;
1526 def.reset( paramType->
create( name ) );
1532 def->fromVariantMap( map );
1533 return def.release();
1538 QString desc = name;
1539 desc.replace(
'_',
' ' );
1545 bool isOptional =
false;
1549 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
1552 QString description = descriptionFromName( name );
1554 if ( type == QStringLiteral(
"boolean" ) )
1556 else if ( type == QStringLiteral(
"crs" ) )
1558 else if ( type == QStringLiteral(
"layer" ) )
1560 else if ( type == QStringLiteral(
"extent" ) )
1562 else if ( type == QStringLiteral(
"point" ) )
1564 else if ( type == QStringLiteral(
"file" ) )
1566 else if ( type == QStringLiteral(
"folder" ) )
1568 else if ( type == QStringLiteral(
"matrix" ) )
1570 else if ( type == QStringLiteral(
"multiple" ) )
1572 else if ( type == QStringLiteral(
"number" ) )
1574 else if ( type == QStringLiteral(
"range" ) )
1576 else if ( type == QStringLiteral(
"raster" ) )
1578 else if ( type == QStringLiteral(
"enum" ) )
1580 else if ( type == QStringLiteral(
"string" ) )
1582 else if ( type == QStringLiteral(
"authcfg" ) )
1584 else if ( type == QStringLiteral(
"expression" ) )
1586 else if ( type == QStringLiteral(
"field" ) )
1588 else if ( type == QStringLiteral(
"vector" ) )
1590 else if ( type == QStringLiteral(
"source" ) )
1592 else if ( type == QStringLiteral(
"sink" ) )
1594 else if ( type == QStringLiteral(
"vectordestination" ) )
1596 else if ( type == QStringLiteral(
"rasterdestination" ) )
1598 else if ( type == QStringLiteral(
"filedestination" ) )
1600 else if ( type == QStringLiteral(
"folderdestination" ) )
1602 else if ( type == QStringLiteral(
"band" ) )
1604 else if ( type == QStringLiteral(
"mesh" ) )
1610 bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
1612 QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
1613 QRegularExpressionMatch m = re.match( code );
1614 if ( !m.hasMatch() )
1617 name = m.captured( 1 );
1618 QString tokens = m.captured( 2 );
1619 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
1622 tokens.remove( 0, 8 );
1629 tokens = tokens.trimmed();
1631 QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
1632 m = re2.match( tokens );
1633 if ( !m.hasMatch() )
1635 type = tokens.toLower().trimmed();
1640 type = m.captured( 1 ).toLower().trimmed();
1641 definition = m.captured( 2 );
1652 , mDescription( description )
1653 , mDefault( defaultValue )
1654 , mFlags( optional ? FlagOptional : 0 )
1659 if ( !input.isValid() && !
mDefault.isValid() )
1662 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
1663 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
1671 if ( !value.isValid() )
1672 return QStringLiteral(
"None" );
1675 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1682 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1684 code += QStringLiteral(
"optional " );
1685 code +=
type() +
' ';
1687 return code.trimmed();
1695 switch ( outputType )
1699 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
1701 code += QStringLiteral(
", optional=True" );
1717 map.insert( QStringLiteral(
"parameter_type" ),
type() );
1718 map.insert( QStringLiteral(
"name" ),
mName );
1719 map.insert( QStringLiteral(
"description" ),
mDescription );
1720 map.insert( QStringLiteral(
"default" ),
mDefault );
1721 map.insert( QStringLiteral(
"flags" ), static_cast< int >(
mFlags ) );
1722 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
1728 mName = map.value( QStringLiteral(
"name" ) ).toString();
1729 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
1730 mDefault = map.value( QStringLiteral(
"default" ) );
1731 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
1732 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
1748 return QStringLiteral(
"<p><b>%1</b></p><p>%2</p>" ).arg(
1750 QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
1764 if ( !val.isValid() )
1765 return QStringLiteral(
"None" );
1769 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
1774 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1776 code += QStringLiteral(
"optional " );
1777 code +=
type() +
' ';
1778 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
1779 return code.trimmed();
1800 if ( !input.isValid() )
1822 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1825 if ( input.type() != QVariant::String || input.toString().isEmpty() )
1833 if ( !value.isValid() )
1834 return QStringLiteral(
"None" );
1839 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
1845 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1848 p.insert(
name(), value );
1858 return new QgsProcessingParameterCrs( name, description, definition.compare( QLatin1String(
"none" ), Qt::CaseInsensitive ) == 0 ? QVariant() : definition, isOptional );
1874 if ( !input.isValid() )
1882 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1887 if ( input.type() != QVariant::String || input.toString().isEmpty() )
1905 if ( !val.isValid() )
1906 return QStringLiteral(
"None" );
1912 p.insert(
name(), val );
1936 if ( !input.isValid() )
1965 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1968 if ( input.type() != QVariant::String || input.toString().isEmpty() )
1977 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1978 QRegularExpressionMatch match = rx.match( input.toString() );
1979 if ( match.hasMatch() )
1981 bool xMinOk =
false;
1982 ( void )match.captured( 1 ).toDouble( &xMinOk );
1983 bool xMaxOk =
false;
1984 ( void )match.captured( 2 ).toDouble( &xMaxOk );
1985 bool yMinOk =
false;
1986 ( void )match.captured( 3 ).toDouble( &yMinOk );
1987 bool yMaxOk =
false;
1988 ( void )match.captured( 4 ).toDouble( &yMaxOk );
1989 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1999 if ( !value.isValid() )
2000 return QStringLiteral(
"None" );
2003 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2023 p.insert(
name(), value );
2049 if ( !input.isValid() )
2066 if ( input.type() == QVariant::String )
2068 if ( input.toString().isEmpty() )
2072 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
2074 QRegularExpressionMatch match = rx.match( input.toString() );
2075 if ( match.hasMatch() )
2078 ( void )match.captured( 1 ).toDouble( &xOk );
2080 ( void )match.captured( 2 ).toDouble( &yOk );
2089 if ( !value.isValid() )
2090 return QStringLiteral(
"None" );
2093 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2119 , mBehavior( behavior )
2120 , mExtension( extension )
2132 if ( !input.isValid() )
2140 QString
string = input.toString().trimmed();
2142 if ( input.type() != QVariant::String ||
string.isEmpty() )
2145 switch ( mBehavior )
2149 if ( !mExtension.isEmpty() )
2150 return string.endsWith( mExtension, Qt::CaseInsensitive );
2162 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2164 code += QStringLiteral(
"optional " );
2165 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
2167 return code.trimmed();
2172 switch ( outputType )
2177 QString code = QStringLiteral(
"QgsProcessingParameterFile('%1', '%2'" ).arg(
name(),
description() );
2179 code += QStringLiteral(
", optional=True" );
2180 code += QStringLiteral(
", behavior=%1" ).arg( mBehavior ==
File ? QStringLiteral(
"QgsProcessingParameterFile.File" ) : QStringLiteral(
"QgsProcessingParameterFile.Folder" ) );
2181 code += QStringLiteral(
", extension='%1'" ).arg( mExtension );
2193 map.insert( QStringLiteral(
"behavior" ), mBehavior );
2194 map.insert( QStringLiteral(
"extension" ), mExtension );
2201 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
2202 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
2213 , mHeaders( headers )
2214 , mNumberRows( numberRows )
2215 , mFixedNumberRows( fixedNumberRows )
2227 if ( !input.isValid() )
2230 if ( input.type() == QVariant::String )
2232 if ( input.toString().isEmpty() )
2236 else if ( input.type() == QVariant::List )
2238 if ( input.toList().isEmpty() )
2242 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
2252 if ( !value.isValid() )
2253 return QStringLiteral(
"None" );
2256 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2259 p.insert(
name(), value );
2263 Q_FOREACH (
const QVariant &v, list )
2265 if ( v.type() == QVariant::List )
2268 Q_FOREACH (
const QVariant &v2, v.toList() )
2270 if ( v2.isNull() || !v2.isValid() )
2271 parts2 << QStringLiteral(
"None" );
2272 else if ( v2.toString().isEmpty() )
2273 parts2 << QStringLiteral(
"''" );
2275 parts2 << v2.toString();
2277 parts << parts2.join(
',' ).prepend(
'[' ).append(
']' );
2281 if ( v.isNull() || !v.isValid() )
2282 parts << QStringLiteral(
"None" );
2283 else if ( v.toString().isEmpty() )
2284 parts << QStringLiteral(
"''" );
2286 parts << v.toString();
2290 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2295 switch ( outputType )
2299 QString code = QStringLiteral(
"QgsProcessingParameterMatrix('%1', '%2'" ).arg(
name(),
description() );
2301 code += QStringLiteral(
", optional=True" );
2302 code += QStringLiteral(
", numberRows=" ).arg( mNumberRows );
2303 code += QStringLiteral(
", hasFixedNumberRows=" ).arg( mFixedNumberRows ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
2306 headers.reserve( mHeaders.size() );
2307 for (
const QString &h : mHeaders )
2309 code += QStringLiteral(
", headers=[%1]" ).arg( headers.join(
',' ) );
2341 return mFixedNumberRows;
2346 mFixedNumberRows = fixedNumberRows;
2352 map.insert( QStringLiteral(
"headers" ), mHeaders );
2353 map.insert( QStringLiteral(
"rows" ), mNumberRows );
2354 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
2361 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
2362 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
2363 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
2369 return new QgsProcessingParameterMatrix( name, description, 0,
false, QStringList(), definition.isEmpty() ? QVariant() : definition, isOptional );
2374 , mLayerType( layerType )
2386 if ( !input.isValid() )
2389 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2394 if ( input.type() == QVariant::String )
2396 if ( input.toString().isEmpty() )
2399 if ( mMinimumNumberInputs > 1 )
2407 else if ( input.type() == QVariant::List )
2409 if ( input.toList().count() < mMinimumNumberInputs )
2412 if ( mMinimumNumberInputs > input.toList().count() )
2418 Q_FOREACH (
const QVariant &v, input.toList() )
2420 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
2428 else if ( input.type() == QVariant::StringList )
2430 if ( input.toStringList().count() < mMinimumNumberInputs )
2433 if ( mMinimumNumberInputs > input.toStringList().count() )
2439 Q_FOREACH (
const QString &v, input.toStringList() )
2451 if ( !value.isValid() )
2452 return QStringLiteral(
"None" );
2455 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2458 p.insert(
name(), value );
2460 if ( !list.isEmpty() )
2467 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2475 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2477 code += QStringLiteral(
"optional " );
2478 switch ( mLayerType )
2481 code += QStringLiteral(
"multiple raster" );
2485 code += QStringLiteral(
"multiple file" );
2489 code += QStringLiteral(
"multiple vector" );
2493 if (
mDefault.type() == QVariant::List )
2496 Q_FOREACH (
const QVariant &var,
mDefault.toList() )
2498 parts << var.toString();
2500 code += parts.join(
',' );
2502 else if (
mDefault.type() == QVariant::StringList )
2504 code +=
mDefault.toStringList().join(
',' );
2510 return code.trimmed();
2515 switch ( outputType )
2519 QString code = QStringLiteral(
"QgsProcessingParameterMultipleLayers('%1', '%2'" ).arg(
name(),
description() );
2521 code += QStringLiteral(
", optional=True" );
2525 code += QStringLiteral(
", layerType=%1" ).arg( layerType );
2546 return mMinimumNumberInputs;
2558 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
2559 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
2567 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
2573 QString
type = definition;
2575 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2576 QRegularExpressionMatch m = re.match( definition );
2579 type = m.captured( 1 ).toLower().trimmed();
2580 defaultVal = m.captured( 2 );
2583 if ( type == QStringLiteral(
"vector" ) )
2585 else if ( type == QStringLiteral(
"raster" ) )
2587 else if ( type == QStringLiteral(
"file" ) )
2600 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg( name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
2611 QVariant input = value;
2612 if ( !input.isValid() )
2626 double res = input.toDouble( &ok );
2630 return !( res < mMin || res > mMax );
2635 if ( !value.isValid() )
2636 return QStringLiteral(
"None" );
2639 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2641 return value.toString();
2648 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
2649 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
2650 if ( mMax < std::numeric_limits<double>::max() )
2651 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
2653 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
2654 QString extra = parts.join( QStringLiteral(
"<br />" ) );
2655 if ( !extra.isEmpty() )
2656 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
2662 switch ( outputType )
2666 QString code = QStringLiteral(
"QgsProcessingParameterNumber('%1', '%2'" ).arg(
name(),
description() );
2668 code += QStringLiteral(
", optional=True" );
2670 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
2672 if ( mMin != std::numeric_limits<double>::lowest() + 1 )
2673 code += QStringLiteral(
", minValue=%1" ).arg( mMin );
2674 if ( mMax != std::numeric_limits<double>::max() )
2675 code += QStringLiteral(
", maxValue=%1" ).arg( mMax );
2717 map.insert( QStringLiteral(
"min" ), mMin );
2718 map.insert( QStringLiteral(
"max" ), mMax );
2719 map.insert( QStringLiteral(
"data_type" ), mDataType );
2726 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
2727 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
2728 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
2735 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
2752 if ( !input.isValid() )
2760 if ( input.type() == QVariant::String )
2762 QStringList list = input.toString().split(
',' );
2763 if ( list.count() != 2 )
2766 list.at( 0 ).toDouble( &ok );
2768 list.at( 1 ).toDouble( &ok2 );
2773 else if ( input.type() == QVariant::List )
2775 if ( input.toList().count() != 2 )
2779 input.toList().at( 0 ).toDouble( &ok );
2781 input.toList().at( 1 ).toDouble( &ok2 );
2792 if ( !value.isValid() )
2793 return QStringLiteral(
"None" );
2796 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2799 p.insert(
name(), value );
2802 QStringList stringParts;
2803 Q_FOREACH (
double v, parts )
2805 stringParts << QString::number( v );
2807 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
2812 switch ( outputType )
2816 QString code = QStringLiteral(
"QgsProcessingParameterRange('%1', '%2'" ).arg(
name(),
description() );
2818 code += QStringLiteral(
", optional=True" );
2820 code += QStringLiteral(
", type=%1" ).arg( mDataType ==
QgsProcessingParameterNumber::Integer ? QStringLiteral(
"QgsProcessingParameterNumber.Integer" ) : QStringLiteral(
"QgsProcessingParameterNumber.Double" ) );
2843 map.insert( QStringLiteral(
"data_type" ), mDataType );
2872 if ( !input.isValid() )
2880 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
2883 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2901 if ( !val.isValid() )
2902 return QStringLiteral(
"None" );
2908 p.insert(
name(), val );
2921 , mOptions( options )
2922 , mAllowMultiple( allowMultiple )
2934 QVariant input = value;
2935 if ( !input.isValid() )
2948 if ( input.type() == QVariant::List )
2950 if ( !mAllowMultiple )
2953 const QVariantList values = input.toList();
2957 for (
const QVariant &val : values )
2960 int res = val.toInt( &ok );
2963 else if ( res < 0 || res >= mOptions.count() )
2969 else if ( input.type() == QVariant::String )
2971 QStringList parts = input.toString().split(
',' );
2972 if ( parts.count() > 1 && !mAllowMultiple )
2975 Q_FOREACH (
const QString &part, parts )
2978 int res = part.toInt( &ok );
2981 else if ( res < 0 || res >= mOptions.count() )
2986 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
2989 int res = input.toInt( &ok );
2992 else if ( res >= 0 && res < mOptions.count() )
3000 if ( !value.isValid() )
3001 return QStringLiteral(
"None" );
3004 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3006 if ( value.type() == QVariant::List )
3009 Q_FOREACH (
const QVariant &val, value.toList() )
3011 parts << QString::number( static_cast< int >( val.toDouble() ) );
3013 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3015 else if ( value.type() == QVariant::String )
3017 QStringList parts = value.toString().split(
',' );
3018 if ( parts.count() > 1 )
3020 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3024 return QString::number( static_cast< int >( value.toDouble() ) );
3029 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3031 code += QStringLiteral(
"optional " );
3032 code += QStringLiteral(
"enum " );
3034 if ( mAllowMultiple )
3035 code += QStringLiteral(
"multiple " );
3037 code += mOptions.join(
';' ) +
' ';
3040 return code.trimmed();
3045 switch ( outputType )
3049 QString code = QStringLiteral(
"QgsProcessingParameterEnum('%1', '%2'" ).arg(
name(),
description() );
3051 code += QStringLiteral(
", optional=True" );
3054 options.reserve( mOptions.size() );
3055 for (
const QString &o : mOptions )
3057 code += QStringLiteral(
", options=[%1]" ).arg( options.join(
',' ) );
3059 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
3081 return mAllowMultiple;
3092 map.insert( QStringLiteral(
"options" ), mOptions );
3093 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
3100 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
3101 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
3108 bool multiple =
false;
3109 QString def = definition;
3110 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
3116 QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
3117 QRegularExpressionMatch m = re.match( def );
3118 QString values = def;
3121 values = m.captured( 1 ).trimmed();
3122 defaultVal = m.captured( 2 );
3125 return new QgsProcessingParameterEnum( name, description, values.split(
';' ), multiple, defaultVal.isEmpty() ? QVariant() : defaultVal, isOptional );
3130 , mMultiLine( multiLine )
3142 if ( !value.isValid() || value.isNull() )
3143 return QStringLiteral(
"None" );
3146 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3148 QString s = value.toString();
3154 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3156 code += QStringLiteral(
"optional " );
3157 code += QStringLiteral(
"string " );
3160 code += QStringLiteral(
"long " );
3163 return code.trimmed();
3168 switch ( outputType )
3172 QString code = QStringLiteral(
"QgsProcessingParameterString('%1', '%2'" ).arg(
name(),
description() );
3174 code += QStringLiteral(
", optional=True" );
3175 code += QStringLiteral(
", multiLine=%1" ).arg( mMultiLine ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
3198 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
3205 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
3211 QString def = definition;
3213 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
3219 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
3221 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
3225 if ( def == QStringLiteral(
"None" ) )
3226 defaultValue = QVariant();
3248 if ( !value.isValid() )
3249 return QStringLiteral(
"None" );
3251 QString s = value.toString();
3257 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3259 code += QStringLiteral(
"optional " );
3260 code += QStringLiteral(
"authcfg " );
3263 return code.trimmed();
3268 QString def = definition;
3270 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
3272 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
3276 if ( def == QStringLiteral(
"None" ) )
3277 defaultValue = QVariant();
3289 , mParentLayerParameterName( parentLayerParameterName )
3301 if ( !value.isValid() )
3302 return QStringLiteral(
"None" );
3305 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3307 QString s = value.toString();
3313 QStringList depends;
3314 if ( !mParentLayerParameterName.isEmpty() )
3315 depends << mParentLayerParameterName;
3321 switch ( outputType )
3325 QString code = QStringLiteral(
"QgsProcessingParameterExpression('%1', '%2'" ).arg(
name(),
description() );
3327 code += QStringLiteral(
", optional=True" );
3329 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
3341 return mParentLayerParameterName;
3352 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
3359 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
3400 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
3403 if ( var.type() != QVariant::String || var.toString().isEmpty() )
3421 if ( !val.isValid() )
3422 return QStringLiteral(
"None" );
3428 p.insert(
name(), val );
3436 switch ( outputType )
3440 QString code = QStringLiteral(
"QgsProcessingParameterVectorLayer('%1', '%2'" ).arg(
name(),
description() );
3442 code += QStringLiteral(
", optional=True" );
3446 QStringList options;
3449 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
3478 map.insert( QStringLiteral(
"data_types" ), types );
3486 QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3487 Q_FOREACH (
const QVariant &val, values )
3533 if ( qobject_cast< QgsMeshLayer * >( qvariant_cast<QObject *>( var ) ) )
3536 if ( var.type() != QVariant::String || var.toString().isEmpty() )
3554 if ( !val.isValid() )
3555 return QStringLiteral(
"None" );
3561 p.insert(
name(), val );
3574 , mParentLayerParameterName( parentLayerParameterName )
3576 , mAllowMultiple( allowMultiple )
3589 if ( !input.isValid() )
3597 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
3599 if ( !mAllowMultiple )
3605 else if ( input.type() == QVariant::String )
3607 if ( input.toString().isEmpty() )
3610 QStringList parts = input.toString().split(
';' );
3611 if ( parts.count() > 1 && !mAllowMultiple )
3616 if ( input.toString().isEmpty() )
3624 if ( !value.isValid() )
3625 return QStringLiteral(
"None" );
3628 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3630 if ( value.type() == QVariant::List )
3633 Q_FOREACH (
const QVariant &val, value.toList() )
3637 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3639 else if ( value.type() == QVariant::StringList )
3642 Q_FOREACH ( QString s, value.toStringList() )
3646 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3654 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3656 code += QStringLiteral(
"optional " );
3657 code += QStringLiteral(
"field " );
3659 switch ( mDataType )
3662 code += QStringLiteral(
"numeric " );
3666 code += QStringLiteral(
"string " );
3670 code += QStringLiteral(
"datetime " );
3677 if ( mAllowMultiple )
3678 code += QStringLiteral(
"multiple " );
3680 code += mParentLayerParameterName +
' ';
3683 return code.trimmed();
3688 switch ( outputType )
3692 QString code = QStringLiteral(
"QgsProcessingParameterField('%1', '%2'" ).arg(
name(),
description() );
3694 code += QStringLiteral(
", optional=True" );
3697 switch ( mDataType )
3700 dataType = QStringLiteral(
"QgsProcessingParameterField.Any" );
3704 dataType = QStringLiteral(
"QgsProcessingParameterField.Numeric" );
3708 dataType = QStringLiteral(
"QgsProcessingParameterField.String" );
3712 dataType = QStringLiteral(
"QgsProcessingParameterField.DateTime" );
3715 code += QStringLiteral(
", type=%1" ).arg( dataType );
3717 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
3718 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
3730 QStringList depends;
3731 if ( !mParentLayerParameterName.isEmpty() )
3732 depends << mParentLayerParameterName;
3738 return mParentLayerParameterName;
3758 return mAllowMultiple;
3769 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
3770 map.insert( QStringLiteral(
"data_type" ), mDataType );
3771 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
3778 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
3779 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
3780 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
3789 QString def = definition;
3791 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
3796 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
3801 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
3807 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
3809 allowMultiple =
true;
3810 def = def.mid( 8 ).trimmed();
3813 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
3814 QRegularExpressionMatch m = re.match( def );
3817 parent = m.captured( 1 ).trimmed();
3818 def = m.captured( 2 );
3843 QVariant var = input;
3844 if ( !var.isValid() )
3871 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
3876 if ( var.type() != QVariant::String || var.toString().isEmpty() )
3894 if ( !value.isValid() )
3895 return QStringLiteral(
"None" );
3898 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3907 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition('%1', True)" ).arg( fromVar.
source.
staticValue().toString() );
3914 layerString = layer->source();
3922 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression('%1'), True)" ).arg( fromVar.
source.
asExpression() );
3926 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
source.
asExpression() );
3930 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
3935 QString layerString = value.toString();
3939 layerString = layer->source();
3946 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3948 code += QStringLiteral(
"optional " );
3949 code += QStringLiteral(
"source " );
3956 code += QStringLiteral(
"point " );
3960 code += QStringLiteral(
"line " );
3964 code += QStringLiteral(
"polygon " );
3971 return code.trimmed();
3976 switch ( outputType )
3980 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSource('%1', '%2'" ).arg(
name(),
description() );
3982 code += QStringLiteral(
", optional=True" );
3986 QStringList options;
3990 code += QStringLiteral(
", types=[%1]" ).arg( options.join(
',' ) );
4015 map.insert( QStringLiteral(
"data_types" ), types );
4023 QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
4024 Q_FOREACH (
const QVariant &val, values )
4034 QString def = definition;
4037 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
4043 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
4049 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
4074 QVariant var = input;
4075 if ( !var.isValid() )
4097 if ( var.type() != QVariant::String )
4100 if ( var.toString().isEmpty() )
4108 if ( !value.isValid() )
4109 return QStringLiteral(
"None" );
4112 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4123 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4132 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4134 code += QStringLiteral(
"optional " );
4135 code += QStringLiteral(
"sink " );
4137 switch ( mDataType )
4140 code += QStringLiteral(
"point " );
4144 code += QStringLiteral(
"line " );
4148 code += QStringLiteral(
"polygon " );
4152 code += QStringLiteral(
"table " );
4160 return code.trimmed();
4176 return p->defaultVectorFileExtension(
hasGeometry() );
4183 return settings.
value( QStringLiteral(
"Processing/DefaultOutputVectorLayerExt" ), QStringLiteral(
"shp" ),
QgsSettings::Core ).toString();
4187 return QStringLiteral(
"dbf" );
4194 switch ( outputType )
4198 QString code = QStringLiteral(
"QgsProcessingParameterFeatureSink('%1', '%2'" ).arg(
name(),
description() );
4200 code += QStringLiteral(
", optional=True" );
4204 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4226 return p->supportedOutputVectorLayerExtensions();
4228 return p->supportedOutputTableExtensions();
4243 switch ( mDataType )
4269 map.insert( QStringLiteral(
"data_type" ), mDataType );
4283 return QStringLiteral(
"memory:%1" ).arg(
description() );
4291 QString def = definition;
4292 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
4297 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
4302 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
4307 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
4328 QVariant var = input;
4329 if ( !var.isValid() )
4351 if ( var.type() != QVariant::String )
4354 if ( var.toString().isEmpty() )
4362 if ( !value.isValid() )
4363 return QStringLiteral(
"None" );
4366 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4377 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4397 return p->defaultRasterFileExtension();
4402 return settings.
value( QStringLiteral(
"Processing/DefaultOutputRasterLayerExt" ), QStringLiteral(
"tif" ),
QgsSettings::Core ).toString();
4414 return p->supportedOutputRasterLayerExtensions();
4430 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
4442 QVariant var = input;
4443 if ( !var.isValid() )
4465 if ( var.type() != QVariant::String )
4468 if ( var.toString().isEmpty() )
4478 if ( !value.isValid() )
4479 return QStringLiteral(
"None" );
4482 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4493 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4502 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
4514 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
4515 return QStringLiteral(
"file" );
4518 QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
4519 QRegularExpressionMatch match = rx.match( mFileFilter );
4520 if ( !match.hasMatch() )
4521 return QStringLiteral(
"file" );
4523 return match.captured( 1 );
4528 switch ( outputType )
4532 QString code = QStringLiteral(
"QgsProcessingParameterFileDestination('%1', '%2'" ).arg(
name(),
description() );
4534 code += QStringLiteral(
", optional=True" );
4538 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4561 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
4568 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
4589 QVariant var = input;
4590 if ( !var.isValid() )
4606 if ( var.type() != QVariant::String )
4609 if ( var.toString().isEmpty() )
4632 , mCreateByDefault( createByDefault )
4640 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
4641 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
4648 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
4649 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
4655 switch ( outputType )
4662 QString code = t->className() + QStringLiteral(
"('%1', '%2'" ).arg(
name(),
description() );
4664 code += QStringLiteral(
", optional=True" );
4666 code += QStringLiteral(
", createByDefault=%1" ).arg( mCreateByDefault ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4693 return mCreateByDefault;
4715 QVariant var = input;
4716 if ( !var.isValid() )
4738 if ( var.type() != QVariant::String )
4741 if ( var.toString().isEmpty() )
4749 if ( !value.isValid() )
4750 return QStringLiteral(
"None" );
4753 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4764 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4773 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4775 code += QStringLiteral(
"optional " );
4776 code += QStringLiteral(
"vectorDestination " );
4778 switch ( mDataType )
4781 code += QStringLiteral(
"point " );
4785 code += QStringLiteral(
"line " );
4789 code += QStringLiteral(
"polygon " );
4797 return code.trimmed();
4813 return p->defaultVectorFileExtension(
hasGeometry() );
4820 return settings.
value( QStringLiteral(
"Processing/DefaultOutputVectorLayerExt" ), QStringLiteral(
"shp" ),
QgsSettings::Core ).toString();
4824 return QStringLiteral(
"dbf" );
4831 switch ( outputType )
4835 QString code = QStringLiteral(
"QgsProcessingParameterVectorDestination('%1', '%2'" ).arg(
name(),
description() );
4837 code += QStringLiteral(
", optional=True" );
4841 code += QStringLiteral(
", createByDefault=%1" ).arg(
createByDefault() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
4863 return p->supportedOutputVectorLayerExtensions();
4865 return p->supportedOutputTableExtensions();
4880 switch ( mDataType )
4906 map.insert( QStringLiteral(
"data_type" ), mDataType );
4920 QString def = definition;
4921 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
4926 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
4931 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
4942 , mParentLayerParameterName( parentLayerParameterName )
4943 , mAllowMultiple( allowMultiple )
4955 if ( !input.isValid() )
4963 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
4965 if ( !mAllowMultiple )
4974 double res = input.toInt( &ok );
4984 return mAllowMultiple;
4994 if ( !value.isValid() )
4995 return QStringLiteral(
"None" );
4998 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
5000 if ( value.type() == QVariant::List )
5003 QVariantList values = value.toList();
5004 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
5006 parts << QString::number( static_cast< int >( it->toDouble() ) );
5008 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5010 else if ( value.type() == QVariant::StringList )
5013 QStringList values = value.toStringList();
5014 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
5016 parts << QString::number( static_cast< int >( it->toDouble() ) );
5018 return parts.join(
',' ).prepend(
'[' ).append(
']' );
5021 return value.toString();
5026 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
5028 code += QStringLiteral(
"optional " );
5029 code += QStringLiteral(
"band " );
5031 if ( mAllowMultiple )
5032 code += QStringLiteral(
"multiple " );
5034 code += mParentLayerParameterName +
' ';
5037 return code.trimmed();
5042 QStringList depends;
5043 if ( !mParentLayerParameterName.isEmpty() )
5044 depends << mParentLayerParameterName;
5050 switch ( outputType )
5054 QString code = QStringLiteral(
"QgsProcessingParameterBand('%1', '%2'" ).arg(
name(),
description() );
5056 code += QStringLiteral(
", optional=True" );
5058 code += QStringLiteral(
", parentLayerParameterName='%1'" ).arg( mParentLayerParameterName );
5059 code += QStringLiteral(
", allowMultiple=%1" ).arg( mAllowMultiple ? QStringLiteral(
"True" ) : QStringLiteral(
"False" ) );
5071 return mParentLayerParameterName;
5082 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
5083 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
5090 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
5091 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
5098 QString def = definition;
5101 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
5103 allowMultiple =
true;
5104 def = def.mid( 8 ).trimmed();
5107 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
5108 QRegularExpressionMatch m = re.match( def );
5111 parent = m.captured( 1 ).trimmed();
5112 def = m.captured( 2 );
5129 , mParentParameterName( parentParameterName )
5146 QStringList depends;
5147 if ( !mParentParameterName.isEmpty() )
5148 depends << mParentParameterName;
5154 switch ( outputType )
5158 QString code = QStringLiteral(
"QgsProcessingParameterDistance('%1', '%2'" ).arg(
name(),
description() );
5160 code += QStringLiteral(
", optional=True" );
5162 code += QStringLiteral(
", parentParameterName='%1'" ).arg( mParentParameterName );
5164 if (
minimum() != std::numeric_limits<double>::lowest() + 1 )
5165 code += QStringLiteral(
", minValue=%1" ).arg(
minimum() );
5166 if (
maximum() != std::numeric_limits<double>::max() )
5167 code += QStringLiteral(
", maxValue=%1" ).arg(
maximum() );
5178 return mParentParameterName;
5189 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
5190 map.insert( QStringLiteral(
"default_unit" ), static_cast< int >( mDefaultUnit ) );
5197 mParentParameterName = map.value( QStringLiteral(
"parent" ) ).toString();
QgsProcessingParameterDefinition(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterDefinition.
QgsProperty sink
Sink/layer definition.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsCoordinateReferenceSystem parameterAsCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a coordinate reference system.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
A boolean parameter for processing algorithms.
Class for parsing and evaluation of expressions (formerly called "search strings").
void setDataTypes(const QList< int > &types)
Sets the geometry types for sources acceptable by the parameter.
static QString typeName()
Returns the type name for the parameter class.
An input file or folder parameter for processing algorithms.
A parameter for processing algorithms which accepts multiple map layers.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
virtual QString asScriptCode() const
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...
A rectangle specified with double values.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
Base class for all map layer types.
static QString descriptionFromName(const QString &name)
Creates an autogenerated parameter description from a parameter name.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterRasterLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static QString typeName()
Returns the type name for the parameter class.
Base class for providing feedback from a processing algorithm.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
virtual bool fromVariantMap(const QVariantMap &map)
Restores 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...
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.
static QVariantList parameterAsMatrix(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a matrix/table of values.
virtual QStringList supportedOutputTableExtensions() const
Returns a list of the table (geometry-less vector layers) file extensions supported by this provider...
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString type() const override
Unique parameter type name.
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
bool hasFixedNumberRows() const
Returns whether the table has a fixed number of rows.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
bool createFromString(const QString &definition)
Set up this CRS from a string definition.
QString type() const override
Unique parameter type name.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
A vector layer or feature source field parameter for processing algorithms.
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 QgsProcessingParameterExtent * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
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.
DataType dataType() const
Returns the acceptable data type for the field.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString type() const override
Unique parameter type name.
This class is a composition of two QSettings instances:
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported for this parameter. ...
void setHasFixedNumberRows(bool hasFixedNumberRows)
Sets whether the table has a fixed number of rows.
QgsProcessingParameterMultipleLayers(const QString &name, const QString &description=QString(), QgsProcessing::SourceType layerType=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMultipleLayers.
QgsProcessingParameterExpression(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false)
Constructor for QgsProcessingParameterExpression.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterRange(const QString &name, const QString &description=QString(), QgsProcessingParameterNumber::Type type=QgsProcessingParameterNumber::Integer, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRange.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
QgsProcessingParameterFeatureSource(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFeatureSource.
void setDataType(QgsProcessingParameterNumber::Type dataType)
Sets the acceptable data type for the range.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
static QString typeName()
Returns the type name for the parameter class.
LayerHint
Layer type hints.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QString typeName()
Returns the type name for the parameter class.
QString type() const override
Unique parameter type name.
A map layer 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 checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QStringList headers() const
Returns a list of column headers (if set).
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
A class to represent a 2D point.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
A HTML file output for processing algorithms.
QgsProcessingProvider * provider() const
Returns a pointer to the provider for the algorithm which owns this parameter.
An expression parameter for processing algorithms.
A QgsPointXY with associated coordinate reference system.
static QString typeName()
Returns the type name for the parameter class.
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.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
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...
QgsProcessingParameterString(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool multiLine=false, bool optional=false)
Constructor for QgsProcessingParameterString.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool createByDefault() const
Returns true if the destination should be created by default.
An interface for objects which accept features via addFeature(s) methods.
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...
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...
PythonOutputType
Available Python output types.
QgsProcessingProvider * originalProvider() const
Original (source) provider which this parameter has been derived from.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
QgsProcessingAlgorithm * mAlgorithm
Pointer to algorithm which owns this parameter.
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported by this provider.
static QString typeName()
Returns the type name for the parameter class.
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap mMetadata
Freeform metadata for parameter. Mostly used by widget wrappers to customize their appearance and beh...
double minimum() const
Returns the minimum value acceptable by the parameter.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource, modifying results according to the settings in a QgsProcessingContext.
Container of fields for a vector layer.
static QgsProcessingParameterCrs * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
A geometry is the spatial representation of a feature.
static QgsMapLayer * parameterAsLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a map layer.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
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.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Abstract base class for processing providers.
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
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...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QgsProcessingParameterMapLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMapLayer.
A raster band parameter for Processing algorithms.
QString type() const override
Unique parameter type name.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
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...
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.
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 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 QgsProcessingParameterDefinition * parameterFromVariantMap(const QVariantMap &map)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied variant map...
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.
QgsProcessingParameterBoolean(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterBoolean.
QString type() const override
Unique parameter type name.
QgsProcessingParameterType * parameterType(const QString &id) const
Returns the parameter type registered for id.
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.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
const QgsCoordinateReferenceSystem & crs
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 convertToCompatibleFormat(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback)
Converts a source vector layer to a file path to a vector layer of compatible format.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setMaximum(double maximum)
Sets the maximum value acceptable by the parameter.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
static QString normalizeLayerSource(const QString &source)
Normalizes a layer source string for safe comparison across different operating system environments...
static QgsVectorLayer * parameterAsVectorLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a vector layer.
Base class for all parameter definitions which represent file or layer destinations, e.g.
Abstract base class for processing algorithms.
static QgsPointXY parameterAsPoint(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a point.
A vector layer output for processing algorithms.
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.
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 QString parameterAsFile(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file/folder name.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
A feature sink output 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 fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of map layers.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
Files (i.e. non map layer sources, such as text files)
bool selectedFeaturesOnly
True if only selected features in the source should be used by algorithms.
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...
virtual QgsRectangle extent() const
Returns the extent of the layer.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
int minimumNumberInputs() const
Returns the minimum number of layers required for the parameter.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
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.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessing::SourceType layerType() const
Returns the layer type for layers acceptable by the parameter.
static QgsGeometry parameterAsExtentGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent, and returns a geometry cove...
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
static QString typeName()
Returns the type name for the parameter class.
A numeric range parameter for processing algorithms.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
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.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
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.
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
QgsProcessingParameterCrs(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCrs.
QVariant toVariant() const
Saves this property to a QVariantMap, wrapped in a QVariant.
QList< int > dataTypes() const
Returns the geometry types for sources acceptable by the parameter.
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.
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set...
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterFolderDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFolderDestination.
static QString typeName()
Returns the type name for the parameter class.
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap(), QgsFeatureSink::SinkFlags sinkFlags=nullptr)
Creates a feature sink ready for adding features.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Can be inherited by parameters which require limits to their acceptable data types.
A raster layer parameter for processing algorithms.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterFeatureSink(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFeatureSink.
QgsProcessingParameterFile(const QString &name, const QString &description=QString(), Behavior behavior=File, const QString &extension=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFile.
Type
The WKB type describes the number of dimensions a geometry has.
static QStringList supportedFormatExtensions(RasterFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats.
virtual QString toolTip() const
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
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.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value. ...
QString valueAsString(const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a string.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
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=nullptr)
Evaluates the parameter with matching definition to a feature sink.
QgsProperty source
Source definition.
virtual QgsProcessingParameterDefinition * create(const QString &name) const =0
Creates a new parameter of this type.
Type propertyType() const
Returns the property 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...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
An enum based parameter for processing algorithms, allowing for selection from predefined values...
bool loadVariant(const QVariant &property)
Loads this property from a QVariantMap, wrapped in a QVariant.
void setMinimum(double minimum)
Sets the minimum value acceptable by the parameter.
Flags flags() const
Returns any flags associated with the parameter.
QgsProcessing::SourceType dataType() const
Returns the layer type for this created vector layer.
static QString typeName()
Returns the type name for the parameter class.
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.
QVariant defaultValue() const
Returns the default value for the parameter.
bool hasGeometry() const
Returns true if the created layer is likely to include geometries.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDistance * clone() const override
Creates a clone of the parameter definition.
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...
bool allowMultiple() const
Returns whether multiple band selections are permitted.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
virtual QString defaultRasterFileExtension() const
Returns the default file extension to use for raster outputs created by the provider.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
A double numeric parameter for distance values.
A file output for processing algorithms.
QgsCoordinateReferenceSystem crs
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).
QgsProcessingDestinationParameter(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingDestinationParameter.
QString parentParameterName() const
Returns the name of the parent 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...
QgsProcessingAlgorithm * algorithm() const
Returns a pointer to the algorithm which owns this parameter.
Parameter is a single file.
static const QString TEMPORARY_OUTPUT
Constant used to indicate that a Processing algorithm output should be a temporary layer/file...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
static QList< double > parameterAsRange(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a range of values.
QString type() const override
Unique parameter type name.
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.
static QStringList supportedFormatExtensions(VectorFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats, e.g "shp", "gpkg".
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
virtual QString type() const =0
Unique parameter type name.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
Reads and writes project states.
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.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
A vector layer (with or without geometry) parameter for processing algorithms.
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.
bool multiLine() const
Returns true if the parameter allows multiline strings.
virtual QString defaultFileExtension() const =0
Returns the default file extension for destination file paths associated with this parameter...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
void setParentParameterName(const QString &parentParameterName)
Sets the name of the parent layer parameter.
QStringList options() const
Returns the list of acceptable options for the parameter.
A QgsRectangle with associated coordinate reference system.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
A mesh layer parameter for processing algorithms.
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.
A coordinate reference system parameter for processing algorithms.
static QgsProcessingFeatureSource * variantToSource(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a new feature source.
A store for object properties.
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...
A rectangular map extent parameter for processing algorithms.
void setMinimumNumberInputs(int minimum)
Sets the minimum number of layers required for 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...
void setLayerType(QgsProcessing::SourceType type)
Sets the layer type for layers acceptable by the parameter.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple band selections are permitted.
Details for layers to load into projects.
void setAllowMultiple(bool allowMultiple)
Sets whether the parameter allows multiple selected values.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A numeric parameter for processing algorithms.
bool loadVariant(const QVariantMap &map)
Loads this output layer definition from a QVariantMap, wrapped in a QVariant.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
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.
QgsExpressionContext & expressionContext()
Returns the expression context.
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...
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.
void setOptions(const QStringList &options)
Sets the list of acceptable options for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QString name() const
Returns the name of 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...
QList< int > mDataTypes
List of acceptable data types for the parameter.
Encapsulates settings relating to a feature source input to a processing algorithm.
void setMultiLine(bool multiLine)
Sets whether the parameter allows multiline strings.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
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...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool supportsNonFileBasedOutput() const
Returns true if the destination parameter supports non filed-based outputs, such as memory layers or ...
Behavior behavior() const
Returns the parameter behavior (e.g.
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.
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.
static QString generateTempFilename(const QString &basename)
Returns a temporary filename for a given file, putting it into a temporary folder (creating that fold...
QString type() const override
Unique parameter type name.
DistanceUnit
Units of distance.
QVariant toVariant() const
Saves this output layer definition to a QVariantMap, wrapped in a QVariant.
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...
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
virtual QString defaultVectorFileExtension(bool hasGeometry=true) const
Returns the default file extension to use for vector outputs created by the provider.
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.
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.
Base class for the definition of processing outputs.
void setCreateByDefault(bool createByDefault)
Sets whether the destination should be created by default.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessing::SourceType dataType() const
Returns the layer type for sinks associated with the parameter.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
QgsProcessingParameterLimitedDataTypes(const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterLimitedDataTypes, with a list of acceptable data types...
void setNumberRows(int rows)
Sets the fixed number of rows in the table.
A vector layer destination parameter, for specifying the destination path for a vector layer created ...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
A point parameter for processing algorithms.
static QgsMeshLayer * parameterAsMeshLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition and value to a mesh layer.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
void setDataType(DataType type)
Sets the acceptable data type for the field.
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 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 asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
static QgsProcessingParameterString * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString source() const
Returns the source for the 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...
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
An input feature source (such as vector layers) parameter for processing algorithms.
A folder destination parameter, for specifying the destination path for a folder created by the algor...
int valueAsInt(const QgsExpressionContext &context, int defaultValue=0, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as an integer.
QString destinationName
Name to use for sink if it's to be loaded into a destination project.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Flags mFlags
Parameter flags.
static QString typeName()
Returns the type name for the parameter class.
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.
Any map layer type (raster or vector or mesh)
Makes metadata of processing parameters available.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
QgsProject * destinationProject
Destination project.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
This class represents a coordinate reference system (CRS).
int numberRows() const
Returns the fixed number of rows in the table.
Base class for the definition of processing parameters.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
static QgsProcessingParameterDefinition * parameterFromScriptCode(const QString &code)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied script code st...
QVariant staticValue() const
Returns the current static value for the property.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
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 double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
QVariant mDefault
Default value for parameter.
SourceType
Data source types enum.
static QString parameterAsOutputLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output layer destination.
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.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString typeName()
Returns the type name for the parameter class.
QString mName
Parameter name.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
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...
QgsProcessingParameterMeshLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMeshLayer.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
Represents a mesh layer supporting display of data on structured or unstructured meshes.
static QString typeName()
Returns the type name for the parameter class.
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
Behavior
Parameter behavior.
virtual QString generateTemporaryDestination() const
Generates a temporary destination value for this parameter.
A folder output for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
DataType
Field data types.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterPoint * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterPoint(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterPoint.
A table (matrix) parameter for processing algorithms.
Full Python QgsProcessingAlgorithm subclass.
Custom exception class for Coordinate Reference System related exceptions.
Type dataType() const
Returns the acceptable data type for the parameter.
QString type() const override
Unique parameter type name.
A string parameter for authentication configuration configuration ID values.
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.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this provider.
QString mDescription
Parameter description.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter. ...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, LayerHint typeHint=UnknownType)
Interprets a string as a map layer within the supplied context.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString 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...
bool hasGeometry() const
Returns true if sink is likely to include geometries.
QgsProcessingParameterAuthConfig(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterAuthConfig.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterExtent(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterExtent.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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)
Constructor for QgsProcessingParameterField.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Processing script...
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.
Represents a vector layer which manages a vector based data sets.
static QString parameterAsExpression(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to an expression.
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...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Invalid (not set) property.
Contains information about the context in which a processing algorithm is executed.
static QString sourceTypeToString(SourceType type)
Converts a source type to a string representation.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this 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...
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the created vector layer.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A string parameter for processing algorithms.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString description() const
Returns the description for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
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...
QgsProcessingParameterVectorLayer(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterVectorLayer.
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the sinks associated with the parameter.
Any vector layer with geometry.
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
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.
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.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
QString authid() const
Returns the authority identifier for the CRS.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
QString generateTemporaryDestination() const override
Generates a temporary destination value for this parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsCoordinateReferenceSystem crs
QgsProcessingParameterRasterLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRasterLayer.
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.
double maximum() const
Returns the maximum value acceptable by the parameter.
QVariantMap createOptions
Map of optional sink/layer creation options, which are passed to the underlying provider when creatin...
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.
QgsProcessingParameterRasterDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterRasterDestination.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
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.
A raster layer output for processing algorithms.
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers, algorithms, and various parameters and outputs.
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.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
static QStringList parameterAsFields(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of fields.
void setHeaders(const QStringList &headers)
Sets the list of column headers.