Skip to content
Permalink
Browse files

Fix processing algs crash when no source features exist

Instead we output an empty layer - this may be critical for
multi-step models where there is validly no features present
in a source layer
  • Loading branch information
nyalldawson committed Jun 23, 2017
1 parent 24eb6fd commit 99cfb8faf3fa02de1512d260ebc99207196a729f
Showing with 105 additions and 105 deletions.
  1. +1 −1 python/plugins/processing/algs/qgis/AddTableField.py
  2. +1 −1 python/plugins/processing/algs/qgis/AutoincrementalField.py
  3. +3 −3 python/plugins/processing/algs/qgis/BasicStatistics.py
  4. +1 −1 python/plugins/processing/algs/qgis/Boundary.py
  5. +1 −1 python/plugins/processing/algs/qgis/BoundingBox.py
  6. +1 −1 python/plugins/processing/algs/qgis/Buffer.py
  7. +1 −1 python/plugins/processing/algs/qgis/CheckValidity.py
  8. +2 −2 python/plugins/processing/algs/qgis/ConvexHull.py
  9. +1 −1 python/plugins/processing/algs/qgis/Datasources2Vrt.py
  10. +2 −2 python/plugins/processing/algs/qgis/Delaunay.py
  11. +1 −1 python/plugins/processing/algs/qgis/DeleteColumn.py
  12. +2 −2 python/plugins/processing/algs/qgis/DeleteDuplicateGeometries.py
  13. +1 −1 python/plugins/processing/algs/qgis/DeleteHoles.py
  14. +1 −1 python/plugins/processing/algs/qgis/DensifyGeometries.py
  15. +1 −1 python/plugins/processing/algs/qgis/DensifyGeometriesInterval.py
  16. +1 −1 python/plugins/processing/algs/qgis/Difference.py
  17. +1 −1 python/plugins/processing/algs/qgis/DropGeometry.py
  18. +1 −1 python/plugins/processing/algs/qgis/EquivalentNumField.py
  19. +1 −1 python/plugins/processing/algs/qgis/ExecuteSQL.py
  20. +1 −1 python/plugins/processing/algs/qgis/Explode.py
  21. +1 −1 python/plugins/processing/algs/qgis/ExportGeometryInfo.py
  22. +1 −1 python/plugins/processing/algs/qgis/ExtendLines.py
  23. +1 −1 python/plugins/processing/algs/qgis/ExtentFromLayer.py
  24. +2 −2 python/plugins/processing/algs/qgis/ExtractByLocation.py
  25. +1 −1 python/plugins/processing/algs/qgis/ExtractNodes.py
  26. +1 −1 python/plugins/processing/algs/qgis/ExtractSpecificNodes.py
  27. +1 −1 python/plugins/processing/algs/qgis/FieldPyculator.py
  28. +1 −1 python/plugins/processing/algs/qgis/FieldsCalculator.py
  29. +1 −1 python/plugins/processing/algs/qgis/FixGeometry.py
  30. +1 −1 python/plugins/processing/algs/qgis/GeometryByExpression.py
  31. +1 −1 python/plugins/processing/algs/qgis/GeometryConvert.py
  32. +1 −1 python/plugins/processing/algs/qgis/Gridify.py
  33. +1 −1 python/plugins/processing/algs/qgis/Heatmap.py
  34. +1 −1 python/plugins/processing/algs/qgis/HubDistanceLines.py
  35. +1 −1 python/plugins/processing/algs/qgis/HubDistancePoints.py
  36. +1 −1 python/plugins/processing/algs/qgis/HubLines.py
  37. +1 −1 python/plugins/processing/algs/qgis/HypsometricCurves.py
  38. +1 −1 python/plugins/processing/algs/qgis/ImportIntoPostGIS.py
  39. +1 −1 python/plugins/processing/algs/qgis/Intersection.py
  40. +2 −2 python/plugins/processing/algs/qgis/JoinAttributes.py
  41. +1 −1 python/plugins/processing/algs/qgis/LinesIntersection.py
  42. +1 −1 python/plugins/processing/algs/qgis/LinesToPolygons.py
  43. +2 −2 python/plugins/processing/algs/qgis/MeanCoords.py
  44. +1 −1 python/plugins/processing/algs/qgis/Merge.py
  45. +1 −1 python/plugins/processing/algs/qgis/MergeLines.py
  46. +1 −1 python/plugins/processing/algs/qgis/NearestNeighbourAnalysis.py
  47. +1 −1 python/plugins/processing/algs/qgis/OffsetLine.py
  48. +2 −2 python/plugins/processing/algs/qgis/OrientedMinimumBoundingBox.py
  49. +1 −1 python/plugins/processing/algs/qgis/Orthogonalize.py
  50. +2 −2 python/plugins/processing/algs/qgis/PointDistance.py
  51. +1 −1 python/plugins/processing/algs/qgis/PointOnSurface.py
  52. +1 −1 python/plugins/processing/algs/qgis/PointsAlongGeometry.py
  53. +2 −2 python/plugins/processing/algs/qgis/PointsDisplacement.py
  54. +1 −1 python/plugins/processing/algs/qgis/PointsFromLines.py
  55. +1 −1 python/plugins/processing/algs/qgis/PointsFromPolygons.py
  56. +1 −1 python/plugins/processing/algs/qgis/PointsInPolygon.py
  57. +1 −1 python/plugins/processing/algs/qgis/PointsInPolygonUnique.py
  58. +1 −1 python/plugins/processing/algs/qgis/PointsInPolygonWeighted.py
  59. +1 −1 python/plugins/processing/algs/qgis/PointsLayerFromTable.py
  60. +2 −2 python/plugins/processing/algs/qgis/PointsToPaths.py
  61. +1 −1 python/plugins/processing/algs/qgis/PoleOfInaccessibility.py
  62. +1 −1 python/plugins/processing/algs/qgis/PolygonsToLines.py
  63. +1 −1 python/plugins/processing/algs/qgis/RandomExtract.py
  64. +2 −2 python/plugins/processing/algs/qgis/RandomExtractWithinSubsets.py
  65. +1 −1 python/plugins/processing/algs/qgis/RandomPointsAlongLines.py
  66. +1 −1 python/plugins/processing/algs/qgis/RandomPointsExtent.py
  67. +1 −1 python/plugins/processing/algs/qgis/RandomPointsLayer.py
  68. +1 −1 python/plugins/processing/algs/qgis/RandomPointsPolygonsFixed.py
  69. +1 −1 python/plugins/processing/algs/qgis/RandomPointsPolygonsVariable.py
  70. +1 −1 python/plugins/processing/algs/qgis/RandomSelectionWithinSubsets.py
  71. +1 −1 python/plugins/processing/algs/qgis/RemoveNullGeometry.py
  72. +1 −1 python/plugins/processing/algs/qgis/ReverseLineDirection.py
  73. +1 −1 python/plugins/processing/algs/qgis/SaveSelectedFeatures.py
  74. +1 −1 python/plugins/processing/algs/qgis/SelectByLocation.py
  75. +1 −1 python/plugins/processing/algs/qgis/ServiceAreaFromLayer.py
  76. +1 −1 python/plugins/processing/algs/qgis/ShortestPathLayerToPoint.py
  77. +1 −1 python/plugins/processing/algs/qgis/ShortestPathPointToLayer.py
  78. +1 −1 python/plugins/processing/algs/qgis/SimplifyGeometries.py
  79. +1 −1 python/plugins/processing/algs/qgis/SinglePartsToMultiparts.py
  80. +1 −1 python/plugins/processing/algs/qgis/SingleSidedBuffer.py
  81. +1 −1 python/plugins/processing/algs/qgis/Smooth.py
  82. +1 −1 python/plugins/processing/algs/qgis/SnapGeometries.py
  83. +1 −1 python/plugins/processing/algs/qgis/SpatialJoin.py
  84. +1 −1 python/plugins/processing/algs/qgis/SplitWithLines.py
  85. +1 −1 python/plugins/processing/algs/qgis/StatisticsByCategories.py
  86. +1 −1 python/plugins/processing/algs/qgis/SumLines.py
  87. +1 −1 python/plugins/processing/algs/qgis/SymmetricalDifference.py
  88. +1 −1 python/plugins/processing/algs/qgis/TextToFloat.py
  89. +1 −1 python/plugins/processing/algs/qgis/Translate.py
  90. +1 −1 python/plugins/processing/algs/qgis/VectorSplit.py
  91. +1 −1 python/plugins/processing/algs/qgis/VoronoiPolygons.py
  92. +1 −1 python/plugins/processing/algs/qgis/ZonalStatistics.py
