Skip to content

Commit

Permalink
Fix: #49145 Distance to nearest hub exception when No destination hubs
Browse files Browse the repository at this point in the history
  • Loading branch information
kornerc committed Jan 11, 2023
1 parent b1186b2 commit e1032d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/plugins/processing/algs/qgis/HubDistanceLines.py
Expand Up @@ -136,6 +136,9 @@ def processAlgorithm(self, parameters, context, feedback):
src = f.geometry().boundingBox().center()

neighbors = index.nearestNeighbor(src, 1)
if len(neighbors) == 0:
continue

ft = next(hub_source.getFeatures(QgsFeatureRequest().setFilterFid(neighbors[0]).setSubsetOfAttributes([fieldName], hub_source.fields()).setDestinationCrs(point_source.sourceCrs(), context.transformContext())))
closest = ft.geometry().boundingBox().center()
hubDist = distance.measureLine(src, closest)
Expand Down
3 changes: 3 additions & 0 deletions python/plugins/processing/algs/qgis/HubDistancePoints.py
Expand Up @@ -134,6 +134,9 @@ def processAlgorithm(self, parameters, context, feedback):
src = f.geometry().boundingBox().center()

neighbors = index.nearestNeighbor(src, 1)
if len(neighbors) == 0:
continue

ft = next(hub_source.getFeatures(QgsFeatureRequest().setFilterFid(neighbors[0]).setSubsetOfAttributes([fieldName], hub_source.fields()).setDestinationCrs(point_source.sourceCrs(), context.transformContext())))
closest = ft.geometry().boundingBox().center()
hubDist = distance.measureLine(src, closest)
Expand Down

0 comments on commit e1032d5

Please sign in to comment.