Skip to content
Permalink
Browse files

Move an enum to new QgsProcessing class

  • Loading branch information
nyalldawson committed Jul 8, 2017
1 parent febf0a0 commit f82b41e0019dec565e4b79c83a937126695dcc47
Showing with 354 additions and 244 deletions.
  1. +1 −0 python/core/core_auto.sip
  2. +51 −0 python/core/processing/qgsprocessing.sip
  3. +4 −4 python/core/processing/qgsprocessingoutputs.sip
  4. +12 −24 python/core/processing/qgsprocessingparameters.sip
  5. +2 −1 python/plugins/processing/algs/qgis/Boundary.py
  6. +2 −1 python/plugins/processing/algs/qgis/BoundingBox.py
  7. +4 −3 python/plugins/processing/algs/qgis/CheckValidity.py
  8. +4 −3 python/plugins/processing/algs/qgis/ConcaveHull.py
  9. +4 −3 python/plugins/processing/algs/qgis/Delaunay.py
  10. +4 −3 python/plugins/processing/algs/qgis/DeleteHoles.py
  11. +2 −1 python/plugins/processing/algs/qgis/DensifyGeometries.py
  12. +2 −1 python/plugins/processing/algs/qgis/DensifyGeometriesInterval.py
  13. +2 −1 python/plugins/processing/algs/qgis/DropGeometry.py
  14. +2 −1 python/plugins/processing/algs/qgis/ExtentFromLayer.py
  15. +2 −1 python/plugins/processing/algs/qgis/FixGeometry.py
  16. +2 −1 python/plugins/processing/algs/qgis/GridPolygon.py
  17. +2 −1 python/plugins/processing/algs/qgis/Merge.py
  18. +4 −3 python/plugins/processing/algs/qgis/PointsLayerFromTable.py
  19. +3 −2 python/plugins/processing/algs/qgis/RegularPoints.py
  20. +5 −4 python/plugins/processing/algs/qgis/SnapGeometries.py
  21. +4 −3 python/plugins/processing/algs/qgis/VoronoiPolygons.py
  22. +3 −2 python/plugins/processing/algs/qgis/ZonalStatistics.py
  23. +4 −3 python/plugins/processing/gui/BatchInputSelectionPanel.py
  24. +6 −6 python/plugins/processing/gui/ParameterGuiUtils.py
  25. +24 −23 python/plugins/processing/gui/wrappers.py
  26. +1 −0 src/core/CMakeLists.txt
  27. +7 −7 src/core/processing/qgsnativealgorithms.cpp
  28. +61 −0 src/core/processing/qgsprocessing.h
  29. +2 −2 src/core/processing/qgsprocessingmodelalgorithm.cpp
  30. +3 −3 src/core/processing/qgsprocessingoutputs.cpp
  31. +4 −4 src/core/processing/qgsprocessingoutputs.h
  32. +56 −56 src/core/processing/qgsprocessingparameters.cpp
  33. +14 −26 src/core/processing/qgsprocessingparameters.h
  34. +51 −51 tests/src/core/testqgsprocessing.cpp
@@ -161,6 +161,7 @@
%Include layout/qgslayoutsize.sip
%Include metadata/qgslayermetadata.sip
%Include metadata/qgslayermetadatavalidator.sip
%Include processing/qgsprocessing.sip
%Include processing/qgsprocessingalgorithm.sip
%Include processing/qgsprocessingcontext.sip
%Include processing/qgsprocessingmodelalgorithm.sip
@@ -0,0 +1,51 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/processing/qgsprocessing.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsProcessing
{
%Docstring

Contains enumerations and other constants for use in processing algorithms
and parameters.

.. versionadded:: 3.0
%End

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

enum LayerType
{
TypeAny,
TypeVectorAny,
TypeVectorPoint,
TypeVectorLine,
TypeVectorPolygon,
TypeRaster,
TypeFile,
TypeTable,
};



};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/processing/qgsprocessing.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -106,7 +106,7 @@ class QgsProcessingOutputVectorLayer : QgsProcessingOutputDefinition
%End
public:

QgsProcessingOutputVectorLayer( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny );
QgsProcessingOutputVectorLayer( const QString &name, const QString &description = QString(), QgsProcessing::LayerType type = QgsProcessing::TypeVectorAny );
%Docstring
Constructor for QgsProcessingOutputVectorLayer.
%End
@@ -118,14 +118,14 @@ class QgsProcessingOutputVectorLayer : QgsProcessingOutputDefinition
%End
virtual QString type() const;

QgsProcessingParameterDefinition::LayerType dataType() const;
QgsProcessing::LayerType dataType() const;
%Docstring
Returns the layer type for the output layer.
.. seealso:: setDataType()
:rtype: QgsProcessingParameterDefinition.LayerType
:rtype: QgsProcessing.LayerType
%End