@@ -100,7 +100,7 @@ def processAlgorithm(self, parameters, context, feedback):
fields, source.wkbType(), source.sourceCrs())

features = source.getFeatures()
total = 100.0 / source.featureCount()
total = 100.0 / source.featureCount() if source.featureCount() else 0

for current, input_feature in enumerate(features):
if feedback.isCanceled():
@@ -74,7 +74,7 @@ def processAlgorithm(self, parameters, context, feedback):
fields, source.wkbType(), source.sourceCrs())

features = source.getFeatures()
total = 100.0 / source.featureCount()
total = total = 100.0 / source.featureCount() if source.featureCount() else 0

This comment has been minimized.

Copy link
@m-kuhn

m-kuhn Jun 23, 2017

Member

total = total =? ;)

This comment has been minimized.

Copy link
@nyalldawson

nyalldawson Jun 23, 2017

Author Collaborator

total = total = copy + paste is evil

for current, input_feature in enumerate(features):
if feedback.isCanceled():
break
@@ -156,7 +156,7 @@ def processAlgorithm(self, parameters, context, feedback):
return results

def calcNumericStats(self, features, feedback, field, count):
total = 100.0 / float(count)
total = 100.0 / count if count else 0
stat = QgsStatisticalSummary()
for current, ft in enumerate(features):
if feedback.isCanceled():
@@ -205,7 +205,7 @@ def calcNumericStats(self, features, feedback, field, count):
return data, results

