38 map.insert( QStringLiteral(
"create_options" ),
createOptions );
45 createOptions = map.value( QStringLiteral(
"create_options" ) ).toMap();
51 QVariant val = parameters.value( name );
63 QVariant val = parameters.value( definition->
name() );
73 return val.toString();
81 QVariant val = parameters.value( definition->
name() );
85 if ( val.isValid() && !val.toString().isEmpty() )
89 return val.toString();
101 QVariant val = parameters.value( definition->
name() );
106 double res = val.toDouble( &ok );
112 return val.toDouble();
120 QVariant val = parameters.value( definition->
name() );
125 double dbl = val.toDouble( &ok );
130 dbl = val.toDouble( &ok );
137 double round = std::round( dbl );
138 if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
143 return std::round( dbl );
154 int val = parameterAsInt( definition, parameters, context );
156 if ( enumDef && val >= enumDef->
options().size() )
168 QVariantList resultList;
169 QVariant val = parameters.value( definition->
name() );
172 else if ( val.type() == QVariant::List )
174 Q_FOREACH (
const QVariant &var, val.toList() )
177 else if ( val.type() == QVariant::String )
179 Q_FOREACH (
const QString &var, val.toString().split(
',' ) )
185 if ( resultList.isEmpty() )
186 return QList< int >();
188 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
192 if ( definition->
defaultValue().type() == QVariant::List )
194 Q_FOREACH (
const QVariant &var, definition->
defaultValue().toList() )
197 else if ( definition->
defaultValue().type() == QVariant::String )
199 Q_FOREACH (
const QString &var, definition->
defaultValue().toString().split(
',' ) )
208 Q_FOREACH (
const QVariant &var, resultList )
210 int resInt = var.toInt();
211 if ( !enumDef || resInt < enumDef->options().size() )
226 QVariant val = parameters.value( definition->
name() );
229 else if ( val.isValid() )
242 val = parameters.value( definition->
name() );
263 else if ( !val.isValid() || val.toString().isEmpty() )
275 dest = val.toString();
278 if ( dest.isEmpty() )
282 destinationIdentifier = dest;
284 if ( destinationProject )
286 if ( destName.isEmpty() && definition )
292 outputName = definition->
name();
296 return sink.release();
304 QVariant val = parameters.value( definition->
name() );
314 QVariant val = parameters.value( definition->
name() );
316 bool selectedFeaturesOnly =
false;
331 vl = qobject_cast<
QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
340 else if ( !val.isValid() || val.toString().isEmpty() )
346 vl = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) );
352 layerRef = val.toString();
357 if ( layerRef.isEmpty() )
368 compatibleFormats, preferredFormat, context, feedback );
377 QVariant val = parameters.value( definition->
name() );
383 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
388 if ( !val.isValid() || val.toString().isEmpty() )
394 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
399 QString layerRef = val.toString();
400 if ( layerRef.isEmpty() )
403 if ( layerRef.isEmpty() )
411 return qobject_cast<
QgsRasterLayer *>( parameterAsLayer( definition, parameters, context ) );
419 val = parameters.value( definition->
name() );
440 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
447 dest = val.toString();
450 if ( destinationProject )
453 if ( destName.isEmpty() && definition )
458 outputName = definition->
name();
470 val = parameters.value( definition->
name() );
485 else if ( !val.isValid() || val.toString().isEmpty() )
492 dest = val.toString();
500 return qobject_cast<
QgsVectorLayer *>( parameterAsLayer( definition, parameters, context ) );
508 QVariant val = parameters.value( definition->
name() );
523 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
529 if ( !val.isValid() )
535 QString crsText = val.toString();
536 if ( crsText.isEmpty() )
539 if ( crsText.isEmpty() )
543 if ( context.
project() && crsText.compare( QStringLiteral(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
562 QVariant val = parameters.value( definition->
name() );
605 rectText = val.toString();
607 if ( rectText.isEmpty() && !layer )
610 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
611 QRegularExpressionMatch match = rx.match( rectText );
612 if ( match.hasMatch() )
615 double xMin = match.captured( 1 ).toDouble( &xMinOk );
617 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
619 double yMin = match.captured( 3 ).toDouble( &yMinOk );
621 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
622 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
626 if ( crs.
isValid() && rectCrs.isValid() && crs != rectCrs )
671 QVariant val = parameters.value( definition->
name() );
679 g = g.densifyByCount( 20 );
709 rectText = val.toString();
711 if ( !rectText.isEmpty() )
713 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
714 QRegularExpressionMatch match = rx.match( rectText );
715 if ( match.hasMatch() )
718 double xMin = match.captured( 1 ).toDouble( &xMinOk );
720 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
722 double yMin = match.captured( 3 ).toDouble( &yMinOk );
724 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
725 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
730 if ( crs.
isValid() && rectCrs.isValid() && crs != rectCrs )
732 g = g.densifyByCount( 20 );
780 QVariant val = parameters.value( definition->
name() );
803 QString valueAsString;
807 valueAsString = val.toString();
809 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
811 QRegularExpressionMatch match = rx.match( valueAsString );
812 if ( match.hasMatch() )
832 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
848 QVariant val = parameters.value( definition->
name() );
871 QString pointText = parameterAsString( definition, parameters, context );
872 if ( pointText.isEmpty() )
875 if ( pointText.isEmpty() )
878 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
880 QString valueAsString = parameterAsString( definition, parameters, context );
881 QRegularExpressionMatch match = rx.match( valueAsString );
882 if ( match.hasMatch() )
885 double x = match.captured( 1 ).toDouble( &xOk );
887 double y = match.captured( 2 ).toDouble( &yOk );
894 if ( crs.
isValid() && pointCrs.isValid() && crs != pointCrs )
915 QVariant val = parameters.value( definition->
name() );
926 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
928 QString valueAsString = parameterAsString( definition, parameters, context );
929 QRegularExpressionMatch match = rx.match( valueAsString );
930 if ( match.hasMatch() )
948 QString fileText = parameterAsString( definition, parameters, context );
949 if ( fileText.isEmpty() )
957 return QVariantList();
959 QString resultString;
960 QVariant val = parameters.value( definition->
name() );
963 else if ( val.type() == QVariant::List )
966 resultString = val.toString();
968 if ( resultString.isEmpty() )
971 if ( definition->
defaultValue().type() == QVariant::List )
978 Q_FOREACH (
const QString &s, resultString.split(
',' ) )
987 return QList<QgsMapLayer *>();
989 QVariant val = parameters.value( definition->
name() );
990 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
992 return QList<QgsMapLayer *>() << layer;
995 QList<QgsMapLayer *> layers;
997 QStringList resultStringList;
999 std::function< void( const QVariant &var ) > processVariant;
1000 processVariant = [ &resultStringList, &layers, &context, &definition, &processVariant ](
const QVariant & var )
1002 if ( var.type() == QVariant::List )
1004 Q_FOREACH (
const QVariant &listVar, var.toList() )
1006 processVariant( listVar );
1009 else if ( var.type() == QVariant::StringList )
1011 Q_FOREACH (
const QString &s, var.toStringList() )
1013 resultStringList << s;
1017 resultStringList << var.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() );
1018 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1024 resultStringList << var.toString();
1028 processVariant( val );
1030 if ( layers.isEmpty() && ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
1032 resultStringList.clear();
1034 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->defaultValue() ) ) )
1038 else if ( definition->defaultValue().type() == QVariant::List )
1040 Q_FOREACH (
const QVariant &var, definition->defaultValue().toList() )
1042 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
1048 resultStringList << var.toString();
1053 resultStringList << definition->defaultValue().toString();
1056 Q_FOREACH (
const QString &s, resultStringList )
1069 return QList<double>();
1071 QStringList resultStringList;
1072 QVariant val = parameters.value( definition->
name() );
1075 else if ( val.type() == QVariant::List )
1077 Q_FOREACH (
const QVariant &var, val.toList() )
1078 resultStringList << var.toString();
1081 resultStringList << val.toString();
1083 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
1085 resultStringList.clear();
1087 if ( definition->
defaultValue().type() == QVariant::List )
1089 Q_FOREACH (
const QVariant &var, definition->
defaultValue().toList() )
1090 resultStringList << var.toString();
1093 resultStringList << definition->
defaultValue().toString();
1096 if ( resultStringList.size() == 1 )
1098 resultStringList = resultStringList.at( 0 ).split(
',' );
1101 if ( resultStringList.size() < 2 )
1102 return QList< double >() << 0.0 << 0.0;
1104 return QList< double >() << resultStringList.at( 0 ).toDouble() << resultStringList.at( 1 ).toDouble();
1110 return QStringList();
1112 QStringList resultStringList;
1113 QVariant val = parameters.value( definition->
name() );
1114 if ( val.isValid() )
1118 else if ( val.type() == QVariant::List )
1120 Q_FOREACH (
const QVariant &var, val.toList() )
1121 resultStringList << var.toString();
1124 resultStringList.append( val.toString().split(
';' ) );
1127 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
1129 resultStringList.clear();
1133 if ( definition->
defaultValue().type() == QVariant::List )
1135 Q_FOREACH (
const QVariant &var, definition->
defaultValue().toList() )
1136 resultStringList << var.toString();
1139 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
1143 return resultStringList;
1148 QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
1149 QString name = map.value( QStringLiteral(
"name" ) ).toString();
1150 std::unique_ptr< QgsProcessingParameterDefinition > def;
1201 def.reset( paramType->
create( name ) );
1207 def->fromVariantMap( map );
1208 return def.release();
1213 QString desc = name;
1214 desc.replace(
'_',
' ' );
1220 bool isOptional =
false;
1224 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
1227 QString description = descriptionFromName( name );
1229 if ( type == QStringLiteral(
"boolean" ) )
1231 else if ( type == QStringLiteral(
"crs" ) )
1233 else if ( type == QStringLiteral(
"layer" ) )
1235 else if ( type == QStringLiteral(
"extent" ) )
1237 else if ( type == QStringLiteral(
"point" ) )
1239 else if ( type == QStringLiteral(
"file" ) )
1241 else if ( type == QStringLiteral(
"folder" ) )
1243 else if ( type == QStringLiteral(
"matrix" ) )
1245 else if ( type == QStringLiteral(
"multiple" ) )
1247 else if ( type == QStringLiteral(
"number" ) )
1249 else if ( type == QStringLiteral(
"range" ) )
1251 else if ( type == QStringLiteral(
"raster" ) )
1253 else if ( type == QStringLiteral(
"enum" ) )
1255 else if ( type == QStringLiteral(
"string" ) )
1257 else if ( type == QStringLiteral(
"expression" ) )
1259 else if ( type == QStringLiteral(
"field" ) )
1261 else if ( type == QStringLiteral(
"vector" ) )
1263 else if ( type == QStringLiteral(
"source" ) )
1265 else if ( type == QStringLiteral(
"sink" ) )
1267 else if ( type == QStringLiteral(
"vectordestination" ) )
1269 else if ( type == QStringLiteral(
"rasterdestination" ) )
1271 else if ( type == QStringLiteral(
"filedestination" ) )
1273 else if ( type == QStringLiteral(
"folderdestination" ) )
1275 else if ( type == QStringLiteral(
"band" ) )
1281 bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
1283 QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
1284 QRegularExpressionMatch m = re.match( code );
1285 if ( !m.hasMatch() )
1288 name = m.captured( 1 );
1289 QString tokens = m.captured( 2 );
1290 if ( tokens.startsWith( QStringLiteral(
"optional" ), Qt::CaseInsensitive ) )
1293 tokens.remove( 0, 8 );
1300 tokens = tokens.trimmed();
1302 QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
1303 m = re2.match( tokens );
1304 if ( !m.hasMatch() )
1306 type = tokens.toLower().trimmed();
1311 type = m.captured( 1 ).toLower().trimmed();
1312 definition = m.captured( 2 );
1323 , mDescription( description )
1324 , mDefault( defaultValue )
1325 , mFlags( optional ? FlagOptional : 0 )
1330 if ( !input.isValid() && !
mDefault.isValid() )
1333 if ( ( input.type() == QVariant::String && input.toString().isEmpty() )
1334 || ( !input.isValid() &&
mDefault.type() == QVariant::String &&
mDefault.toString().isEmpty() ) )
1342 if ( !value.isValid() )
1343 return QStringLiteral(
"None" );
1346 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1353 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1355 code += QStringLiteral(
"optional " );
1356 code +=
type() +
' ';
1358 return code.trimmed();
1364 map.insert( QStringLiteral(
"parameter_type" ),
type() );
1365 map.insert( QStringLiteral(
"name" ),
mName );
1366 map.insert( QStringLiteral(
"description" ),
mDescription );
1367 map.insert( QStringLiteral(
"default" ),
mDefault );
1368 map.insert( QStringLiteral(
"flags" ), static_cast< int >(
mFlags ) );
1369 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
1375 mName = map.value( QStringLiteral(
"name" ) ).toString();
1376 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
1377 mDefault = map.value( QStringLiteral(
"default" ) );
1378 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
1379 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
1395 return QStringLiteral(
"<p><b>%1</b></p><p>%2</p>" ).arg(
1397 QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
1411 if ( !val.isValid() )
1412 return QStringLiteral(
"None" );
1416 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
1421 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1423 code += QStringLiteral(
"optional " );
1424 code +=
type() +
' ';
1425 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
1426 return code.trimmed();
1447 if ( !input.isValid() )
1461 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1464 if ( input.type() != QVariant::String || input.toString().isEmpty() )
1472 if ( !value.isValid() )
1473 return QStringLiteral(
"None" );
1476 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1479 p.insert(
name(), value );
1489 return new QgsProcessingParameterCrs( name, description, definition.toLower() == QStringLiteral(
"none" ) ? QVariant() : definition, isOptional );
1505 if ( !input.isValid() )
1513 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1518 if ( input.type() != QVariant::String || input.toString().isEmpty() )
1536 if ( !val.isValid() )
1537 return QStringLiteral(
"None" );
1543 p.insert(
name(), val );
1567 if ( !input.isValid() )
1587 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1590 if ( input.type() != QVariant::String || input.toString().isEmpty() )
1599 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1600 QRegularExpressionMatch match = rx.match( input.toString() );
1601 if ( match.hasMatch() )
1603 bool xMinOk =
false;
1604 ( void )match.captured( 1 ).toDouble( &xMinOk );
1605 bool xMaxOk =
false;
1606 ( void )match.captured( 2 ).toDouble( &xMaxOk );
1607 bool yMinOk =
false;
1608 ( void )match.captured( 3 ).toDouble( &yMinOk );
1609 bool yMaxOk =
false;
1610 ( void )match.captured( 4 ).toDouble( &yMaxOk );
1611 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1621 if ( !value.isValid() )
1622 return QStringLiteral(
"None" );
1625 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1645 p.insert(
name(), value );
1671 if ( !input.isValid() )
1688 if ( input.type() == QVariant::String )
1690 if ( input.toString().isEmpty() )
1694 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1696 QRegularExpressionMatch match = rx.match( input.toString() );
1697 if ( match.hasMatch() )
1700 ( void )match.captured( 1 ).toDouble( &xOk );
1702 ( void )match.captured( 2 ).toDouble( &yOk );
1711 if ( !value.isValid() )
1712 return QStringLiteral(
"None" );
1715 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1741 , mBehavior( behavior )
1742 , mExtension( extension )
1754 if ( !input.isValid() )
1762 QString
string = input.toString().trimmed();
1764 if ( input.type() != QVariant::String ||
string.isEmpty() )
1767 switch ( mBehavior )
1771 if ( !mExtension.isEmpty() )
1772 return string.endsWith( mExtension, Qt::CaseInsensitive );
1784 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1786 code += QStringLiteral(
"optional " );
1787 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
1789 return code.trimmed();
1795 map.insert( QStringLiteral(
"behavior" ), mBehavior );
1796 map.insert( QStringLiteral(
"extension" ), mExtension );
1803 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
1804 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
1815 , mHeaders( headers )
1816 , mNumberRows( numberRows )
1817 , mFixedNumberRows( fixedNumberRows )
1829 if ( !input.isValid() )
1832 if ( input.type() == QVariant::String )
1834 if ( input.toString().isEmpty() )
1838 else if ( input.type() == QVariant::List )
1840 if ( input.toList().isEmpty() )
1844 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
1854 if ( !value.isValid() )
1855 return QStringLiteral(
"None" );
1858 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1861 p.insert(
name(), value );
1865 Q_FOREACH (
const QVariant &v, list )
1867 if ( v.type() == QVariant::List )
1870 Q_FOREACH (
const QVariant &v2, v.toList() )
1872 if ( v2.isNull() || !v2.isValid() )
1873 parts2 << QStringLiteral(
"None" );
1874 else if ( v2.toString().isEmpty() )
1875 parts2 << QStringLiteral(
"''" );
1877 parts2 << v2.toString();
1879 parts << parts2.join(
',' ).prepend(
'[' ).append(
']' );
1883 if ( v.isNull() || !v.isValid() )
1884 parts << QStringLiteral(
"None" );
1885 else if ( v.toString().isEmpty() )
1886 parts << QStringLiteral(
"''" );
1888 parts << v.toString();
1892 return parts.join(
',' ).prepend(
'[' ).append(
']' );
1917 return mFixedNumberRows;
1922 mFixedNumberRows = fixedNumberRows;
1928 map.insert( QStringLiteral(
"headers" ), mHeaders );
1929 map.insert( QStringLiteral(
"rows" ), mNumberRows );
1930 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
1937 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
1938 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
1939 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
1945 return new QgsProcessingParameterMatrix( name, description, 0,
false, QStringList(), definition.isEmpty() ? QVariant() : definition, isOptional );
1950 , mLayerType( layerType )
1962 if ( !input.isValid() )
1965 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1970 if ( input.type() == QVariant::String )
1972 if ( input.toString().isEmpty() )
1975 if ( mMinimumNumberInputs > 1 )
1983 else if ( input.type() == QVariant::List )
1985 if ( input.toList().count() < mMinimumNumberInputs )
1988 if ( mMinimumNumberInputs > input.toList().count() )
1994 Q_FOREACH (
const QVariant &v, input.toList() )
1996 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
2004 else if ( input.type() == QVariant::StringList )
2006 if ( input.toStringList().count() < mMinimumNumberInputs )
2009 if ( mMinimumNumberInputs > input.toStringList().count() )
2015 Q_FOREACH (
const QString &v, input.toStringList() )
2027 if ( !value.isValid() )
2028 return QStringLiteral(
"None" );
2031 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2034 p.insert(
name(), value );
2036 if ( !list.isEmpty() )
2043 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2051 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2053 code += QStringLiteral(
"optional " );
2054 switch ( mLayerType )
2057 code += QStringLiteral(
"multiple raster" );
2061 code += QStringLiteral(
"multiple file" );
2065 code += QStringLiteral(
"multiple vector" );
2069 if (
mDefault.type() == QVariant::List )
2072 Q_FOREACH (
const QVariant &var,
mDefault.toList() )
2074 parts << var.toString();
2076 code += parts.join(
',' );
2078 else if (
mDefault.type() == QVariant::StringList )
2080 code +=
mDefault.toStringList().join(
',' );
2086 return code.trimmed();
2101 return mMinimumNumberInputs;
2113 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
2114 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
2122 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
2128 QString
type = definition;
2130 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
2131 QRegularExpressionMatch m = re.match( definition );
2134 type = m.captured( 1 ).toLower().trimmed();
2135 defaultVal = m.captured( 2 );
2138 if ( type == QStringLiteral(
"vector" ) )
2140 else if ( type == QStringLiteral(
"raster" ) )
2142 else if ( type == QStringLiteral(
"file" ) )
2155 QgsMessageLog::logMessage( QObject::tr(
"Invalid number parameter \"%1\": min value %2 is >= max value %3!" ).arg( name ).arg( mMin ).arg( mMax ), QObject::tr(
"Processing" ) );
2166 QVariant input = value;
2167 if ( !input.isValid() )
2181 double res = input.toDouble( &ok );
2185 return !( res < mMin || res > mMax );
2190 if ( !value.isValid() )
2191 return QStringLiteral(
"None" );
2194 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2196 return value.toString();
2203 if ( mMin > std::numeric_limits<double>::lowest() + 1 )
2204 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
2205 if ( mMax < std::numeric_limits<double>::max() )
2206 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
2208 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
2209 QString extra = parts.join( QStringLiteral(
"<br />" ) );
2210 if ( !extra.isEmpty() )
2211 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
2248 map.insert( QStringLiteral(
"min" ), mMin );
2249 map.insert( QStringLiteral(
"max" ), mMax );
2250 map.insert( QStringLiteral(
"data_type" ), mDataType );
2257 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
2258 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
2259 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
2266 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
2283 if ( !input.isValid() )
2291 if ( input.type() == QVariant::String )
2293 QStringList list = input.toString().split(
',' );
2294 if ( list.count() != 2 )
2297 list.at( 0 ).toDouble( &ok );
2299 list.at( 1 ).toDouble( &ok2 );
2304 else if ( input.type() == QVariant::List )
2306 if ( input.toList().count() != 2 )
2310 input.toList().at( 0 ).toDouble( &ok );
2312 input.toList().at( 1 ).toDouble( &ok2 );
2323 if ( !value.isValid() )
2324 return QStringLiteral(
"None" );
2327 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2330 p.insert(
name(), value );
2333 QStringList stringParts;
2334 Q_FOREACH (
double v, parts )
2336 stringParts << QString::number( v );
2338 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
2354 map.insert( QStringLiteral(
"data_type" ), mDataType );
2383 if ( !input.isValid() )
2391 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
2394 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2412 if ( !val.isValid() )
2413 return QStringLiteral(
"None" );
2419 p.insert(
name(), val );
2431 , mOptions( options )
2432 , mAllowMultiple( allowMultiple )
2444 QVariant input = value;
2445 if ( !input.isValid() )
2458 if ( input.type() == QVariant::List )
2460 if ( !mAllowMultiple )
2463 const QVariantList values = input.toList();
2467 for (
const QVariant &val : values )
2470 int res = val.toInt( &ok );
2473 else if ( res < 0 || res >= mOptions.count() )
2479 else if ( input.type() == QVariant::String )
2481 QStringList parts = input.toString().split(
',' );
2482 if ( parts.count() > 1 && !mAllowMultiple )
2485 Q_FOREACH (
const QString &part, parts )
2488 int res = part.toInt( &ok );
2491 else if ( res < 0 || res >= mOptions.count() )
2496 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
2499 int res = input.toInt( &ok );
2502 else if ( res >= 0 && res < mOptions.count() )
2510 if ( !value.isValid() )
2511 return QStringLiteral(
"None" );
2514 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2516 if ( value.type() == QVariant::List )
2519 Q_FOREACH (
const QVariant &val, value.toList() )
2521 parts << QString::number( static_cast< int >( val.toDouble() ) );
2523 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2525 else if ( value.type() == QVariant::String )
2527 QStringList parts = value.toString().split(
',' );
2528 if ( parts.count() > 1 )
2530 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2534 return QString::number( static_cast< int >( value.toDouble() ) );
2539 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2541 code += QStringLiteral(
"optional " );
2542 code += QStringLiteral(
"enum " );
2544 if ( mAllowMultiple )
2545 code += QStringLiteral(
"multiple " );
2547 code += mOptions.join(
';' ) +
' ';
2550 return code.trimmed();
2565 return mAllowMultiple;
2576 map.insert( QStringLiteral(
"options" ), mOptions );
2577 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
2584 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
2585 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
2592 bool multiple =
false;
2593 QString def = definition;
2594 if ( def.startsWith( QStringLiteral(
"multiple" ), Qt::CaseInsensitive ) )
2600 QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
2601 QRegularExpressionMatch m = re.match( def );
2602 QString values = def;
2605 values = m.captured( 1 ).trimmed();
2606 defaultVal = m.captured( 2 );
2609 return new QgsProcessingParameterEnum( name, description, values.split(
';' ), multiple, defaultVal.isEmpty() ? QVariant() : defaultVal, isOptional );
2614 , mMultiLine( multiLine )
2626 if ( !value.isValid() )
2627 return QStringLiteral(
"None" );
2630 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2632 QString s = value.toString();
2633 s.replace(
'\n', QStringLiteral(
"\\n" ) );
2639 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2641 code += QStringLiteral(
"optional " );
2642 code += QStringLiteral(
"string " );
2645 code += QStringLiteral(
"long " );
2648 return code.trimmed();
2664 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
2671 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
2677 QString def = definition;
2679 if ( def.startsWith( QStringLiteral(
"long" ), Qt::CaseInsensitive ) )
2685 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
2687 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
2691 if ( def == QStringLiteral(
"None" ) )
2692 defaultValue = QVariant();
2699 , mParentLayerParameterName( parentLayerParameterName )
2711 if ( !value.isValid() )
2712 return QStringLiteral(
"None" );
2715 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2717 QString s = value.toString();
2718 s.replace(
'\n', QStringLiteral(
"\\n" ) );
2724 QStringList depends;
2725 if ( !mParentLayerParameterName.isEmpty() )
2726 depends << mParentLayerParameterName;
2732 return mParentLayerParameterName;
2743 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
2750 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
2791 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
2794 if ( var.type() != QVariant::String || var.toString().isEmpty() )
2812 if ( !val.isValid() )
2813 return QStringLiteral(
"None" );
2819 p.insert(
name(), val );
2843 map.insert( QStringLiteral(
"data_types" ), types );
2851 QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
2852 Q_FOREACH (
const QVariant &val, values )
2866 , mParentLayerParameterName( parentLayerParameterName )
2868 , mAllowMultiple( allowMultiple )
2880 if ( !input.isValid() )
2888 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
2890 if ( !mAllowMultiple )
2896 else if ( input.type() == QVariant::String )
2898 if ( input.toString().isEmpty() )
2901 QStringList parts = input.toString().split(
';' );
2902 if ( parts.count() > 1 && !mAllowMultiple )
2907 if ( input.toString().isEmpty() )
2915 if ( !value.isValid() )
2916 return QStringLiteral(
"None" );
2919 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2921 if ( value.type() == QVariant::List )
2924 Q_FOREACH (
const QVariant &val, value.toList() )
2928 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2930 else if ( value.type() == QVariant::StringList )
2933 Q_FOREACH ( QString s, value.toStringList() )
2937 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2945 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2947 code += QStringLiteral(
"optional " );
2948 code += QStringLiteral(
"field " );
2950 switch ( mDataType )
2953 code += QStringLiteral(
"numeric " );
2957 code += QStringLiteral(
"string " );
2961 code += QStringLiteral(
"datetime " );
2968 if ( mAllowMultiple )
2969 code += QStringLiteral(
"multiple " );
2971 code += mParentLayerParameterName +
' ';
2974 return code.trimmed();
2979 QStringList depends;
2980 if ( !mParentLayerParameterName.isEmpty() )
2981 depends << mParentLayerParameterName;
2987 return mParentLayerParameterName;
3007 return mAllowMultiple;
3018 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
3019 map.insert( QStringLiteral(
"data_type" ), mDataType );
3020 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
3027 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
3028 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
3029 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
3038 QString def = definition;
3040 if ( def.startsWith( QStringLiteral(
"numeric " ), Qt::CaseInsensitive ) )
3045 else if ( def.startsWith( QStringLiteral(
"string " ), Qt::CaseInsensitive ) )
3050 else if ( def.startsWith( QStringLiteral(
"datetime " ), Qt::CaseInsensitive ) )
3056 if ( def.startsWith( QStringLiteral(
"multiple" ), Qt::CaseInsensitive ) )
3058 allowMultiple =
true;
3059 def = def.mid( 8 ).trimmed();
3062 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
3063 QRegularExpressionMatch m = re.match( def );
3066 parent = m.captured( 1 ).trimmed();
3067 def = m.captured( 2 );
3092 QVariant var = input;
3093 if ( !var.isValid() )
3114 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
3119 if ( var.type() != QVariant::String || var.toString().isEmpty() )
3137 if ( !value.isValid() )
3138 return QStringLiteral(
"None" );
3141 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3150 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition('%1', True)" ).arg( fromVar.
source.
staticValue().toString() );
3157 layerString = layer->source();
3165 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression('%1'), True)" ).arg( fromVar.
source.
asExpression() );
3169 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
source.
asExpression() );
3173 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
3183 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3185 code += QStringLiteral(
"optional " );
3186 code += QStringLiteral(
"source " );
3193 code += QStringLiteral(
"point " );
3197 code += QStringLiteral(
"line " );
3201 code += QStringLiteral(
"polygon " );
3208 return code.trimmed();
3225 map.insert( QStringLiteral(
"data_types" ), types );
3233 QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3234 Q_FOREACH (
const QVariant &val, values )
3244 QString def = definition;
3247 if ( def.startsWith( QStringLiteral(
"point" ), Qt::CaseInsensitive ) )
3253 else if ( def.startsWith( QStringLiteral(
"line" ), Qt::CaseInsensitive ) )
3259 else if ( def.startsWith( QStringLiteral(
"polygon" ), Qt::CaseInsensitive ) )
3284 QVariant var = input;
3285 if ( !var.isValid() )
3307 if ( var.type() != QVariant::String )
3310 if ( var.toString().isEmpty() )
3318 if ( !value.isValid() )
3319 return QStringLiteral(
"None" );
3322 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3329 return QStringLiteral(
"'%1'" ).arg( fromVar.
sink.
staticValue().toString() );
3333 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
3342 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3344 code += QStringLiteral(
"optional " );
3345 code += QStringLiteral(
"sink " );
3347 switch ( mDataType )
3350 code += QStringLiteral(
"point " );
3354 code += QStringLiteral(
"line " );
3358 code += QStringLiteral(
"polygon " );
3362 code += QStringLiteral(
"table " );
3370 return code.trimmed();
3386 return p->defaultVectorFileExtension(
hasGeometry() );
3393 return settings.
value( QStringLiteral(
"Processing/DefaultOutputVectorLayerExt" ), QStringLiteral(
"shp" ),
QgsSettings::Core ).toString();
3397 return QStringLiteral(
"dbf" );
3410 return p->supportedOutputVectorLayerExtensions();
3425 switch ( mDataType )
3450 map.insert( QStringLiteral(
"data_type" ), mDataType );
3464 return QStringLiteral(
"memory:%1" ).arg(
description() );
3472 QString def = definition;
3473 if ( def.startsWith( QStringLiteral(
"point" ), Qt::CaseInsensitive ) )
3478 else if ( def.startsWith( QStringLiteral(
"line" ), Qt::CaseInsensitive ) )
3483 else if ( def.startsWith( QStringLiteral(
"polygon" ), Qt::CaseInsensitive ) )
3488 else if ( def.startsWith( QStringLiteral(
"table" ), Qt::CaseInsensitive ) )
3509 QVariant var = input;
3510 if ( !var.isValid() )
3532 if ( var.type() != QVariant::String )
3535 if ( var.toString().isEmpty() )
3543 if ( !value.isValid() )
3544 return QStringLiteral(
"None" );
3547 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3554 return QStringLiteral(
"'%1'" ).arg( fromVar.
sink.
staticValue().toString() );
3558 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
3578 return p->defaultRasterFileExtension();
3583 return settings.
value( QStringLiteral(
"Processing/DefaultOutputRasterLayerExt" ), QStringLiteral(
"tif" ),
QgsSettings::Core ).toString();
3595 return p->supportedOutputRasterLayerExtensions();
3611 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
3623 QVariant var = input;
3624 if ( !var.isValid() )
3646 if ( var.type() != QVariant::String )
3649 if ( var.toString().isEmpty() )
3659 if ( !value.isValid() )
3660 return QStringLiteral(
"None" );
3663 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3670 return QStringLiteral(
"'%1'" ).arg( fromVar.
sink.
staticValue().toString() );
3674 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
3683 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
3695 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
3696 return QStringLiteral(
"file" );
3699 QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
3700 QRegularExpressionMatch match = rx.match( mFileFilter );
3701 if ( !match.hasMatch() )
3702 return QStringLiteral(
"file" );
3704 return match.captured( 1 );
3720 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
3727 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
3748 QVariant var = input;
3749 if ( !var.isValid() )
3765 if ( var.type() != QVariant::String )
3768 if ( var.toString().isEmpty() )
3791 , mCreateByDefault( createByDefault )
3799 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
3800 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
3807 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
3808 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
3826 return mCreateByDefault;
3848 QVariant var = input;
3849 if ( !var.isValid() )
3871 if ( var.type() != QVariant::String )
3874 if ( var.toString().isEmpty() )
3882 if ( !value.isValid() )
3883 return QStringLiteral(
"None" );
3886 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3893 return QStringLiteral(
"'%1'" ).arg( fromVar.
sink.
staticValue().toString() );
3897 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
3906 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3908 code += QStringLiteral(
"optional " );
3909 code += QStringLiteral(
"vectorDestination " );
3911 switch ( mDataType )
3914 code += QStringLiteral(
"point " );
3918 code += QStringLiteral(
"line " );
3922 code += QStringLiteral(
"polygon " );
3930 return code.trimmed();
3946 return p->defaultVectorFileExtension(
hasGeometry() );
3953 return settings.
value( QStringLiteral(
"Processing/DefaultOutputVectorLayerExt" ), QStringLiteral(
"shp" ),
QgsSettings::Core ).toString();
3957 return QStringLiteral(
"dbf" );
3970 return p->supportedOutputVectorLayerExtensions();
3985 switch ( mDataType )
4010 map.insert( QStringLiteral(
"data_type" ), mDataType );
4024 QString def = definition;
4025 if ( def.startsWith( QStringLiteral(
"point" ), Qt::CaseInsensitive ) )
4030 else if ( def.startsWith( QStringLiteral(
"line" ), Qt::CaseInsensitive ) )
4035 else if ( def.startsWith( QStringLiteral(
"polygon" ), Qt::CaseInsensitive ) )
4046 , mParentLayerParameterName( parentLayerParameterName )
4058 if ( !input.isValid() )
4067 double res = input.toInt( &ok );
4077 if ( !value.isValid() )
4078 return QStringLiteral(
"None" );
4081 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
4083 return value.toString();
4088 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
4090 code += QStringLiteral(
"optional " );
4091 code += QStringLiteral(
"band " );
4093 code += mParentLayerParameterName +
' ';
4096 return code.trimmed();
4101 QStringList depends;
4102 if ( !mParentLayerParameterName.isEmpty() )
4103 depends << mParentLayerParameterName;
4109 return mParentLayerParameterName;
4120 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
4127 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
4134 QString def = definition;
4136 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
4137 QRegularExpressionMatch m = re.match( def );
4140 parent = m.captured( 1 ).trimmed();
4141 def = m.captured( 2 );
4158 , mParentParameterName( parentParameterName )
4175 QStringList depends;
4176 if ( !mParentParameterName.isEmpty() )
4177 depends << mParentParameterName;
4183 return mParentParameterName;
4194 map.insert( QStringLiteral(
"parent" ), mParentParameterName );
4201 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.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true)
Interprets a string as a map layer within the supplied context.
Class for parsing and evaluation of expressions (formerly called "search strings").
void setDataTypes(const QList< int > &types)
Sets the geometry types for sources acceptable by the parameter.
static QString typeName()
Returns the type name for the parameter class.
An input file or folder parameter for processing algorithms.
A parameter for processing algorithms which accepts multiple map layers.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
virtual QString asScriptCode() const
Returns the parameter definition encoded in a string which can be used within a Python processing scr...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
A rectangle specified with double values.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
Base class for all map layer types.
static QString descriptionFromName(const QString &name)
Creates an autogenerated parameter description from a parameter name.
static QString parameterAsString(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static string value.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterRasterLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
static int parameterAsEnum(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a enum value.
static QString typeName()
Returns the type name for the parameter class.
Base class for providing feedback from a processing algorithm.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
virtual bool fromVariantMap(const QVariantMap &map)
Restores this parameter to a QVariantMap.
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 type() const override
Unique parameter type name.
static QgsApplication * instance()
Returns the singleton instance of the QgsApplication.
bool hasFixedNumberRows() const
Returns whether the table has a fixed number of rows.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
bool createFromString(const QString &definition)
Set up this CRS from a string definition.
QString type() const override
Unique parameter type name.
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.
DataType dataType() const
Returns the acceptable data type for the field.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
This class is a composition of two QSettings instances:
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported for this parameter. ...
void setHasFixedNumberRows(bool hasFixedNumberRows)
Sets whether the table has a fixed number of rows.
QgsProcessingParameterMultipleLayers(const QString &name, const QString &description=QString(), QgsProcessing::SourceType layerType=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMultipleLayers.
QgsProcessingParameterExpression(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false)
Constructor for QgsProcessingParameterExpression.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterRange(const QString &name, const QString &description=QString(), QgsProcessingParameterNumber::Type type=QgsProcessingParameterNumber::Integer, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRange.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
QgsProcessingParameterFeatureSource(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFeatureSource.
void setDataType(QgsProcessingParameterNumber::Type dataType)
Sets the acceptable data type for the range.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
static QString typeName()
Returns the type name for the parameter class.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
static QList< int > parameterAsEnums(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to list of enum values.
static QString typeName()
Returns the type name for the parameter class.
QString type() const override
Unique parameter type name.
A map layer parameter for processing algorithms.
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...
QStringList headers() const
Returns a list of column headers (if set).
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
QgsProcessingProvider * provider() const
Returns the provider to which this algorithm belongs.
A class to represent a 2D point.
A HTML file output for processing algorithms.
QgsProcessingProvider * provider() const
Returns a pointer to the provider for the algorithm which owns this parameter.
An expression parameter for processing algorithms.
A QgsPointXY with associated coordinate reference system.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterRange * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterString(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool multiLine=false, bool optional=false)
Constructor for QgsProcessingParameterString.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool createByDefault() const
Returns true if the destination should be created by default.
An interface for objects which accept features via addFeature(s) methods.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingProvider * originalProvider() const
Original (source) provider which this parameter has been derived from.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
QgsProcessingAlgorithm * mAlgorithm
Pointer to algorithm which owns this parameter.
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported by this provider.
static QString typeName()
Returns the type name for the parameter class.
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QString typeName()
Returns the type name for the parameter class.
QVariantMap mMetadata
Freeform metadata for parameter. Mostly used by widget wrappers to customize their appearance and beh...
double minimum() const
Returns the minimum value acceptable by the parameter.
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource, modifying results according to the settings in a QgsProcessingContext.
Container of fields for a vector layer.
static QgsProcessingParameterCrs * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsRasterLayer * parameterAsRasterLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a raster layer.
A geometry is the spatial representation of a feature.
static QgsMapLayer * parameterAsLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a map layer.
static QgsProcessingParameterMultipleLayers * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Abstract base class for processing providers.
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
bool allowMultiple() const
Returns true if the parameter allows multiple selected values.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString 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.
virtual QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
static QString typeName()
Returns the type name for the parameter class.
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QgsProcessingParameterDefinition * parameterFromVariantMap(const QVariantMap &map)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied variant map...
QgsProcessingParameterEnum(const QString &name, const QString &description=QString(), const QStringList &options=QStringList(), bool allowMultiple=false, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterEnum.
QgsProcessingParameterBoolean(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterBoolean.
QString type() const override
Unique parameter type name.
QgsProcessingParameterType * parameterType(const QString &id) const
Returns the parameter type registered for id.
static QgsProcessingParameterMapLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QString typeName()
Returns the type name for the parameter class.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
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.
static QgsProcessingParameterBand * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static QString parameterAsFile(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file/folder name.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
A feature sink output for processing algorithms.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString fileFilter() const
Returns the file filter string for file destinations compatible with this parameter.
static QList< QgsMapLayer * > parameterAsLayerList(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of map layers.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
Files (i.e. non map layer sources, such as text files)
bool selectedFeaturesOnly
True if only selected features in the source should be used by algorithms.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
virtual QgsRectangle extent() const
Returns the extent of the layer.
A raster layer destination parameter, for specifying the destination path for a raster layer created ...
int minimumNumberInputs() const
Returns the minimum number of layers required for the parameter.
void setAllowMultiple(bool allowMultiple)
Sets whether multiple field selections are permitted.
static QgsProcessingParameterBoolean * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterBand(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentLayerParameterName=QString(), bool optional=false)
Constructor for QgsProcessingParameterBand.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessing::SourceType layerType() const
Returns the layer type for layers acceptable by the parameter.
static QgsGeometry parameterAsExtentGeometry(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent, and returns a geometry cove...
static QgsCoordinateReferenceSystem parameterAsExtentCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an extent parameter value.
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...
QgsProcessingParameterCrs(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterCrs.
QVariant toVariant() const
Saves this property to a QVariantMap, wrapped in a QVariant.
QList< int > dataTypes() const
Returns the geometry types for sources acceptable by the parameter.
static QgsRectangle parameterAsExtent(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem())
Evaluates the parameter with matching definition to a rectangular extent.
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set...
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingParameterFolderDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFolderDestination.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
Can be inherited by parameters which require limits to their acceptable data types.
A raster layer parameter for processing algorithms.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessingParameterFeatureSink(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFeatureSink.
QgsProcessingParameterFile(const QString &name, const QString &description=QString(), Behavior behavior=File, const QString &extension=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFile.
Type
The WKB type describes the number of dimensions a geometry has.
static QStringList supportedFormatExtensions(RasterFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats.
virtual QString toolTip() const
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
static QgsProcessingParameterNumber * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
static QgsCoordinateReferenceSystem parameterAsPointCrs(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Returns the coordinate reference system associated with an point parameter value. ...
QString valueAsString(const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a string.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
QgsProperty source
Source definition.
virtual QgsProcessingParameterDefinition * create(const QString &name) const =0
Creates a new parameter of this type.
Type propertyType() const
Returns the property type.
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.
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap())
Creates a feature sink ready for adding features.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
An enum based parameter for processing algorithms, allowing for selection from predefined values...
bool loadVariant(const QVariant &property)
Loads this property from a QVariantMap, wrapped in a QVariant.
void setMinimum(double minimum)
Sets the minimum value acceptable by the parameter.
Flags flags() const
Returns any flags associated with the parameter.
QgsProcessing::SourceType dataType() const
Returns the layer type for this created vector layer.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterFeatureSink * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QVariant defaultValue() const
Returns the default value for the parameter.
bool hasGeometry() const
Returns true if the created layer is likely to include geometries.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QgsProcessingParameterDistance * clone() const override
Creates a clone of the parameter definition.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
QgsGeometry densifyByCount(int extraNodesPerSegment) const
Returns a copy of the geometry which has been densified by adding the specified number of extra nodes...
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
virtual QString defaultRasterFileExtension() const
Returns the default file extension to use for raster outputs created by the provider.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
A double numeric parameter for distance values.
A file output for processing algorithms.
QgsCoordinateReferenceSystem crs
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
QgsProcessingDestinationParameter(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingDestinationParameter.
QString parentParameterName() const
Returns the name of the parent parameter, or an empty string if this is not set.
bool valueAsBool(const QgsExpressionContext &context, bool defaultValue=false, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as an boolean.
QgsProcessingAlgorithm * algorithm() const
Returns a pointer to the algorithm which owns this parameter.
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.
QgsCoordinateReferenceSystem crs() const
Returns the layer's spatial reference system.
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.
A vector layer (with or without geometry) parameter for processing algorithms.
static QgsProcessingParameterExpression * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool multiLine() const
Returns true if the parameter allows multiline strings.
virtual QString defaultFileExtension() const =0
Returns the default file extension for destination file paths associated with this parameter...
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
void setParentLayerParameterName(const QString &parentLayerParameterName)
Sets the name of the parent layer parameter.
void setParentParameterName(const QString &parentParameterName)
Sets the name of the parent layer parameter.
QStringList options() const
Returns the list of acceptable options for the parameter.
A QgsRectangle with associated coordinate reference system.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
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.
Details for layers to load into projects.
void setAllowMultiple(bool allowMultiple)
Sets whether the parameter allows multiple selected values.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A numeric parameter for processing algorithms.
bool loadVariant(const QVariantMap &map)
Loads this output layer definition from a QVariantMap, wrapped in a QVariant.
A generic file based destination parameter, for specifying the destination path for a file (non-map l...
static QgsProcessingParameterVectorDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsExpressionContext & expressionContext()
Returns the expression context.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDistance(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), const QString &parentParameterName=QString(), bool optional=false, double minValue=std::numeric_limits< double >::lowest()+1, double maxValue=std::numeric_limits< double >::max())
Constructor for QgsProcessingParameterDistance.
void setOptions(const QStringList &options)
Sets the list of acceptable options for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a Python processing scr...
QString name() const
Returns the name of the parameter.
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.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
double valueAsDouble(const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a double.
bool supportsNonFileBasedOutput() const
Returns true if the destination parameter supports non filed-based outputs, such as memory layers or ...
Behavior behavior() const
Returns the parameter behavior (e.g.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
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.
QVariant toVariant() const
Saves this output layer definition to a QVariantMap, wrapped in a QVariant.
void addLayerToLoadOnCompletion(const QString &layer, const QgsProcessingContext::LayerDetails &details)
Adds a layer to load (by ID or datasource) into the canvas upon completion of the algorithm or model...
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
virtual QString defaultVectorFileExtension(bool hasGeometry=true) const
Returns the default file extension to use for vector outputs created by the provider.
static QgsProcessingParameterFile * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition, Behavior behavior=File)
Creates a new parameter using the definition from a script code.
static QgsProcessingParameterMatrix * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Base class for the definition of processing outputs.
void setCreateByDefault(bool createByDefault)
Sets whether the destination should be created by default.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QgsProcessing::SourceType dataType() const
Returns the layer type for sinks associated with the parameter.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
QgsProcessingParameterLimitedDataTypes(const QList< int > &types=QList< int >())
Constructor for QgsProcessingParameterLimitedDataTypes, with a list of acceptable data types...
void setNumberRows(int rows)
Sets the fixed number of rows in the table.
A vector layer destination parameter, for specifying the destination path for a vector layer created ...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QString parentLayerParameterName() const
Returns the name of the parent layer parameter, or an empty string if this is not set...
A point parameter for processing algorithms.
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 source() const
Returns the source for the layer.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
An input feature source (such as vector layers) parameter for processing algorithms.
A folder destination parameter, for specifying the destination path for a folder created by the algor...
int valueAsInt(const QgsExpressionContext &context, int defaultValue=0, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as an integer.
QString destinationName
Name to use for sink if it's to be loaded into a destination project.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
Flags mFlags
Parameter flags.
static QString typeName()
Returns the type name for the parameter class.
static QgsProcessingParameterVectorLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
Any map layer type (raster or vector)
Makes metadata of processing parameters available.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsFeatureSink * parameterAsSink(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context, QString &destinationIdentifier)
Evaluates the parameter with matching definition to a feature sink.
QString toolTip() const override
Returns a formatted tooltip for use with the parameter, which gives helpful information like paramete...
QgsProject * destinationProject
Destination project.
This class represents a coordinate reference system (CRS).
int numberRows() const
Returns the fixed number of rows in the table.
Base class for the definition of processing parameters.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
static QgsProcessingParameterDefinition * parameterFromScriptCode(const QString &code)
Creates a new QgsProcessingParameterDefinition using the configuration from a supplied script code st...
QVariant staticValue() const
Returns the current static value for the property.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
static double parameterAsDouble(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static double value.
QVariant mDefault
Default value for parameter.
SourceType
Data source types enum.
static QString parameterAsOutputLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output layer destination.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QgsProcessingParameterRasterDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
static int parameterAsInt(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static integer value.
static QString typeName()
Returns the type name for the parameter class.
QString mName
Parameter name.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
static QgsProcessingFeatureSource * parameterAsSource(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a feature source.
bool fromVariantMap(const QVariantMap &map) override
Restores this parameter to a QVariantMap.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
static QString typeName()
Returns the type name for the parameter class.
static bool parameterAsBool(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context)
Evaluates the parameter with matching definition to a static boolean value.
Behavior
Parameter behavior.
virtual QString generateTemporaryDestination() const
Generates a temporary destination value for this parameter.
A folder output for processing algorithms.
static QString typeName()
Returns the type name for the parameter class.
DataType
Field data types.
QString asScriptCode() const override
Returns the parameter definition encoded in a string which can be used within a 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.
Type dataType() const
Returns the acceptable data type for the parameter.
QString type() const override
Unique parameter type name.
static QgsProcessingParameterEnum * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this provider.
QString mDescription
Parameter description.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter. ...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static QString parameterAsCompatibleSourceLayerPath(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat=QString("shp"), QgsProcessingFeedback *feedback=nullptr)
Evaluates the parameter with matching definition to a source vector layer file path of compatible for...
bool hasGeometry() const
Returns true if sink is likely to include geometries.
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.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the created vector layer.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A string parameter for processing algorithms.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
QString description() const
Returns the description for the parameter.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
static bool isDynamic(const QVariantMap ¶meters, const QString &name)
Returns true if the parameter with matching name is a dynamic parameter, and must be evaluated once f...
QgsProcessingParameterVectorLayer(const QString &name, const QString &description=QString(), const QList< int > &types=QList< int >(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterVectorLayer.
void setDataType(QgsProcessing::SourceType type)
Sets the layer type for the sinks associated with the parameter.
Any vector layer with geometry.
QgsProcessingParameterNumber::Type dataType() const
Returns the acceptable data type for the range.
QgsProcessingParameterMatrix(const QString &name, const QString &description=QString(), int numberRows=3, bool hasFixedNumberRows=false, const QStringList &headers=QStringList(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterMatrix.
QString type() const override
Unique parameter type name.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
bool allowMultiple() const
Returns whether multiple field selections are permitted.
QString authid() const
Returns the authority identifier for the CRS.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this parameter.
QString generateTemporaryDestination() const override
Generates a temporary destination value for this parameter.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterRasterLayer(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRasterLayer.
QgsProcessingParameterFileDestination(const QString &name, const QString &description=QString(), const QString &fileFilter=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterFileDestination.
double maximum() const
Returns the maximum value acceptable by the parameter.
QVariantMap createOptions
Map of optional sink/layer creation options, which are passed to the underlying provider when creatin...
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
static QgsProcessingParameterFileDestination * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QgsProcessingParameterRasterDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, bool createByDefault=true)
Constructor for QgsProcessingParameterRasterDestination.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingOutputDefinition * toOutputDefinition() const override
Returns a new QgsProcessingOutputDefinition corresponding to the definition of the destination parame...
static QString typeName()
Returns the type name for the parameter class.
A raster layer output for processing algorithms.
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers, algorithms, and various parameters and outputs.
static QString parameterAsFileOutput(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a file based output destination.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
static QStringList parameterAsFields(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a list of fields.
void setHeaders(const QStringList &headers)
Sets the list of column headers.