Skip to content
Permalink
Browse files

Move declaration of algorithm parameters/outputs to a new virtual

initAlgorithm() method

This allows 2 benefits:
- algorithms can be subclassed and have subclasses add additional
parameters/outputs to the algorithm. With the previous approach
of declaring parameters/outputs in the constructor, it's not
possible to call virtual methods to add additional parameters/
outputs (since you can't call virtual methods from a constructor).

- initAlgorithm takes a variant map argument, allowing the algorithm
to dynamically adjust its declared parameters and outputs according
to this configuration map. This potentially allows model algorithms which
can be configured to have variable numbers of parameters and
outputs at run time. E.g. a "router" algorithm which directs
features to one of any number of output sinks depending on some
user configured criteria.
  • Loading branch information
nyalldawson committed Jul 10, 2017
1 parent fc221a6 commit 1e13d733c27e1998ccb730c38f5f49a66d865b63
Showing with 409 additions and 58 deletions.
  1. +6 −2 python/core/processing/models/qgsprocessingmodelalgorithm.sip
  2. +37 −0 python/core/processing/qgsprocessingalgorithm.sip
  3. +1 −0 python/plugins/processing/algs/qgis/AddTableField.py
  4. +1 −0 python/plugins/processing/algs/qgis/Aspect.py
  5. +1 −0 python/plugins/processing/algs/qgis/AutoincrementalField.py
  6. +1 −0 python/plugins/processing/algs/qgis/BarPlot.py
  7. +1 −0 python/plugins/processing/algs/qgis/BasicStatistics.py
  8. +2 −0 python/plugins/processing/algs/qgis/Boundary.py
  9. +1 −0 python/plugins/processing/algs/qgis/BoundingBox.py
  10. +2 −0 python/plugins/processing/algs/qgis/BoxPlot.py
  11. +2 −0 python/plugins/processing/algs/qgis/CheckValidity.py
  12. +1 −0 python/plugins/processing/algs/qgis/ConcaveHull.py
  13. +2 −0 python/plugins/processing/algs/qgis/ConvexHull.py
  14. +2 −0 python/plugins/processing/algs/qgis/CreateAttributeIndex.py
  15. +2 −0 python/plugins/processing/algs/qgis/CreateConstantRaster.py
  16. +2 −0 python/plugins/processing/algs/qgis/Datasources2Vrt.py
  17. +2 −0 python/plugins/processing/algs/qgis/DefineProjection.py
  18. +1 −0 python/plugins/processing/algs/qgis/Delaunay.py
  19. +1 −0 python/plugins/processing/algs/qgis/DeleteColumn.py
  20. +2 −0 python/plugins/processing/algs/qgis/DeleteDuplicateGeometries.py
  21. +8 −6 python/plugins/processing/algs/qgis/DeleteHoles.py
  22. +1 −0 python/plugins/processing/algs/qgis/DensifyGeometries.py
  23. +1 −0 python/plugins/processing/algs/qgis/DensifyGeometriesInterval.py
  24. +2 −0 python/plugins/processing/algs/qgis/Difference.py
  25. +1 −0 python/plugins/processing/algs/qgis/DropGeometry.py
  26. +2 −0 python/plugins/processing/algs/qgis/EliminateSelection.py
  27. +2 −0 python/plugins/processing/algs/qgis/EquivalentNumField.py
  28. +2 −0 python/plugins/processing/algs/qgis/ExecuteSQL.py
  29. +2 −0 python/plugins/processing/algs/qgis/Explode.py
  30. +2 −0 python/plugins/processing/algs/qgis/ExportGeometryInfo.py
  31. +2 −0 python/plugins/processing/algs/qgis/ExtendLines.py
  32. +1 −0 python/plugins/processing/algs/qgis/ExtentFromLayer.py
  33. +2 −0 python/plugins/processing/algs/qgis/ExtractByLocation.py
  34. +2 −0 python/plugins/processing/algs/qgis/ExtractNodes.py
  35. +2 −0 python/plugins/processing/algs/qgis/ExtractSpecificNodes.py
  36. +2 −0 python/plugins/processing/algs/qgis/FieldPyculator.py
  37. +2 −0 python/plugins/processing/algs/qgis/FieldsCalculator.py
  38. +2 −0 python/plugins/processing/algs/qgis/FieldsMapper.py
  39. +2 −0 python/plugins/processing/algs/qgis/FindProjection.py
  40. +2 −0 python/plugins/processing/algs/qgis/FixGeometry.py
  41. +2 −0 python/plugins/processing/algs/qgis/FixedDistanceBuffer.py
  42. +2 −0 python/plugins/processing/algs/qgis/GeometryByExpression.py
  43. +2 −0 python/plugins/processing/algs/qgis/GeometryConvert.py
  44. +2 −0 python/plugins/processing/algs/qgis/GridLine.py
  45. +2 −0 python/plugins/processing/algs/qgis/GridPolygon.py
  46. +2 −0 python/plugins/processing/algs/qgis/Gridify.py
  47. +2 −0 python/plugins/processing/algs/qgis/Heatmap.py
  48. +2 −0 python/plugins/processing/algs/qgis/Hillshade.py
  49. +2 −0 python/plugins/processing/algs/qgis/HubDistanceLines.py
  50. +2 −0 python/plugins/processing/algs/qgis/HubDistancePoints.py
  51. +2 −0 python/plugins/processing/algs/qgis/HubLines.py
  52. +2 −0 python/plugins/processing/algs/qgis/HypsometricCurves.py
  53. +1 −0 python/plugins/processing/algs/qgis/IdwInterpolation.py
  54. +2 −0 python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
  55. +2 −0 python/plugins/processing/algs/qgis/ImportIntoSpatialite.py
  56. +2 −0 python/plugins/processing/algs/qgis/Intersection.py
  57. +2 −0 python/plugins/processing/algs/qgis/JoinAttributes.py
  58. +2 −0 python/plugins/processing/algs/qgis/LinesIntersection.py
  59. +2 −0 python/plugins/processing/algs/qgis/LinesToPolygons.py
  60. +2 −0 python/plugins/processing/algs/qgis/MeanAndStdDevPlot.py
  61. +2 −0 python/plugins/processing/algs/qgis/MeanCoords.py
  62. +2 −0 python/plugins/processing/algs/qgis/Merge.py
  63. +2 −0 python/plugins/processing/algs/qgis/MergeLines.py
  64. +2 −0 python/plugins/processing/algs/qgis/NearestNeighbourAnalysis.py
  65. +2 −0 python/plugins/processing/algs/qgis/OffsetLine.py
  66. +2 −0 python/plugins/processing/algs/qgis/OrientedMinimumBoundingBox.py
  67. +2 −0 python/plugins/processing/algs/qgis/Orthogonalize.py
  68. +2 −0 python/plugins/processing/algs/qgis/PointDistance.py
  69. +2 −0 python/plugins/processing/algs/qgis/PointOnSurface.py
  70. +2 −0 python/plugins/processing/algs/qgis/PointsAlongGeometry.py
  71. +2 −0 python/plugins/processing/algs/qgis/PointsDisplacement.py
  72. +2 −0 python/plugins/processing/algs/qgis/PointsFromLines.py
  73. +2 −0 python/plugins/processing/algs/qgis/PointsFromPolygons.py
  74. +2 −0 python/plugins/processing/algs/qgis/PointsInPolygon.py
  75. +2 −0 python/plugins/processing/algs/qgis/PointsInPolygonUnique.py
  76. +2 −0 python/plugins/processing/algs/qgis/PointsInPolygonWeighted.py
  77. +1 −0 python/plugins/processing/algs/qgis/PointsLayerFromTable.py
  78. +2 −0 python/plugins/processing/algs/qgis/PointsToPaths.py
  79. +2 −0 python/plugins/processing/algs/qgis/PolarPlot.py
  80. +2 −0 python/plugins/processing/algs/qgis/PoleOfInaccessibility.py
  81. +2 −0 python/plugins/processing/algs/qgis/Polygonize.py
  82. +2 −0 python/plugins/processing/algs/qgis/PolygonsToLines.py
  83. +1 −0 python/plugins/processing/algs/qgis/PostGISExecuteSQL.py
  84. +2 −0 python/plugins/processing/algs/qgis/RandomExtract.py
  85. +2 −0 python/plugins/processing/algs/qgis/RandomExtractWithinSubsets.py
  86. +2 −0 python/plugins/processing/algs/qgis/RandomPointsAlongLines.py
  87. +2 −0 python/plugins/processing/algs/qgis/RandomPointsExtent.py
  88. +2 −0 python/plugins/processing/algs/qgis/RandomPointsLayer.py
  89. +2 −0 python/plugins/processing/algs/qgis/RandomPointsPolygonsFixed.py
  90. +2 −0 python/plugins/processing/algs/qgis/RandomPointsPolygonsVariable.py
  91. +2 −0 python/plugins/processing/algs/qgis/RandomSelection.py
  92. +2 −0 python/plugins/processing/algs/qgis/RandomSelectionWithinSubsets.py
  93. +2 −0 python/plugins/processing/algs/qgis/RasterCalculator.py
  94. +2 −0 python/plugins/processing/algs/qgis/RasterLayerHistogram.py
  95. +2 −0 python/plugins/processing/algs/qgis/RasterLayerStatistics.py
  96. +2 −0 python/plugins/processing/algs/qgis/RectanglesOvalsDiamondsFixed.py
  97. +2 −0 python/plugins/processing/algs/qgis/RectanglesOvalsDiamondsVariable.py
  98. +2 −0 python/plugins/processing/algs/qgis/RegularPoints.py
  99. +1 −0 python/plugins/processing/algs/qgis/Relief.py
  100. +2 −0 python/plugins/processing/algs/qgis/RemoveNullGeometry.py
  101. +2 −0 python/plugins/processing/algs/qgis/ReverseLineDirection.py
  102. +2 −0 python/plugins/processing/algs/qgis/Ruggedness.py
  103. +1 −0 python/plugins/processing/algs/qgis/SaveSelectedFeatures.py
  104. +2 −0 python/plugins/processing/algs/qgis/SelectByAttribute.py
  105. +2 −0 python/plugins/processing/algs/qgis/SelectByAttributeSum.py
  106. +2 −0 python/plugins/processing/algs/qgis/SelectByExpression.py
  107. +2 −0 python/plugins/processing/algs/qgis/SelectByLocation.py
  108. +2 −0 python/plugins/processing/algs/qgis/ServiceAreaFromLayer.py
  109. +2 −0 python/plugins/processing/algs/qgis/ServiceAreaFromPoint.py
  110. +2 −0 python/plugins/processing/algs/qgis/SetRasterStyle.py
  111. +2 −0 python/plugins/processing/algs/qgis/SetVectorStyle.py
  112. +2 −0 python/plugins/processing/algs/qgis/ShortestPathLayerToPoint.py
  113. +2 −0 python/plugins/processing/algs/qgis/ShortestPathPointToLayer.py
  114. +2 −0 python/plugins/processing/algs/qgis/ShortestPathPointToPoint.py
  115. +2 −0 python/plugins/processing/algs/qgis/SimplifyGeometries.py
  116. +2 −0 python/plugins/processing/algs/qgis/SinglePartsToMultiparts.py
  117. +2 −0 python/plugins/processing/algs/qgis/SingleSidedBuffer.py
  118. +2 −0 python/plugins/processing/algs/qgis/Slope.py
  119. +2 −0 python/plugins/processing/algs/qgis/Smooth.py
  120. +1 −0 python/plugins/processing/algs/qgis/SnapGeometries.py
  121. +2 −0 python/plugins/processing/algs/qgis/SpatialIndex.py
  122. +2 −0 python/plugins/processing/algs/qgis/SpatialJoin.py
  123. +2 −0 python/plugins/processing/algs/qgis/SpatialiteExecuteSQL.py
  124. +2 −0 python/plugins/processing/algs/qgis/SplitWithLines.py
  125. +2 −0 python/plugins/processing/algs/qgis/StatisticsByCategories.py
  126. +2 −0 python/plugins/processing/algs/qgis/SumLines.py
  127. +1 −0 python/plugins/processing/algs/qgis/SymmetricalDifference.py
  128. +2 −0 python/plugins/processing/algs/qgis/TextToFloat.py
  129. +2 −0 python/plugins/processing/algs/qgis/TinInterpolation.py
  130. +2 −0 python/plugins/processing/algs/qgis/TopoColors.py
  131. +2 −0 python/plugins/processing/algs/qgis/Translate.py
  132. +2 −0 python/plugins/processing/algs/qgis/TruncateTable.py
  133. +2 −0 python/plugins/processing/algs/qgis/Union.py
  134. +2 −0 python/plugins/processing/algs/qgis/UniqueValues.py
  135. +2 −0 python/plugins/processing/algs/qgis/VariableDistanceBuffer.py
  136. +2 −0 python/plugins/processing/algs/qgis/VectorLayerHistogram.py
  137. +2 −0 python/plugins/processing/algs/qgis/VectorLayerScatterplot.py
  138. +2 −0 python/plugins/processing/algs/qgis/VectorLayerScatterplot3D.py
  139. +1 −0 python/plugins/processing/algs/qgis/VectorSplit.py
  140. +1 −0 python/plugins/processing/algs/qgis/VoronoiPolygons.py
  141. +2 −0 python/plugins/processing/algs/qgis/ZonalStatistics.py
  142. +1 −1 python/plugins/processing/core/Processing.py
  143. +1 −1 python/plugins/processing/gui/AlgorithmLocatorFilter.py
  144. +11 −7 python/plugins/processing/gui/ProcessingToolbox.py
  145. +1 −1 python/plugins/processing/gui/TestTools.py
  146. +2 −2 python/plugins/processing/modeler/ModelerDialog.py
  147. +1 −1 python/plugins/processing/preconfigured/PreconfiguredAlgorithm.py
  148. +3 −0 python/plugins/processing/script/ScriptAlgorithm.py
  149. +2 −1 python/plugins/processing/tests/AlgorithmsTestBase.py
  150. +3 −0 python/plugins/processing/tests/QgisAlgorithmsTest.py
  151. +3 −3 python/plugins/processing/tools/general.py
  152. +1 −1 python/plugins/processing/tools/help.py
  153. +1 −1 scripts/spell_check/spelling.dat
  154. +4 −0 src/core/processing/models/qgsprocessingmodelalgorithm.cpp
  155. +4 −1 src/core/processing/models/qgsprocessingmodelalgorithm.h
  156. +9 −12 src/core/processing/qgsnativealgorithms.cpp
  157. +18 −17 src/core/processing/qgsnativealgorithms.h
  158. +1 −0 src/core/processing/qgsprocessingalgorithm.cpp
  159. +37 −0 src/core/processing/qgsprocessingalgorithm.h
  160. +0 −1 src/core/processing/qgsprocessingregistry.cpp
  161. +1 −0 tests/src/core/testqgsprocessing.cpp
@@ -27,6 +27,9 @@ class QgsProcessingModelAlgorithm : QgsProcessingAlgorithm
Constructor for QgsProcessingModelAlgorithm.
%End

virtual void initAlgorithm( const QVariantMap &configuration = QVariantMap() ); //#spellok


virtual QString name() const;

virtual QString displayName() const;
@@ -46,8 +49,6 @@ class QgsProcessingModelAlgorithm : QgsProcessingAlgorithm

virtual QString asPythonCommand( const QVariantMap &parameters, QgsProcessingContext &context ) const;

virtual QgsProcessingModelAlgorithm *createInstance() const /Factory/;


void setName( const QString &name );
%Docstring
@@ -364,6 +365,9 @@ Translated description of variable

protected:

virtual QgsProcessingAlgorithm *createInstance() const /Factory/;


virtual QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback );


@@ -38,6 +38,10 @@ class QgsProcessingAlgorithm
QgsProcessingAlgorithm();
%Docstring
Constructor for QgsProcessingAlgorithm.

initAlgorithm() should be called after creating an algorithm to ensure it can correctly configure
its parameterDefinitions() and outputDefinitions(). Alternatively, calling create() will return
a pre-initialized copy of the algorithm.
%End

virtual ~QgsProcessingAlgorithm();
@@ -46,6 +50,11 @@ class QgsProcessingAlgorithm
QgsProcessingAlgorithm *create() const /Factory/;
%Docstring
Creates a copy of the algorithm, ready for execution.

This method returns a new, preinitialized copy of the algorithm, ready for
executing.

.. seealso:: initAlgorithm()
:rtype: QgsProcessingAlgorithm
%End

@@ -345,11 +354,35 @@ class QgsProcessingAlgorithm
sipTransferTo( resObj, Py_None );
%End

virtual void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) = 0;
%Docstring
Initializes the algorithm using the specified ``configuration``.

This should be called directly after creating algorithms and before retrieving
any parameterDefinitions() or outputDefinitions().

Subclasses should use their implementations to add all required input parameter and output
definitions (which can be dynamically adjusted according to ``configuration``).

Dynamic configuration can be used by algorithms which alter their behavior
when used inside processing models. For instance, a "feature router" type
algorithm which sends input features to one of any number of outputs sinks
based on some preconfigured filter parameters can use the init method to
create these outputs based on the specified ``configuration``.