def calcStringStats(self, features, feedback, field, count):
total = 100.0 / float(count)
total = 100.0 / count if count else 1
stat = QgsStringStatisticalSummary()
for current, ft in enumerate(features):
if feedback.isCanceled():
@@ -237,7 +237,7 @@ def calcStringStats(self, features, feedback, field, count):
return data, results

def calcDateTimeStats(self, features, feedback, field, count):
total = 100.0 / float(count)
total = 100.0 / count if count else 1
stat = QgsDateTimeStatisticalSummary()
for current, ft in enumerate(features):
if feedback.isCanceled():
@@ -86,7 +86,7 @@ def processAlgorithm(self, parameters, context, feedback):
source.fields(), output_wkb, source.sourceCrs())

features = source.getFeatures()
total = 100.0 / source.featureCount()
total = 100.0 / source.featureCount() if source.featureCount() else 0

for current, input_feature in enumerate(features):
if feedback.isCanceled():
@@ -78,7 +78,7 @@ def processAlgorithm(self, parameters, context, feedback):
source.fields(), QgsWkbTypes.Polygon, source.sourceCrs())

features = source.getFeatures()
total = 100.0 / source.featureCount()
total = 100.0 / source.featureCount() if source.featureCount() else 0

for current, input_feature in enumerate(features):
if feedback.isCanceled():
@@ -38,7 +38,7 @@ def buffering(feedback, context, writer, distance, field, useField, layer, disso

current = 0
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0

# With dissolve
if dissolve:
@@ -129,7 +129,7 @@ def doCheck(self, method, parameters, context, feedback):
error_count = 0

features = source.getFeatures()
total = 100.0 / source.featureCount()
total = 100.0 / source.featureCount() if source.featureCount() else 0
for current, inFeat in enumerate(features):
if feedback.isCanceled():
break
@@ -120,7 +120,7 @@ def processAlgorithm(self, parameters, context, feedback):
if useField:
unique = layer.uniqueValues(index)
current = 0
total = 100.0 / (QgsProcessingUtils.featureCount(layer, context) * len(unique))
total = 100.0 / (layer.featureCount() * len(unique)) if layer.featureCount() else 1
for i in unique:
first = True
hull = []
@@ -152,7 +152,7 @@ def processAlgorithm(self, parameters, context, feedback):
fid += 1
else:
hull = []
total = 100.0 / layer.featureCount()
total = 100.0 / layer.featureCount() if layer.featureCount() else 1
features = QgsProcessingUtils.getFeatures(layer, context)
for current, f in enumerate(features):
inGeom = f.geometry()
@@ -110,7 +110,7 @@ def mergeDataSources2Vrt(self, dataSources, outFile, union=False, relative=False
if union:
vrt += '<OGRVRTUnionLayer name="UnionedLayer">'

total = 100.0 / len(dataSources)
total = 100.0 / len(dataSources) if dataSources else 1
for current, inFile in enumerate(dataSources):
feedback.setProgress(int(current * total))

@@ -92,7 +92,7 @@ def processAlgorithm(self, parameters, context, feedback):
ptNdx = -1
c = voronoi.Context()
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0
for current, inFeat in enumerate(features):
geom = QgsGeometry(inFeat.geometry())
if geom.isNull():
@@ -122,7 +122,7 @@ def processAlgorithm(self, parameters, context, feedback):
triangles = c.triangles
feat = QgsFeature()

total = 100.0 / len(triangles)
total = 100.0 / len(triangles) if triangles else 1
for current, triangle in enumerate(triangles):
indices = list(triangle)
indices.append(indices[0])
@@ -91,7 +91,7 @@ def processAlgorithm(self, parameters, context, feedback):
fields, source.wkbType(), source.sourceCrs())

features = source.getFeatures()
total = 100.0 / source.featureCount()
total = 100.0 / source.featureCount() if source.featureCount() else 0

for current, f in enumerate(features):
if feedback.isCanceled():
@@ -68,7 +68,7 @@ def processAlgorithm(self, parameters, context, feedback):

features = QgsProcessingUtils.getFeatures(layer, context)

total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0
geoms = dict()
for current, f in enumerate(features):
geoms[f.id()] = f.geometry()
@@ -83,7 +83,7 @@ def processAlgorithm(self, parameters, context, feedback):
if g.isGeosEqual(cleaned[j]):
del cleaned[j]

total = 100.0 / len(cleaned)
total = 100.0 / len(cleaned) if cleaned else 1
request = QgsFeatureRequest().setFilterFids(list(cleaned.keys()))
for current, f in enumerate(layer.getFeatures(request)):
writer.addFeature(f)
@@ -79,7 +79,7 @@ def processAlgorithm(self, parameters, context, feedback):
source.fields(), source.wkbType(), source.sourceCrs())

