Skip to content
Permalink
Browse files

Merge pull request #712 from ddanielvaz/fix-8219

Fix 8219
  • Loading branch information
NathanW2 committed Jul 11, 2013
2 parents b50a893 + 522aecc commit b45b7d6f88d9165cce43a1f6a7573a56bd1d8a0e
Showing with 22 additions and 10 deletions.
  1. +22 −10 python/plugins/fTools/tools/doGeoprocessing.py
@@ -463,13 +463,26 @@ def convex_hull(self, useField ):
GEOS_EXCEPT = True
FEATURE_EXCEPT = True
vproviderA = self.vlayerA.dataProvider()
writer = QgsVectorFileWriter( self.myName, self.myEncoding, vproviderA.fields(),
# creating fields
idField = QgsField("outID", QVariant.String)
areaField = QgsField("area", QVariant.Double)
perimField = QgsField("perim", QVariant.Double)
# appending fields
outFeatFields = QgsFields()
outFeatFields.append(idField)
outFeatFields.append(areaField)
outFeatFields.append(perimField)
#
writer = QgsVectorFileWriter( self.myName, self.myEncoding, outFeatFields,
QGis.WKBPolygon, vproviderA.crs() )
if writer.hasError():
return GEOS_EXCEPT, FEATURE_EXCEPT, True, writer.errorMessage()

inFeat = QgsFeature()
outFeat = QgsFeature()
# set feature fields
outFeat.setFields(outFeatFields)
#
inGeom = QgsGeometry()
outGeom = QgsGeometry()
nElement = 0
@@ -487,11 +500,10 @@ def convex_hull(self, useField ):
hull = []
first = True
outID = 0
vproviderA.rewind()
for inFeat in selectionA:
atMap = inFeat.attributes()
idVar = atMap[ self.myParam ]
if idVar.strip() == i.strip():
if idVar == i:
if first:
outID = idVar
first = False
@@ -506,9 +518,9 @@ def convex_hull(self, useField ):
outGeom = tmpGeom.convexHull()
outFeat.setGeometry( outGeom )
(area, perim) = self.simpleMeasure( outGeom )
outFeat.setAttribute( 0, outID )
outFeat.setAttribute( 1, area )
outFeat.setAttribute( 2, perim )
outFeat.setAttribute( "outID", outID )
outFeat.setAttribute( "area", area )
outFeat.setAttribute( "perim", perim )
writer.addFeature( outFeat )
except:
GEOS_EXCEPT = False
@@ -547,7 +559,7 @@ def convex_hull(self, useField ):
while fitA.nextFeature( inFeat ):
atMap = inFeat.attributes()
idVar = atMap[ self.myParam ]
if idVar.strip() == i.strip():
if idVar == i:
if first:
outID = idVar
first = False
@@ -562,9 +574,9 @@ def convex_hull(self, useField ):
outGeom = tmpGeom.convexHull()
outFeat.setGeometry( outGeom )
(area, perim) = self.simpleMeasure( outGeom )
outFeat.setAttribute( 0, outID )
outFeat.setAttribute( 1, area )
outFeat.setAttribute( 2, perim )
outFeat.setAttribute( "outID", outID )
outFeat.setAttribute( "area", area )
outFeat.setAttribute( "perim", perim )
writer.addFeature( outFeat )
except:
GEOS_EXCEPT = False

0 comments on commit b45b7d6

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