Skip to content

Commit 30caf1a

Browse files
author
cfarmer
committedMay 16, 2010
Fix merge all functionality in singleparts to multipart ftools function. Fixes #2550.
git-svn-id: http://svn.osgeo.org/qgis/trunk@13506 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e03e5a1 commit 30caf1a

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed
 

‎python/plugins/fTools/tools/doGeometry.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def single_to_multi( self ):
237237
allAttrs = vprovider.attributeIndexes()
238238
vprovider.select( allAttrs )
239239
fields = vprovider.fields()
240-
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
240+
writer = QgsVectorFileWriter( self.myName, self.myEncoding,
241241
fields, vprovider.geometryType(), vprovider.crs() )
242242
inFeat = QgsFeature()
243243
outFeat = QgsFeature()
@@ -247,20 +247,27 @@ def single_to_multi( self ):
247247
if not index == -1:
248248
unique = ftools_utils.getUniqueValues( vprovider, int( index ) )
249249
else:
250-
unique = range( 0, self.vlayer.featureCount() )
250+
unique = [QVariant(QString())]
251251
nFeat = vprovider.featureCount() * len( unique )
252252
nElement = 0
253253
self.emit( SIGNAL( "runStatus(PyQt_PyObject)" ), 0 )
254254
self.emit( SIGNAL( "runRange(PyQt_PyObject)" ), ( 0, nFeat ) )
255-
if not len( unique ) == self.vlayer.featureCount():
255+
merge_all = self.myField == QString("--- " + self.tr( "Merge all" ) + " ---")
256+
if not len( unique ) == self.vlayer.featureCount() \
257+
or merge_all:
256258
for i in unique:
257259
vprovider.rewind()
258260
multi_feature= []
259261
first = True
262+
vprovider.select(allAttrs)
260263
while vprovider.nextFeature( inFeat ):
261264
atMap = inFeat.attributeMap()
262-
idVar = atMap[ index ]
263-
if idVar.toString().trimmed() == i.toString().trimmed():
265+
if not merge_all:
266+
idVar = atMap[ index ]
267+
else:
268+
idVar = QVariant(QString())
269+
if idVar.toString().trimmed() == i.toString().trimmed() \
270+
or merge_all:
264271
if first:
265272
atts = atMap
266273
first = False

0 commit comments

Comments
 (0)
Please sign in to comment.