Skip to content

Commit

Permalink
Merge pull request #5344 from nyalldawson/algs
Browse files Browse the repository at this point in the history
[processing] Port some algs to c++, minor improvements
  • Loading branch information
nyalldawson authored Oct 12, 2017
2 parents edf7346 + d39427b commit f6ee7cb
Show file tree
Hide file tree
Showing 42 changed files with 1,914 additions and 615 deletions.
15 changes: 15 additions & 0 deletions python/core/processing/qgsprocessingalgorithm.sip
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,14 @@ class QgsProcessingFeatureBasedAlgorithm : QgsProcessingAlgorithm
:rtype: str
%End

virtual QList<int> inputLayerTypes() const;
%Docstring
Returns the valid input layer types for the source layer for this algorithm.
By default vector layers with any geometry types (excluding non-spatial, geometryless layers)
are accepted.
:rtype: list of int
%End

virtual QgsProcessing::SourceType outputLayerType() const;
%Docstring
Returns the layer type for layers generated by this algorithm, if
Expand Down Expand Up @@ -888,6 +896,13 @@ class QgsProcessingFeatureBasedAlgorithm : QgsProcessingAlgorithm
virtual QVariantMap processAlgorithm( const QVariantMap &parameters,
QgsProcessingContext &context, QgsProcessingFeedback *feedback );

virtual QgsFeatureRequest request() const;
%Docstring
Returns the feature request used for fetching features to process from the
source layer. The default implementation requests all attributes and geometry.
:rtype: QgsFeatureRequest
%End

};


Expand Down
23 changes: 0 additions & 23 deletions python/plugins/processing/algs/help/qgis.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
qgis:addautoincrementalfield: >
This algorithm adds a new integer field to a vector layer, with a sequential value for each feature.

This field can be used as a unique ID for features in the layer.

The new attribute is not added to the input layer but a new layer is generated instead.

qgis:addfieldtoattributestable: >
This algorithm adds a new attribute to a vector layer.

Expand Down Expand Up @@ -160,12 +153,6 @@ qgis:distancetonearesthub: >

The resulting layer can contain only source points with an additional field indicating the distance to the nearest point and the name of the destination point, or lines linking each source point with its nearest destination point.

qgis:dropgeometries: >
This algorithm removes any geometries from an input layer and returns a layer containing only the feature attributes.

qgis:dropmzvalues: >
This algorithm can remove any measure (M) or Z values from input geometries.

qgis:eliminateselectedpolygons: >
This algorithm combines selected polygons of the input layer with certain adjacent polygons by erasing their common boundary. The adjacent polygon can be either the one with the largest or smallest area or the one sharing the largest common boundary with the polygon to be eliminated. The selected features will always be eliminated whether the option "Use only selected features" is set or not.
Eliminate is normally used to get rid of sliver polygons, i.e. tiny polygons that are a result of polygon intersection processes where boundaries of the inputs are similar but not identical.
Expand Down Expand Up @@ -236,11 +223,6 @@ qgis:generatepointspixelcentroidsalongline:
qgis:generatepointspixelcentroidsinsidepolygons:


qgis:hublines:
This algorithm creates hub and spoke diagrams with lines drawn from points on the Spoke Point layer to matching points in the Hub Point layer.

Determination of which hub goes with each point is based on a match between the Hub ID field on the hub points and the Spoke ID field on the spoke points.

qgis:hypsometriccurves: >
This algorithm computes hypsometric curves for an input Digital Elevation Model. Curves are produced as table files in an output folder specified by the user.

Expand All @@ -262,11 +244,6 @@ qgis:joinattributesbylocation: >

The additional attributes and their values are taken from a second vector layer. A spatial criteria is applied to select the values from the second layer that are added to each feature from the first layer in the resulting one.

qgis:joinattributestable: >
This algorithm takes an input vector layer and creates a new vector layer that is an extended version of the input one, with additional attributes in its attribute table.

The additional attributes and their values are taken from a second vector layer. An attribute is selected in each of them to define the join criteria.

qgis:joinbylocationsummary: >
This algorithm takes an input vector layer and creates a new vector layer that is an extended version of the input one, with additional attributes in its attribute table.

