Skip to content
Permalink
Browse files

[processing] nodes -> vertices algorithm renaming

- "Extract nodes" renamed to "Extract vertices"
- "Extract specific nodes" renamed to "Extract specific vertices"
  • Loading branch information
nirvn committed Jan 29, 2018
1 parent a420d04 commit e0c12d519ff6443866f89e8853731ccd9c73125f
Showing with 667 additions and 669 deletions.
  1. +4 −9 python/plugins/processing/algs/help/qgis.yaml
  2. +1 −1 python/plugins/processing/algs/qgis/DensifyGeometries.py
  3. +3 −0 python/plugins/processing/algs/qgis/DensifyGeometriesInterval.py
  4. +30 −30 python/plugins/processing/algs/qgis/{ExtractSpecificNodes.py → ExtractSpecificVertices.py}
  5. +2 −2 python/plugins/processing/algs/qgis/QgisAlgorithmProvider.py
  6. +6 −6 python/plugins/processing/tests/testdata/expected/extract_nodes_lines.gfs
  7. +51 −51 python/plugins/processing/tests/testdata/expected/extract_nodes_lines.gml
  8. +6 −6 python/plugins/processing/tests/testdata/expected/extract_nodes_multilines.gfs
  9. +45 −45 python/plugins/processing/tests/testdata/expected/extract_nodes_multilines.gml
  10. +8 −8 python/plugins/processing/tests/testdata/expected/extract_nodes_multipolys.gfs
  11. +100 −100 python/plugins/processing/tests/testdata/expected/extract_nodes_multipolys.gml
  12. +8 −8 python/plugins/processing/tests/testdata/expected/extract_nodes_polys.gfs
  13. +132 −132 python/plugins/processing/tests/testdata/expected/extract_nodes_polys.gml
  14. +8 −8 python/plugins/processing/tests/testdata/expected/extract_specific_nodes_lines.gfs
  15. +84 −84 python/plugins/processing/tests/testdata/expected/extract_specific_nodes_lines.gml
  16. +10 −10 python/plugins/processing/tests/testdata/expected/extract_specific_nodes_polys.gfs
  17. +90 −90 python/plugins/processing/tests/testdata/expected/extract_specific_nodes_polys.gml
  18. +16 −16 python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
  19. +2 −2 src/analysis/CMakeLists.txt
  20. +22 −22 src/analysis/processing/{qgsalgorithmextractnodes.cpp → qgsalgorithmextractvertices.cpp}
  21. +7 −7 src/analysis/processing/{qgsalgorithmextractnodes.h → qgsalgorithmextractvertices.h}
  22. +21 −21 ...lysis/processing/{qgsalgorithmremoveduplicatenodes.cpp → qgsalgorithmremoveduplicatevertices.cpp}
  23. +7 −7 src/analysis/processing/{qgsalgorithmremoveduplicatenodes.h → qgsalgorithmremoveduplicatevertices.h}
  24. +4 −4 src/analysis/processing/qgsnativealgorithms.cpp
@@ -176,17 +176,12 @@ qgis:extractbyexpression: >

For more information about expressions see the <a href ="{qgisdocs}/user_manual/working_with_vector/expression.html">user manual</a>

qgis:extractnodes: >
This algorithm takes a line or polygon layer and generates a point layer with points representing the nodes in the input lines or polygons. The attributes associated to each point are the same ones associated to the line or polygon that the point belongs to.
qgis:extractspecificvertices: >
This algorithm takes a line or polygon layer and generates a point layer with points representing specific vertices in the input lines or polygons. For instance, this algorithm can be used to extract the first or last vertices in the geometry. The attributes associated to each point are the same ones associated to the line or polygon that the point belongs to.

Additional fields are added to the nodes indicating the node index (beginning at 0), distance along original geometry and bisector angle of node for original geometry.
The vertex indices parameter accepts a comma separated string specifying the indices of the vertices to extract. The first vertex corresponds to an index of 0, the second vertex has an index of 1, etc. Negative indices can be used to find vertices at the end of the geometry, e.g., an index of -1 corresponds to the last vertex, -2 corresponds to the second last vertex, etc.