.. seealso:: addParameter()
.. seealso:: addOutput()
%End

bool addParameter( QgsProcessingParameterDefinition *parameterDefinition /Transfer/ );
%Docstring
Adds a parameter ``definition`` to the algorithm. Ownership of the definition is transferred to the algorithm.
Returns true if parameter could be successfully added, or false if the parameter could not be added (e.g.
as a result of a duplicate name).

This should usually be called from a subclass' initAlgorithm() implementation.

.. seealso:: initAlgorithm()
.. seealso:: addOutput()
:rtype: bool
%End
@@ -365,7 +398,11 @@ class QgsProcessingAlgorithm
Adds an output ``definition`` to the algorithm. Ownership of the definition is transferred to the algorithm.
Returns true if the output could be successfully added, or false if the output could not be added (e.g.
as a result of a duplicate name).

This should usually be called from a subclass' initAlgorithm() implementation.

.. seealso:: addParameter()
.. seealso:: initAlgorithm()
:rtype: bool
%End

@@ -60,6 +60,7 @@ def __init__(self):
self.tr('Float'),
self.tr('String')]

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER,
self.tr('Input layer')))
self.addParameter(QgsProcessingParameterString(self.FIELD_NAME,
@@ -60,6 +60,7 @@ def group(self):
def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterRasterLayer(self.INPUT,
self.tr('Elevation layer')))
self.addParameter(QgsProcessingParameterNumber(self.Z_FACTOR,
@@ -45,6 +45,7 @@ class AutoincrementalField(QgisAlgorithm):
def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Input layer')))

@@ -53,6 +53,7 @@ def group(self):
def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Input layer')))
self.addParameter(QgsProcessingParameterField(self.NAME_FIELD,
@@ -88,6 +88,7 @@ def group(self):
def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER,
self.tr('Input layer')))

@@ -55,6 +55,8 @@ class Boundary(QgisAlgorithm):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
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")))
@@ -63,6 +63,7 @@ def group(self):
def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER, self.tr('Input layer')))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT_LAYER, self.tr('Bounds'), QgsProcessing.TypeVectorPolygon))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT_LAYER, self.tr("Bounds")))
@@ -52,6 +52,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(ParameterTable(self.INPUT, self.tr('Input table')))
self.addParameter(ParameterTableField(self.NAME_FIELD,
self.tr('Category name field'),
@@ -73,6 +73,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.methods = [self.tr('The one selected in digitizing settings'),
'QGIS',
'GEOS']
@@ -61,6 +61,7 @@ def group(self):
def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
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)'),
@@ -65,6 +65,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.methods = [self.tr('Create single minimum convex hull'),
self.tr('Create convex hulls based on field')]

@@ -47,6 +47,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterVectorLayer(self.INPUT,
self.tr('Input Layer')))
self.addParameter(QgsProcessingParameterField(self.FIELD,
@@ -47,6 +47,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(ParameterRaster(self.INPUT,
self.tr('Reference layer')))
self.addParameter(ParameterNumber(self.NUMBER,
@@ -53,6 +53,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(ParameterMultipleInput(self.DATASOURCES,
self.tr('Input datasources'),
dataobjects.TYPE_TABLE))
@@ -52,6 +52,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(ParameterVector(self.INPUT,
self.tr('Input Layer')))
self.addParameter(ParameterCrs(self.CRS, 'Output CRS'))
@@ -68,6 +68,7 @@ def group(self):
def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
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))
@@ -50,6 +50,7 @@ def group(self):
def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT, self.tr('Input layer')))
self.addParameter(QgsProcessingParameterField(self.COLUMNS,
self.tr('Fields to drop'),
@@ -44,6 +44,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(ParameterVector(self.INPUT,
self.tr('Input layer')))
self.addOutput(OutputVector(self.OUTPUT, self.tr('Cleaned')))
@@ -42,14 +42,10 @@ class DeleteHoles(QgisAlgorithm):
MIN_AREA = 'MIN_AREA'
OUTPUT = 'OUTPUT'

def tags(self):
return self.tr('remove,delete,drop,holes,rings,fill').split(',')

def group(self):
return self.tr('Vector geometry tools')

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Input layer'), [QgsProcessing.TypeVectorPolygon]))
self.addParameter(QgsProcessingParameterNumber(self.MIN_AREA,
@@ -59,6 +55,12 @@ def __init__(self):
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Cleaned'), QgsProcessing.TypeVectorPolygon))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr('Cleaned'), QgsProcessing.TypeVectorPolygon))

def tags(self):
return self.tr('remove,delete,drop,holes,rings,fill').split(',')

def group(self):
return self.tr('Vector geometry tools')

def name(self):
return 'deleteholes'

@@ -55,6 +55,7 @@ def group(self):
def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Input layer'), [QgsProcessing.TypeVectorPolygon, QgsProcessing.TypeVectorLine]))
self.addParameter(QgsProcessingParameterNumber(self.VERTICES,
@@ -53,6 +53,7 @@ def group(self):
def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Input layer'), [QgsProcessing.TypeVectorPolygon, QgsProcessing.TypeVectorLine]))
self.addParameter(QgsProcessingParameterNumber(self.INTERVAL,
@@ -58,6 +58,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(ParameterVector(Difference.INPUT,
self.tr('Input layer')))
self.addParameter(ParameterVector(Difference.OVERLAY,
@@ -52,6 +52,7 @@ def group(self):
def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
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")))
@@ -65,6 +65,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.modes = [self.tr('Largest area'),
self.tr('Smallest Area'),
self.tr('Largest common boundary')]
@@ -48,6 +48,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(ParameterVector(self.INPUT,
self.tr('Input layer')))
self.addParameter(ParameterTableField(self.FIELD,
@@ -61,6 +61,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(ParameterMultipleInput(name=self.INPUT_DATASOURCES,
description=self.tr('Additional input datasources (called input1, .., inputN in the query)'),
optional=True))
@@ -48,6 +48,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(ParameterVector(self.INPUT,
self.tr('Input layer'),
[dataobjects.TYPE_VECTOR_LINE]))
@@ -59,6 +59,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.calc_methods = [self.tr('Layer CRS'),
self.tr('Project CRS'),
self.tr('Ellipsoidal')]
@@ -47,6 +47,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(ParameterVector(self.INPUT_LAYER,
self.tr('Input layer'), [dataobjects.TYPE_VECTOR_LINE]))
self.addParameter(ParameterNumber(self.START_DISTANCE,
@@ -73,6 +73,7 @@ def group(self):
def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT_LAYER, self.tr('Input layer')))
self.addParameter(QgsProcessingParameterBoolean(self.BY_FEATURE,
self.tr('Calculate extent for each feature separately'), False))
@@ -53,6 +53,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.predicates = (
('intersects', self.tr('intersects')),
('contains', self.tr('contains')),
@@ -54,6 +54,8 @@ def group(self):

def __init__(self):
super().__init__()

def initAlgorithm(self, config=None):
self.addParameter(ParameterVector(self.INPUT,
self.tr('Input layer'),
[dataobjects.TYPE_VECTOR_POLYGON,

0 comments on commit 1e13d73

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