void setDataType( QgsProcessingParameterDefinition::LayerType type );
void setDataType( QgsProcessing::LayerType type );
%Docstring
Sets the layer ``type`` for the output layer.
.. seealso:: dataType()
@@ -201,18 +201,6 @@ class QgsProcessingParameterDefinition
typedef QFlags<QgsProcessingParameterDefinition::Flag> Flags;


enum LayerType
{
TypeAny,
TypeVectorAny,
TypeVectorPoint,
TypeVectorLine,
TypeVectorPolygon,
TypeRaster,
TypeFile,
TypeTable,
};

QgsProcessingParameterDefinition( const QString &name, const QString &description = QString(), const QVariant &defaultValue = QVariant(),
bool optional = false );
%Docstring
@@ -963,7 +951,7 @@ class QgsProcessingParameterMultipleLayers : QgsProcessingParameterDefinition
%End
public:

QgsProcessingParameterMultipleLayers( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType layerType = QgsProcessingParameterDefinition::TypeVectorAny,
QgsProcessingParameterMultipleLayers( const QString &name, const QString &description = QString(), QgsProcessing::LayerType layerType = QgsProcessing::TypeVectorAny,
const QVariant &defaultValue = QVariant(),
bool optional = false );
%Docstring
@@ -983,14 +971,14 @@ class QgsProcessingParameterMultipleLayers : QgsProcessingParameterDefinition
virtual QString asScriptCode() const;


QgsProcessingParameterDefinition::LayerType layerType() const;
QgsProcessing::LayerType layerType() const;
%Docstring
Returns the layer type for layers acceptable by the parameter.
.. seealso:: setLayerType()
:rtype: QgsProcessingParameterDefinition.LayerType
:rtype: QgsProcessing.LayerType
%End

void setLayerType( QgsProcessingParameterDefinition::LayerType type );
void setLayerType( QgsProcessing::LayerType type );
%Docstring
Sets the layer ``type`` for layers acceptable by the parameter.
.. seealso:: layerType()
@@ -1665,7 +1653,7 @@ class QgsProcessingParameterFeatureSink : QgsProcessingDestinationParameter
%End
public:

QgsProcessingParameterFeatureSink( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(),
QgsProcessingParameterFeatureSink( const QString &name, const QString &description = QString(), QgsProcessing::LayerType type = QgsProcessing::TypeVectorAny, const QVariant &defaultValue = QVariant(),
bool optional = false );
%Docstring
Constructor for QgsProcessingParameterFeatureSink.
@@ -1688,11 +1676,11 @@ class QgsProcessingParameterFeatureSink : QgsProcessingDestinationParameter
virtual QString defaultFileExtension() const;


QgsProcessingParameterDefinition::LayerType dataType() const;
QgsProcessing::LayerType dataType() const;
%Docstring
Returns the layer type for sinks associated with the parameter.
.. seealso:: setDataType()
:rtype: QgsProcessingParameterDefinition.LayerType
:rtype: QgsProcessing.LayerType
%End

bool hasGeometry() const;
@@ -1702,7 +1690,7 @@ class QgsProcessingParameterFeatureSink : QgsProcessingDestinationParameter
:rtype: bool
%End

void setDataType( QgsProcessingParameterDefinition::LayerType type );
void setDataType( QgsProcessing::LayerType type );
%Docstring
Sets the layer ``type`` for the sinks associated with the parameter.
.. seealso:: dataType()
@@ -1737,7 +1725,7 @@ class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter
%End
public:

QgsProcessingParameterVectorOutput( const QString &name, const QString &description = QString(), QgsProcessingParameterDefinition::LayerType type = QgsProcessingParameterDefinition::TypeVectorAny, const QVariant &defaultValue = QVariant(),
QgsProcessingParameterVectorOutput( const QString &name, const QString &description = QString(), QgsProcessing::LayerType type = QgsProcessing::TypeVectorAny, const QVariant &defaultValue = QVariant(),
bool optional = false );
%Docstring
Constructor for QgsProcessingParameterVectorOutput.
@@ -1760,11 +1748,11 @@ class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter
virtual QString defaultFileExtension() const;


QgsProcessingParameterDefinition::LayerType dataType() const;
QgsProcessing::LayerType dataType() const;
%Docstring
Returns the layer type for layers associated with the parameter.
.. seealso:: setDataType()
:rtype: QgsProcessingParameterDefinition.LayerType
:rtype: QgsProcessing.LayerType
%End

bool hasGeometry() const;
@@ -1774,7 +1762,7 @@ class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter
:rtype: bool
%End

void setDataType( QgsProcessingParameterDefinition::LayerType type );
void setDataType( QgsProcessing::LayerType type );
%Docstring
Sets the layer ``type`` for the layers associated with the parameter.
.. seealso:: dataType()
@@ -30,6 +30,7 @@
from qgis.core import (QgsGeometry,
QgsWkbTypes,
QgsFeatureSink,
QgsProcessing,
QgsProcessingUtils,
QgsProcessingParameterDefinition,
QgsProcessingParameterFeatureSource,
@@ -54,7 +55,7 @@ class Boundary(QgisAlgorithm):

def __init__(self):
super().__init__()
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER, self.tr('Input layer'), [QgsProcessingParameterDefinition.TypeVectorLine, QgsProcessingParameterDefinition.TypeVectorPolygon]))
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER, self.tr('Input layer'), [QgsProcessing.TypeVectorLine, QgsProcessing.TypeVectorPolygon]))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT_LAYER, self.tr('Boundary')))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT_LAYER, self.tr("Boundaries")))

