Skip to content
Permalink
Browse files

Take advantage of auto created outputs in ported algorithms

  • Loading branch information
nyalldawson committed Jul 11, 2017
1 parent 058271b commit d92583c10e5b3269746b1f0cf64c752df94f07d3
Showing with 39 additions and 175 deletions.
  1. +1 −6 python/plugins/processing/algs/qgis/AddTableField.py
  2. +0 −1 python/plugins/processing/algs/qgis/Aspect.py
  3. +1 −6 python/plugins/processing/algs/qgis/AutoincrementalField.py
  4. +1 −8 python/plugins/processing/algs/qgis/Boundary.py
  5. +1 −8 python/plugins/processing/algs/qgis/BoundingBox.py
  6. +0 −6 python/plugins/processing/algs/qgis/CheckValidity.py
  7. +1 −7 python/plugins/processing/algs/qgis/ConcaveHull.py
  8. +0 −1 python/plugins/processing/algs/qgis/CreateAttributeIndex.py
  9. +2 −6 python/plugins/processing/algs/qgis/Delaunay.py
  10. +2 −6 python/plugins/processing/algs/qgis/DeleteColumn.py
  11. +2 −7 python/plugins/processing/algs/qgis/DeleteHoles.py
  12. +2 −7 python/plugins/processing/algs/qgis/DensifyGeometries.py
  13. +2 −9 python/plugins/processing/algs/qgis/DensifyGeometriesInterval.py
  14. +1 −6 python/plugins/processing/algs/qgis/Difference.py
  15. +1 −5 python/plugins/processing/algs/qgis/DropGeometry.py
  16. +1 −9 python/plugins/processing/algs/qgis/ExtentFromLayer.py
  17. +1 −4 python/plugins/processing/algs/qgis/FixGeometry.py
  18. +2 −8 python/plugins/processing/algs/qgis/GridPolygon.py
  19. +0 −7 python/plugins/processing/algs/qgis/Merge.py
  20. +0 −3 python/plugins/processing/algs/qgis/PointsLayerFromTable.py
  21. +1 −3 python/plugins/processing/algs/qgis/RandomExtract.py
  22. +2 −6 python/plugins/processing/algs/qgis/RandomExtractWithinSubsets.py
  23. +8 −6 python/plugins/processing/algs/qgis/RegularPoints.py
  24. +1 −3 python/plugins/processing/algs/qgis/SaveSelectedFeatures.py
  25. +1 −4 python/plugins/processing/algs/qgis/SimplifyGeometries.py
  26. +2 −6 python/plugins/processing/algs/qgis/Smooth.py
  27. +1 −4 python/plugins/processing/algs/qgis/SnapGeometries.py
  28. +1 −4 python/plugins/processing/algs/qgis/SymmetricalDifference.py
  29. +0 −4 python/plugins/processing/algs/qgis/VoronoiPolygons.py
  30. +1 −4 python/plugins/processing/algs/qgis/ZonalStatistics.py
  31. +0 −11 src/core/processing/qgsnativealgorithms.cpp
@@ -27,16 +27,12 @@

from qgis.PyQt.QtCore import QVariant
from qgis.core import (QgsField,
QgsFeature,
QgsFeatureSink,
QgsApplication,
QgsProcessingUtils,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterString,
QgsProcessingParameterNumber,
QgsProcessingParameterEnum,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer)
QgsProcessingParameterFeatureSink)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm


@@ -73,7 +69,6 @@ def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterNumber(self.FIELD_PRECISION,
self.tr('Field precision'), QgsProcessingParameterNumber.Integer, 0, False, 0, 10))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT_LAYER, self.tr('Added')))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT_LAYER, self.tr('Added')))

def name(self):
return 'addfieldtoattributestable'
@@ -67,7 +67,6 @@ def initAlgorithm(self, config=None):
self.tr('Z factor'), QgsProcessingParameterNumber.Double,
1, False, 1, 999999.99))
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT, self.tr('Aspect')))
self.addOutput(QgsProcessingOutputRasterLayer(self.OUTPUT, self.tr('Aspect')))

def name(self):
return 'aspect'
@@ -27,13 +27,9 @@

from qgis.PyQt.QtCore import QVariant
from qgis.core import (QgsField,
QgsFeature,
QgsFeatureSink,
QgsApplication,
QgsProcessingUtils,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer)
QgsProcessingParameterFeatureSink)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm


@@ -50,7 +46,6 @@ def initAlgorithm(self, config=None):
self.tr('Input layer')))

self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Incremented')))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr('Incremented')))

def group(self):
return self.tr('Vector table tools')
@@ -31,19 +31,13 @@
QgsWkbTypes,
QgsFeatureSink,
QgsProcessing,
QgsProcessingUtils,
QgsProcessingParameterDefinition,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer)
QgsProcessingParameterFeatureSink)

from qgis.PyQt.QtGui import QIcon

from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.core.parameters import ParameterVector
from processing.core.outputs import OutputVector
from processing.tools import dataobjects

pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]

@@ -59,7 +53,6 @@ def __init__(self):
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")))

def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'ftools', 'convex_hull.png'))
@@ -31,20 +31,14 @@
QgsWkbTypes,
QgsFeatureSink,
QgsProcessing,
QgsProcessingUtils,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer,
QgsProcessingParameterDefinition)
QgsProcessingParameterFeatureSink)


from qgis.PyQt.QtGui import QIcon

from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.core.parameters import ParameterVector
from processing.core.outputs import OutputVector
from processing.tools import dataobjects

pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]

@@ -66,7 +60,6 @@ def __init__(self):
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")))