qgis:extractspecificnodes: >
This algorithm takes a line or polygon layer and generates a point layer with points representing specific nodes in the input lines or polygons. For instance, this algorithm can be used to extract the first or last nodes in the geometry. The attributes associated to each point are the same ones associated to the line or polygon that the point belongs to.

The node indices parameter accepts a comma separated string specifying the indices of the nodes to extract. The first node corresponds to an index of 0, the second node has an index of 1, etc. Negative indices can be used to find nodes at the end of the geometry, e.g., an index of -1 corresponds to the last node, -2 corresponds to the second last node, etc.

Additional fields are added to the nodes indicating the specific node position (e.g., 0, -1, etc), the original node index, the node’s part and its index within the part (as well as its ring for polygons), distance along the original geometry and bisector angle of node for the original geometry.
Additional fields are added to the points indicating the specific vertex position (e.g., 0, -1, etc), the original vertex index, the vertex’s part and its index within the part (as well as its ring for polygons), distance along the original geometry and bisector angle of vertex for the original geometry.

qgis:fieldcalculator: >
This algorithm computes a new vector layer with the same features of the input layer, but with an additional attribute. The values of this new attribute are computed from each feature using a mathematical formula, based on the properties and attributes of the feature.
@@ -38,7 +38,7 @@ class DensifyGeometries(QgisFeatureBasedAlgorithm):
VERTICES = 'VERTICES'

def tags(self):
return self.tr('add,vertices,points').split(',')
return self.tr('add,vertex,vertices,points,nodes').split(',')

def group(self):
return self.tr('Vector geometry')
@@ -36,6 +36,9 @@ class DensifyGeometriesInterval(QgisFeatureBasedAlgorithm):

INTERVAL = 'INTERVAL'

def tags(self):
return self.tr('add,vertex,vertices,points,nodes').split(',')

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

@@ -2,7 +2,7 @@

