Skip to content
Permalink
Browse files

[processing] save travel cost to output attribute table

  • Loading branch information
alexbruy committed Dec 13, 2016
1 parent 16c92dd commit 729567db35465e7406bc882909b2b0583f85778e
Showing with 4 additions and 1 deletion.
  1. +4 −1 python/plugins/processing/algs/qgis/ShortestPathPointToPoint.py
@@ -27,9 +27,10 @@

import os

from qgis.PyQt.QtCore import QVariant
from qgis.PyQt.QtGui import QIcon

from qgis.core import QgsWkbTypes, QgsUnitTypes, QgsFeature, QgsGeometry, QgsPoint
from qgis.core import QgsWkbTypes, QgsUnitTypes, QgsFeature, QgsGeometry, QgsPoint, QgsFields, QgsField
from qgis.analysis import (QgsVectorLayerDirector,
QgsNetworkDistanceStrategy,
QgsNetworkSpeedStrategy,
@@ -163,6 +164,7 @@ def processAlgorithm(self, progress):
fields = QgsFields()
fields.append(QgsField('start', QVariant.String, '', 254, 0))
fields.append(QgsField('end', QVariant.String, '', 254, 0))
fields.append(QgsField('cost', QVariant.Double, '', 20, 7))

writer = self.getOutputFromName(
self.OUTPUT_LAYER).getVectorWriter(
@@ -235,6 +237,7 @@ def processAlgorithm(self, progress):
feat.setFields(fields)
feat['start'] = startPoint.toString()
feat['end'] = endPoint.toString()
feat['cost'] = cost / multiplier
feat.setGeometry(geom)
writer.addFeature(feat)
del writer

0 comments on commit 729567d

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