Skip to content

Commit

Permalink
Minor processing parameter evaluation refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 14, 2018
1 parent 9a1f129 commit bef88f3
Show file tree
Hide file tree
Showing 3 changed files with 565 additions and 20 deletions.
197 changes: 197 additions & 0 deletions python/core/auto_generated/processing/qgsprocessingparameters.sip.in
Expand Up @@ -491,36 +491,85 @@ be evaluated once for every input feature processed.
static QString parameterAsString( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, 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 &parameters, 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 &parameters, 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 &parameters, 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 &parameters, 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 &parameters, 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 &parameters, 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 &parameters,
Expand All @@ -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 &parameters, QgsProcessingContext &context ) /Factory/;
Expand All @@ -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 &parameters,
Expand All @@ -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 &parameters, QgsProcessingContext &context );
Expand All @@ -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 &parameters, 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 &parameters, 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 &parameters, QgsProcessingContext &context );
Expand All @@ -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 &parameters, 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 &parameters, QgsProcessingContext &context,
Expand All @@ -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 &parameters, QgsProcessingContext &context,
Expand Down Expand Up @@ -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 &parameters, QgsProcessingContext &context );
Expand All @@ -662,27 +823,63 @@ Returns the coordinate reference system associated with an point parameter value
static QString parameterAsFile( const QgsProcessingParameterDefinition *definition, const QVariantMap &parameters, 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 &parameters, 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 &parameters, 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 &parameters, 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 &parameters, 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/;
Expand Down

0 comments on commit bef88f3

Please sign in to comment.