def name(self):
return 'boundingboxes'
@@ -37,15 +37,12 @@
QgsFeatureRequest,
QgsFeatureSink,
QgsWkbTypes,
QgsProcessingUtils,
QgsFields,
QgsProcessing,
QgsProcessingFeatureSource,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterEnum,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer,
QgsProcessingParameterDefinition,
QgsProcessingOutputNumber
)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
@@ -85,15 +82,12 @@ def initAlgorithm(self, config=None):
self.tr('Method'), self.methods))

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'), 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'), QgsProcessing.TypeVectorAny, '', True))
self.addOutput(QgsProcessingOutputVectorLayer(self.ERROR_OUTPUT, self.tr('Error output')))
self.addOutput(QgsProcessingOutputNumber(self.ERROR_COUNT, self.tr('Count of errors')))

def name(self):
@@ -31,16 +31,11 @@
QgsGeometry,
QgsFeatureSink,
QgsWkbTypes,
QgsApplication,
QgsProcessing,
QgsProcessingUtils,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterDefinition,
QgsProcessingParameterNumber,
QgsProcessingParameterBoolean,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer)
QgsProcessingParameterFeatureSink)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
import processing
@@ -73,7 +68,6 @@ def initAlgorithm(self, config=None):
self.tr('Split multipart geometry into singleparts geometries'), defaultValue=False))

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'
@@ -27,7 +27,6 @@

from qgis.core import (QgsVectorDataProvider,
QgsFields,
QgsApplication,
QgsProcessingParameterVectorLayer,
QgsProcessingParameterField,
QgsProcessingParameterDefinition,
@@ -39,12 +39,9 @@
QgsPointXY,
QgsWkbTypes,
QgsProcessing,
QgsProcessingUtils,
QgsFields,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterDefinition,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer)
QgsProcessingParameterFeatureSource
QgsProcessingParameterFeatureSink)

from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
@@ -71,7 +68,6 @@ def __init__(self):
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))

def name(self):
return 'delaunaytriangulation'
@@ -25,13 +25,10 @@

__revision__ = '$Format:%H$'

from qgis.core import (QgsApplication,
QgsFeatureSink,
QgsProcessingUtils,
from qgis.core import (QgsFeatureSink,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
QgsProcessingParameterField,
QgsProcessingOutputVectorLayer)
QgsProcessingParameterField)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm


@@ -57,7 +54,6 @@ def initAlgorithm(self, config=None):
None, self.INPUT, QgsProcessingParameterField.Any, True))

self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Output layer')))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr("Output layer")))

def name(self):
return 'deletecolumn'
@@ -24,15 +24,11 @@

__revision__ = '$Format:%H$'

from qgis.core import (QgsApplication,
QgsFeatureSink,
from qgis.core import (QgsFeatureSink,
QgsProcessing,
QgsProcessingUtils,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterNumber,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer,
QgsProcessingParameterDefinition)
QgsProcessingParameterFeatureSink)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm


@@ -53,7 +49,6 @@ def initAlgorithm(self, config=None):
0, True, 0.0, 10000000.0))

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(',')
@@ -28,15 +28,11 @@

import os

from qgis.core import (QgsWkbTypes,
QgsFeatureSink,
QgsApplication,
from qgis.core import (QgsFeatureSink,
QgsProcessing,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterNumber,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer,
QgsProcessingParameterDefinition)
QgsProcessingParameterFeatureSink)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm


@@ -63,7 +59,6 @@ def initAlgorithm(self, config=None):
1, False, 1, 10000000))

self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Densified')))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr('Densified')))

def name(self):
return 'densifygeometries'
@@ -27,17 +27,11 @@

__revision__ = '$Format:%H$'

from math import sqrt

from qgis.core import (QgsWkbTypes,
QgsApplication,
QgsFeatureSink,
from qgis.core import (QgsFeatureSink,
QgsProcessing,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterNumber,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer,
QgsProcessingParameterDefinition)
QgsProcessingParameterFeatureSink)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm


@@ -61,7 +55,6 @@ def initAlgorithm(self, config=None):
1, False, 0, 10000000))

self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Densified')))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr('Densified')))

def name(self):
return 'densifygeometriesgivenaninterval'
@@ -33,13 +33,9 @@
QgsFeatureSink,
QgsGeometry,
QgsFeatureRequest,
NULL,
QgsWkbTypes,
QgsMessageLog,
QgsProcessingUtils,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer,
QgsProcessingParameterFeatureSink
QgsSpatialIndex)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm

@@ -68,7 +64,6 @@ def initAlgorithm(self, config=None):
self.tr('Difference layer')))

self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Difference')))
self.addOutput(QgsProcessingOutputVectorLayer(self.OUTPUT, self.tr('Difference')))

def name(self):
return 'difference'
@@ -29,12 +29,9 @@
QgsWkbTypes,
QgsFeatureSink,
QgsCoordinateReferenceSystem,
QgsApplication,
QgsProcessing,
QgsProcessingParameterDefinition,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer)
QgsProcessingParameterFeatureSink)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm


@@ -55,7 +52,6 @@ def __init__(self):
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")))

def name(self):
return 'dropgeometries'
@@ -37,19 +37,12 @@
QgsFeature,
QgsWkbTypes,
QgsProcessing,
QgsProcessingUtils,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputVectorLayer,
QgsProcessingParameterBoolean,
QgsProcessingParameterDefinition,
QgsFields)

from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.core.parameters import ParameterVector
from processing.core.parameters import ParameterBoolean
from processing.core.outputs import OutputVector
from processing.tools import dataobjects

pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]

@@ -78,8 +71,7 @@ def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterBoolean(self.BY_FEATURE,
self.tr('Calculate extent for each feature separately'), False))

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

def name(self):
return 'polygonfromlayerextent'

0 comments on commit d92583c

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