Skip to content

Commit 4c05932

Browse files
committed
Merge pull request #526 from vinayan/pip7414
[fTools] fix Points in Polygon and Delaunay triangulation (closes #7414, #7360)
2 parents e6f3b2e + 58737b6 commit 4c05932

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

python/plugins/fTools/tools/doGeometry.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,14 +655,17 @@ def delaunay_triangulation( self ):
655655
indicies = list( triangle )
656656
indicies.append( indicies[ 0 ] )
657657
polygon = []
658+
attrs = []
658659
step = 0
659660
for index in indicies:
660661
vprovider.getFeatures( QgsFeatureRequest().setFilterFid( ptDict[ ids[ index ] ] ) ).nextFeature( inFeat )
661662
geom = QgsGeometry( inFeat.geometry() )
662663
point = QgsPoint( geom.asPoint() )
663664
polygon.append( point )
664-
if step <= 3: feat.setAttribute( step, QVariant( ids[ index ] ) )
665+
if step <= 3:
666+
attrs.append(QVariant( ids[ index ] ) )
665667
step += 1
668+
feat.setAttributes(attrs)
666669
geometry = QgsGeometry().fromPolygon( [ polygon ] )
667670
feat.setGeometry( geometry )
668671
writer.addFeature( feat )

python/plugins/fTools/tools/doPointsInPolygon.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def run(self):
169169
fieldList = ftools_utils.getFieldList(self.layerPoly)
170170
index = polyProvider.fieldNameIndex(unicode(self.fieldName))
171171
if index == -1:
172-
index = polyProvider.fieldCount()
172+
index = polyProvider.fields().count()
173173
fieldList.append( QgsField(unicode(self.fieldName), QVariant.Double, "real", 24, 15, self.tr("point count field")) )
174174

175175
sRs = polyProvider.crs()
@@ -218,7 +218,8 @@ def run(self):
218218
interrupted = True
219219
break
220220

221-
outFeat.setAttribute(index, QVariant(count))
221+
atMap.append(QVariant(count))
222+
outFeat.setAttributes(atMap)
222223
writer.addFeature(outFeat)
223224

224225
self.emit( SIGNAL( "updateProgress()" ) )

0 commit comments

Comments
 (0)