Skip to content
Permalink
Browse files

Fix merge all functionality in singleparts to multipart ftools functi…

…on. Fixes #2550.

git-svn-id: http://svn.osgeo.org/qgis/trunk@13506 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer
cfarmer committed May 16, 2010
1 parent e03e5a1 commit 30caf1ae30a5d951d57c7552e1af8b24e49d4b13
Showing with 12 additions and 5 deletions.
  1. +12 −5 python/plugins/fTools/tools/doGeometry.py
@@ -237,7 +237,7 @@ def single_to_multi( self ):
allAttrs = vprovider.attributeIndexes()
vprovider.select( allAttrs )
fields = vprovider.fields()
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
fields, vprovider.geometryType(), vprovider.crs() )
inFeat = QgsFeature()
outFeat = QgsFeature()
@@ -247,20 +247,27 @@ def single_to_multi( self ):
if not index == -1:
unique = ftools_utils.getUniqueValues( vprovider, int( index ) )
else:
unique = range( 0, self.vlayer.featureCount() )
unique = [QVariant(QString())]
nFeat = vprovider.featureCount() * len( unique )
nElement = 0
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
if not len( unique ) == self.vlayer.featureCount():
merge_all = self.myField == QString("--- " + self.tr( "Merge all" ) + " ---")
if not len( unique ) == self.vlayer.featureCount() \
or merge_all:
for i in unique:
vprovider.rewind()
multi_feature= []
first = True
vprovider.select(allAttrs)
while vprovider.nextFeature( inFeat ):
atMap = inFeat.attributeMap()
idVar = atMap[ index ]
if idVar.toString().trimmed() == i.toString().trimmed():
if not merge_all:
idVar = atMap[ index ]
else:
idVar = QVariant(QString())
if idVar.toString().trimmed() == i.toString().trimmed() \
or merge_all:
if first:
atts = atMap
first = False

0 comments on commit 30caf1a

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