mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
Remove duplicate testForUniqueness method (replaced with QgsProcessingUtils.combineFields)
This commit is contained in:
parent
54e5bfda5c
commit
a191c77bcb
@ -39,7 +39,8 @@ from qgis.core import (QgsFeatureRequest,
|
||||
QgsProcessingParameterFeatureSource,
|
||||
QgsProcessingParameterFeatureSink,
|
||||
QgsSpatialIndex,
|
||||
QgsProcessingParameterField)
|
||||
QgsProcessingParameterField,
|
||||
QgsProcessingUtils)
|
||||
|
||||
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
|
||||
from processing.tools import vector
|
||||
@ -122,12 +123,10 @@ class Intersection(QgisAlgorithm):
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user