Skip to content

Commit a57aa0c

Browse files
committed
fix Sum line length tool after API changes (fix #7335)
1 parent 105bfdd commit a57aa0c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

python/plugins/fTools/tools/doSumLines.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def compute(self, inPoly, inLns, inField, outPath, progressBar):
103103
fieldList = ftools_utils.getFieldList(polyLayer)
104104
index = polyProvider.fieldNameIndex(unicode(inField))
105105
if index == -1:
106-
index = polyProvider.fieldCount()
106+
index = polyProvider.fields().count()
107107
fieldList.append( QgsField(unicode(inField), QVariant.Double, "real", 24, 15, self.tr("length field")) )
108108
sRs = polyProvider.crs()
109109
inFeat = QgsFeature()
@@ -119,17 +119,13 @@ def compute(self, inPoly, inLns, inField, outPath, progressBar):
119119
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
120120
return
121121
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fieldList, polyProvider.geometryType(), sRs)
122-
#writer = QgsVectorFileWriter(outPath, "UTF-8", fieldList, polyProvider.geometryType(), sRs)
123122
spatialIndex = ftools_utils.createIndex( lineProvider )
124-
polyFit = polyProvider.getFeatures()
123+
polyFit = polyProvider.getFeatures()
125124
while polyFit.nextFeature(inFeat):
126125
inGeom = QgsGeometry(inFeat.geometry())
127126
atMap = inFeat.attributes()
128127
lineList = []
129128
length = 0
130-
#(check, lineList) = lineLayer.featuresInRectangle(inGeom.boundingBox(), True, False)
131-
#lineLayer.select(inGeom.boundingBox(), False)
132-
#lineList = lineLayer.selectedFeatures()
133129
lineList = spatialIndex.intersects(inGeom.boundingBox())
134130
if len(lineList) > 0: check = 0
135131
else: check = 1
@@ -141,8 +137,9 @@ def compute(self, inPoly, inLns, inField, outPath, progressBar):
141137
outGeom = inGeom.intersection(tmpGeom)
142138
length = length + distArea.measure(outGeom)
143139
outFeat.setGeometry(inGeom)
140+
atMap.append(QVariant(length))
144141
outFeat.setAttributes(atMap)
145-
outFeat.setAttribute(index, QVariant(length))
142+
#outFeat.setAttribute(index, QVariant(length))
146143
writer.addFeature(outFeat)
147144
start = start + 1
148145
progressBar.setValue(start)

0 commit comments

Comments
 (0)