[processing] add cancellation support where possible

This commit is contained in:
Alexander Bruy 2017-07-16 11:52:52 +03:00
parent 5af177e963
commit 95de3a414a
2 changed files with 6 additions and 0 deletions

View File

@ -237,6 +237,9 @@ class ShortestPathLayerToPoint(QgisAlgorithm):
total = 100.0 / source.featureCount() if source.featureCount() else 1 total = 100.0 / source.featureCount() if source.featureCount() else 1
for i in range(1, count + 1): for i in range(1, count + 1):
if feedback.isCanceled():
break
idxStart = graph.findVertex(snappedPoints[i]) idxStart = graph.findVertex(snappedPoints[i])
tree, cost = QgsGraphAnalyzer.dijkstra(graph, idxStart, 0) tree, cost = QgsGraphAnalyzer.dijkstra(graph, idxStart, 0)

View File

@ -238,6 +238,9 @@ class ShortestPathPointToLayer(QgisAlgorithm):
total = 100.0 / source.featureCount() if source.featureCount() else 1 total = 100.0 / source.featureCount() if source.featureCount() else 1
for i in range(1, count + 1): for i in range(1, count + 1):
if feedback.isCanceled():
break
idxEnd = graph.findVertex(snappedPoints[i]) idxEnd = graph.findVertex(snappedPoints[i])
if tree[idxEnd] == -1: if tree[idxEnd] == -1: