32 QVariant val = parameters.value( name );
44 QVariant val = parameters.value( definition->
name() );
54 return val.toString();
62 QVariant val = parameters.value( definition->
name() );
66 if ( val.isValid() && !val.toString().isEmpty() )
68 QgsExpression e( val.toString() );
70 return val.toString();
82 QVariant val = parameters.value( definition->
name() );
87 double res = val.toDouble( &ok );
93 return val.toDouble();
101 QVariant val = parameters.value( definition->
name() );
106 double dbl = val.toDouble( &ok );
111 dbl = val.toDouble( &ok );
118 double round = std::round( dbl );
119 if ( round > INT_MAX || round < -INT_MAX )
124 return std::round( dbl );
137 if ( enumDef && val >= enumDef->
options().size() )
149 QVariantList resultList;
150 QVariant val = parameters.value( definition->
name() );
153 else if ( val.type() == QVariant::List )
155 Q_FOREACH (
const QVariant &var, val.toList() )
158 else if ( val.type() == QVariant::String )
160 Q_FOREACH (
const QString &var, val.toString().split(
',' ) )
166 if ( resultList.isEmpty() )
167 return QList< int >();
169 if ( ( !val.isValid() || !resultList.at( 0 ).isValid() ) && definition )
173 if ( definition->
defaultValue().type() == QVariant::List )
175 Q_FOREACH (
const QVariant &var, definition->
defaultValue().toList() )
178 else if ( definition->
defaultValue().type() == QVariant::String )
180 Q_FOREACH (
const QString &var, definition->
defaultValue().toString().split(
',' ) )
189 Q_FOREACH (
const QVariant &var, resultList )
191 int resInt = var.toInt();
192 if ( !enumDef || resInt < enumDef->options().size() )
207 QVariant val = parameters.value( definition->
name() );
210 else if ( val.isValid() )
223 val = parameters.value( definition->
name() );
228 QVariantMap createOptions;
244 else if ( !val.isValid() || val.toString().isEmpty() )
256 dest = val.toString();
259 if ( dest.isEmpty() )
263 destinationIdentifier = dest;
265 if ( destinationProject )
267 if ( destName.isEmpty() && definition )
273 outputName = definition->
name();
277 return sink.release();
285 QVariant val = parameters.value( definition->
name() );
295 QVariant val = parameters.value( definition->
name() );
297 bool selectedFeaturesOnly =
false;
311 else if ( !val.isValid() || val.toString().isEmpty() )
318 layerRef = val.toString();
321 if ( layerRef.isEmpty() )
329 compatibleFormats, preferredFormat, context, feedback );
338 QVariant val = parameters.value( definition->
name() );
344 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
349 if ( !val.isValid() || val.toString().isEmpty() )
355 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
360 QString layerRef = val.toString();
361 if ( layerRef.isEmpty() )
364 if ( layerRef.isEmpty() )
380 val = parameters.value( definition->
name() );
384 QVariantMap createOptions;
401 else if ( definition && ( !val.isValid() || val.toString().isEmpty() ) )
408 dest = val.toString();
411 if ( destinationProject )
414 if ( destName.isEmpty() && definition )
419 outputName = definition->
name();
431 val = parameters.value( definition->
name() );
446 else if ( !val.isValid() || val.toString().isEmpty() )
453 dest = val.toString();
469 QVariant val = parameters.value( definition->
name() );
472 if ( crsText.isEmpty() )
475 if ( crsText.isEmpty() )
479 if ( context.
project() && crsText.compare( QStringLiteral(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
483 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
500 QVariant val = parameters.value( definition->
name() );
531 rectText = val.toString();
533 if ( rectText.isEmpty() && !layer )
536 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
537 QRegularExpressionMatch match = rx.match( rectText );
538 if ( match.hasMatch() )
541 double xMin = match.captured( 1 ).toDouble( &xMinOk );
543 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
545 double yMin = match.captured( 3 ).toDouble( &yMinOk );
547 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
548 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
552 if ( crs.
isValid() && rectCrs.isValid() && crs != rectCrs )
597 QVariant val = parameters.value( definition->
name() );
605 g = g.densifyByCount( 20 );
623 rectText = val.toString();
625 if ( !rectText.isEmpty() )
627 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
628 QRegularExpressionMatch match = rx.match( rectText );
629 if ( match.hasMatch() )
632 double xMin = match.captured( 1 ).toDouble( &xMinOk );
634 double xMax = match.captured( 2 ).toDouble( &xMaxOk );
636 double yMin = match.captured( 3 ).toDouble( &yMinOk );
638 double yMax = match.captured( 4 ).toDouble( &yMaxOk );
639 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
644 if ( crs.
isValid() && rectCrs.isValid() && crs != rectCrs )
646 g = g.densifyByCount( 20 );
694 QVariant val = parameters.value( definition->
name() );
705 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?),\\s*(.*?),\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
708 QRegularExpressionMatch match = rx.match( valueAsString );
709 if ( match.hasMatch() )
717 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
733 QVariant val = parameters.value( definition->
name() );
757 if ( pointText.isEmpty() )
760 if ( pointText.isEmpty() )
763 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
766 QRegularExpressionMatch match = rx.match( valueAsString );
767 if ( match.hasMatch() )
770 double x = match.captured( 1 ).toDouble( &xOk );
772 double y = match.captured( 2 ).toDouble( &yOk );
779 if ( crs.
isValid() && pointCrs.isValid() && crs != pointCrs )
800 QVariant val = parameters.value( definition->
name() );
811 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
814 QRegularExpressionMatch match = rx.match( valueAsString );
815 if ( match.hasMatch() )
834 if ( fileText.isEmpty() )
842 return QVariantList();
844 QString resultString;
845 QVariant val = parameters.value( definition->
name() );
848 else if ( val.type() == QVariant::List )
851 resultString = val.toString();
853 if ( resultString.isEmpty() )
856 if ( definition->
defaultValue().type() == QVariant::List )
863 Q_FOREACH (
const QString &s, resultString.split(
',' ) )
872 return QList<QgsMapLayer *>();
874 QVariant val = parameters.value( definition->
name() );
875 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
877 return QList<QgsMapLayer *>() << layer;
880 QList<QgsMapLayer *> layers;
882 QStringList resultStringList;
884 std::function< void( const QVariant &var ) > processVariant;
885 processVariant = [ &resultStringList, &layers, &context, &definition, &processVariant ](
const QVariant & var )
887 if ( var.type() == QVariant::List )
889 Q_FOREACH (
const QVariant &listVar, var.toList() )
891 processVariant( listVar );
894 else if ( var.type() == QVariant::StringList )
896 Q_FOREACH (
const QString &s, var.toStringList() )
898 resultStringList << s;
902 resultStringList << var.value<
QgsProperty >().
valueAsString( context.expressionContext(), definition->defaultValue().toString() );
903 else if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
909 resultStringList << var.toString();
913 processVariant( val );
915 if ( layers.isEmpty() && ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
917 resultStringList.clear();
919 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( definition->defaultValue() ) ) )
923 else if ( definition->defaultValue().type() == QVariant::List )
925 Q_FOREACH (
const QVariant &var, definition->defaultValue().toList() )
927 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( var ) ) )
933 resultStringList << var.toString();
938 resultStringList << definition->defaultValue().toString();
941 Q_FOREACH (
const QString &s, resultStringList )
954 return QList<double>();
956 QStringList resultStringList;
957 QVariant val = parameters.value( definition->
name() );
960 else if ( val.type() == QVariant::List )
962 Q_FOREACH (
const QVariant &var, val.toList() )
963 resultStringList << var.toString();
966 resultStringList << val.toString();
968 if ( ( resultStringList.isEmpty() || ( resultStringList.size() == 1 && resultStringList.at( 0 ).isEmpty() ) ) )
970 resultStringList.clear();
972 if ( definition->
defaultValue().type() == QVariant::List )
974 Q_FOREACH (
const QVariant &var, definition->
defaultValue().toList() )
975 resultStringList << var.toString();
978 resultStringList << definition->
defaultValue().toString();
981 if ( resultStringList.size() == 1 )
983 resultStringList = resultStringList.at( 0 ).split(
',' );
986 if ( resultStringList.size() < 2 )
987 return QList< double >() << 0.0 << 0.0;
989 return QList< double >() << resultStringList.at( 0 ).toDouble() << resultStringList.at( 1 ).toDouble();
995 return QStringList();
997 QStringList resultStringList;
998 QVariant val = parameters.value( definition->
name() );
1003 else if ( val.type() == QVariant::List )
1005 Q_FOREACH (
const QVariant &var, val.toList() )
1006 resultStringList << var.toString();
1009 resultStringList.append( val.toString().split(
';' ) );
1012 if ( ( resultStringList.isEmpty() || resultStringList.at( 0 ).isEmpty() ) )
1014 resultStringList.clear();
1018 if ( definition->
defaultValue().type() == QVariant::List )
1020 Q_FOREACH (
const QVariant &var, definition->
defaultValue().toList() )
1021 resultStringList << var.toString();
1024 resultStringList.append( definition->
defaultValue().toString().split(
';' ) );
1028 return resultStringList;
1033 QString type = map.value( QStringLiteral(
"parameter_type" ) ).toString();
1034 QString name = map.value( QStringLiteral(
"name" ) ).toString();
1035 std::unique_ptr< QgsProcessingParameterDefinition > def;
1087 return def.release();
1092 QString desc = name;
1093 desc.replace(
'_',
' ' );
1099 bool isOptional =
false;
1103 if ( !parseScriptCodeParameterOptions( code, isOptional, name, type, definition ) )
1108 if ( type == QStringLiteral(
"boolean" ) )
1110 else if ( type == QStringLiteral(
"crs" ) )
1112 else if ( type == QStringLiteral(
"layer" ) )
1114 else if ( type == QStringLiteral(
"extent" ) )
1116 else if ( type == QStringLiteral(
"point" ) )
1118 else if ( type == QStringLiteral(
"file" ) )
1120 else if ( type == QStringLiteral(
"folder" ) )
1122 else if ( type == QStringLiteral(
"matrix" ) )
1124 else if ( type == QStringLiteral(
"multiple" ) )
1126 else if ( type == QStringLiteral(
"number" ) )
1128 else if ( type == QStringLiteral(
"range" ) )
1130 else if ( type == QStringLiteral(
"raster" ) )
1132 else if ( type == QStringLiteral(
"enum" ) )
1134 else if ( type == QStringLiteral(
"string" ) )
1136 else if ( type == QStringLiteral(
"expression" ) )
1138 else if ( type == QStringLiteral(
"field" ) )
1140 else if ( type == QStringLiteral(
"vector" ) )
1142 else if ( type == QStringLiteral(
"source" ) )
1144 else if ( type == QStringLiteral(
"sink" ) )
1146 else if ( type == QStringLiteral(
"vectordestination" ) )
1148 else if ( type == QStringLiteral(
"rasterdestination" ) )
1150 else if ( type == QStringLiteral(
"filedestination" ) )
1152 else if ( type == QStringLiteral(
"folderdestination" ) )
1154 else if ( type == QStringLiteral(
"band" ) )
1160 bool QgsProcessingParameters::parseScriptCodeParameterOptions(
const QString &code,
bool &isOptional, QString &name, QString &type, QString &definition )
1162 QRegularExpression re( QStringLiteral(
"(?:#*)(.*?)=\\s*(.*)" ) );
1163 QRegularExpressionMatch m = re.match( code );
1164 if ( !m.hasMatch() )
1167 name = m.captured( 1 );
1168 QString tokens = m.captured( 2 );
1169 if ( tokens.startsWith( QStringLiteral(
"optional" ), Qt::CaseInsensitive ) )
1172 tokens.remove( 0, 8 );
1179 tokens = tokens.trimmed();
1181 QRegularExpression re2( QStringLiteral(
"(.*?)\\s+(.*)" ) );
1182 m = re2.match( tokens );
1183 if ( !m.hasMatch() )
1185 type = tokens.toLower().trimmed();
1190 type = m.captured( 1 ).toLower().trimmed();
1191 definition = m.captured( 2 );
1202 , mDescription( description )
1203 , mDefault( defaultValue )
1204 , mFlags( optional ? FlagOptional : 0 )
1209 if ( !input.isValid() )
1212 if ( input.type() == QVariant::String && input.toString().isEmpty() )
1221 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1228 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1230 code += QStringLiteral(
"optional " );
1231 code +=
type() +
' ';
1233 return code.trimmed();
1239 map.insert( QStringLiteral(
"parameter_type" ),
type() );
1240 map.insert( QStringLiteral(
"name" ),
mName );
1241 map.insert( QStringLiteral(
"description" ),
mDescription );
1242 map.insert( QStringLiteral(
"default" ),
mDefault );
1243 map.insert( QStringLiteral(
"flags" ), static_cast< int >(
mFlags ) );
1244 map.insert( QStringLiteral(
"metadata" ),
mMetadata );
1250 mName = map.value( QStringLiteral(
"name" ) ).toString();
1251 mDescription = map.value( QStringLiteral(
"description" ) ).toString();
1252 mDefault = map.value( QStringLiteral(
"default" ) );
1253 mFlags =
static_cast< Flags
>( map.value( QStringLiteral(
"flags" ) ).toInt() );
1254 mMetadata = map.value( QStringLiteral(
"metadata" ) ).toMap();
1270 return QStringLiteral(
"<p><b>%1</b></p><p>%2</p>" ).arg(
1272 QObject::tr(
"Python identifier: ‘%1’" ).arg( QStringLiteral(
"<i>%1</i>" ).arg(
name() ) ) );
1288 return val.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
1293 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1295 code += QStringLiteral(
"optional " );
1296 code +=
type() +
' ';
1297 code +=
mDefault.toBool() ? QStringLiteral(
"true" ) : QStringLiteral(
"false" );
1298 return code.trimmed();
1319 if ( !input.isValid() )
1328 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1331 if ( input.type() != QVariant::String || input.toString().isEmpty() )
1340 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1343 p.insert(
name(), value );
1353 return new QgsProcessingParameterCrs( name, description, definition.toLower() == QStringLiteral(
"none" ) ? QVariant() : definition, isOptional );
1369 if ( !input.isValid() )
1377 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1382 if ( input.type() != QVariant::String || input.toString().isEmpty() )
1404 p.insert(
name(), val );
1428 if ( !input.isValid() )
1448 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1451 if ( input.type() != QVariant::String || input.toString().isEmpty() )
1460 QRegularExpression rx( QStringLiteral(
"^(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*$" ) );
1461 QRegularExpressionMatch match = rx.match( input.toString() );
1462 if ( match.hasMatch() )
1464 bool xMinOk =
false;
1465 ( void )match.captured( 1 ).toDouble( &xMinOk );
1466 bool xMaxOk =
false;
1467 ( void )match.captured( 2 ).toDouble( &xMaxOk );
1468 bool yMinOk =
false;
1469 ( void )match.captured( 3 ).toDouble( &yMinOk );
1470 bool yMaxOk =
false;
1471 ( void )match.captured( 4 ).toDouble( &yMaxOk );
1472 if ( xMinOk && xMaxOk && yMinOk && yMaxOk )
1483 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1503 p.insert(
name(), value );
1529 if ( !input.isValid() )
1546 if ( input.type() == QVariant::String )
1548 if ( input.toString().isEmpty() )
1552 QRegularExpression rx( QStringLiteral(
"^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
1554 QRegularExpressionMatch match = rx.match( input.toString() );
1555 if ( match.hasMatch() )
1558 ( void )match.captured( 1 ).toDouble( &xOk );
1560 ( void )match.captured( 2 ).toDouble( &yOk );
1570 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1596 , mBehavior( behavior )
1597 , mExtension( extension )
1609 if ( !input.isValid() )
1617 QString
string = input.toString().trimmed();
1619 if ( input.type() != QVariant::String ||
string.isEmpty() )
1622 switch ( mBehavior )
1626 if ( !mExtension.isEmpty() )
1627 return string.endsWith( mExtension, Qt::CaseInsensitive );
1639 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1641 code += QStringLiteral(
"optional " );
1642 code += ( mBehavior ==
File ? QStringLiteral(
"file" ) : QStringLiteral(
"folder" ) ) +
' ';
1644 return code.trimmed();
1650 map.insert( QStringLiteral(
"behavior" ), mBehavior );
1651 map.insert( QStringLiteral(
"extension" ), mExtension );
1658 mBehavior =
static_cast< Behavior >( map.value( QStringLiteral(
"behavior" ) ).toInt() );
1659 mExtension = map.value( QStringLiteral(
"extension" ) ).toString();
1670 , mHeaders( headers )
1671 , mNumberRows( numberRows )
1672 , mFixedNumberRows( fixedNumberRows )
1684 if ( !input.isValid() )
1687 if ( input.type() == QVariant::String )
1689 if ( input.toString().isEmpty() )
1693 else if ( input.type() == QVariant::List )
1695 if ( input.toList().isEmpty() )
1699 else if ( input.type() == QVariant::Double || input.type() == QVariant::Int )
1710 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1713 p.insert(
name(), value );
1717 Q_FOREACH (
const QVariant &v, list )
1719 if ( v.type() == QVariant::List )
1722 Q_FOREACH (
const QVariant &v2, v.toList() )
1724 parts2 << v2.toString();
1726 parts << parts2.join(
',' ).prepend(
'[' ).append(
']' );
1730 parts << v.toString();
1734 return parts.join(
',' ).prepend(
'[' ).append(
']' );
1759 return mFixedNumberRows;
1764 mFixedNumberRows = fixedNumberRows;
1770 map.insert( QStringLiteral(
"headers" ), mHeaders );
1771 map.insert( QStringLiteral(
"rows" ), mNumberRows );
1772 map.insert( QStringLiteral(
"fixed_number_rows" ), mFixedNumberRows );
1779 mHeaders = map.value( QStringLiteral(
"headers" ) ).toStringList();
1780 mNumberRows = map.value( QStringLiteral(
"rows" ) ).toInt();
1781 mFixedNumberRows = map.value( QStringLiteral(
"fixed_number_rows" ) ).toBool();
1787 return new QgsProcessingParameterMatrix( name, description, 0,
false, QStringList(), definition.isEmpty() ? QVariant() : definition, isOptional );
1792 , mLayerType( layerType )
1804 if ( !input.isValid() )
1807 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( input ) ) )
1812 if ( input.type() == QVariant::String )
1814 if ( input.toString().isEmpty() )
1817 if ( mMinimumNumberInputs > 1 )
1825 else if ( input.type() == QVariant::List )
1827 if ( input.toList().count() < mMinimumNumberInputs )
1830 if ( mMinimumNumberInputs > input.toList().count() )
1836 Q_FOREACH (
const QVariant &v, input.toList() )
1838 if ( qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( v ) ) )
1846 else if ( input.type() == QVariant::StringList )
1848 if ( input.toStringList().count() < mMinimumNumberInputs )
1851 if ( mMinimumNumberInputs > input.toStringList().count() )
1857 Q_FOREACH (
const QString &v, input.toStringList() )
1870 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
1873 p.insert(
name(), value );
1875 if ( !list.isEmpty() )
1882 return parts.join(
',' ).prepend(
'[' ).append(
']' );
1890 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
1892 code += QStringLiteral(
"optional " );
1893 switch ( mLayerType )
1896 code += QStringLiteral(
"multiple raster" );
1900 code += QStringLiteral(
"multiple file" );
1904 code += QStringLiteral(
"multiple vector" );
1908 if (
mDefault.type() == QVariant::List )
1911 Q_FOREACH (
const QVariant &var,
mDefault.toList() )
1913 parts << var.toString();
1915 code += parts.join(
',' );
1917 else if (
mDefault.type() == QVariant::StringList )
1919 code +=
mDefault.toStringList().join(
',' );
1925 return code.trimmed();
1940 return mMinimumNumberInputs;
1952 map.insert( QStringLiteral(
"layer_type" ), mLayerType );
1953 map.insert( QStringLiteral(
"min_inputs" ), mMinimumNumberInputs );
1961 mMinimumNumberInputs = map.value( QStringLiteral(
"min_inputs" ) ).toInt();
1967 QString
type = definition;
1969 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)" ) );
1970 QRegularExpressionMatch m = re.match( definition );
1973 type = m.captured( 1 ).toLower().trimmed();
1974 defaultVal = m.captured( 2 );
1977 if ( type == QStringLiteral(
"vector" ) )
1979 else if ( type == QStringLiteral(
"raster" ) )
1981 else if ( type == QStringLiteral(
"file" ) )
2002 if ( !input.isValid() )
2011 double res = input.toDouble( &ok );
2015 return !( res < mMin || res > mMax );
2021 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2023 return value.toString();
2030 if ( mMin > -DBL_MAX + 1 )
2031 parts << QObject::tr(
"Minimum value: %1" ).arg( mMin );
2032 if ( mMax < DBL_MAX )
2033 parts << QObject::tr(
"Maximum value: %1" ).arg( mMax );
2035 parts << QObject::tr(
"Default value: %1" ).arg( mDataType ==
Integer ?
mDefault.toInt() :
mDefault.toDouble() );
2036 QString extra = parts.join( QStringLiteral(
"<br />" ) );
2037 if ( !extra.isEmpty() )
2038 text += QStringLiteral(
"<p>%1</p>" ).arg( extra );
2075 map.insert( QStringLiteral(
"min" ), mMin );
2076 map.insert( QStringLiteral(
"max" ), mMax );
2077 map.insert( QStringLiteral(
"data_type" ), mDataType );
2084 mMin = map.value( QStringLiteral(
"min" ) ).toDouble();
2085 mMax = map.value( QStringLiteral(
"max" ) ).toDouble();
2086 mDataType =
static_cast< Type >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
2093 : ( definition.toLower().trimmed() == QStringLiteral(
"none" ) ? QVariant() : definition ), isOptional );
2110 if ( !input.isValid() )
2118 if ( input.type() == QVariant::String )
2120 QStringList list = input.toString().split(
',' );
2121 if ( list.count() != 2 )
2124 list.at( 0 ).toDouble( &ok );
2126 list.at( 1 ).toDouble( &ok2 );
2131 else if ( input.type() == QVariant::List )
2133 if ( input.toList().count() != 2 )
2137 input.toList().at( 0 ).toDouble( &ok );
2139 input.toList().at( 1 ).toDouble( &ok2 );
2151 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2154 p.insert(
name(), value );
2157 QStringList stringParts;
2158 Q_FOREACH (
double v, parts )
2160 stringParts << QString::number( v );
2162 return stringParts.join(
',' ).prepend(
'[' ).append(
']' );
2178 map.insert( QStringLiteral(
"data_type" ), mDataType );
2207 if ( !input.isValid() )
2215 if ( qobject_cast< QgsRasterLayer * >( qvariant_cast<QObject *>( input ) ) )
2218 if ( input.type() != QVariant::String || input.toString().isEmpty() )
2240 p.insert(
name(), val );
2252 , mOptions( options )
2253 , mAllowMultiple( allowMultiple )
2265 if ( !input.isValid() )
2273 if ( input.type() == QVariant::List )
2275 if ( !mAllowMultiple )
2278 const QVariantList values = input.toList();
2282 for (
const QVariant &val : values )
2285 int res = val.toInt( &ok );
2288 else if ( res < 0 || res >= mOptions.count() )
2294 else if ( input.type() == QVariant::String )
2296 QStringList parts = input.toString().split(
',' );
2297 if ( parts.count() > 1 && !mAllowMultiple )
2300 Q_FOREACH (
const QString &part, parts )
2303 int res = part.toInt( &ok );
2306 else if ( res < 0 || res >= mOptions.count() )
2311 else if ( input.type() == QVariant::Int || input.type() == QVariant::Double )
2314 int res = input.toInt( &ok );
2317 else if ( res >= 0 && res < mOptions.count() )
2326 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2328 if ( value.type() == QVariant::List )
2331 Q_FOREACH (
const QVariant &val, value.toList() )
2333 parts << QString::number( static_cast< int >( val.toDouble() ) );
2335 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2337 else if ( value.type() == QVariant::String )
2339 QStringList parts = value.toString().split(
',' );
2340 if ( parts.count() > 1 )
2342 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2346 return QString::number( static_cast< int >( value.toDouble() ) );
2351 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2353 code += QStringLiteral(
"optional " );
2354 code += QStringLiteral(
"enum " );
2356 if ( mAllowMultiple )
2357 code += QStringLiteral(
"multiple " );
2359 code += mOptions.join(
';' ) +
' ';
2362 return code.trimmed();
2377 return mAllowMultiple;
2388 map.insert( QStringLiteral(
"options" ), mOptions );
2389 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
2396 mOptions = map.value( QStringLiteral(
"options" ) ).toStringList();
2397 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
2404 bool multiple =
false;
2405 QString def = definition;
2406 if ( def.startsWith( QStringLiteral(
"multiple" ), Qt::CaseInsensitive ) )
2412 QRegularExpression re( QStringLiteral(
"(.*)\\s+(.*?)$" ) );
2413 QRegularExpressionMatch m = re.match( def );
2414 QString values = def;
2417 values = m.captured( 1 ).trimmed();
2418 defaultVal = m.captured( 2 );
2421 return new QgsProcessingParameterEnum( name, description, values.split(
';' ), multiple, defaultVal.isEmpty() ? QVariant() : defaultVal, isOptional );
2426 , mMultiLine( multiLine )
2439 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2441 QString s = value.toString();
2442 s.replace(
'\n', QStringLiteral(
"\\n" ) );
2443 return s.prepend(
'\'' ).append(
'\'' );
2448 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2450 code += QStringLiteral(
"optional " );
2451 code += QStringLiteral(
"string " );
2454 code += QStringLiteral(
"long " );
2457 return code.trimmed();
2473 map.insert( QStringLiteral(
"multiline" ), mMultiLine );
2480 mMultiLine = map.value( QStringLiteral(
"multiline" ) ).toBool();
2486 QString def = definition;
2488 if ( def.startsWith( QStringLiteral(
"long" ), Qt::CaseInsensitive ) )
2494 if ( def.startsWith(
'"' ) || def.startsWith(
'\'' ) )
2496 if ( def.endsWith(
'"' ) || def.endsWith(
'\'' ) )
2500 if ( def == QStringLiteral(
"None" ) )
2501 defaultValue = QVariant();
2508 , mParentLayerParameterName( parentLayerParameterName )
2521 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2523 QString s = value.toString();
2524 s.replace(
'\n', QStringLiteral(
"\\n" ) );
2525 return s.prepend(
'\'' ).append(
'\'' );
2530 QStringList depends;
2531 if ( !mParentLayerParameterName.isEmpty() )
2532 depends << mParentLayerParameterName;
2538 return mParentLayerParameterName;
2549 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
2556 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
2579 if ( !var.isValid() )
2587 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( var ) ) )
2590 if ( var.type() != QVariant::String || var.toString().isEmpty() )
2612 p.insert(
name(), val );
2636 map.insert( QStringLiteral(
"data_types" ), types );
2644 QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
2645 Q_FOREACH (
const QVariant &val, values )
2659 , mParentLayerParameterName( parentLayerParameterName )
2661 , mAllowMultiple( allowMultiple )
2673 if ( !input.isValid() )
2681 if ( input.type() == QVariant::List || input.type() == QVariant::StringList )
2683 if ( !mAllowMultiple )
2689 else if ( input.type() == QVariant::String )
2691 if ( input.toString().isEmpty() )
2694 QStringList parts = input.toString().split(
';' );
2695 if ( parts.count() > 1 && !mAllowMultiple )
2700 if ( input.toString().isEmpty() )
2709 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2711 if ( value.type() == QVariant::List )
2714 Q_FOREACH (
const QVariant &val, value.toList() )
2718 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2720 else if ( value.type() == QVariant::StringList )
2723 Q_FOREACH ( QString s, value.toStringList() )
2727 return parts.join(
',' ).prepend(
'[' ).append(
']' );
2735 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2737 code += QStringLiteral(
"optional " );
2738 code += QStringLiteral(
"field " );
2740 switch ( mDataType )
2743 code += QStringLiteral(
"numeric " );
2747 code += QStringLiteral(
"string " );
2751 code += QStringLiteral(
"datetime " );
2758 if ( mAllowMultiple )
2759 code += QStringLiteral(
"multiple " );
2761 code += mParentLayerParameterName +
' ';
2764 return code.trimmed();
2769 QStringList depends;
2770 if ( !mParentLayerParameterName.isEmpty() )
2771 depends << mParentLayerParameterName;
2777 return mParentLayerParameterName;
2797 return mAllowMultiple;
2808 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
2809 map.insert( QStringLiteral(
"data_type" ), mDataType );
2810 map.insert( QStringLiteral(
"allow_multiple" ), mAllowMultiple );
2817 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
2818 mDataType =
static_cast< DataType >( map.value( QStringLiteral(
"data_type" ) ).toInt() );
2819 mAllowMultiple = map.value( QStringLiteral(
"allow_multiple" ) ).toBool();
2828 QString def = definition;
2830 if ( def.startsWith( QStringLiteral(
"numeric " ), Qt::CaseInsensitive ) )
2835 else if ( def.startsWith( QStringLiteral(
"string " ), Qt::CaseInsensitive ) )
2840 else if ( def.startsWith( QStringLiteral(
"datetime " ), Qt::CaseInsensitive ) )
2846 if ( def.startsWith( QStringLiteral(
"multiple" ), Qt::CaseInsensitive ) )
2848 allowMultiple =
true;
2849 def = def.mid( 8 ).trimmed();
2852 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
2853 QRegularExpressionMatch m = re.match( def );
2856 parent = m.captured( 1 ).trimmed();
2857 def = m.captured( 2 );
2882 QVariant var = input;
2883 if ( !var.isValid() )
2896 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
2901 if ( var.type() != QVariant::String || var.toString().isEmpty() )
2920 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
2929 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition('%1', True)" ).arg( fromVar.
source.
staticValue().toString() );
2936 layerString = layer->source();
2937 return layerString.prepend(
'\'' ).append(
'\'' );
2944 return QStringLiteral(
"QgsProcessingFeatureSourceDefinition(QgsProperty.fromExpression('%1'), True)" ).arg( fromVar.
source.
asExpression() );
2948 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
source.
asExpression() );
2952 else if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( value ) ) )
2954 return layer->source().prepend(
'\'' ).append(
'\'' );
2957 return value.toString().prepend(
'\'' ).append(
'\'' );
2962 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
2964 code += QStringLiteral(
"optional " );
2965 code += QStringLiteral(
"source " );
2972 code += QStringLiteral(
"point " );
2976 code += QStringLiteral(
"line " );
2980 code += QStringLiteral(
"polygon " );
2987 return code.trimmed();
3004 map.insert( QStringLiteral(
"data_types" ), types );
3012 QVariantList values = map.value( QStringLiteral(
"data_types" ) ).toList();
3013 Q_FOREACH (
const QVariant &val, values )
3023 QString def = definition;
3026 if ( def.startsWith( QStringLiteral(
"point" ), Qt::CaseInsensitive ) )
3032 else if ( def.startsWith( QStringLiteral(
"line" ), Qt::CaseInsensitive ) )
3038 else if ( def.startsWith( QStringLiteral(
"polygon" ), Qt::CaseInsensitive ) )
3064 QVariant var = input;
3065 if ( !var.isValid() )
3079 if ( var.type() != QVariant::String )
3082 if ( var.toString().isEmpty() )
3091 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3098 return QStringLiteral(
"'%1'" ).arg( fromVar.
sink.
staticValue().toString() );
3102 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
3106 return value.toString().prepend(
'\'' ).append(
'\'' );
3111 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3113 code += QStringLiteral(
"optional " );
3114 code += QStringLiteral(
"sink " );
3116 switch ( mDataType )
3119 code += QStringLiteral(
"point " );
3123 code += QStringLiteral(
"line " );
3127 code += QStringLiteral(
"polygon " );
3131 code += QStringLiteral(
"table " );
3139 return code.trimmed();
3151 return p->defaultVectorFileExtension(
hasGeometry() );
3158 return settings.
value( QStringLiteral(
"Processing/DefaultOutputVectorLayerExt" ), QStringLiteral(
"shp" ),
QgsSettings::Core ).toString();
3162 return QStringLiteral(
"dbf" );
3174 switch ( mDataType )
3199 map.insert( QStringLiteral(
"data_type" ), mDataType );
3213 return QStringLiteral(
"memory:%1" ).arg(
description() );
3221 QString def = definition;
3222 if ( def.startsWith( QStringLiteral(
"point" ), Qt::CaseInsensitive ) )
3227 else if ( def.startsWith( QStringLiteral(
"line" ), Qt::CaseInsensitive ) )
3232 else if ( def.startsWith( QStringLiteral(
"polygon" ), Qt::CaseInsensitive ) )
3237 else if ( def.startsWith( QStringLiteral(
"table" ), Qt::CaseInsensitive ) )
3257 QVariant var = input;
3258 if ( !var.isValid() )
3272 if ( var.type() != QVariant::String )
3275 if ( var.toString().isEmpty() )
3284 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3291 return QStringLiteral(
"'%1'" ).arg( fromVar.
sink.
staticValue().toString() );
3295 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
3299 return value.toString().prepend(
'\'' ).append(
'\'' );
3311 return p->defaultRasterFileExtension();
3316 return settings.
value( QStringLiteral(
"Processing/DefaultOutputRasterLayerExt" ), QStringLiteral(
"tif" ),
QgsSettings::Core ).toString();
3328 , mFileFilter( fileFilter.isEmpty() ? QObject::tr(
"All files (*.*)" ) : fileFilter )
3340 QVariant var = input;
3341 if ( !var.isValid() )
3355 if ( var.type() != QVariant::String )
3358 if ( var.toString().isEmpty() )
3369 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3376 return QStringLiteral(
"'%1'" ).arg( fromVar.
sink.
staticValue().toString() );
3380 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
3384 return value.toString().prepend(
'\'' ).append(
'\'' );
3389 if ( !mFileFilter.isEmpty() && mFileFilter.contains( QStringLiteral(
"htm" ), Qt::CaseInsensitive ) )
3401 if ( mFileFilter.isEmpty() || mFileFilter == QObject::tr(
"All files (*.*)" ) )
3402 return QStringLiteral(
"file" );
3405 QRegularExpression rx( QStringLiteral(
".*?\\(\\*\\.([a-zA-Z0-9._]+).*" ) );
3406 QRegularExpressionMatch match = rx.match( mFileFilter );
3407 if ( !match.hasMatch() )
3408 return QStringLiteral(
"file" );
3410 return match.captured( 1 );
3426 map.insert( QStringLiteral(
"file_filter" ), mFileFilter );
3433 mFileFilter = map.value( QStringLiteral(
"file_filter" ) ).toString();
3454 QVariant var = input;
3455 if ( !var.isValid() )
3463 if ( var.type() != QVariant::String )
3466 if ( var.toString().isEmpty() )
3496 map.insert( QStringLiteral(
"supports_non_file_outputs" ), mSupportsNonFileBasedOutputs );
3497 map.insert( QStringLiteral(
"create_by_default" ), mCreateByDefault );
3504 mSupportsNonFileBasedOutputs = map.value( QStringLiteral(
"supports_non_file_outputs" ) ).toBool();
3505 mCreateByDefault = map.value( QStringLiteral(
"create_by_default" ), QStringLiteral(
"1" ) ).toBool();
3516 return mCreateByDefault;
3538 QVariant var = input;
3539 if ( !var.isValid() )
3553 if ( var.type() != QVariant::String )
3556 if ( var.toString().isEmpty() )
3565 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3572 return QStringLiteral(
"'%1'" ).arg( fromVar.
sink.
staticValue().toString() );
3576 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( fromVar.
sink.
asExpression() );
3580 return value.toString().prepend(
'\'' ).append(
'\'' );
3585 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3587 code += QStringLiteral(
"optional " );
3588 code += QStringLiteral(
"vectorDestination " );
3590 switch ( mDataType )
3593 code += QStringLiteral(
"point " );
3597 code += QStringLiteral(
"line " );
3601 code += QStringLiteral(
"polygon " );
3609 return code.trimmed();
3621 return p->defaultVectorFileExtension(
hasGeometry() );
3628 return settings.
value( QStringLiteral(
"Processing/DefaultOutputVectorLayerExt" ), QStringLiteral(
"shp" ),
QgsSettings::Core ).toString();
3632 return QStringLiteral(
"dbf" );
3644 switch ( mDataType )
3669 map.insert( QStringLiteral(
"data_type" ), mDataType );
3683 QString def = definition;
3684 if ( def.startsWith( QStringLiteral(
"point" ), Qt::CaseInsensitive ) )
3689 else if ( def.startsWith( QStringLiteral(
"line" ), Qt::CaseInsensitive ) )
3694 else if ( def.startsWith( QStringLiteral(
"polygon" ), Qt::CaseInsensitive ) )
3705 , mParentLayerParameterName( parentLayerParameterName )
3717 if ( !input.isValid() )
3726 double res = input.toInt( &ok );
3737 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
3739 return value.toString();
3744 QString code = QStringLiteral(
"##%1=" ).arg(
mName );
3746 code += QStringLiteral(
"optional " );
3747 code += QStringLiteral(
"band " );
3749 code += mParentLayerParameterName +
' ';
3752 return code.trimmed();
3757 QStringList depends;
3758 if ( !mParentLayerParameterName.isEmpty() )
3759 depends << mParentLayerParameterName;
3765 return mParentLayerParameterName;
3776 map.insert( QStringLiteral(
"parent_layer" ), mParentLayerParameterName );
3783 mParentLayerParameterName = map.value( QStringLiteral(
"parent_layer" ) ).toString();
3790 QString def = definition;
3792 QRegularExpression re( QStringLiteral(
"(.*?)\\s+(.*)$" ) );
3793 QRegularExpressionMatch m = re.match( def );
3796 parent = m.captured( 1 ).trimmed();
3797 def = m.captured( 2 );
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.
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.
QgsProcessingDestinationParameter(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingDestinationParameter.
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.
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.
bool hasFixedNumberRows() const
Returns whether the table has a fixed number of rows.
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.
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:
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.
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...
QgsProcessingParameterFeatureSink(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFeatureSink.
QgsProcessingParameterRasterDestination(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterRasterDestination.
QString defaultFileExtension() const override
Returns the default file extension for destination file paths associated with this parameter...
QgsProcessingAlgorithm * mAlgorithm
Pointer to algorithm which owns this parameter.
static QString typeName()
Returns the type name for the parameter class.
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
bool 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 customise 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.
static QgsProcessingParameterMapLayer * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
bool 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.
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...
QgsProcessingParameterNumber(const QString &name, const QString &description=QString(), Type type=Integer, const QVariant &defaultValue=QVariant(), bool optional=false, double minValue=-DBL_MAX+1, double maxValue=DBL_MAX)
Constructor for QgsProcessingParameterNumber.
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.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning)
add a message to the instance (and create it if necessary)
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.
QgsProcessingParameterVectorDestination(const QString &name, const QString &description=QString(), QgsProcessing::SourceType type=QgsProcessing::TypeVectorAnyGeometry, const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterVectorDestination.
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.
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.
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.
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.
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...
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.
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.
QVariantMap toVariantMap() const override
Saves this parameter to a QVariantMap.
A file output for processing algorithms.
QgsCoordinateReferenceSystem crs
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.
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.
QStringList options() const
Returns the list of acceptable options for the parameter.
A QgsRectangle with associated coordinate reference system.
QStringList dependsOnOtherParameters() const override
Returns a list of other parameter names on which this parameter is dependent (e.g.
A coordinate reference system parameter for processing algorithms.
static QgsProcessingFeatureSource * variantToSource(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a new feature source.
A store for object properties.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
A rectangular map extent parameter for processing algorithms.
void setMinimumNumberInputs(int minimum)
Sets the minimum number of layers required for the parameter.
QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const override
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
void setLayerType(QgsProcessing::SourceType type)
Sets the layer type for layers acceptable by the parameter.
void setAllowMultiple(bool allowMultiple)
Sets whether the parameter allows multiple selected values.
QgsProcessingParameterDefinition * clone() const override
Creates a clone of the parameter definition.
A numeric parameter for processing algorithms.
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...
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
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.
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.
QgsProcessingParameterFileDestination(const QString &name, const QString &description=QString(), const QString &fileFilter=QString(), const QVariant &defaultValue=QVariant(), bool optional=false)
Constructor for QgsProcessingParameterFileDestination.
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.
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...
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.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), const Section section=NoSection) const
Returns the value for setting key.
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)
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.
Details for layers to load into projects.
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.
An 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.
static QgsProcessingParameterEnum * fromScriptCode(const QString &name, const QString &description, bool isOptional, const QString &definition)
Creates a new parameter using the definition from a script code.
QString mDescription
Parameter description.
void setFileFilter(const QString &filter)
Sets the file filter string for file destinations compatible with this parameter. ...
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
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...
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.
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.
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 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.