Better reporting of errors when paths cannot be found, also

output point but with no geometry and missing attributes so
that it's clear which points could not be linked
This commit is contained in:
Nyall Dawson 2017-10-28 15:55:16 +10:00
parent 36a38f4e2d
commit 4149da0556
2 changed files with 15 additions and 4 deletions

View File

@ -246,12 +246,18 @@ class ShortestPathLayerToPoint(QgisAlgorithm):
break
idxStart = graph.findVertex(snappedPoints[i])
tree, cost = QgsGraphAnalyzer.dijkstra(graph, idxStart, 0)
if tree[idxEnd] == -1:
msg = self.tr('There is no route from start point ({}) to end point ({}).'.format(points[i].toString(), endPoint.toString()))
feedback.setProgressText(msg)
QgsMessageLog.logMessage(msg, self.tr('Processing'), QgsMessageLog.WARNING)
feedback.reportError(msg)
# add feature with no geometry
feat.clearGeometry()
attrs = source_attributes[i]
attrs.append(points[i].toString())
feat.setAttributes(attrs)
sink.addFeature(feat, QgsFeatureSink.FastInsert)
continue
cost = 0.0

View File

@ -250,8 +250,13 @@ class ShortestPathPointToLayer(QgisAlgorithm):
if tree[idxEnd] == -1:
msg = self.tr('There is no route from start point ({}) to end point ({}).'.format(startPoint.toString(), points[i].toString()))
feedback.setProgressText(msg)
QgsMessageLog.logMessage(msg, self.tr('Processing'), QgsMessageLog.WARNING)
feedback.reportError(msg)
# add feature with no geometry
feat.clearGeometry()
attrs = source_attributes[i]
attrs.extend([NULL, points[i].toString()])
feat.setAttributes(attrs)
sink.addFeature(feat, QgsFeatureSink.FastInsert)
continue
cost = 0.0