@@ -30,6 +30,7 @@
from qgis.core import (QgsGeometry,
QgsWkbTypes,
QgsFeatureSink,
QgsProcessing,
QgsProcessingUtils,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
@@ -63,7 +64,7 @@ def __init__(self):
super().__init__()

self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER, self.tr('Input layer')))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT_LAYER, self.tr('Bounds'), QgsProcessingParameterDefinition.TypeVectorPolygon))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT_LAYER, self.tr('Bounds'), QgsProcessing.TypeVectorPolygon))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT_LAYER, self.tr("Bounds")))

def name(self):
@@ -39,6 +39,7 @@
QgsWkbTypes,
QgsProcessingUtils,
QgsFields,
QgsProcessing,
QgsProcessingFeatureSource,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterEnum,
@@ -81,15 +82,15 @@ def __init__(self):
self.addParameter(QgsProcessingParameterEnum(self.METHOD,
self.tr('Method'), self.methods))

self.addParameter(QgsProcessingParameterFeatureSink(self.VALID_OUTPUT, self.tr('Valid output'), QgsProcessingParameterDefinition.TypeVectorAny, '', True))
self.addParameter(QgsProcessingParameterFeatureSink(self.VALID_OUTPUT, self.tr('Valid output'), QgsProcessing.TypeVectorAny, '', True))
self.addOutput(QgsProcessingOutputVectorLayer(self.VALID_OUTPUT, self.tr('Valid output')))
self.addOutput(QgsProcessingOutputNumber(self.VALID_COUNT, self.tr('Count of valid features')))

self.addParameter(QgsProcessingParameterFeatureSink(self.INVALID_OUTPUT, self.tr('Invalid output'), QgsProcessingParameterDefinition.TypeVectorAny, '', True))
self.addParameter(QgsProcessingParameterFeatureSink(self.INVALID_OUTPUT, self.tr('Invalid output'), QgsProcessing.TypeVectorAny, '', True))
self.addOutput(QgsProcessingOutputVectorLayer(self.INVALID_OUTPUT, self.tr('Invalid output')))
self.addOutput(QgsProcessingOutputNumber(self.INVALID_COUNT, self.tr('Count of invalid features')))

self.addParameter(QgsProcessingParameterFeatureSink(self.ERROR_OUTPUT, self.tr('Error output'), QgsProcessingParameterDefinition.TypeVectorAny, '', True))
self.addParameter(QgsProcessingParameterFeatureSink(self.ERROR_OUTPUT, self.tr('Error output'), QgsProcessing.TypeVectorAny, '', True))
self.addOutput(QgsProcessingOutputVectorLayer(self.ERROR_OUTPUT, self.tr('Error output')))
self.addOutput(QgsProcessingOutputNumber(self.ERROR_COUNT, self.tr('Count of errors')))

@@ -32,6 +32,7 @@
QgsFeatureSink,
QgsWkbTypes,
QgsApplication,
QgsProcessing,
QgsProcessingUtils,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterVectorLayer,
@@ -60,7 +61,7 @@ def group(self):
def __init__(self):
super().__init__()

self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT, self.tr('Input point layer'), [QgsProcessingParameterDefinition.TypeVectorPoint]))
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT, self.tr('Input point layer'), [QgsProcessing.TypeVectorPoint]))
self.addParameter(QgsProcessingParameterNumber(self.ALPHA,
self.tr('Threshold (0-1, where 1 is equivalent with Convex Hull)'),
minValue=0, maxValue=1, defaultValue=0.3, type=QgsProcessingParameterNumber.Double))
@@ -70,8 +71,8 @@ def __init__(self):
self.addParameter(QgsProcessingParameterBoolean(self.NO_MULTIGEOMETRY,
self.tr('Split multipart geometry into singleparts geometries'), defaultValue=False))