Expand Down
4 changes: 4 additions & 0 deletions python/plugins/processing/algs/qgis/AddTableField.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

from qgis.PyQt.QtCore import QVariant
from qgis.core import (QgsField,
QgsProcessing,
QgsProcessingParameterString,
QgsProcessingParameterNumber,
QgsProcessingParameterEnum)
Expand Down Expand Up @@ -72,6 +73,9 @@ def displayName(self):
def outputName(self):
return self.tr('Added')

def inputLayerTypes(self):
return [QgsProcessing.TypeVector]

def prepareAlgorithm(self, parameters, context, feedback):
field_type = self.parameterAsEnum(parameters, self.FIELD_TYPE, context)
field_name = self.parameterAsString(parameters, self.FIELD_NAME, context)
Expand Down
60 changes: 0 additions & 60 deletions python/plugins/processing/algs/qgis/AutoincrementalField.py

This file was deleted.

81 changes: 0 additions & 81 deletions python/plugins/processing/algs/qgis/Boundary.py

This file was deleted.

6 changes: 5 additions & 1 deletion python/plugins/processing/algs/qgis/DeleteColumn.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

__revision__ = '$Format:%H$'

from qgis.core import (QgsProcessingParameterField)
from qgis.core import (QgsProcessingParameterField,
QgsProcessing)
from processing.algs.qgis.QgisAlgorithm import QgisFeatureBasedAlgorithm


Expand All @@ -49,6 +50,9 @@ def initParameters(self, config=None):
self.tr('Fields to drop'),
None, 'INPUT', QgsProcessingParameterField.Any, True))

def inputLayerTypes(self):
return [QgsProcessing.TypeVector]

def name(self):
return 'deletecolumn'

Expand Down
6 changes: 5 additions & 1 deletion python/plugins/processing/algs/qgis/DeleteHoles.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

__revision__ = '$Format:%H$'

from qgis.core import (QgsProcessingParameterNumber)
from qgis.core import (QgsProcessingParameterNumber,
QgsProcessing)
from processing.algs.qgis.QgisAlgorithm import QgisFeatureBasedAlgorithm


Expand Down Expand Up @@ -56,6 +57,9 @@ def displayName(self):
def outputName(self):
return self.tr('Cleaned')

def inputLayerTypes(self):
return [QgsProcessing.TypeVectorPolygon]

def prepareAlgorithm(self, parameters, context, feedback):
self.min_area = self.parameterAsDouble(parameters, self.MIN_AREA, context)
if self.min_area == 0.0:
Expand Down
6 changes: 5 additions & 1 deletion python/plugins/processing/algs/qgis/DensifyGeometries.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@

import os

from qgis.core import (QgsProcessingParameterNumber)
from qgis.core import (QgsProcessingParameterNumber,
QgsProcessing)

from processing.algs.qgis.QgisAlgorithm import QgisFeatureBasedAlgorithm

Expand Down Expand Up @@ -61,6 +62,9 @@ def displayName(self):
def outputName(self):
return self.tr('Densified')

def inputLayerTypes(self):
return [QgsProcessing.TypeVectorLine, QgsProcessing.TypeVectorPolygon]

def prepareAlgorithm(self, parameters, context, feedback):
self.vertices = self.parameterAsInt(parameters, self.VERTICES, context)
return True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

__revision__ = '$Format:%H$'

from qgis.core import (QgsProcessingParameterNumber)
from qgis.core import (QgsProcessingParameterNumber,
QgsProcessing)

from processing.algs.qgis.QgisAlgorithm import QgisFeatureBasedAlgorithm

Expand Down Expand Up @@ -57,6 +58,9 @@ def displayName(self):
def outputName(self):
return self.tr('Densified')

def inputLayerTypes(self):
return [QgsProcessing.TypeVectorLine, QgsProcessing.TypeVectorPolygon]

def prepareAlgorithm(self, parameters, context, feedback):
interval = self.parameterAsDouble(parameters, self.INTERVAL, context)
return True
Expand Down
62 changes: 0 additions & 62 deletions python/plugins/processing/algs/qgis/DropGeometry.py

This file was deleted.

Loading

0 comments on commit f6ee7cb

Please sign in to comment.