"""
***************************************************************************
ExtractSpecificNodes.py
ExtractSpecificVertices.py
--------------------
Date : October 2016
Copyright : (C) 2016 by Nyall Dawson
@@ -42,10 +42,10 @@
from qgis.PyQt.QtCore import QVariant


class ExtractSpecificNodes(QgisAlgorithm):
class ExtractSpecificVertices(QgisAlgorithm):
INPUT = 'INPUT'
OUTPUT = 'OUTPUT'
NODES = 'NODES'
VERTICES = 'VERTICES'

def group(self):
return self.tr('Vector geometry')
@@ -59,29 +59,29 @@ def __init__(self):
def initAlgorithm(self, config=None):
self.addParameter(QgsProcessingParameterFeatureSource(self.INPUT,
self.tr('Input layer'), [QgsProcessing.TypeVectorAnyGeometry]))
self.addParameter(QgsProcessingParameterString(self.NODES,
self.tr('Node indices'), defaultValue='0'))
self.addParameter(QgsProcessingParameterString(self.VERTICES,
self.tr('Vertex indices'), defaultValue='0'))

self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Nodes'), QgsProcessing.TypeVectorPoint))
self.addParameter(QgsProcessingParameterFeatureSink(self.OUTPUT, self.tr('Vertices'), QgsProcessing.TypeVectorPoint))

def name(self):
return 'extractspecificnodes'
return 'extractspecificvertices'

def displayName(self):
return self.tr('Extract specific nodes')
return self.tr('Extract specific vertices')

def tags(self):
return self.tr('points,vertex,vertices').split(',')
return self.tr('points,vertex,nodes').split(',')

def processAlgorithm(self, parameters, context, feedback):
source = self.parameterAsSource(parameters, self.INPUT, context)
fields = source.fields()
fields.append(QgsField('node_pos', QVariant.Int))
fields.append(QgsField('node_index', QVariant.Int))
fields.append(QgsField('node_part', QVariant.Int))
fields.append(QgsField('vertex_pos', QVariant.Int))
fields.append(QgsField('vertex_index', QVariant.Int))
fields.append(QgsField('vertex_part', QVariant.Int))
if QgsWkbTypes.geometryType(source.wkbType()) == QgsWkbTypes.PolygonGeometry:
fields.append(QgsField('node_part_ring', QVariant.Int))
fields.append(QgsField('node_part_index', QVariant.Int))
fields.append(QgsField('vertex_part_ring', QVariant.Int))
fields.append(QgsField('vertex_part_index', QVariant.Int))
fields.append(QgsField('distance', QVariant.Double))
fields.append(QgsField('angle', QVariant.Double))

@@ -94,14 +94,14 @@ def processAlgorithm(self, parameters, context, feedback):
(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
fields, wkb_type, source.sourceCrs())

node_indices_string = self.parameterAsString(parameters, self.NODES, context)
vertex_indices_string = self.parameterAsString(parameters, self.VERTICES, context)
indices = []
for node in node_indices_string.split(','):
for vertex in vertex_indices_string.split(','):
try:
indices.append(int(node))
indices.append(int(vertex))
except:
raise QgsProcessingException(
self.tr('\'{}\' is not a valid node index').format(node))
self.tr('\'{}\' is not a valid vertex index').format(vertex))

features = source.getFeatures()
total = 100.0 / source.featureCount() if source.featureCount() else 0
@@ -114,26 +114,26 @@ def processAlgorithm(self, parameters, context, feedback):
if not input_geometry:
sink.addFeature(f, QgsFeatureSink.FastInsert)
else:
total_nodes = input_geometry.constGet().nCoordinates()
total_vertices = input_geometry.constGet().nCoordinates()

for node in indices:
if node < 0:
node_index = total_nodes + node
for vertex in indices:
if vertex < 0:
vertex_index = total_vertices + vertex
else:
node_index = node
vertex_index = vertex

if node_index < 0 or node_index >= total_nodes:
if vertex_index < 0 or vertex_index >= total_vertices:
continue

(success, vertex_id) = input_geometry.vertexIdFromVertexNr(node_index)
(success, vertex_id) = input_geometry.vertexIdFromVertexNr(vertex_index)

distance = input_geometry.distanceToVertex(node_index)
angle = math.degrees(input_geometry.angleAtVertex(node_index))
distance = input_geometry.distanceToVertex(vertex_index)
angle = math.degrees(input_geometry.angleAtVertex(vertex_index))

output_feature = QgsFeature()
attrs = f.attributes()
attrs.append(node)
attrs.append(node_index)
attrs.append(vertex)
attrs.append(vertex_index)
attrs.append(vertex_id.part)
if QgsWkbTypes.geometryType(source.wkbType()) == QgsWkbTypes.PolygonGeometry:
attrs.append(vertex_id.ring)
@@ -142,7 +142,7 @@ def processAlgorithm(self, parameters, context, feedback):
attrs.append(angle)
output_feature.setAttributes(attrs)

point = input_geometry.vertexAt(node_index)
point = input_geometry.vertexAt(vertex_index)
output_feature.setGeometry(QgsGeometry(point))

sink.addFeature(output_feature, QgsFeatureSink.FastInsert)
@@ -63,7 +63,7 @@
from .ExportGeometryInfo import ExportGeometryInfo
from .ExtendLines import ExtendLines
from .ExtentFromLayer import ExtentFromLayer
from .ExtractSpecificNodes import ExtractSpecificNodes
from .ExtractSpecificVertices import ExtractSpecificVertices
from .FieldPyculator import FieldsPyculator
from .FieldsCalculator import FieldsCalculator
from .FieldsMapper import FieldsMapper
@@ -183,7 +183,7 @@ def getAlgs(self):
ExportGeometryInfo(),
ExtendLines(),
ExtentFromLayer(),
ExtractSpecificNodes(),
ExtractSpecificVertices(),
FieldsCalculator(),
FieldsMapper(),
FieldsPyculator(),
@@ -12,18 +12,18 @@
<ExtentYMax>5.00000</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>node_index</Name>
<ElementPath>node_index</ElementPath>
<Name>vertex_index</Name>
<ElementPath>vertex_index</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
<PropertyDefn>
<Name>node_part</Name>
<ElementPath>node_part</ElementPath>
<Name>vertex_part</Name>
<ElementPath>vertex_part</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
<PropertyDefn>
<Name>node_part_index</Name>
<ElementPath>node_part_index</ElementPath>
<Name>vertex_part_index</Name>
<ElementPath>vertex_part_index</ElementPath>
<Type>Integer</Type>
</PropertyDefn>
<PropertyDefn>

0 comments on commit e0c12d5

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