self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Concave hull'), type=QgsProcessingParameterDefinition.TypeVectorPolygon))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr("Concave hull"), type=QgsProcessingParameterDefinition.TypeVectorPolygon))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Concave hull'), type=QgsProcessing.TypeVectorPolygon))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr("Concave hull"), type=QgsProcessing.TypeVectorPolygon))

def name(self):
return 'concavehull'
@@ -38,6 +38,7 @@
QgsGeometry,
QgsPointXY,
QgsWkbTypes,
QgsProcessing,
QgsProcessingUtils,
QgsFields,
QgsProcessingParameterFeatureSource,
@@ -67,9 +68,9 @@ def group(self):
def __init__(self):
super().__init__()

self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT, self.tr('Input layer'), [QgsProcessingParameterDefinition.TypeVectorPoint]))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Delaunay triangulation'), type=QgsProcessingParameterDefinition.TypeVectorPolygon))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr("Delaunay triangulation"), type=QgsProcessingParameterDefinition.TypeVectorPolygon))
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT, self.tr('Input layer'), [QgsProcessing.TypeVectorPoint]))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Delaunay triangulation'), type=QgsProcessing.TypeVectorPolygon))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr("Delaunay triangulation"), type=QgsProcessing.TypeVectorPolygon))

def name(self):
return 'delaunaytriangulation'
@@ -26,6 +26,7 @@

from qgis.core import (QgsApplication,
QgsFeatureSink,
QgsProcessing,
QgsProcessingUtils,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterNumber,
@@ -50,13 +51,13 @@ def group(self):
def __init__(self):
super().__init__()
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Input layer'), [QgsProcessingParameterDefinition.TypeVectorPolygon]))
self.tr('Input layer'), [QgsProcessing.TypeVectorPolygon]))
self.addParameter(QgsProcessingParameterNumber(self.MIN_AREA,
self.tr('Remove holes with area less than'), QgsProcessingParameterNumber.Double,
0, True, 0.0, 10000000.0))

self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Cleaned'), QgsProcessingParameterDefinition.TypeVectorPolygon))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr('Cleaned'), QgsProcessingParameterDefinition.TypeVectorPolygon))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Cleaned'), QgsProcessing.TypeVectorPolygon))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr('Cleaned'), QgsProcessing.TypeVectorPolygon))

def name(self):
return 'deleteholes'
@@ -31,6 +31,7 @@
from qgis.core import (QgsWkbTypes,
QgsFeatureSink,
QgsApplication,
QgsProcessing,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterNumber,
QgsProcessingParameterFeatureSink,
@@ -55,7 +56,7 @@ def __init__(self):
super().__init__()

self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Input layer'), [QgsProcessingParameterDefinition.TypeVectorPolygon, QgsProcessingParameterDefinition.TypeVectorLine]))
self.tr('Input layer'), [QgsProcessing.TypeVectorPolygon, QgsProcessing.TypeVectorLine]))
self.addParameter(QgsProcessingParameterNumber(self.VERTICES,
self.tr('Vertices to add'), QgsProcessingParameterNumber.Integer,
1, False, 1, 10000000))
@@ -32,6 +32,7 @@
from qgis.core import (QgsWkbTypes,
QgsApplication,
QgsFeatureSink,
QgsProcessing,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterNumber,
QgsProcessingParameterFeatureSink,
@@ -53,7 +54,7 @@ def __init__(self):
super().__init__()

self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Input layer'), [QgsProcessingParameterDefinition.TypeVectorPolygon, QgsProcessingParameterDefinition.TypeVectorLine]))
self.tr('Input layer'), [QgsProcessing.TypeVectorPolygon, QgsProcessing.TypeVectorLine]))
self.addParameter(QgsProcessingParameterNumber(self.INTERVAL,
self.tr('Interval between vertices to add'), QgsProcessingParameterNumber.Double,
1, False, 0, 10000000))
@@ -30,6 +30,7 @@
QgsFeatureSink,
QgsCoordinateReferenceSystem,
QgsApplication,
QgsProcessing,
QgsProcessingParameterDefinition,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
@@ -51,7 +52,7 @@ def group(self):
def __init__(self):
super().__init__()

self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT, self.tr('Input layer'), [QgsProcessingParameterDefinition.TypeVectorPoint, QgsProcessingParameterDefinition.TypeVectorLine, QgsProcessingParameterDefinition.TypeVectorPolygon]))
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT, self.tr('Input layer'), [QgsProcessing.TypeVectorPoint, QgsProcessing.TypeVectorLine, QgsProcessing.TypeVectorPolygon]))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Dropped geometry')))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr("Dropped geometry")))

0 comments on commit f82b41e

Please sign in to comment.
You can’t perform that action at this time.