Skip to content

Commit 4149da0

Browse files
committedOct 31, 2017
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
1 parent 36a38f4 commit 4149da0

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed
 

‎python/plugins/processing/algs/qgis/ShortestPathLayerToPoint.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,18 @@ def processAlgorithm(self, parameters, context, feedback):
246246
break
247247

248248
idxStart = graph.findVertex(snappedPoints[i])
249+
249250
tree, cost = QgsGraphAnalyzer.dijkstra(graph, idxStart, 0)
250251

251252
if tree[idxEnd] == -1:
252253
msg = self.tr('There is no route from start point ({}) to end point ({}).'.format(points[i].toString(), endPoint.toString()))
253-
feedback.setProgressText(msg)
254-
QgsMessageLog.logMessage(msg, self.tr('Processing'), QgsMessageLog.WARNING)
254+
feedback.reportError(msg)
255+
# add feature with no geometry
256+
feat.clearGeometry()
257+
attrs = source_attributes[i]
258+
attrs.append(points[i].toString())
259+
feat.setAttributes(attrs)
260+
sink.addFeature(feat, QgsFeatureSink.FastInsert)
255261
continue
256262

257263
cost = 0.0

‎python/plugins/processing/algs/qgis/ShortestPathPointToLayer.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,13 @@ def processAlgorithm(self, parameters, context, feedback):
250250

251251
if tree[idxEnd] == -1:
252252
msg = self.tr('There is no route from start point ({}) to end point ({}).'.format(startPoint.toString(), points[i].toString()))
253-
feedback.setProgressText(msg)
254-
QgsMessageLog.logMessage(msg, self.tr('Processing'), QgsMessageLog.WARNING)
253+
feedback.reportError(msg)
254+
# add feature with no geometry
255+
feat.clearGeometry()
256+
attrs = source_attributes[i]
257+
attrs.extend([NULL, points[i].toString()])
258+
feat.setAttributes(attrs)
259+
sink.addFeature(feat, QgsFeatureSink.FastInsert)
255260
continue
256261

257262
cost = 0.0

0 commit comments

Comments
 (0)
Please sign in to comment.