Skip to content
Permalink
Browse files

Remove duplicate testForUniqueness method (replaced with QgsProcessin…

…gUtils.combineFields)
  • Loading branch information
nyalldawson committed Sep 22, 2017
1 parent 54e5bfd commit a191c77bcbc177738956fc43b5462c524971c36d
Showing with 4 additions and 21 deletions.
  1. +4 −5 python/plugins/processing/algs/qgis/Intersection.py
  2. +0 −16 python/plugins/processing/tools/vector.py
@@ -39,7 +39,8 @@
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
QgsSpatialIndex,
QgsProcessingParameterField)
QgsProcessingParameterField,
QgsProcessingUtils)

from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.tools import vector
@@ -122,12 +123,10 @@ def processAlgorithm(self, parameters, context, feedback):
fieldListB = sourceB.fields()
field_indices_b = [i for i in range(0, fieldListB.count())]

fieldListB = vector.testForUniqueness(fieldListA, fieldListB)
for b in fieldListB:
fieldListA.append(b)
output_fields = QgsProcessingUtils.combineFields(fieldListA, fieldListB)

(sink, dest_id) = self.parameterAsSink(parameters, self.OUTPUT, context,
fieldListA, geomType, sourceA.sourceCrs())
output_fields, geomType, sourceA.sourceCrs())

outFeat = QgsFeature()
indexB = QgsSpatialIndex(sourceB.getFeatures(QgsFeatureRequest().setSubsetOfAttributes([]).setDestinationCrs(sourceA.sourceCrs())), feedback)
@@ -95,22 +95,6 @@ def values(source, *attributes):
return ret


def testForUniqueness(fieldList1, fieldList2):
'''Returns a modified version of fieldList2, removing naming
collisions with fieldList1.'''
changed = True
while changed:
changed = False
for i in range(0, len(fieldList1)):
for j in range(0, len(fieldList2)):
if fieldList1[i].name() == fieldList2[j].name():
field = fieldList2[j]
name = createUniqueFieldName(field.name(), fieldList1)
fieldList2[j] = QgsField(name, field.type(), len=field.length(), prec=field.precision(), comment=field.comment())
changed = True
return fieldList2


def createUniqueFieldName(fieldName, fieldList):
def nextname(name):
num = 1

0 comments on commit a191c77

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