Skip to content

Commit

Permalink
Merge pull request #526 from vinayan/pip7414
Browse files Browse the repository at this point in the history
[fTools] fix Points in Polygon and Delaunay triangulation (closes #7414, #7360)
  • Loading branch information
alexbruy committed Apr 17, 2013
2 parents e6f3b2e + 58737b6 commit 4c05932
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion python/plugins/fTools/tools/doGeometry.py
Expand Up @@ -655,14 +655,17 @@ def delaunay_triangulation( self ):
indicies = list( triangle )
indicies.append( indicies[ 0 ] )
polygon = []
attrs = []
step = 0
for index in indicies:
vprovider.getFeatures( QgsFeatureRequest().setFilterFid( ptDict[ ids[ index ] ] ) ).nextFeature( inFeat )
geom = QgsGeometry( inFeat.geometry() )
point = QgsPoint( geom.asPoint() )
polygon.append( point )
if step <= 3: feat.setAttribute( step, QVariant( ids[ index ] ) )
if step <= 3:
attrs.append(QVariant( ids[ index ] ) )
step += 1
feat.setAttributes(attrs)
geometry = QgsGeometry().fromPolygon( [ polygon ] )
feat.setGeometry( geometry )
writer.addFeature( feat )
Expand Down
5 changes: 3 additions & 2 deletions python/plugins/fTools/tools/doPointsInPolygon.py
Expand Up @@ -169,7 +169,7 @@ def run(self):
fieldList = ftools_utils.getFieldList(self.layerPoly)
index = polyProvider.fieldNameIndex(unicode(self.fieldName))
if index == -1:
index = polyProvider.fieldCount()
index = polyProvider.fields().count()
fieldList.append( QgsField(unicode(self.fieldName), QVariant.Double, "real", 24, 15, self.tr("point count field")) )

sRs = polyProvider.crs()
Expand Down Expand Up @@ -218,7 +218,8 @@ def run(self):
interrupted = True
break

outFeat.setAttribute(index, QVariant(count))
atMap.append(QVariant(count))
outFeat.setAttributes(atMap)
writer.addFeature(outFeat)

self.emit( SIGNAL( "updateProgress()" ) )
Expand Down

0 comments on commit 4c05932

Please sign in to comment.