Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] add vector tile destination parameter
  • Loading branch information
alexbruy authored and nyalldawson committed May 17, 2023
1 parent a4a873c commit a1013f8
Show file tree
Hide file tree
Showing 21 changed files with 731 additions and 6 deletions.
5 changes: 4 additions & 1 deletion python/core/auto_additions/qgsprocessingutils.py
Expand Up @@ -18,5 +18,8 @@
QgsProcessingUtils.Annotation = QgsProcessingUtils.LayerHint.Annotation
QgsProcessingUtils.Annotation.is_monkey_patched = True
QgsProcessingUtils.LayerHint.Annotation.__doc__ = "Annotation layer type, since QGIS 3.22"
QgsProcessingUtils.LayerHint.__doc__ = 'Layer type hints.\n\n.. versionadded:: 3.4\n\n' + '* ``UnknownType``: ' + QgsProcessingUtils.LayerHint.UnknownType.__doc__ + '\n' + '* ``Vector``: ' + QgsProcessingUtils.LayerHint.Vector.__doc__ + '\n' + '* ``Raster``: ' + QgsProcessingUtils.LayerHint.Raster.__doc__ + '\n' + '* ``Mesh``: ' + QgsProcessingUtils.LayerHint.Mesh.__doc__ + '\n' + '* ``PointCloud``: ' + QgsProcessingUtils.LayerHint.PointCloud.__doc__ + '\n' + '* ``Annotation``: ' + QgsProcessingUtils.LayerHint.Annotation.__doc__
QgsProcessingUtils.VectorTile = QgsProcessingUtils.LayerHint.VectorTile
QgsProcessingUtils.VectorTile.is_monkey_patched = True
QgsProcessingUtils.LayerHint.VectorTile.__doc__ = "Vector tile layer type, since QGIS 3.32"
QgsProcessingUtils.LayerHint.__doc__ = 'Layer type hints.\n\n.. versionadded:: 3.4\n\n' + '* ``UnknownType``: ' + QgsProcessingUtils.LayerHint.UnknownType.__doc__ + '\n' + '* ``Vector``: ' + QgsProcessingUtils.LayerHint.Vector.__doc__ + '\n' + '* ``Raster``: ' + QgsProcessingUtils.LayerHint.Raster.__doc__ + '\n' + '* ``Mesh``: ' + QgsProcessingUtils.LayerHint.Mesh.__doc__ + '\n' + '* ``PointCloud``: ' + QgsProcessingUtils.LayerHint.PointCloud.__doc__ + '\n' + '* ``Annotation``: ' + QgsProcessingUtils.LayerHint.Annotation.__doc__ + '\n' + '* ``VectorTile``: ' + QgsProcessingUtils.LayerHint.VectorTile.__doc__
# --
27 changes: 27 additions & 0 deletions python/core/auto_generated/processing/qgsprocessingoutputs.sip.in
Expand Up @@ -33,6 +33,8 @@ as generated layers or calculated values.
sipType = sipType_QgsProcessingOutputRasterLayer;
else if ( sipCpp->type() == QgsProcessingOutputPointCloudLayer::typeName() )
sipType = sipType_QgsProcessingOutputPointCloudLayer;
else if ( sipCpp->type() == QgsProcessingOutputVectorTileLayer::typeName() )
sipType = sipType_QgsProcessingOutputVectorTileLayer;
else if ( sipCpp->type() == QgsProcessingOutputMapLayer::typeName() )
sipType = sipType_QgsProcessingOutputMapLayer;
else if ( sipCpp->type() == QgsProcessingOutputMultipleLayers::typeName() )
Expand Down Expand Up @@ -460,6 +462,31 @@ Returns the type name for the output class.
virtual QString type() const;
};

class QgsProcessingOutputVectorTileLayer : QgsProcessingOutputDefinition
{
%Docstring(signature="appended")
A vector tile layer output for processing algorithms.

.. versionadded:: 3.32
%End

%TypeHeaderCode
#include "qgsprocessingoutputs.h"
%End
public:

QgsProcessingOutputVectorTileLayer( const QString &name, const QString &description = QString() );
%Docstring
Constructor for QgsProcessingOutputVectorTileLayer.
%End

static QString typeName();
%Docstring
Returns the type name for the output class.
%End
virtual QString type() const;
};

