Skip to content

Commit

Permalink
Fix merge all functionality in singleparts to multipart ftools functi…
Browse files Browse the repository at this point in the history
…on. Fixes #2550.

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13506 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
cfarmer committed May 16, 2010
1 parent dd90eed commit a9e1255
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions python/plugins/fTools/tools/doGeometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit a9e1255

Please sign in to comment.