40 map.insert( QStringLiteral(
"create_options" ),
createOptions );
47 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
53 QVariant val = parameters.value( name );
65 return parameterAsString( definition, parameters.value( definition->
name() ), context );
83 return val.toString();
91 return parameterAsExpression( definition, parameters.value( definition->
name() ), context );
103 if ( val.isValid() && !val.toString().isEmpty() )
107 return val.toString();
119 return parameterAsDouble( definition, parameters.value( definition->
name() ), context );
127 QVariant val = value;
132 double res = val.toDouble( &ok );
138 return val.toDouble();
146 return parameterAsInt( definition, parameters.value( definition->
name() ), context );
154 QVariant val = value;
159 double dbl = val.toDouble( &ok );
164 dbl = val.toDouble( &ok );
171 double round = std::round( dbl );
172 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
177 return static_cast< int >( std::round( dbl ) );
186 return QList< int >();
188 return parameterAsInts( definition, parameters.value( definition->
name() ), context );
194 return QList< int >();
196 QList< int > resultList;
197 QVariant val = value;
202 else if ( val.type() == QVariant::List )
204 QVariantList list = val.toList();
205 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
206 resultList << it->toInt();
210 QStringList parts = val.toString().split(
';' );
211 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
212 resultList << it->toInt();
216 if ( ( resultList.isEmpty() || resultList.at( 0 ) == 0 ) )
222 if ( definition->
defaultValue().type() == QVariant::List )
224 QVariantList list = definition->
defaultValue().toList();
225 for (
auto it = list.constBegin(); it != list.constEnd(); ++it )
226 resultList << it->toInt();
230 QStringList parts = definition->
defaultValue().toString().split(
';' );
231 for (
auto it = parts.constBegin(); it != parts.constEnd(); ++it )
232 resultList << it->toInt();
245 return parameterAsEnum( definition, parameters.value( definition->
name() ), context );
253 int val = parameterAsInt( definition, value, context );
255 if ( enumDef && val >= enumDef->
options().size() )
267 QVariantList resultList;
268 return parameterAsEnums( definition, parameters.value( definition->
name() ), context );
276 QVariantList resultList;
277 QVariant val = value;
280 else if ( val.type() == QVariant::List )
282 Q_FOREACH (
const QVariant &var, val.toList() )
285 else if ( val.type() == QVariant::String )
287 Q_FOREACH (
const QString &var, val.toString().split(
',' ) )
293 if ( resultList.isEmpty() )
294 return QList< int >();
296 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
300 if ( definition->
defaultValue().type() == QVariant::List )
302 Q_FOREACH (
const QVariant &var, definition->
defaultValue().toList() )
305 else if ( definition->
defaultValue().type() == QVariant::String )
307 Q_FOREACH (
const QString &var, definition->
defaultValue().toString().split(
',' ) )
316 Q_FOREACH (
const QVariant &var, resultList )
318 int resInt = var.toInt();
319 if ( !enumDef || resInt < enumDef->options().size() )
332 return parameterAsBool( definition, parameters.value( definition->
name() ), context );
342 QVariant val = value;
345 else if ( val.isValid() )
353 QgsProcessingContext &context, QString &destinationIdentifier, QgsFeatureSink::SinkFlags sinkFlags )
358 val = parameters.value( definition->
name() );
361 return parameterAsSink( definition, val, fields, geometryType, crs, context, destinationIdentifier, sinkFlags );
366 QVariant val = value;
387 else if ( !val.isValid() || val.toString().isEmpty() )
399 dest = val.toString();
402 if ( dest.isEmpty() )
406 destinationIdentifier = dest;
408 if ( destinationProject )
410 if ( destName.isEmpty() && definition )
416 outputName = definition->
name();
420 return sink.release();
428 return parameterAsSource( definition, parameters.value( definition->
name() ), context );
444 QVariant val = parameters.value( definition->
name() );
446 bool selectedFeaturesOnly =
false;
467 vl = qobject_cast<
QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
476 else if ( !val.isValid() || val.toString().isEmpty() )
482 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
488 layerRef = val.toString();
493 if ( layerRef.isEmpty() )
504 compatibleFormats, preferredFormat, context, feedback );
513 return parameterAsLayer( definition, parameters.value( definition->
name() ), context );
521 QVariant val = value;
527 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
544 if ( !val.isValid() || val.toString().isEmpty() )
550 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
555 QString layerRef = val.toString();
556 if ( layerRef.isEmpty() )
559 if ( layerRef.isEmpty() )
567 return qobject_cast<
QgsRasterLayer *>( parameterAsLayer( definition, parameters, context ) );
572 return qobject_cast<
QgsRasterLayer *>( parameterAsLayer( definition, value, context ) );
580 val = parameters.value( definition->
name() );
582 return parameterAsOutputLayer( definition, val, context );
587 QVariant val = value;
607 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
614 dest = val.toString();
617 if ( destinationProject )
620 if ( destName.isEmpty() && definition )
625 outputName = definition->
name();
644 val = parameters.value( definition->
name() );
646 return parameterAsFileOutput( definition, val, context );
651 QVariant val = value;
665 else if ( !val.isValid() || val.toString().isEmpty() )
672 dest = val.toString();
680 return qobject_cast<
QgsVectorLayer *>( parameterAsLayer( definition, parameters, context ) );
685 return qobject_cast<
QgsVectorLayer *>( parameterAsLayer( definition, value, context ) );
693 return parameterAsCrs( definition, parameters.value( definition->
name() ), context );
701 QVariant val = value;
727 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
733 if ( !val.isValid() )
739 QString crsText = val.toString();
740 if ( crsText.isEmpty() )
743 if ( crsText.isEmpty() )
747 if ( context.
project() && crsText.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
766 return parameterAsExtent( definition, parameters.value( definition->
name() ), context, crs );
774 QVariant val = value;
823 rectText = val.toString();
825 if ( rectText.isEmpty() && !layer )
828 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
829 QRegularExpressionMatch match = rx.match( rectText );
830 if ( match.hasMatch() )
833 double xMin = match.captured( 1 ).toDouble( &xMinOk );
835 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
837 double yMin = match.captured( 3 ).toDouble( &yMinOk );
839 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
840 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
844 if ( crs.
isValid() && rectCrs.isValid() && crs != rectCrs )
889 QVariant val = parameters.value( definition->
name() );
897 g = g.densifyByCount( 20 );
933 rectText = val.toString();
935 if ( !rectText.isEmpty() )
937 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
938 QRegularExpressionMatch match = rx.match( rectText );
939 if ( match.hasMatch() )
942 double xMin = match.captured( 1 ).toDouble( &xMinOk );
944 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
946 double yMin = match.captured( 3 ).toDouble( &yMinOk );
948 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
949 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
954 if ( crs.
isValid() && rectCrs.isValid() && crs != rectCrs )
956 g = g.densifyByCount( 20 );
1004 QVariant val = parameters.value( definition->
name() );
1033 QString valueAsString;
1037 valueAsString = val.toString();
1039 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1041 QRegularExpressionMatch match = rx.match( valueAsString );
1042 if ( match.hasMatch() )
1068 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1069 return layer->crs();
1071 return layer->crs();
1084 return parameterAsPoint( definition, parameters.value( definition->
name() ), context, crs );
1092 QVariant val = value;
1115 QString pointText = parameterAsString( definition, value, context );
1116 if ( pointText.isEmpty() )
1119 if ( pointText.isEmpty() )
1122 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1124 QString valueAsString = parameterAsString( definition, value, context );
1125 QRegularExpressionMatch match = rx.match( valueAsString );
1126 if ( match.hasMatch() )
1129 double x = match.captured( 1 ).toDouble( &xOk );
1131 double y = match.captured( 2 ).toDouble( &yOk );
1138 if ( crs.
isValid() && pointCrs.isValid() && crs != pointCrs )
1159 QVariant val = parameters.value( definition->
name() );
1170 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1172 QString valueAsString = parameterAsString( definition, parameters, context );
1173 QRegularExpressionMatch match = rx.match( valueAsString );
1174 if ( match.hasMatch() )
1192 QString fileText = parameterAsString( definition, parameters, context );
1193 if ( fileText.isEmpty() )
1203 QString fileText = parameterAsString( definition, value, context );
1204 if ( fileText.isEmpty() )
1212 return QVariantList();
1214 return parameterAsMatrix( definition, parameters.value( definition->
name() ), context );
1220 return QVariantList();
1222 QString resultString;
1223 QVariant val = value;
1226 else if ( val.type() == QVariant::List )
1227 return val.toList();
1229 resultString = val.toString();
1231 if ( resultString.isEmpty() )
1234 if ( definition->
defaultValue().type() == QVariant::List )
1240 QVariantList result;
1241 Q_FOREACH (
const QString &s, resultString.split(
',' ) )
1250 return QList<QgsMapLayer *>();
1252 return parameterAsLayerList( definition, parameters.value( definition->
name() ), context );
1258 return QList<QgsMapLayer *>();
1260 QVariant val = value;
1261 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
1263 return QList<QgsMapLayer *>() << layer;
1266 QList<QgsMapLayer *> layers;
1268 std::function< void( const QVariant &var ) > processVariant;
1269 processVariant = [ &layers, &context, &definition, &processVariant ](
const QVariant & var )
1271 if ( var.type() == QVariant::List )
1273 Q_FOREACH (
const QVariant &listVar, var.toList() )
1275 processVariant( listVar );
1278 else if ( var.type() == QVariant::StringList )
1280 Q_FOREACH (
const QString &s, var.toStringList() )
1282 processVariant( s );
1286 processVariant( var.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1294 processVariant( sink.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() ) );
1297 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1309 processVariant( val );
1311 if ( layers.isEmpty() )
1314 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->defaultValue() ) ) )
1318 else if ( definition->defaultValue().type() == QVariant::List )
1320 Q_FOREACH (
const QVariant &var, definition->defaultValue().toList() )
1322 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1328 processVariant( var );
1333 processVariant( definition->defaultValue() );
1342 return QList<double>();
1344 return parameterAsRange( definition, parameters.value( definition->
name() ), context );
1350 return QList<double>();
1352 QStringList resultStringList;
1353 QVariant val = value;
1356 else if ( val.type() == QVariant::List )
1358 Q_FOREACH (
const QVariant &var, val.toList() )
1359 resultStringList << var.toString();
1362 resultStringList << val.toString();
1364 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1366 resultStringList.clear();
1368 if ( definition->
defaultValue().type() == QVariant::List )
1370 Q_FOREACH (
const QVariant &var, definition->
defaultValue().toList() )
1371 resultStringList << var.toString();
1374 resultStringList << definition->
defaultValue().toString();
1377 if ( resultStringList.size() == 1 )
1379 resultStringList = resultStringList.at( 0 ).split(
',' );
1382 if ( resultStringList.size() < 2 )
1383 return QList< double >() << 0.0 << 0.0;
1385 return QList< double >() << resultStringList.at( 0 ).toDouble() << resultStringList.at( 1 ).toDouble();
1391 return QStringList();
1393 QStringList resultStringList;
1394 return parameterAsFields( definition, parameters.value( definition->
name() ), context );
1400 return QStringList();
1402 QStringList resultStringList;
1403 QVariant val = value;
1404 if ( val.isValid() )
1408 else if ( val.type() == QVariant::List )
1410 Q_FOREACH (
const QVariant &var, val.toList() )
1411 resultStringList << var.toString();
1414 resultStringList.append( val.toString().split(
';' ) );
1417 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
1419 resultStringList.clear();
1423 if ( definition->
defaultValue().type() == QVariant::List )
1425 Q_FOREACH (
const QVariant &var, definition->
defaultValue().toList() )
1426 resultStringList << var.toString();
1429 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
1433 return resultStringList;
1438 QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
1439 QString name = map.value( QStringLiteral(
"name" ) ).toString();
1440 std::unique_ptr< QgsProcessingParameterDefinition > def;
1491 def.reset( paramType->
create( name ) );
1497 def->fromVariantMap( map );
1498 return def.release();
1503 QString desc = name;
1504 desc.replace(
'_',
' ' );
1510 bool isOptional =
false;
1514 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
1517 QString description = descriptionFromName( name );
1519 if ( type == QStringLiteral(
"boolean" ) )
1521 else if ( type == QStringLiteral(
"crs" ) )
1523 else if ( type == QStringLiteral(
"layer" ) )
1525 else if ( type == QStringLiteral(
"extent" ) )
1527 else if ( type == QStringLiteral(
"point" ) )
1529 else if ( type == QStringLiteral(
"file" ) )
1531 else if ( type == QStringLiteral(
"folder" ) )
1533 else if ( type == QStringLiteral(
"matrix" ) )
1535 else if ( type == QStringLiteral(
"multiple" ) )
1537 else if ( type == QStringLiteral(
"number" ) )
1539 else if ( type == QStringLiteral(
"range" ) )
1541 else if ( type == QStringLiteral(
"raster" ) )
1543 else if ( type == QStringLiteral(
"enum" ) )
1545 else if ( type == QStringLiteral(
"string" ) )
1547 else if ( type == QStringLiteral(
"expression" ) )
1549 else if ( type == QStringLiteral(
"field" ) )
1551 else if ( type == QStringLiteral(
"vector" ) )
1553 else if ( type == QStringLiteral(
"source" ) )
1555 else if ( type == QStringLiteral(
"sink" ) )
1557 else if ( type == QStringLiteral(
"vectordestination" ) )
1559 else if ( type == QStringLiteral(
"rasterdestination" ) )
1561 else if ( type == QStringLiteral(
"filedestination" ) )
1563 else if ( type == QStringLiteral(
"folderdestination" ) )
1565 else if ( type == QStringLiteral(
"band" ) )
1571 bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
1573 QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
1574 QRegularExpressionMatch m = re.match( code );
1575 if ( !m.hasMatch() )
1578 name = m.captured( 1 );
1579 QString tokens = m.captured( 2 );
1580 if ( tokens.startsWith( QLatin1String(
"optional" ), Qt::CaseInsensitive ) )
1583 tokens.remove( 0, 8 );
1590 tokens = tokens.trimmed();
1592 QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
1593 m = re2.match( tokens );
1594 if ( !m.hasMatch() )
1596 type = tokens.toLower().trimmed();
1601 type = m.captured( 1 ).toLower().trimmed();
1602 definition = m.captured( 2 );
1613 , mDescription( description )
1614 , mDefault( defaultValue )
1615 , mFlags( optional ? FlagOptional : 0 )
1620 if ( !input.isValid() && !
mDefault.isValid() )
1623 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
1624 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
1632 if ( !value.isValid() )
1633 return QStringLiteral(
"None" );
1636 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1643 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1645 code += QStringLiteral(
"optional " );
1646 code +=
type() +
' ';
1648 return code.trimmed();
1654 map.insert( QStringLiteral(
"parameter_type" ),
type() );
1655 map.insert( QStringLiteral(
"name" ),
mName );
1656 map.insert( QStringLiteral(
"description" ),
mDescription );
1657 map.insert( QStringLiteral(
"default" ),
mDefault );
1658 map.insert( QStringLiteral(
"flags" ), static_cast< int >(
mFlags ) );
1659 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
1665 mName = map.value( QStringLiteral(
"name" ) ).toString();
1666 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
1667 mDefault = map.value( QStringLiteral(
"default" ) );
1668 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
1669 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
1685 return QStringLiteral(
"<p><b>%1</b></p><p>%2</p>" ).arg(
1687 QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
1701 if ( !val.isValid() )
1702 return QStringLiteral(
"None" );
1706 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
1711 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1713 code += QStringLiteral(
"optional " );
1714 code +=
type() +
' ';
1715 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
1716 return code.trimmed();
1737 if ( !input.isValid() )
1759 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1762 if ( input.type() != QVariant::String || input.toString().isEmpty() )
1770 if ( !value.isValid() )
1771 return QStringLiteral(
"None" );
1776 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
1782 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1785 p.insert(
name(), value );
1795 return new QgsProcessingParameterCrs( name, description, definition.compare( QLatin1String(
"none" ), Qt::CaseInsensitive ) == 0 ? QVariant() : definition, isOptional );
1811 if ( !input.isValid() )
1819 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1824 if ( input.type() != QVariant::String || input.toString().isEmpty() )
1842 if ( !val.isValid() )
1843 return QStringLiteral(
"None" );
1849 p.insert(
name(), val );
1873 if ( !input.isValid() )
1902 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1905 if ( input.type() != QVariant::String || input.toString().isEmpty() )
1914 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1915 QRegularExpressionMatch match = rx.match( input.toString() );
1916 if ( match.hasMatch() )
1918 bool xMinOk =
false;
1919 ( void )match.captured( 1 ).toDouble( &xMinOk );
1920 bool xMaxOk =
false;
1921 ( void )match.captured( 2 ).toDouble( &xMaxOk );
1922 bool yMinOk =
false;
1923 ( void )match.captured( 3 ).toDouble( &yMinOk );
1924 bool yMaxOk =
false;
1925 ( void )match.captured( 4 ).toDouble( &yMaxOk );
1926 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1936 if ( !value.isValid() )
1937 return QStringLiteral(
"None" );
1940 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1960 p.insert(
name(), value );
1986 if ( !input.isValid() )
2003 if ( input.type() == QVariant::String )
2005 if ( input.toString().isEmpty() )
2009 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
2011 QRegularExpressionMatch match = rx.match( input.toString() );
2012 if ( match.hasMatch() )
2015 ( void )match.captured( 1 ).toDouble( &xOk );
2017 ( void )match.captured( 2 ).toDouble( &yOk );
2026 if ( !value.isValid() )
2027 return QStringLiteral(
"None" );
2030 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2056 , mBehavior( behavior )
2057 , mExtension( extension )
2069 if ( !input.isValid() )
2077 QString
string = input.toString().trimmed();
2079 if ( input.type() != QVariant::String ||
string.isEmpty() )
2082 switch ( mBehavior )
2086 if ( !mExtension.isEmpty() )
2087 return string.endsWith( mExtension, Qt::CaseInsensitive );
2099 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2101 code += QStringLiteral(
"optional " );
2102 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
2104 return code.trimmed();
2110 map.insert( QStringLiteral(
"behavior" ), mBehavior );
2111 map.insert( QStringLiteral(
"extension" ), mExtension );
2118 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
2119 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
2130 , mHeaders( headers )
2131 , mNumberRows( numberRows )
2132 , mFixedNumberRows( fixedNumberRows )
2144 if ( !input.isValid() )
2147 if ( input.type() == QVariant::String )
2149 if ( input.toString().isEmpty() )
2153 else if ( input.type() == QVariant::List )
2155 if ( input.toList().isEmpty() )
2159 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
2169 if ( !value.isValid() )
2170 return QStringLiteral(
"None" );
2173 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2176 p.insert(
name(), value );
2180 Q_FOREACH (
const QVariant &v, list )
2182 if ( v.type() == QVariant::List )
2185 Q_FOREACH (
const QVariant &v2, v.toList() )
2187 if ( v2.isNull() || !v2.isValid() )
2188 parts2 << QStringLiteral(
"None" );
2189 else if ( v2.toString().isEmpty() )
2190 parts2 << QStringLiteral(
"''" );
2192 parts2 << v2.toString();
2194 parts << parts2.join(
',' ).prepend(
'[' ).append(
']' );
2198 if ( v.isNull() || !v.isValid() )
2199 parts << QStringLiteral(
"None" );
2200 else if ( v.toString().isEmpty() )
2201 parts << QStringLiteral(
"''" );
2203 parts << v.toString();
2207 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2232 return mFixedNumberRows;
2237 mFixedNumberRows = fixedNumberRows;
2243 map.insert( QStringLiteral(
"headers" ), mHeaders );
2244 map.insert( QStringLiteral(
"rows" ), mNumberRows );
2245 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
2252 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
2253 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
2254 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
2260 return new QgsProcessingParameterMatrix( name, description, 0,
false, QStringList(), definition.isEmpty() ? QVariant() : definition, isOptional );
2265 , mLayerType( layerType )
2277 if ( !input.isValid() )
2280 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
2285 if ( input.type() == QVariant::String )
2287 if ( input.toString().isEmpty() )
2290 if ( mMinimumNumberInputs > 1 )
2298 else if ( input.type() == QVariant::List )
2300 if ( input.toList().count() < mMinimumNumberInputs )
2303 if ( mMinimumNumberInputs > input.toList().count() )
2309 Q_FOREACH (
const QVariant &v, input.toList() )
2311 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
2319 else if ( input.type() == QVariant::StringList )
2321 if ( input.toStringList().count() < mMinimumNumberInputs )
2324 if ( mMinimumNumberInputs > input.toStringList().count() )
2330 Q_FOREACH (
const QString &v, input.toStringList() )
2342 if ( !value.isValid() )
2343 return QStringLiteral(
"None" );
2346 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2349 p.insert(
name(), value );
2351 if ( !list.isEmpty() )
2358 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2366 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2368 code += QStringLiteral(
"optional " );
2369 switch ( mLayerType )
2372 code += QStringLiteral(
"multiple raster" );
2376 code += QStringLiteral(
"multiple file" );
2380 code += QStringLiteral(
"multiple vector" );
2384 if (
mDefault.type() == QVariant::List )
2387 Q_FOREACH (
const QVariant &var,
mDefault.toList() )
2389 parts << var.toString();
2391 code += parts.join(
',' );
2393 else if (
mDefault.type() == QVariant::StringList )
2395 code +=
mDefault.toStringList().join(
',' );
2401 return code.trimmed();
2416 return mMinimumNumberInputs;
2428 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
2429 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
2437 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
2443 QString
type = definition;
2445 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2446 QRegularExpressionMatch m = re.match( definition );
2449 type = m.captured( 1 ).toLower().trimmed();
2450 defaultVal = m.captured( 2 );
2453 if ( type == QStringLiteral(
"vector" ) )
2455 else if ( type == QStringLiteral(
"raster" ) )
2457 else if ( type == QStringLiteral(
"file" ) )
2470 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg( name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
2481 QVariant input = value;
2482 if ( !input.isValid() )
2496 double res = input.toDouble( &ok );
2500 return !( res < mMin || res > mMax );
2505 if ( !value.isValid() )
2506 return QStringLiteral(
"None" );
2509 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2511 return value.toString();
2518 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
2519 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
2520 if ( mMax < std::numeric_limits<double>::max() )
2521 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
2523 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
2524 QString extra = parts.join( QStringLiteral(
"<br />" ) );
2525 if ( !extra.isEmpty() )
2526 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
2563 map.insert( QStringLiteral(
"min" ), mMin );
2564 map.insert( QStringLiteral(
"max" ), mMax );
2565 map.insert( QStringLiteral(
"data_type" ), mDataType );
2572 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
2573 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
2574 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
2581 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
2598 if ( !input.isValid() )
2606 if ( input.type() == QVariant::String )
2608 QStringList list = input.toString().split(
',' );
2609 if ( list.count() != 2 )
2612 list.at( 0 ).toDouble( &ok );
2614 list.at( 1 ).toDouble( &ok2 );
2619 else if ( input.type() == QVariant::List )
2621 if ( input.toList().count() != 2 )
2625 input.toList().at( 0 ).toDouble( &ok );
2627 input.toList().at( 1 ).toDouble( &ok2 );
2638 if ( !value.isValid() )
2639 return QStringLiteral(
"None" );
2642 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2645 p.insert(
name(), value );
2648 QStringList stringParts;
2649 Q_FOREACH (
double v, parts )
2651 stringParts << QString::number( v );
2653 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
2669 map.insert( QStringLiteral(
"data_type" ), mDataType );
2698 if ( !input.isValid() )
2706 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
2709 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2727 if ( !val.isValid() )
2728 return QStringLiteral(
"None" );
2734 p.insert(
name(), val );
2747 , mOptions( options )
2748 , mAllowMultiple( allowMultiple )
2760 QVariant input = value;
2761 if ( !input.isValid() )
2774 if ( input.type() == QVariant::List )
2776 if ( !mAllowMultiple )
2779 const QVariantList values = input.toList();
2783 for (
const QVariant &val : values )
2786 int res = val.toInt( &ok );
2789 else if ( res < 0 || res >= mOptions.count() )
2795 else if ( input.type() == QVariant::String )
2797 QStringList parts = input.toString().split(
',' );
2798 if ( parts.count() > 1 && !mAllowMultiple )
2801 Q_FOREACH (
const QString &part, parts )
2804 int res = part.toInt( &ok );
2807 else if ( res < 0 || res >= mOptions.count() )
2812 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
2815 int res = input.toInt( &ok );
2818 else if ( res >= 0 && res < mOptions.count() )
2826 if ( !value.isValid() )
2827 return QStringLiteral(
"None" );
2830 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2832 if ( value.type() == QVariant::List )
2835 Q_FOREACH (
const QVariant &val, value.toList() )
2837 parts << QString::number( static_cast< int >( val.toDouble() ) );
2839 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2841 else if ( value.type() == QVariant::String )
2843 QStringList parts = value.toString().split(
',' );
2844 if ( parts.count() > 1 )
2846 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2850 return QString::number( static_cast< int >( value.toDouble() ) );
2855 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2857 code += QStringLiteral(
"optional " );
2858 code += QStringLiteral(
"enum " );
2860 if ( mAllowMultiple )
2861 code += QStringLiteral(
"multiple " );
2863 code += mOptions.join(
';' ) +
' ';
2866 return code.trimmed();
2881 return mAllowMultiple;
2892 map.insert( QStringLiteral(
"options" ), mOptions );
2893 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
2900 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
2901 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
2908 bool multiple =
false;
2909 QString def = definition;
2910 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
2916 QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
2917 QRegularExpressionMatch m = re.match( def );
2918 QString values = def;
2921 values = m.captured( 1 ).trimmed();
2922 defaultVal = m.captured( 2 );
2925 return new QgsProcessingParameterEnum( name, description, values.split(
';' ), multiple, defaultVal.isEmpty() ? QVariant() : defaultVal, isOptional );
2930 , mMultiLine( multiLine )
2942 if ( !value.isValid() )
2943 return QStringLiteral(
"None" );
2946 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2948 QString s = value.toString();
2954 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2956 code += QStringLiteral(
"optional " );
2957 code += QStringLiteral(
"string " );
2960 code += QStringLiteral(
"long " );
2963 return code.trimmed();
2979 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
2986 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
2992 QString def = definition;
2994 if ( def.startsWith( QLatin1String(
"long" ), Qt::CaseInsensitive ) )
3000 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
3002 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
3006 if ( def == QStringLiteral(
"None" ) )
3007 defaultValue = QVariant();
3014 , mParentLayerParameterName( parentLayerParameterName )
3026 if ( !value.isValid() )
3027 return QStringLiteral(
"None" );
3030 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3032 QString s = value.toString();
3038 QStringList depends;
3039 if ( !mParentLayerParameterName.isEmpty() )
3040 depends << mParentLayerParameterName;
3046 return mParentLayerParameterName;
3057 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
3064 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
3105 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
3108 if ( var.type() != QVariant::String || var.toString().isEmpty() )
3126 if ( !val.isValid() )
3127 return QStringLiteral(
"None" );
3133 p.insert(
name(), val );
3157 map.insert( QStringLiteral(
"data_types" ), types );
3165 QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3166 Q_FOREACH (
const QVariant &val, values )
3180 , mParentLayerParameterName( parentLayerParameterName )
3182 , mAllowMultiple( allowMultiple )
3194 if ( !input.isValid() )
3202 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
3204 if ( !mAllowMultiple )
3210 else if ( input.type() == QVariant::String )
3212 if ( input.toString().isEmpty() )
3215 QStringList parts = input.toString().split(
';' );
3216 if ( parts.count() > 1 && !mAllowMultiple )
3221 if ( input.toString().isEmpty() )
3229 if ( !value.isValid() )
3230 return QStringLiteral(
"None" );
3233 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3235 if ( value.type() == QVariant::List )
3238 Q_FOREACH (
const QVariant &val, value.toList() )
3242 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3244 else if ( value.type() == QVariant::StringList )
3247 Q_FOREACH ( QString s, value.toStringList() )
3251 return parts.join(
',' ).prepend(
'[' ).append(
']' );
3259 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3261 code += QStringLiteral(
"optional " );
3262 code += QStringLiteral(
"field " );
3264 switch ( mDataType )
3267 code += QStringLiteral(
"numeric " );
3271 code += QStringLiteral(
"string " );
3275 code += QStringLiteral(
"datetime " );
3282 if ( mAllowMultiple )
3283 code += QStringLiteral(
"multiple " );
3285 code += mParentLayerParameterName +
' ';
3288 return code.trimmed();
3293 QStringList depends;
3294 if ( !mParentLayerParameterName.isEmpty() )
3295 depends << mParentLayerParameterName;
3301 return mParentLayerParameterName;
3321 return mAllowMultiple;
3332 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
3333 map.insert( QStringLiteral(
"data_type" ), mDataType );
3334 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
3341 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
3342 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
3343 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
3352 QString def = definition;
3354 if ( def.startsWith( QLatin1String(
"numeric " ), Qt::CaseInsensitive ) )
3359 else if ( def.startsWith( QLatin1String(
"string " ), Qt::CaseInsensitive ) )
3364 else if ( def.startsWith( QLatin1String(
"datetime " ), Qt::CaseInsensitive ) )
3370 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
3372 allowMultiple =
true;
3373 def = def.mid( 8 ).trimmed();
3376 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
3377 QRegularExpressionMatch m = re.match( def );
3380 parent = m.captured( 1 ).trimmed();
3381 def = m.captured( 2 );
3406 QVariant var = input;
3407 if ( !var.isValid() )
3434 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
3439 if ( var.type() != QVariant::String || var.toString().isEmpty() )
3457 if ( !value.isValid() )
3458 return QStringLiteral(
"None" );
3461 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3470 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition('%1', True)" ).arg( fromVar.
source.
staticValue().toString() );
3477 layerString = layer->source();
3485 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression('%1'), True)" ).arg( fromVar.
source.
asExpression() );
3489 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
source.
asExpression() );
3493 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
3498 QString layerString = value.toString();
3502 layerString = layer->source();
3509 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3511 code += QStringLiteral(
"optional " );
3512 code += QStringLiteral(
"source " );
3519 code += QStringLiteral(
"point " );
3523 code += QStringLiteral(
"line " );
3527 code += QStringLiteral(
"polygon " );
3534 return code.trimmed();
3551 map.insert( QStringLiteral(
"data_types" ), types );
3559 QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3560 Q_FOREACH (
const QVariant &val, values )
3570 QString def = definition;
3573 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
3579 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
3585 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
3610 QVariant var = input;
3611 if ( !var.isValid() )
3633 if ( var.type() != QVariant::String )
3636 if ( var.toString().isEmpty() )
3644 if ( !value.isValid() )
3645 return QStringLiteral(
"None" );
3648 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3659 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
3668 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3670 code += QStringLiteral(
"optional " );
3671 code += QStringLiteral(
"sink " );
3673 switch ( mDataType )
3676 code += QStringLiteral(
"point " );
3680 code += QStringLiteral(
"line " );
3684 code += QStringLiteral(
"polygon " );
3688 code += QStringLiteral(
"table " );
3696 return code.trimmed();
3712 return p->defaultVectorFileExtension(
hasGeometry() );
3719 return settings.
value( QStringLiteral(
"Processing/DefaultOutputVectorLayerExt" ), QStringLiteral(
"shp" ),
QgsSettings::Core ).toString();
3723 return QStringLiteral(
"dbf" );
3740 return p->supportedOutputVectorLayerExtensions();
3742 return p->supportedOutputTableExtensions();
3757 switch ( mDataType )
3782 map.insert( QStringLiteral(
"data_type" ), mDataType );
3796 return QStringLiteral(
"memory:%1" ).arg(
description() );
3804 QString def = definition;
3805 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
3810 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
3815 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
3820 else if ( def.startsWith( QLatin1String(
"table" ), Qt::CaseInsensitive ) )
3841 QVariant var = input;
3842 if ( !var.isValid() )
3864 if ( var.type() != QVariant::String )
3867 if ( var.toString().isEmpty() )
3875 if ( !value.isValid() )
3876 return QStringLiteral(
"None" );
3879 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3890 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
3910 return p->defaultRasterFileExtension();
3915 return settings.
value( QStringLiteral(
"Processing/DefaultOutputRasterLayerExt" ), QStringLiteral(
"tif" ),
QgsSettings::Core ).toString();
3927 return p->supportedOutputRasterLayerExtensions();
3943 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
3955 QVariant var = input;
3956 if ( !var.isValid() )
3978 if ( var.type() != QVariant::String )
3981 if ( var.toString().isEmpty() )
3991 if ( !value.isValid() )
3992 return QStringLiteral(
"None" );
3995 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4006 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4015 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
4027 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
4028 return QStringLiteral(
"file" );
4031 QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
4032 QRegularExpressionMatch match = rx.match( mFileFilter );
4033 if ( !match.hasMatch() )
4034 return QStringLiteral(
"file" );
4036 return match.captured( 1 );
4052 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
4059 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
4080 QVariant var = input;
4081 if ( !var.isValid() )
4097 if ( var.type() != QVariant::String )
4100 if ( var.toString().isEmpty() )
4123 , mCreateByDefault( createByDefault )
4131 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
4132 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
4139 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
4140 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
4158 return mCreateByDefault;
4180 QVariant var = input;
4181 if ( !var.isValid() )
4203 if ( var.type() != QVariant::String )
4206 if ( var.toString().isEmpty() )
4214 if ( !value.isValid() )
4215 return QStringLiteral(
"None" );
4218 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4229 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
4238 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4240 code += QStringLiteral(
"optional " );
4241 code += QStringLiteral(
"vectorDestination " );
4243 switch ( mDataType )
4246 code += QStringLiteral(
"point " );
4250 code += QStringLiteral(
"line " );
4254 code += QStringLiteral(
"polygon " );
4262 return code.trimmed();
4278 return p->defaultVectorFileExtension(
hasGeometry() );
4285 return settings.
value( QStringLiteral(
"Processing/DefaultOutputVectorLayerExt" ), QStringLiteral(
"shp" ),
QgsSettings::Core ).toString();
4289 return QStringLiteral(
"dbf" );
4306 return p->supportedOutputVectorLayerExtensions();
4308 return p->supportedOutputTableExtensions();
4323 switch ( mDataType )
4348 map.insert( QStringLiteral(
"data_type" ), mDataType );
4362 QString def = definition;
4363 if ( def.startsWith( QLatin1String(
"point" ), Qt::CaseInsensitive ) )
4368 else if ( def.startsWith( QLatin1String(
"line" ), Qt::CaseInsensitive ) )
4373 else if ( def.startsWith( QLatin1String(
"polygon" ), Qt::CaseInsensitive ) )
4384 , mParentLayerParameterName( parentLayerParameterName )
4385 , mAllowMultiple( allowMultiple )
4397 if ( !input.isValid() )
4405 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
4407 if ( !mAllowMultiple )
4416 double res = input.toInt( &ok );
4426 return mAllowMultiple;
4436 if ( !value.isValid() )
4437 return QStringLiteral(
"None" );
4440 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4442 if ( value.type() == QVariant::List )
4445 QVariantList values = value.toList();
4446 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
4448 parts << QString::number( static_cast< int >( it->toDouble() ) );
4450 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4452 else if ( value.type() == QVariant::StringList )
4455 QStringList values = value.toStringList();
4456 for (
auto it = values.constBegin(); it != values.constEnd(); ++it )
4458 parts << QString::number( static_cast< int >( it->toDouble() ) );
4460 return parts.join(
',' ).prepend(
'[' ).append(
']' );
4463 return value.toString();
4468 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4470 code += QStringLiteral(
"optional " );
4471 code += QStringLiteral(
"band " );
4473 if ( mAllowMultiple )
4474 code += QStringLiteral(
"multiple " );
4476 code += mParentLayerParameterName +
' ';
4479 return code.trimmed();
4484 QStringList depends;
4485 if ( !mParentLayerParameterName.isEmpty() )
4486 depends << mParentLayerParameterName;
4492 return mParentLayerParameterName;
4503 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
4504 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
4511 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
4512 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
4519 QString def = definition;
4522 if ( def.startsWith( QLatin1String(
"multiple" ), Qt::CaseInsensitive ) )
4524 allowMultiple =
true;
4525 def = def.mid( 8 ).trimmed();
4528 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
4529 QRegularExpressionMatch m = re.match( def );
4532 parent = m.captured( 1 ).trimmed();
4533 def = m.captured( 2 );
4550 , mParentParameterName( parentParameterName )
4567 QStringList depends;
4568 if ( !mParentParameterName.isEmpty() )
4569 depends << mParentParameterName;
4575 return mParentParameterName;
4586 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
4587 map.insert( QStringLiteral(
"default_unit" ), static_cast< int >( mDefaultUnit ) );
4594 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.
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.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
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...
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set...
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.
Base class for all map layer types.
static QString descriptionFromName(const QString &name)
Creates an autogenerated parameter description from a parameter name.
QVariant toVariant() const
Saves this output layer definition to a QVariantMap, wrapped in a QVariant.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this provider.
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.
QgsProcessingParameterType * parameterType(const QString &id) const
Returns the parameter type registered for id.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool hasFixedNumberRows() const
Returns whether the table has a fixed number of rows.
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...
double maximum() const
Returns the maximum value acceptable by the parameter.
virtual bool fromVariantMap(const QVariantMap &map)
Restores this parameter to a QVariantMap.
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.
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 parentParameterName() const
Returns the name of the parent parameter, or an empty string if this is not set.
QString type() const override
Unique parameter type name.
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
bool createFromString(const QString &definition)
Set up this CRS from a string definition.
QString type() const override
Unique parameter type name.
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.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
This class is a composition of two QSettings instances:
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.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
QgsProcessingParameterExpression(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false)
Constructor for QgsProcessingParameterExpression.
QString name() const
Returns the name of the parameter.
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.
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.
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.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
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.
QgsProcessing::SourceType layerType() const
Returns the layer type for layers acceptable by the parameter.
A map layer parameter for processing algorithms.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Python processing scr...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
A class to represent a 2D point.
bool createByDefault() const
Returns true if the destination should be created by default.
A HTML file output for processing algorithms.
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.
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...
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 parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
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 isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
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.
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 multiLine() const
Returns true if the parameter allows multiline strings.
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...
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
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.
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.
QString source() const
Returns the source for the layer.
Abstract base class for processing providers.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QStringList headers() const
Returns a list of column headers (if set).
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Python processing scr...
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.
QVariant toVariant() const
Saves this property to a QVariantMap, wrapped in a QVariant.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static 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.
QVariant staticValue() const
Returns the current static value for the property.
QString type() const override
Unique parameter type name.
bool hasGeometry() const
Returns true if sink is likely to include geometries.
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.
Type dataType() const
Returns the acceptable data type for the parameter.
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 asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Python processing scr...
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.
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
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...
virtual QString defaultVectorFileExtension(bool hasGeometry=true) const
Returns the default file extension to use for vector outputs created by the provider.
QgsProcessing::SourceType dataType() const
Returns the layer type for sinks associated with the parameter.
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.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of map layers.
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.
double minimum() const
Returns the minimum value acceptable by the parameter.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
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.
QgsProcessingProvider * provider() const
Returns a pointer to the provider for the algorithm which owns this parameter.
static QString typeName()
Returns the type name for the parameter class.
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.
Behavior behavior() const
Returns the parameter behavior (e.g.
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.
QgsProcessingParameterCrs(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCrs.
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
static 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 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.
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.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
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.
QList< int > dataTypes() const
Returns the geometry types for sources acceptable by the parameter.
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.
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. ...
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.
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
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.
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.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
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.
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
void setMinimum(double minimum)
Sets the minimum value acceptable by the parameter.
virtual QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
virtual QgsRectangle extent() const
Returns the extent of the 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.
QStringList options() const
Returns the list of acceptable options for the parameter.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDistance * clone() const override
Creates a clone of the parameter definition.
QgsProcessingProvider * originalProvider() const
Original (source) provider which this parameter has been derived from.
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...
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
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.
Flags flags() const
Returns any flags associated with the parameter.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
A double numeric parameter for distance values.
Type propertyType() const
Returns the property type.
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 parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
Parameter is a single file.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Python processing scr...
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 Python processing scr...
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
Reads and writes project states.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
DataType dataType() const
Returns the acceptable data type for the field.
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.
virtual QString defaultFileExtension() const =0
Returns the default file extension for destination file paths associated with this parameter...
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported for this parameter. ...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported by this provider.
bool allowMultiple() const
Returns whether multiple band selections are permitted.
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.
A QgsRectangle with associated coordinate reference system.
QgsProcessingAlgorithm * algorithm() const
Returns a pointer to the algorithm which owns this parameter.
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
int minimumNumberInputs() const
Returns the minimum number of layers required for the parameter.
QString description() const
Returns the description for the parameter.
QgsProcessingParameterNumber(const QString &name, const QString &description=QString(), Type type=Integer, const QVariant &defaultValue=QVariant(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterNumber.
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...
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.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
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.
QString asScriptCode() const override
Returns the parameter definition encoded in a string 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.
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 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.
virtual QString asScriptCode() const
Returns the parameter definition encoded in a string 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.
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...
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 QStringList supportedOutputTableExtensions() const
Returns a list of the table (geometry-less vector layers) file extensions supported by this 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.
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 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...
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
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.
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
virtual QString generateTemporaryDestination() const
Generates a temporary destination value for this parameter.
A point parameter for processing algorithms.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
void setDataType(DataType type)
Sets the acceptable data type for the field.
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 Python processing scr...
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Python processing scr...
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 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...
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)
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...
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
QgsProject * destinationProject
Destination project.
This class represents a coordinate reference system (CRS).
Base class for the definition of processing parameters.
static QgsProcessingParameterDefinition * parameterFromScriptCode(const QString &code)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied script code st...
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...
QString authid() const
Returns the authority identifier for the CRS.
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.
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.
virtual QString toolTip() const
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
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...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
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.
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.
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 Python processing scr...
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.
Custom exception class for Coordinate Reference System related exceptions.
int numberRows() const
Returns the fixed number of rows in the table.
QString type() const override
Unique parameter type name.
QVariant defaultValue() const
Returns the default value for the parameter.
static QgsProcessingParameterEnum * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString 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.
QgsProcessing::SourceType dataType() const
Returns the layer type for this created vector layer.
static QString parameterAsCompatibleSourceLayerPath(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path of compatible for...
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 Python processing scr...
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.
bool supportsNonFileBasedOutput() const
Returns true if the destination parameter supports non filed-based outputs, such as memory layers or ...
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
double xMinimum() const
Returns the x minimum value (left 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...
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.
bool hasGeometry() const
Returns true if the created layer is likely to include geometries.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
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.
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.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with 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.
virtual QString defaultRasterFileExtension() const
Returns the default file extension to use for raster outputs created by the provider.
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.
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...
bool allowMultiple() const
Returns whether multiple field selections are permitted.
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.
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.