mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Minor processing parameter evaluation refactoring
This commit is contained in:
parent
9a1f129640
commit
bef88f30df
@ -491,36 +491,85 @@ be evaluated once for every input feature processed.
|
||||
static QString parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a static string value.
|
||||
%End
|
||||
|
||||
static QString parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a static string value.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QString parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to an expression.
|
||||
%End
|
||||
|
||||
static QString parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definitionand`` ``value`` to an expression.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static double parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a static double value.
|
||||
%End
|
||||
|
||||
static double parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a static double value.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static int parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a static integer value.
|
||||
%End
|
||||
|
||||
static int parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a static integer value.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static int parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a enum value.
|
||||
%End
|
||||
|
||||
static int parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a enum value.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QList<int> parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to list of enum values.
|
||||
%End
|
||||
|
||||
static QList<int> parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to list of enum values.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static bool parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a static boolean value.
|
||||
%End
|
||||
|
||||
static bool parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a static boolean value.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QgsFeatureSink *parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters,
|
||||
@ -538,6 +587,25 @@ argument will be set to a string which can be used to retrieve the layer corresp
|
||||
to the sink, e.g. via calling :py:func:`QgsProcessingUtils.mapLayerFromString()`
|
||||
|
||||
This function creates a new object and the caller takes responsibility for deleting the returned object.
|
||||
%End
|
||||
|
||||
static QgsFeatureSink *parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariant &value,
|
||||
const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs,
|
||||
QgsProcessingContext &context, QString &destinationIdentifier /Out/ ) /Factory/;
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a feature sink.
|
||||
|
||||
The ``fields``, ``geometryType`` and ``crs`` parameters dictate the properties
|
||||
of the resulting feature sink.
|
||||
|
||||
Sinks will either be taken from ``context``'s active project, or created from external
|
||||
providers and stored temporarily in the ``context``. The ``destinationIdentifier``
|
||||
argument will be set to a string which can be used to retrieve the layer corresponding
|
||||
to the sink, e.g. via calling :py:func:`QgsProcessingUtils.mapLayerFromString()`
|
||||
|
||||
This function creates a new object and the caller takes responsibility for deleting the returned object.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QgsProcessingFeatureSource *parameterAsSource( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context ) /Factory/;
|
||||
@ -548,6 +616,18 @@ Sources will either be taken from ``context``'s active project, or loaded from e
|
||||
sources and stored temporarily in the ``context``.
|
||||
|
||||
This function creates a new object and the caller takes responsibility for deleting the returned object.
|
||||
%End
|
||||
|
||||
static QgsProcessingFeatureSource *parameterAsSource( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context ) /Factory/;
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a feature source.
|
||||
|
||||
Sources will either be taken from ``context``'s active project, or loaded from external
|
||||
sources and stored temporarily in the ``context``.
|
||||
|
||||
This function creates a new object and the caller takes responsibility for deleting the returned object.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QString parameterAsCompatibleSourceLayerPath( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters,
|
||||
@ -572,6 +652,17 @@ Evaluates the parameter with matching ``definition`` to a map layer.
|
||||
Layers will either be taken from ``context``'s active project, or loaded from external
|
||||
sources and stored temporarily in the ``context``. In either case, callers do not
|
||||
need to handle deletion of the returned layer.
|
||||
%End
|
||||
|
||||
static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a map layer.
|
||||
|
||||
Layers will either be taken from ``context``'s active project, or loaded from external
|
||||
sources and stored temporarily in the ``context``. In either case, callers do not
|
||||
need to handle deletion of the returned layer.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QgsRasterLayer *parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
@ -581,16 +672,41 @@ Evaluates the parameter with matching ``definition`` to a raster layer.
|
||||
Layers will either be taken from ``context``'s active project, or loaded from external
|
||||
sources and stored temporarily in the ``context``. In either case, callers do not
|
||||
need to handle deletion of the returned layer.
|
||||
%End
|
||||
|
||||
static QgsRasterLayer *parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a raster layer.
|
||||
|
||||
Layers will either be taken from ``context``'s active project, or loaded from external
|
||||
sources and stored temporarily in the ``context``. In either case, callers do not
|
||||
need to handle deletion of the returned layer.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a output layer destination.
|
||||
%End
|
||||
|
||||
static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a output layer destination.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QString parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a file based output destination.
|
||||
%End
|
||||
|
||||
static QString parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a file based output destination.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QgsVectorLayer *parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
@ -600,11 +716,29 @@ Evaluates the parameter with matching ``definition`` to a vector layer.
|
||||
Layers will either be taken from ``context``'s active project, or loaded from external
|
||||
sources and stored temporarily in the ``context``. In either case, callers do not
|
||||
need to handle deletion of the returned layer.
|
||||
%End
|
||||
|
||||
static QgsVectorLayer *parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a vector layer.
|
||||
|
||||
Layers will either be taken from ``context``'s active project, or loaded from external
|
||||
sources and stored temporarily in the ``context``. In either case, callers do not
|
||||
need to handle deletion of the returned layer.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QgsCoordinateReferenceSystem parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a coordinate reference system.
|
||||
%End
|
||||
|
||||
static QgsCoordinateReferenceSystem parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a coordinate reference system.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QgsRectangle parameterAsExtent( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context,
|
||||
@ -618,6 +752,21 @@ reprojected so that it is in the specified ``crs``. In this case the extent of t
|
||||
.. seealso:: :py:func:`parameterAsExtentGeometry`
|
||||
|
||||
.. seealso:: :py:func:`parameterAsExtentCrs`
|
||||
%End
|
||||
|
||||
static QgsRectangle parameterAsExtent( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context,
|
||||
const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a rectangular extent.
|
||||
|
||||
If ``crs`` is set, and the original coordinate reference system of the parameter can be determined, then the extent will be automatically
|
||||
reprojected so that it is in the specified ``crs``. In this case the extent of the reproject rectangle will be returned.
|
||||
|
||||
.. seealso:: :py:func:`parameterAsExtentGeometry`
|
||||
|
||||
.. seealso:: :py:func:`parameterAsExtentCrs`
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QgsGeometry parameterAsExtentGeometry( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context,
|
||||
@ -650,6 +799,18 @@ Evaluates the parameter with matching ``definition`` to a point.
|
||||
If ``crs`` is set then the point will be automatically reprojected so that it is in the specified ``crs``.
|
||||
|
||||
.. seealso:: :py:func:`parameterAsPointCrs`
|
||||
%End
|
||||
|
||||
static QgsPointXY parameterAsPoint( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context,
|
||||
const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a point.
|
||||
|
||||
If ``crs`` is set then the point will be automatically reprojected so that it is in the specified ``crs``.
|
||||
|
||||
.. seealso:: :py:func:`parameterAsPointCrs`
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QgsCoordinateReferenceSystem parameterAsPointCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
@ -662,27 +823,63 @@ Returns the coordinate reference system associated with an point parameter value
|
||||
static QString parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a file/folder name.
|
||||
%End
|
||||
|
||||
static QString parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a file/folder name.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QVariantList parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a matrix/table of values.
|
||||
Tables are collapsed to a 1 dimensional list.
|
||||
%End
|
||||
|
||||
static QVariantList parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a matrix/table of values.
|
||||
Tables are collapsed to a 1 dimensional list.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QList< QgsMapLayer *> parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a list of map layers.
|
||||
%End
|
||||
|
||||
static QList< QgsMapLayer *> parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a list of map layers.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QList<double> parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a range of values.
|
||||
%End
|
||||
|
||||
static QList<double> parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a range of values.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QStringList parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a list of fields.
|
||||
%End
|
||||
|
||||
static QStringList parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a list of fields.
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
static QgsProcessingParameterDefinition *parameterFromVariantMap( const QVariantMap &map ) /Factory/;
|
||||
|
@ -60,7 +60,15 @@ QString QgsProcessingParameters::parameterAsString( const QgsProcessingParameter
|
||||
if ( !definition )
|
||||
return QString();
|
||||
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
return parameterAsString( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
QString QgsProcessingParameters::parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return QString();
|
||||
|
||||
QVariant val = value;
|
||||
if ( val.canConvert<QgsProperty>() )
|
||||
return val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
|
||||
|
||||
@ -78,7 +86,15 @@ QString QgsProcessingParameters::parameterAsExpression( const QgsProcessingParam
|
||||
if ( !definition )
|
||||
return QString();
|
||||
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
return parameterAsExpression( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
QString QgsProcessingParameters::parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return QString();
|
||||
|
||||
QVariant val = value;
|
||||
if ( val.canConvert<QgsProperty>() )
|
||||
return val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
|
||||
|
||||
@ -98,7 +114,15 @@ double QgsProcessingParameters::parameterAsDouble( const QgsProcessingParameterD
|
||||
if ( !definition )
|
||||
return 0;
|
||||
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
return parameterAsDouble( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
double QgsProcessingParameters::parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return 0;
|
||||
|
||||
QVariant val = value;
|
||||
if ( val.canConvert<QgsProperty>() )
|
||||
return val.value< QgsProperty >().valueAsDouble( context.expressionContext(), definition->defaultValue().toDouble() );
|
||||
|
||||
@ -117,7 +141,15 @@ int QgsProcessingParameters::parameterAsInt( const QgsProcessingParameterDefinit
|
||||
if ( !definition )
|
||||
return 0;
|
||||
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
return parameterAsInt( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
int QgsProcessingParameters::parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return 0;
|
||||
|
||||
QVariant val = value;
|
||||
if ( val.canConvert<QgsProperty>() )
|
||||
return val.value< QgsProperty >().valueAsInt( context.expressionContext(), definition->defaultValue().toInt() );
|
||||
|
||||
@ -140,7 +172,7 @@ int QgsProcessingParameters::parameterAsInt( const QgsProcessingParameterDefinit
|
||||
//double too large to fit in int
|
||||
return 0;
|
||||
}
|
||||
return std::round( dbl );
|
||||
return static_cast< int >( std::round( dbl ) );
|
||||
}
|
||||
|
||||
return val.toInt();
|
||||
@ -151,7 +183,15 @@ int QgsProcessingParameters::parameterAsEnum( const QgsProcessingParameterDefini
|
||||
if ( !definition )
|
||||
return 0;
|
||||
|
||||
int val = parameterAsInt( definition, parameters, context );
|
||||
return parameterAsEnum( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
int QgsProcessingParameters::parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return 0;
|
||||
|
||||
int val = parameterAsInt( definition, value, context );
|
||||
const QgsProcessingParameterEnum *enumDef = dynamic_cast< const QgsProcessingParameterEnum *>( definition );
|
||||
if ( enumDef && val >= enumDef->options().size() )
|
||||
{
|
||||
@ -166,7 +206,16 @@ QList<int> QgsProcessingParameters::parameterAsEnums( const QgsProcessingParamet
|
||||
return QList<int>();
|
||||
|
||||
QVariantList resultList;
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
return parameterAsEnums( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
QList<int> QgsProcessingParameters::parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return QList<int>();
|
||||
|
||||
QVariantList resultList;
|
||||
QVariant val = value;
|
||||
if ( val.canConvert<QgsProperty>() )
|
||||
resultList << val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
|
||||
else if ( val.type() == QVariant::List )
|
||||
@ -217,13 +266,21 @@ QList<int> QgsProcessingParameters::parameterAsEnums( const QgsProcessingParamet
|
||||
}
|
||||
|
||||
bool QgsProcessingParameters::parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return false;
|
||||
|
||||
return parameterAsBool( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
bool QgsProcessingParameters::parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return false;
|
||||
|
||||
QVariant def = definition->defaultValue();
|
||||
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
QVariant val = value;
|
||||
if ( val.canConvert<QgsProperty>() )
|
||||
return val.value< QgsProperty >().valueAsBool( context.expressionContext(), def.toBool() );
|
||||
else if ( val.isValid() )
|
||||
@ -242,6 +299,13 @@ QgsFeatureSink *QgsProcessingParameters::parameterAsSink( const QgsProcessingPar
|
||||
val = parameters.value( definition->name() );
|
||||
}
|
||||
|
||||
return parameterAsSink( definition, val, fields, geometryType, crs, context, destinationIdentifier );
|
||||
}
|
||||
|
||||
QgsFeatureSink *QgsProcessingParameters::parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context, QString &destinationIdentifier )
|
||||
{
|
||||
QVariant val = value;
|
||||
|
||||
QgsProject *destinationProject = nullptr;
|
||||
QString destName;
|
||||
QVariantMap createOptions;
|
||||
@ -301,9 +365,15 @@ QgsProcessingFeatureSource *QgsProcessingParameters::parameterAsSource( const Qg
|
||||
if ( !definition )
|
||||
return nullptr;
|
||||
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
return parameterAsSource( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
return QgsProcessingUtils::variantToSource( val, context, definition->defaultValue() );
|
||||
QgsProcessingFeatureSource *QgsProcessingParameters::parameterAsSource( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return nullptr;
|
||||
|
||||
return QgsProcessingUtils::variantToSource( value, context, definition->defaultValue() );
|
||||
}
|
||||
|
||||
QString QgsProcessingParameters::parameterAsCompatibleSourceLayerPath( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingFeedback *feedback )
|
||||
@ -380,7 +450,15 @@ QgsMapLayer *QgsProcessingParameters::parameterAsLayer( const QgsProcessingParam
|
||||
if ( !definition )
|
||||
return nullptr;
|
||||
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
return parameterAsLayer( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
QgsMapLayer *QgsProcessingParameters::parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return nullptr;
|
||||
|
||||
QVariant val = value;
|
||||
if ( val.canConvert<QgsProperty>() )
|
||||
{
|
||||
val = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
|
||||
@ -417,6 +495,11 @@ QgsRasterLayer *QgsProcessingParameters::parameterAsRasterLayer( const QgsProces
|
||||
return qobject_cast< QgsRasterLayer *>( parameterAsLayer( definition, parameters, context ) );
|
||||
}
|
||||
|
||||
QgsRasterLayer *QgsProcessingParameters::parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
return qobject_cast< QgsRasterLayer *>( parameterAsLayer( definition, value, context ) );
|
||||
}
|
||||
|
||||
QString QgsProcessingParameters::parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context )
|
||||
{
|
||||
QVariant val;
|
||||
@ -424,6 +507,12 @@ QString QgsProcessingParameters::parameterAsOutputLayer( const QgsProcessingPara
|
||||
{
|
||||
val = parameters.value( definition->name() );
|
||||
}
|
||||
return parameterAsOutputLayer( definition, val, context );
|
||||
}
|
||||
|
||||
QString QgsProcessingParameters::parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
QVariant val = value;
|
||||
|
||||
QgsProject *destinationProject = nullptr;
|
||||
QVariantMap createOptions;
|
||||
@ -475,6 +564,12 @@ QString QgsProcessingParameters::parameterAsFileOutput( const QgsProcessingParam
|
||||
{
|
||||
val = parameters.value( definition->name() );
|
||||
}
|
||||
return parameterAsFileOutput( definition, val, context );
|
||||
}
|
||||
|
||||
QString QgsProcessingParameters::parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
QVariant val = value;
|
||||
|
||||
if ( val.canConvert<QgsProcessingOutputLayerDefinition>() )
|
||||
{
|
||||
@ -506,12 +601,25 @@ QgsVectorLayer *QgsProcessingParameters::parameterAsVectorLayer( const QgsProces
|
||||
return qobject_cast< QgsVectorLayer *>( parameterAsLayer( definition, parameters, context ) );
|
||||
}
|
||||
|
||||
QgsVectorLayer *QgsProcessingParameters::parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
return qobject_cast< QgsVectorLayer *>( parameterAsVectorLayer( definition, value, context ) );
|
||||
}
|
||||
|
||||
QgsCoordinateReferenceSystem QgsProcessingParameters::parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return QgsCoordinateReferenceSystem();
|
||||
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
return parameterAsCrs( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
QgsCoordinateReferenceSystem QgsProcessingParameters::parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return QgsCoordinateReferenceSystem();
|
||||
|
||||
QVariant val = value;
|
||||
|
||||
if ( val.canConvert<QgsProcessingFeatureSourceDefinition>() )
|
||||
{
|
||||
@ -571,7 +679,15 @@ QgsRectangle QgsProcessingParameters::parameterAsExtent( const QgsProcessingPara
|
||||
if ( !definition )
|
||||
return QgsRectangle();
|
||||
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
return parameterAsExtent( definition, parameters.value( definition->name() ), context, crs );
|
||||
}
|
||||
|
||||
QgsRectangle QgsProcessingParameters::parameterAsExtent( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs )
|
||||
{
|
||||
if ( !definition )
|
||||
return QgsRectangle();
|
||||
|
||||
QVariant val = value;
|
||||
|
||||
if ( val.canConvert< QgsRectangle >() )
|
||||
{
|
||||
@ -881,7 +997,15 @@ QgsPointXY QgsProcessingParameters::parameterAsPoint( const QgsProcessingParamet
|
||||
if ( !definition )
|
||||
return QgsPointXY();
|
||||
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
return parameterAsPoint( definition, parameters.value( definition->name() ), context, crs );
|
||||
}
|
||||
|
||||
QgsPointXY QgsProcessingParameters::parameterAsPoint( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context, const QgsCoordinateReferenceSystem &crs )
|
||||
{
|
||||
if ( !definition )
|
||||
return QgsPointXY();
|
||||
|
||||
QVariant val = value;
|
||||
if ( val.canConvert< QgsPointXY >() )
|
||||
{
|
||||
return val.value<QgsPointXY>();
|
||||
@ -904,7 +1028,7 @@ QgsPointXY QgsProcessingParameters::parameterAsPoint( const QgsProcessingParamet
|
||||
return rp;
|
||||
}
|
||||
|
||||
QString pointText = parameterAsString( definition, parameters, context );
|
||||
QString pointText = parameterAsString( definition, value, context );
|
||||
if ( pointText.isEmpty() )
|
||||
pointText = definition->defaultValue().toString();
|
||||
|
||||
@ -913,7 +1037,7 @@ QgsPointXY QgsProcessingParameters::parameterAsPoint( const QgsProcessingParamet
|
||||
|
||||
QRegularExpression rx( QStringLiteral( "^\\s*\\(?\\s*(.*?)\\s*,\\s*(.*?)\\s*(?:\\[(.*)\\])?\\s*\\)?\\s*$" ) );
|
||||
|
||||
QString valueAsString = parameterAsString( definition, parameters, context );
|
||||
QString valueAsString = parameterAsString( definition, value, context );
|
||||
QRegularExpressionMatch match = rx.match( valueAsString );
|
||||
if ( match.hasMatch() )
|
||||
{
|
||||
@ -987,13 +1111,32 @@ QString QgsProcessingParameters::parameterAsFile( const QgsProcessingParameterDe
|
||||
return fileText;
|
||||
}
|
||||
|
||||
QString QgsProcessingParameters::parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return QString();
|
||||
|
||||
QString fileText = parameterAsString( definition, value, context );
|
||||
if ( fileText.isEmpty() )
|
||||
fileText = definition->defaultValue().toString();
|
||||
return fileText;
|
||||
}
|
||||
|
||||
QVariantList QgsProcessingParameters::parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return QVariantList();
|
||||
|
||||
return parameterAsMatrix( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
QVariantList QgsProcessingParameters::parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return QVariantList();
|
||||
|
||||
QString resultString;
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
QVariant val = value;
|
||||
if ( val.canConvert<QgsProperty>() )
|
||||
resultString = val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
|
||||
else if ( val.type() == QVariant::List )
|
||||
@ -1022,7 +1165,15 @@ QList<QgsMapLayer *> QgsProcessingParameters::parameterAsLayerList( const QgsPro
|
||||
if ( !definition )
|
||||
return QList<QgsMapLayer *>();
|
||||
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
return parameterAsLayerList( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
QList<QgsMapLayer *> QgsProcessingParameters::parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return QList<QgsMapLayer *>();
|
||||
|
||||
QVariant val = value;
|
||||
if ( QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
|
||||
{
|
||||
return QList<QgsMapLayer *>() << layer;
|
||||
@ -1100,12 +1251,20 @@ QList<QgsMapLayer *> QgsProcessingParameters::parameterAsLayerList( const QgsPro
|
||||
}
|
||||
|
||||
QList<double> QgsProcessingParameters::parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return QList<double>();
|
||||
|
||||
return parameterAsRange( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
QList<double> QgsProcessingParameters::parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return QList<double>();
|
||||
|
||||
QStringList resultStringList;
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
QVariant val = value;
|
||||
if ( val.canConvert<QgsProperty>() )
|
||||
resultStringList << val.value< QgsProperty >().valueAsString( context.expressionContext(), definition->defaultValue().toString() );
|
||||
else if ( val.type() == QVariant::List )
|
||||
@ -1146,7 +1305,16 @@ QStringList QgsProcessingParameters::parameterAsFields( const QgsProcessingParam
|
||||
return QStringList();
|
||||
|
||||
QStringList resultStringList;
|
||||
QVariant val = parameters.value( definition->name() );
|
||||
return parameterAsFields( definition, parameters.value( definition->name() ), context );
|
||||
}
|
||||
|
||||
QStringList QgsProcessingParameters::parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
if ( !definition )
|
||||
return QStringList();
|
||||
|
||||
QStringList resultStringList;
|
||||
QVariant val = value;
|
||||
if ( val.isValid() )
|
||||
{
|
||||
if ( val.canConvert<QgsProperty>() )
|
||||
|
@ -563,36 +563,78 @@ class CORE_EXPORT QgsProcessingParameters
|
||||
*/
|
||||
static QString parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a static string value.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QString parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to an expression.
|
||||
*/
|
||||
static QString parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definitionand \a value to an expression.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QString parameterAsExpression( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a static double value.
|
||||
*/
|
||||
static double parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a static double value.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static double parameterAsDouble( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a static integer value.
|
||||
*/
|
||||
static int parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a static integer value.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static int parameterAsInt( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a enum value.
|
||||
*/
|
||||
static int parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a enum value.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static int parameterAsEnum( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to list of enum values.
|
||||
*/
|
||||
static QList<int> parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to list of enum values.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QList<int> parameterAsEnums( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a static boolean value.
|
||||
*/
|
||||
static bool parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a static boolean value.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static bool parameterAsBool( const QgsProcessingParameterDefinition *definition, const QVariant &value, const QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a feature sink.
|
||||
*
|
||||
@ -610,6 +652,25 @@ class CORE_EXPORT QgsProcessingParameters
|
||||
const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs,
|
||||
QgsProcessingContext &context, QString &destinationIdentifier SIP_OUT ) SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a feature sink.
|
||||
*
|
||||
* The \a fields, \a geometryType and \a crs parameters dictate the properties
|
||||
* of the resulting feature sink.
|
||||
*
|
||||
* Sinks will either be taken from \a context's active project, or created from external
|
||||
* providers and stored temporarily in the \a context. The \a destinationIdentifier
|
||||
* argument will be set to a string which can be used to retrieve the layer corresponding
|
||||
* to the sink, e.g. via calling QgsProcessingUtils::mapLayerFromString().
|
||||
*
|
||||
* This function creates a new object and the caller takes responsibility for deleting the returned object.
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QgsFeatureSink *parameterAsSink( const QgsProcessingParameterDefinition *definition, const QVariant &value,
|
||||
const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs,
|
||||
QgsProcessingContext &context, QString &destinationIdentifier SIP_OUT ) SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a feature source.
|
||||
*
|
||||
@ -620,6 +681,18 @@ class CORE_EXPORT QgsProcessingParameters
|
||||
*/
|
||||
static QgsProcessingFeatureSource *parameterAsSource( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context ) SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a feature source.
|
||||
*
|
||||
* Sources will either be taken from \a context's active project, or loaded from external
|
||||
* sources and stored temporarily in the \a context.
|
||||
*
|
||||
* This function creates a new object and the caller takes responsibility for deleting the returned object.
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QgsProcessingFeatureSource *parameterAsSource( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context ) SIP_FACTORY;
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a source vector layer file path of compatible format.
|
||||
*
|
||||
@ -644,6 +717,17 @@ class CORE_EXPORT QgsProcessingParameters
|
||||
*/
|
||||
static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a map layer.
|
||||
*
|
||||
* Layers will either be taken from \a context's active project, or loaded from external
|
||||
* sources and stored temporarily in the \a context. In either case, callers do not
|
||||
* need to handle deletion of the returned layer.
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a raster layer.
|
||||
*
|
||||
@ -653,16 +737,39 @@ class CORE_EXPORT QgsProcessingParameters
|
||||
*/
|
||||
static QgsRasterLayer *parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a raster layer.
|
||||
*
|
||||
* Layers will either be taken from \a context's active project, or loaded from external
|
||||
* sources and stored temporarily in the \a context. In either case, callers do not
|
||||
* need to handle deletion of the returned layer.
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QgsRasterLayer *parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a output layer destination.
|
||||
*/
|
||||
static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a output layer destination.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QString parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a file based output destination.
|
||||
*/
|
||||
static QString parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a file based output destination.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QString parameterAsFileOutput( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a vector layer.
|
||||
*
|
||||
@ -672,11 +779,28 @@ class CORE_EXPORT QgsProcessingParameters
|
||||
*/
|
||||
static QgsVectorLayer *parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a vector layer.
|
||||
*
|
||||
* Layers will either be taken from \a context's active project, or loaded from external
|
||||
* sources and stored temporarily in the \a context. In either case, callers do not
|
||||
* need to handle deletion of the returned layer.
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QgsVectorLayer *parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a coordinate reference system.
|
||||
*/
|
||||
static QgsCoordinateReferenceSystem parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a coordinate reference system.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QgsCoordinateReferenceSystem parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a rectangular extent.
|
||||
*
|
||||
@ -689,6 +813,20 @@ class CORE_EXPORT QgsProcessingParameters
|
||||
static QgsRectangle parameterAsExtent( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context,
|
||||
const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a rectangular extent.
|
||||
*
|
||||
* If \a crs is set, and the original coordinate reference system of the parameter can be determined, then the extent will be automatically
|
||||
* reprojected so that it is in the specified \a crs. In this case the extent of the reproject rectangle will be returned.
|
||||
*
|
||||
* \see parameterAsExtentGeometry()
|
||||
* \see parameterAsExtentCrs()
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QgsRectangle parameterAsExtent( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context,
|
||||
const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a rectangular extent, and returns a geometry covering this extent.
|
||||
*
|
||||
@ -720,6 +858,17 @@ class CORE_EXPORT QgsProcessingParameters
|
||||
static QgsPointXY parameterAsPoint( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context,
|
||||
const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a point.
|
||||
*
|
||||
* If \a crs is set then the point will be automatically reprojected so that it is in the specified \a crs.
|
||||
*
|
||||
* \see parameterAsPointCrs()
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QgsPointXY parameterAsPoint( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context,
|
||||
const QgsCoordinateReferenceSystem &crs = QgsCoordinateReferenceSystem() );
|
||||
|
||||
/**
|
||||
* Returns the coordinate reference system associated with an point parameter value.
|
||||
*
|
||||
@ -732,27 +881,58 @@ class CORE_EXPORT QgsProcessingParameters
|
||||
*/
|
||||
static QString parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a file/folder name.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QString parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a matrix/table of values.
|
||||
* Tables are collapsed to a 1 dimensional list.
|
||||
*/
|
||||
static QVariantList parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a matrix/table of values.
|
||||
* Tables are collapsed to a 1 dimensional list.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QVariantList parameterAsMatrix( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a list of map layers.
|
||||
*/
|
||||
static QList< QgsMapLayer *> parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a list of map layers.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QList< QgsMapLayer *> parameterAsLayerList( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a range of values.
|
||||
*/
|
||||
static QList<double> parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a range of values.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QList<double> parameterAsRange( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a list of fields.
|
||||
*/
|
||||
static QStringList parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a list of fields.
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QStringList parameterAsFields( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
|
||||
/**
|
||||
* Creates a new QgsProcessingParameterDefinition using the configuration from a
|
||||
* supplied variant \a map.
|
||||
|
Loading…
x
Reference in New Issue
Block a user