Skip to content

Commit

Permalink
fix Merge shapefiles tool in fTools (fix #7570)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Apr 11, 2013
1 parent 6ebedbc commit f8834f2
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions python/plugins/fTools/tools/doMergeShapes.py
Expand Up @@ -260,10 +260,10 @@ def run( self ):
for mergedField in mergedFields:
if mergedField.name() == layerField.name() and mergedField.type() == layerField.type():
fieldFound = True
break
break

if not fieldFound:
if not fieldMap.has_key(shapeIndex):
if not fieldMap.has_key(shapeIndex):
fieldMap[shapeIndex]={}

fieldMap[shapeIndex][fieldIndex] = len(mergedFields)
Expand All @@ -283,8 +283,12 @@ def run( self ):
self.geom = newLayer.wkbType()
vprovider = newLayer.dataProvider()

fields = QgsFields()
for f in mergedFields:
fields.append(f)

writer = QgsVectorFileWriter( self.outputFileName, self.outputEncoding,
mergedFields, self.geom, self.crs )
fields, self.geom, self.crs )

shapeIndex = 0
for fileName in self.shapes:
Expand All @@ -306,10 +310,10 @@ def run( self ):
mergedAttrs = [QVariant()] * len(mergedFields)

# fill available attributes with values
fieldIndex = 0
fieldIndex = 0
for v in inFeat.attributes():
if fieldMap.has_key(shapeIndex) and fieldMap[shapeIndex].has_key(layerIndex):
mergedAttrs[ fieldMap[shapeIndex][layerIndex] ] = v
if fieldMap.has_key(shapeIndex) and fieldMap[shapeIndex].has_key(fieldIndex):
mergedAttrs[ fieldMap[shapeIndex][fieldIndex] ] = v
fieldIndex += 1

inGeom = QgsGeometry( inFeat.geometry() )
Expand Down

0 comments on commit f8834f2

Please sign in to comment.