features = source.getFeatures()
total = 100.0 / source.featureCount()
total = 100.0 / source.featureCount() if source.featureCount() else 0

for current, f in enumerate(features):
if feedback.isCanceled():
@@ -82,7 +82,7 @@ def processAlgorithm(self, parameters, context, feedback):
source.fields(), source.wkbType(), source.sourceCrs())

features = source.getFeatures()
total = 100.0 / source.featureCount()
total = 100.0 / source.featureCount() if source.featureCount() else 0

for current, f in enumerate(features):
if feedback.isCanceled():
@@ -80,7 +80,7 @@ def processAlgorithm(self, parameters, context, feedback):
source.fields(), source.wkbType(), source.sourceCrs())

features = source.getFeatures()
total = 100.0 / source.featureCount()
total = 100.0 / source.featureCount() if source.featureCount() else 0
for current, f in enumerate(features):
if feedback.isCanceled():
break
@@ -80,7 +80,7 @@ def processAlgorithm(self, parameters, context, feedback):
outFeat = QgsFeature()
index = QgsProcessingUtils.createSpatialIndex(layerB, context)
selectionA = QgsProcessingUtils.getFeatures(layerA, context)
total = 100.0 / QgsProcessingUtils.featureCount(layerA, context)
total = 100.0 / layerA.featureCount() if layerA.featureCount() else 0
for current, inFeatA in enumerate(selectionA):
geom = inFeatA.geometry()
diff_geom = QgsGeometry(geom)
@@ -73,7 +73,7 @@ def processAlgorithm(self, parameters, context, feedback):

request = QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry)
features = source.getFeatures(request)
total = 100.0 / source.featureCount()
total = 100.0 / source.featureCount() if source.featureCount() else 0

for current, input_feature in enumerate(features):
if feedback.isCanceled():
@@ -77,7 +77,7 @@ def processAlgorithm(self, parameters, context, feedback):
classes = {}

features = QgsProcessingUtils.getFeatures(vlayer, context)
total = 100.0 / QgsProcessingUtils.featureCount(vlayer, context)
total = 100.0 / vlayer.featureCount() if vlayer.featureCount() else 0
for current, feature in enumerate(features):
feedback.setProgress(int(current * total))
inGeom = feature.geometry()
@@ -151,7 +151,7 @@ def processAlgorithm(self, parameters, context, feedback):
vLayer.crs(), context)

features = QgsProcessingUtils.getFeatures(vLayer, context)
total = 100.0 / QgsProcessingUtils.featureCount(vLayer, context)
total = 100.0 / vLayer.featureCount() if vLayer.featureCount() else 0
outFeat = QgsFeature()
for current, inFeat in enumerate(features):
outFeat.setAttributes(inFeat.attributes())
@@ -71,7 +71,7 @@ def processAlgorithm(self, parameters, context, feedback):
writer = output.getVectorWriter(fields, QgsWkbTypes.LineString, vlayer.crs(), context)
outFeat = QgsFeature()
features = QgsProcessingUtils.getFeatures(vlayer, context)
total = 100.0 / QgsProcessingUtils.featureCount(vlayer, context)
total = 100.0 / vlayer.featureCount() if vlayer.featureCount() else 0
for current, feature in enumerate(features):
feedback.setProgress(int(current * total))
inGeom = feature.geometry()
@@ -133,7 +133,7 @@ def processAlgorithm(self, parameters, context, feedback):
outFeat.setFields(fields)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0
for current, f in enumerate(features):
inGeom = f.geometry()

@@ -77,7 +77,7 @@ def processAlgorithm(self, parameters, context, feedback):
end_distance = self.getParameterValue(self.END_DISTANCE)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0

for current, input_feature in enumerate(features):
output_feature = input_feature
@@ -143,7 +143,7 @@ def layerExtent(self, source, sink, feedback):

def featureExtent(self, source, context, sink, feedback):
features = source.getFeatures()
total = 100.0 / source.featureCount()
total = 100.0 / source.featureCount() if source.featureCount() else 0
feat = QgsFeature()
for current, f in enumerate(features):
if feedback.isCanceled():
@@ -107,7 +107,7 @@ def processAlgorithm(self, parameters, context, feedback):

selectedSet = []
features = QgsProcessingUtils.getFeatures(selectLayer, context)
total = 100.0 / QgsProcessingUtils.featureCount(selectLayer, context)
total = 100.0 / selectLayer.featureCount() if selectLayer.featureCount() else 0
for current, f in enumerate(features):
geom = vector.snapToPrecision(f.geometry(), precision)
bbox = geom.boundingBox()
@@ -136,7 +136,7 @@ def processAlgorithm(self, parameters, context, feedback):
selectedSet = selectedSet + disjoinSet

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0
for current, f in enumerate(features):
if f.id() in selectedSet:
writer.addFeature(f)
@@ -78,7 +78,7 @@ def processAlgorithm(self, parameters, context, feedback):
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields, QgsWkbTypes.Point, layer.crs(), context)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0
for current, f in enumerate(features):
input_geometry = f.geometry()
if not input_geometry:
@@ -92,7 +92,7 @@ def processAlgorithm(self, parameters, context, feedback):
self.tr('\'{}\' is not a valid node index').format(node))

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0

for current, f in enumerate(features):

