mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
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:
parent
36a38f4e2d
commit
4149da0556
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user