/************************************************************************
* This file has been generated automatically from *
* *
Expand Down
Expand Up @@ -337,6 +337,8 @@ their acceptable ranges, defaults, etc.
sipType = sipType_QgsProcessingParameterAnnotationLayer;
else if ( sipCpp->type() == QgsProcessingParameterPointCloudAttribute::typeName() )
sipType = sipType_QgsProcessingParameterPointCloudAttribute;
else if ( sipCpp->type() == QgsProcessingParameterVectorTileDestination::typeName() )
sipType = sipType_QgsProcessingParameterVectorTileDestination;
else
sipType = nullptr;
%End
Expand Down Expand Up @@ -4902,6 +4904,62 @@ Creates a new parameter using the definition from a script code.

};

class QgsProcessingParameterVectorTileDestination : QgsProcessingDestinationParameter
{
%Docstring(signature="appended")
A vector tile layer destination parameter, for specifying the destination path for a vector tile layer
created by the algorithm.

.. versionadded:: 3.32
%End

%TypeHeaderCode
#include "qgsprocessingparameters.h"
%End
public:

QgsProcessingParameterVectorTileDestination( const QString &name, const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
bool optional = false,
bool createByDefault = true );
%Docstring
Constructor for QgsProcessingParameterVectorTileDestination.

If ``createByDefault`` is ``False`` and the parameter is ``optional``, then this destination
output will not be created by default.
%End

static QString typeName();
%Docstring
Returns the type name for the parameter class.
%End
virtual QgsProcessingParameterDefinition *clone() const /Factory/;

virtual QString type() const;
virtual bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = 0 ) const;

virtual QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const;

virtual QgsProcessingOutputDefinition *toOutputDefinition() const /Factory/;

virtual QString defaultFileExtension() const;

virtual QString createFileFilter() const;


virtual QStringList supportedOutputVectorTileLayerExtensions() const;
%Docstring
Returns a list of the point cloud format file extensions supported for this parameter.

.. seealso:: :py:func:`defaultFileExtension`
%End

static QgsProcessingParameterVectorTileDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
%End
};




Expand Down
51 changes: 51 additions & 0 deletions python/core/auto_generated/processing/qgsprocessingprovider.sip.in
Expand Up @@ -145,6 +145,10 @@ Returns ``True`` if the provider is active and able to run algorithms.
Returns a list of the raster format file extensions supported by this provider.

.. seealso:: :py:func:`supportedOutputVectorLayerExtensions`

.. seealso:: :py:func:`supportedOutputPointCloudLayerExtensions`

.. seealso:: :py:func:`supportedOutputVectorTileLayerExtensions`
%End

virtual QStringList supportedOutputVectorLayerExtensions() const;
Expand All @@ -160,6 +164,8 @@ Returns a list of the vector format file extensions supported by this provider.
.. seealso:: :py:func:`supportsNonFileBasedOutput`

.. seealso:: :py:func:`supportedOutputPointCloudLayerExtensions`

.. seealso:: :py:func:`supportedOutputVectorTileLayerExtensions`
%End

virtual QStringList supportedOutputPointCloudLayerExtensions() const;
Expand All @@ -170,13 +176,34 @@ Returns a list of the point cloud format file extensions supported by this provi

.. seealso:: :py:func:`supportedOutputRasterLayerExtensions`

.. seealso:: :py:func:`supportedOutputVectorTileLayerExtensions`

.. seealso:: :py:func:`supportedOutputTableExtensions`

.. seealso:: :py:func:`defaultVectorFileExtension`

.. seealso:: :py:func:`supportsNonFileBasedOutput`

.. versionadded:: 3.24
%End

virtual QStringList supportedOutputVectorTileLayerExtensions() const;
%Docstring
Returns a list of the vector tile format file extensions supported by this provider.

By default returns a list containing only "mbtiles" extension.

.. seealso:: :py:func:`supportedOutputVectorLayerExtensions`

.. seealso:: :py:func:`supportedOutputRasterLayerExtensions`

.. seealso:: :py:func:`supportedOutputTableExtensions`

.. seealso:: :py:func:`defaultVectorFileExtension`

.. seealso:: :py:func:`supportsNonFileBasedOutput`

.. versionadded:: 3.32
%End

virtual QStringList supportedOutputTableExtensions() const;
Expand Down Expand Up @@ -225,6 +252,8 @@ Otherwise the first reported supported vector format will be used.
.. seealso:: :py:func:`defaultRasterFileExtension`

.. seealso:: :py:func:`defaultPointCloudFileExtension`

.. seealso:: :py:func:`defaultVectorTileFileExtension`
%End

virtual QString defaultRasterFileExtension() const;
Expand All @@ -241,6 +270,8 @@ Otherwise the first reported supported raster format will be used.
.. seealso:: :py:func:`defaultVectorFileExtension`

.. seealso:: :py:func:`defaultPointCloudFileExtension`

.. seealso:: :py:func:`defaultVectorTileFileExtension`
%End

virtual QString defaultPointCloudFileExtension() const;
Expand All @@ -258,7 +289,27 @@ Otherwise the first reported supported point cloud format will be used.

.. seealso:: :py:func:`defaultRasterFileExtension`

.. seealso:: :py:func:`defaultVectorTileFileExtension`

.. versionadded:: 3.24
%End

virtual QString defaultVectorTileFileExtension() const;
%Docstring
Returns the default file extension to use for vector tile outputs created by the
provider.

The default implementation returns the user's default Processing vector tile output format
setting, if it's supported by the provider (see :py:func:`~QgsProcessingProvider.supportedOutputVectorTileLayerExtensions`).
Otherwise the first reported supported vector tile format will be used.

.. seealso:: :py:func:`supportedOutputPointCloudLayerExtensions`

.. seealso:: :py:func:`defaultVectorFileExtension`

.. seealso:: :py:func:`defaultRasterFileExtension`

.. versionadded:: 3.32
%End

virtual bool supportsNonFileBasedOutput() const;
Expand Down
23 changes: 23 additions & 0 deletions python/core/auto_generated/processing/qgsprocessingutils.sip.in
Expand Up @@ -246,6 +246,7 @@ Decodes a provider key and layer ``uri`` from an encoded string, for use with
Mesh,
PointCloud,
Annotation,
VectorTile,
};

static QgsMapLayer *mapLayerFromString( const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers = true, QgsProcessingUtils::LayerHint typeHint = QgsProcessingUtils::LayerHint::UnknownType, QgsProcessing::LayerOptionsFlags flags = QgsProcessing::LayerOptionsFlags() );
Expand Down Expand Up @@ -503,6 +504,8 @@ a fallback value of "gpkg".

.. seealso:: :py:func:`defaultPointCloudExtension`

.. seealso:: :py:func:`defaultVectorTileExtension`

.. versionadded:: 3.10
%End

Expand All @@ -518,6 +521,8 @@ a fallback value of "tif".

.. seealso:: :py:func:`defaultPointCloudExtension`

.. seealso:: :py:func:`defaultVectorTileExtension`

.. versionadded:: 3.10
%End

Expand All @@ -532,7 +537,25 @@ This method returns a fallback value of "las".

.. seealso:: :py:func:`defaultRasterExtension`

.. seealso:: :py:func:`defaultVectorTileExtension`

.. versionadded:: 3.24
%End

static QString defaultVectorTileExtension();
%Docstring
Returns the default vector tile extension to use, in the absence of all other constraints (e.g.
provider based support for extensions).

This method returns a fallback value of "mbtiles".

.. seealso:: :py:func:`defaultVectorExtension`

.. seealso:: :py:func:`defaultRasterExtension`

.. seealso:: :py:func:`defaultPointCloudExtension`

.. versionadded:: 3.32
%End

static QVariantMap removePointerValuesFromMap( const QVariantMap &map );
Expand Down
4 changes: 4 additions & 0 deletions src/core/processing/qgsprocessingoutputs.cpp
Expand Up @@ -45,6 +45,10 @@ QgsProcessingOutputPointCloudLayer::QgsProcessingOutputPointCloudLayer( const QS
: QgsProcessingOutputDefinition( name, description )
{}

QgsProcessingOutputVectorTileLayer::QgsProcessingOutputVectorTileLayer( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}

QgsProcessingOutputHtml::QgsProcessingOutputHtml( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}
Expand Down
24 changes: 24 additions & 0 deletions src/core/processing/qgsprocessingoutputs.h
Expand Up @@ -49,6 +49,8 @@ class CORE_EXPORT QgsProcessingOutputDefinition
sipType = sipType_QgsProcessingOutputRasterLayer;
else if ( sipCpp->type() == QgsProcessingOutputPointCloudLayer::typeName() )
sipType = sipType_QgsProcessingOutputPointCloudLayer;
else if ( sipCpp->type() == QgsProcessingOutputVectorTileLayer::typeName() )
sipType = sipType_QgsProcessingOutputVectorTileLayer;
else if ( sipCpp->type() == QgsProcessingOutputMapLayer::typeName() )
sipType = sipType_QgsProcessingOutputMapLayer;
else if ( sipCpp->type() == QgsProcessingOutputMultipleLayers::typeName() )
Expand Down Expand Up @@ -437,4 +439,26 @@ class CORE_EXPORT QgsProcessingOutputConditionalBranch : public QgsProcessingOut
QString type() const override { return typeName(); }
};

/**
* \class QgsProcessingOutputVectorTileLayer
* \ingroup core
* \brief A vector tile layer output for processing algorithms.
* \since QGIS 3.32
*/
class CORE_EXPORT QgsProcessingOutputVectorTileLayer : public QgsProcessingOutputDefinition
{
public:

/**
* Constructor for QgsProcessingOutputVectorTileLayer.
*/
QgsProcessingOutputVectorTileLayer( const QString &name, const QString &description = QString() );

/**
* Returns the type name for the output class.
*/
static QString typeName() { return QStringLiteral( "outputVectorTile" ); }
QString type() const override { return typeName(); }
};

#endif // QGSPROCESSINGOUTPUTS_H

0 comments on commit a1013f8

Please sign in to comment.