Skip to content
Permalink
Browse files

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
  • Loading branch information
nyalldawson committed Oct 28, 2017
1 parent 36a38f4 commit 4149da055625ee2ab1a22f46e29b8dcc96f992b9
@@ -246,12 +246,18 @@ def processAlgorithm(self, parameters, context, feedback):
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
@@ -250,8 +250,13 @@ def processAlgorithm(self, parameters, context, feedback):

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

0 comments on commit 4149da0

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