Skip to content
Permalink
Browse files

fix Merge shapefiles tool in fTools (fix #7570)

  • Loading branch information
alexbruy committed Apr 11, 2013
1 parent 6ebedbc commit f8834f201a1c3984403bda86b95ad159674d9ab5
Showing with 10 additions and 6 deletions.
  1. +10 −6 python/plugins/fTools/tools/doMergeShapes.py
@@ -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)
@@ -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:
@@ -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() )

0 comments on commit f8834f2

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