@@ -144,7 +144,7 @@ def processAlgorithm(self, parameters, context, feedback):

# Run
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0
for current, feat in enumerate(features):
feedback.setProgress(int(current * total))
attrs = feat.attributes()
@@ -137,7 +137,7 @@ def processAlgorithm(self, parameters, context, feedback):
calculationSuccess = True

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0

rownum = 1
for current, f in enumerate(features):
@@ -79,7 +79,7 @@ def processAlgorithm(self, parameters, context, feedback):
if QgsProcessingUtils.featureCount(layer, context) == 0:
raise GeoAlgorithmExecutionException(self.tr('There are no features in the input layer'))

total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0
for current, inputFeature in enumerate(features):
outputFeature = inputFeature
if inputFeature.geometry():
@@ -115,7 +115,7 @@ def processAlgorithm(self, parameters, context, feedback):
self.tr('Evaluation error: {0}').format(expression.evalErrorString()))

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0
for current, input_feature in enumerate(features):
output_feature = input_feature

@@ -94,7 +94,7 @@ def processAlgorithm(self, parameters, context, feedback):
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(layer.fields(), newType, layer.crs(), context)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0

for current, f in enumerate(features):
geom = f.geometry()
@@ -84,7 +84,7 @@ def processAlgorithm(self, parameters, context, feedback):
context)

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0

for current, f in enumerate(features):
geom = f.geometry()
@@ -174,7 +174,7 @@ def processAlgorithm(self, parameters, context, feedback):
request = QgsFeatureRequest()
request.setSubsetOfAttributes(attrs)
features = QgsProcessingUtils.getFeatures(layer, context, request)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0
for current, f in enumerate(features):
if kde.addFeature(f) != QgsKernelDensityEstimation.Success:
QgsMessageLog.logMessage(self.tr('Error adding feature with ID {} to heatmap').format(f.id()), self.tr('Processing'), QgsMessageLog.CRITICAL)
@@ -122,7 +122,7 @@ def processAlgorithm(self, parameters, context, feedback):

# Scan source points, find nearest hub, and write to output file
features = QgsProcessingUtils.getFeatures(layerPoints, context)
total = 100.0 / QgsProcessingUtils.featureCount(layerPoints, context)
total = 100.0 / layerPoints.featureCount() if layerPoints.featureCount() else 0
for current, f in enumerate(features):
src = f.geometry().boundingBox().center()

@@ -122,7 +122,7 @@ def processAlgorithm(self, parameters, context, feedback):

# Scan source points, find nearest hub, and write to output file
features = QgsProcessingUtils.getFeatures(layerPoints, context)
total = 100.0 / QgsProcessingUtils.featureCount(layerPoints, context)
total = 100.0 / layerPoints.featureCount() if layerPoints.featureCount() else 0
for current, f in enumerate(features):
src = f.geometry().boundingBox().center()

@@ -92,7 +92,7 @@ def processAlgorithm(self, parameters, context, feedback):

spokes = QgsProcessingUtils.getFeatures(layerSpoke, context)
hubs = QgsProcessingUtils.getFeatures(layerHub, context)
total = 100.0 / QgsProcessingUtils.featureCount(layerSpoke, context)
total = 100.0 / layerSpoke.featureCount() if layerSpoke.featureCount() else 0

for current, spokepoint in enumerate(spokes):
p = spokepoint.geometry().boundingBox().center()
@@ -114,7 +114,7 @@ def processAlgorithm(self, parameters, context, feedback):
memRasterDriver = gdal.GetDriverByName('MEM')

features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / layer.featureCount() if layer.featureCount() else 0

for current, f in enumerate(features):
geom = f.geometry()
@@ -180,7 +180,7 @@ def processAlgorithm(self, parameters, context, feedback):
self.tr('Error importing to PostGIS\n{0}').format(exporter.errorMessage()))

features = source.getFeatures()
total = 100.0 / source.featureCount()
total = 100.0 / source.featureCount() if source.featureCount() else 0
for current, f in enumerate(features):
if feedback.isCanceled():
break

0 comments on commit 99cfb8f

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