Skip to content
Permalink
Browse files
Remove vector.features
Use QgsProcessingUtils.getFeatures instead
  • Loading branch information
nyalldawson committed Apr 26, 2017
1 parent 6397386 commit 427c3b168417c8bc032da7d2842e5aa2cbdb78a8
Showing with 133 additions and 220 deletions.
  1. +2 −2 python/plugins/processing/algs/exampleprovider/ExampleAlgorithm.py
  2. +1 −1 python/plugins/processing/algs/qgis/AddTableField.py
  3. +1 −1 python/plugins/processing/algs/qgis/AutoincrementalField.py
  4. +1 −1 python/plugins/processing/algs/qgis/BasicStatistics.py
  5. +1 −1 python/plugins/processing/algs/qgis/BasicStatisticsNumbers.py
  6. +1 −1 python/plugins/processing/algs/qgis/BasicStatisticsStrings.py
  7. +1 −1 python/plugins/processing/algs/qgis/Boundary.py
  8. +1 −1 python/plugins/processing/algs/qgis/BoundingBox.py
  9. +2 −2 python/plugins/processing/algs/qgis/Buffer.py
  10. +1 −1 python/plugins/processing/algs/qgis/Centroids.py
  11. +1 −1 python/plugins/processing/algs/qgis/CheckValidity.py
  12. +3 −3 python/plugins/processing/algs/qgis/Clip.py
  13. +3 −3 python/plugins/processing/algs/qgis/ConvexHull.py
  14. +1 −1 python/plugins/processing/algs/qgis/Delaunay.py
  15. +1 −1 python/plugins/processing/algs/qgis/DeleteColumn.py
  16. +1 −1 python/plugins/processing/algs/qgis/DeleteDuplicateGeometries.py
  17. +1 −1 python/plugins/processing/algs/qgis/DeleteHoles.py
  18. +1 −1 python/plugins/processing/algs/qgis/DensifyGeometries.py
  19. +1 −1 python/plugins/processing/algs/qgis/DensifyGeometriesInterval.py
  20. +1 −1 python/plugins/processing/algs/qgis/Difference.py
  21. +1 −1 python/plugins/processing/algs/qgis/Dissolve.py
  22. +1 −1 python/plugins/processing/algs/qgis/DropGeometry.py
  23. +1 −1 python/plugins/processing/algs/qgis/EquivalentNumField.py
  24. +1 −1 python/plugins/processing/algs/qgis/ExecuteSQL.py
  25. +1 −1 python/plugins/processing/algs/qgis/Explode.py
  26. +1 −1 python/plugins/processing/algs/qgis/ExportGeometryInfo.py
  27. +1 −1 python/plugins/processing/algs/qgis/ExtendLines.py
  28. +1 −1 python/plugins/processing/algs/qgis/ExtentFromLayer.py
  29. +3 −3 python/plugins/processing/algs/qgis/ExtractByLocation.py
  30. +1 −1 python/plugins/processing/algs/qgis/ExtractNodes.py
  31. +1 −1 python/plugins/processing/algs/qgis/ExtractSpecificNodes.py
  32. +1 −1 python/plugins/processing/algs/qgis/FieldPyculator.py
  33. +1 −1 python/plugins/processing/algs/qgis/FieldsCalculator.py
  34. +1 −1 python/plugins/processing/algs/qgis/FieldsMapper.py
  35. +1 −1 python/plugins/processing/algs/qgis/FixGeometry.py
  36. +1 −1 python/plugins/processing/algs/qgis/GeometryByExpression.py
  37. +1 −1 python/plugins/processing/algs/qgis/GeometryConvert.py
  38. +1 −1 python/plugins/processing/algs/qgis/Gridify.py
  39. +1 −1 python/plugins/processing/algs/qgis/Heatmap.py
  40. +1 −1 python/plugins/processing/algs/qgis/HubDistanceLines.py
  41. +1 −1 python/plugins/processing/algs/qgis/HubDistancePoints.py
  42. +2 −2 python/plugins/processing/algs/qgis/HubLines.py
  43. +1 −1 python/plugins/processing/algs/qgis/HypsometricCurves.py
  44. +1 −1 python/plugins/processing/algs/qgis/Intersection.py
  45. +2 −2 python/plugins/processing/algs/qgis/JoinAttributes.py
  46. +1 −1 python/plugins/processing/algs/qgis/LinesIntersection.py
  47. +1 −1 python/plugins/processing/algs/qgis/LinesToPolygons.py
  48. +1 −1 python/plugins/processing/algs/qgis/MeanCoords.py
  49. +1 −1 python/plugins/processing/algs/qgis/MergeLines.py
  50. +1 −1 python/plugins/processing/algs/qgis/MultipartToSingleparts.py
  51. +1 −1 python/plugins/processing/algs/qgis/NearestNeighbourAnalysis.py
  52. +1 −1 python/plugins/processing/algs/qgis/OffsetLine.py
  53. +2 −2 python/plugins/processing/algs/qgis/OrientedMinimumBoundingBox.py
  54. +1 −1 python/plugins/processing/algs/qgis/Orthogonalize.py
  55. +2 −2 python/plugins/processing/algs/qgis/PointDistance.py
  56. +1 −1 python/plugins/processing/algs/qgis/PointOnSurface.py
  57. +1 −1 python/plugins/processing/algs/qgis/PointsAlongGeometry.py
  58. +1 −1 python/plugins/processing/algs/qgis/PointsDisplacement.py
  59. +1 −1 python/plugins/processing/algs/qgis/PointsFromLines.py
  60. +1 −1 python/plugins/processing/algs/qgis/PointsFromPolygons.py
  61. +1 −1 python/plugins/processing/algs/qgis/PointsInPolygon.py
  62. +1 −1 python/plugins/processing/algs/qgis/PointsInPolygonUnique.py
  63. +1 −1 python/plugins/processing/algs/qgis/PointsInPolygonWeighted.py
  64. +1 −1 python/plugins/processing/algs/qgis/PointsLayerFromTable.py
  65. +1 −1 python/plugins/processing/algs/qgis/PointsToPaths.py
  66. +1 −1 python/plugins/processing/algs/qgis/PoleOfInaccessibility.py
  67. +1 −1 python/plugins/processing/algs/qgis/PolygonCentroids.py
  68. +1 −1 python/plugins/processing/algs/qgis/Polygonize.py
  69. +1 −1 python/plugins/processing/algs/qgis/PolygonsToLines.py
  70. +1 −1 python/plugins/processing/algs/qgis/RandomExtract.py
  71. +3 −3 python/plugins/processing/algs/qgis/RandomExtractWithinSubsets.py
  72. +1 −1 python/plugins/processing/algs/qgis/RandomPointsPolygonsFixed.py
  73. +1 −1 python/plugins/processing/algs/qgis/RandomPointsPolygonsVariable.py
  74. +1 −1 python/plugins/processing/algs/qgis/RandomSelectionWithinSubsets.py
  75. +1 −1 python/plugins/processing/algs/qgis/RectanglesOvalsDiamondsFixed.py
  76. +1 −1 python/plugins/processing/algs/qgis/RectanglesOvalsDiamondsVariable.py
  77. +1 −1 python/plugins/processing/algs/qgis/RemoveNullGeometry.py
  78. +1 −1 python/plugins/processing/algs/qgis/ReprojectLayer.py
  79. +1 −1 python/plugins/processing/algs/qgis/ReverseLineDirection.py
  80. +2 −2 python/plugins/processing/algs/qgis/SelectByLocation.py
  81. +1 −1 python/plugins/processing/algs/qgis/ServiceAreaFromLayer.py
  82. +1 −1 python/plugins/processing/algs/qgis/ShortestPathLayerToPoint.py
  83. +1 −1 python/plugins/processing/algs/qgis/ShortestPathPointToLayer.py
  84. +1 −1 python/plugins/processing/algs/qgis/SimplifyGeometries.py
  85. +1 −1 python/plugins/processing/algs/qgis/SinglePartsToMultiparts.py
  86. +1 −1 python/plugins/processing/algs/qgis/SingleSidedBuffer.py
  87. +1 −1 python/plugins/processing/algs/qgis/Smooth.py
  88. +1 −1 python/plugins/processing/algs/qgis/SnapGeometries.py
  89. +2 −2 python/plugins/processing/algs/qgis/SpatialJoin.py
  90. +1 −1 python/plugins/processing/algs/qgis/SplitLinesWithLines.py
  91. +3 −3 python/plugins/processing/algs/qgis/SplitWithLines.py
  92. +1 −1 python/plugins/processing/algs/qgis/StatisticsByCategories.py
  93. +1 −1 python/plugins/processing/algs/qgis/SumLines.py
  94. +2 −2 python/plugins/processing/algs/qgis/SymmetricalDifference.py
  95. +1 −1 python/plugins/processing/algs/qgis/TextToFloat.py
  96. +1 −1 python/plugins/processing/algs/qgis/TopoColors.py
  97. +1 −1 python/plugins/processing/algs/qgis/Translate.py
  98. +2 −2 python/plugins/processing/algs/qgis/Union.py
  99. +1 −1 python/plugins/processing/algs/qgis/VectorSplit.py
  100. +1 −1 python/plugins/processing/algs/qgis/VoronoiPolygons.py
  101. +1 −1 python/plugins/processing/algs/qgis/ZonalStatistics.py
  102. +2 −2 python/plugins/processing/core/GeoAlgorithm.py
  103. +2 −2 python/plugins/processing/core/parameters.py
  104. +3 −2 python/plugins/processing/gui/AlgorithmExecutor.py
  105. +0 −55 python/plugins/processing/tests/ToolsTest.py
  106. +5 −38 python/plugins/processing/tools/vector.py
@@ -25,7 +25,7 @@

__revision__ = '$Format:%H$'

from qgis.core import QgsVectorFileWriter, QgsSettings
from qgis.core import QgsVectorFileWriter, QgsSettings, QgsProcessingUtils

from processing.core.GeoAlgorithm import GeoAlgorithm
from processing.core.parameters import ParameterVector
@@ -113,7 +113,7 @@ def processAlgorithm(self, context, feedback):
# selection that might exist in layer and the configuration that
# indicates should algorithm use only selected features or all
# of them
features = vector.features(vectorLayer, context)
features = QgsProcessingUtils.getFeatures(vectorLayer, context)
for f in features:
writer.addFeature(f)

@@ -100,7 +100,7 @@ def processAlgorithm(self, context, feedback):
writer = output.getVectorWriter(fields, layer.wkbType(),
layer.crs())
outFeat = QgsFeature()
features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
for current, feat in enumerate(features):
feedback.setProgress(int(current * total))
@@ -70,7 +70,7 @@ def processAlgorithm(self, context, feedback):
writer = output.getVectorWriter(fields, vlayer.wkbType(),
vlayer.crs())
outFeat = QgsFeature()
features = vector.features(vlayer, context)
features = QgsProcessingUtils.getFeatures(vlayer, context)
total = 100.0 / QgsProcessingUtils.featureCount(vlayer, context)
for current, feat in enumerate(features):
feedback.setProgress(int(current * total))
@@ -130,7 +130,7 @@ def processAlgorithm(self, context, feedback):
output_file = self.getOutputValue(self.OUTPUT_HTML_FILE)

request = QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry).setSubsetOfAttributes([field_name], layer.fields())
features = vector.features(layer, context, request)
features = QgsProcessingUtils.getFeatures(layer, context, request)

data = []
data.append(self.tr('Analyzed layer: {}').format(layer.name()))
@@ -124,7 +124,7 @@ def processAlgorithm(self, context, feedback):

request = QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry).setSubsetOfAttributes([fieldName], layer.fields())
stat = QgsStatisticalSummary()
features = vector.features(layer, context, request)
features = QgsProcessingUtils.getFeatures(layer, context, request)
count = QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / float(count)
for current, ft in enumerate(features):
@@ -111,7 +111,7 @@ def processAlgorithm(self, context, feedback):
request = QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry).setSubsetOfAttributes([fieldName],
layer.fields())
stat = QgsStringStatisticalSummary()
features = vector.features(layer, context, request)
features = QgsProcessingUtils.getFeatures(layer, context, request)
count = QgsProcessingUtils.featureCount(layer, context)
total = 100.0 / float(count)
for current, ft in enumerate(features):
@@ -83,7 +83,7 @@ def processAlgorithm(self, context, feedback):
output_wkb,
layer.crs())

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)

for current, input_feature in enumerate(features):
@@ -72,7 +72,7 @@ def processAlgorithm(self, context, feedback):
QgsWkbTypes.Polygon,
layer.crs())

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)

for current, input_feature in enumerate(features):
@@ -25,7 +25,7 @@

__revision__ = '$Format:%H$'

from qgis.core import QgsFeature, QgsGeometry
from qgis.core import QgsFeature, QgsGeometry, QgsProcessingUtils

from processing.tools import vector

@@ -39,7 +39,7 @@ def buffering(feedback, context, writer, distance, field, useField, layer, disso
outFeat = QgsFeature()

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

# With dissolve
@@ -73,7 +73,7 @@ def processAlgorithm(self, context, feedback):
QgsWkbTypes.Point,
layer.crs())

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
for current, input_feature in enumerate(features):
output_feature = input_feature
@@ -136,7 +136,7 @@ def doCheck(self, context, feedback):
layer.crs())
error_count = 0

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
for current, inFeat in enumerate(features):
geom = inFeat.geometry()
@@ -78,7 +78,7 @@ def processAlgorithm(self, context, feedback):

# first build up a list of clip geometries
clip_geoms = []
for maskFeat in vector.features(mask_layer, context, QgsFeatureRequest().setSubsetOfAttributes([])):
for maskFeat in QgsProcessingUtils.getFeatures(mask_layer, context, QgsFeatureRequest().setSubsetOfAttributes([])):
clip_geoms.append(maskFeat.geometry())

# are we clipping against a single feature? if so, we can show finer progress reports
@@ -96,8 +96,8 @@ def processAlgorithm(self, context, feedback):
tested_feature_ids = set()

for i, clip_geom in enumerate(clip_geoms):
input_features = [f for f in vector.features(source_layer, context,
QgsFeatureRequest().setFilterRect(clip_geom.boundingBox()))]
input_features = [f for f in QgsProcessingUtils.getFeatures(source_layer, context,
QgsFeatureRequest().setFilterRect(clip_geom.boundingBox()))]

if not input_features:
continue
@@ -112,15 +112,15 @@ def processAlgorithm(self, context, feedback):

fid = 0
val = None
features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
if useField:
unique = layer.uniqueValues(index)
current = 0
total = 100.0 / (QgsProcessingUtils.featureCount(layer, context) * len(unique))
for i in unique:
first = True
hull = []
features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
for f in features:
idVar = f[fieldName]
if str(idVar).strip() == str(i).strip():
@@ -149,7 +149,7 @@ def processAlgorithm(self, context, feedback):
else:
hull = []
total = 100.0 / layer.featureCount()
features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
for current, f in enumerate(features):
inGeom = f.geometry()
points = vector.extractPoints(inGeom)
@@ -84,7 +84,7 @@ def processAlgorithm(self, context, feedback):
ptDict = {}
ptNdx = -1
c = voronoi.Context()
features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
for current, inFeat in enumerate(features):
geom = QgsGeometry(inFeat.geometry())
@@ -86,7 +86,7 @@ def processAlgorithm(self, context, feedback):
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
layer.wkbType(), layer.crs())

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)

for current, f in enumerate(features):
@@ -68,7 +68,7 @@ def processAlgorithm(self, context, feedback):
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
layer.wkbType(), layer.crs())

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)

total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
geoms = dict()
@@ -82,7 +82,7 @@ def processAlgorithm(self, context, feedback):
layer.wkbType(),
layer.crs())

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)

for current, f in enumerate(features):
@@ -88,7 +88,7 @@ def processAlgorithm(self, context, feedback):
self.OUTPUT).getVectorWriter(layer.fields().toList(),
layer.wkbType(), layer.crs())

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
for current, f in enumerate(features):
feature = f
@@ -82,7 +82,7 @@ def processAlgorithm(self, context, feedback):
self.OUTPUT).getVectorWriter(layer.fields().toList(),
layer.wkbType(), layer.crs())

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
for current, f in enumerate(features):
feature = f
@@ -79,7 +79,7 @@ def processAlgorithm(self, context, feedback):

outFeat = QgsFeature()
index = vector.spatialindex(layerB)
selectionA = vector.features(layerA, context)
selectionA = QgsProcessingUtils.getFeatures(layerA, context)
total = 100.0 / QgsProcessingUtils.featureCount(layerA, context)
for current, inFeatA in enumerate(selectionA):
geom = inFeatA.geometry()
@@ -86,7 +86,7 @@ def processAlgorithm(self, context, feedback):
vlayerA.crs())

outFeat = QgsFeature()
features = vector.features(vlayerA, context)
features = QgsProcessingUtils.getFeatures(vlayerA, context)
total = 100.0 / QgsProcessingUtils.featureCount(vlayerA, context)

if not useField:
@@ -76,7 +76,7 @@ def processAlgorithm(self, context, feedback):
QgsCoordinateReferenceSystem())

request = QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry)
features = vector.features(layer, context, request)
features = QgsProcessingUtils.getFeatures(layer, context, request)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)

for current, input_feature in enumerate(features):
@@ -78,7 +78,7 @@ def processAlgorithm(self, context, feedback):
outFeat = QgsFeature()
classes = {}

features = vector.features(vlayer, context)
features = QgsProcessingUtils.getFeatures(vlayer, context)
total = 100.0 / QgsProcessingUtils.featureCount(vlayer, context)
for current, feature in enumerate(features):
feedback.setProgress(int(current * total))
@@ -152,7 +152,7 @@ def processAlgorithm(self, context, feedback):
vLayer.wkbType() if geometry_type != 1 else 1,
vLayer.crs())

features = vector.features(vLayer, context)
features = QgsProcessingUtils.getFeatures(vLayer, context)
total = 100.0 / QgsProcessingUtils.featureCount(vLayer, context)
outFeat = QgsFeature()
for current, inFeat in enumerate(features):
@@ -71,7 +71,7 @@ def processAlgorithm(self, context, feedback):
writer = output.getVectorWriter(fields, QgsWkbTypes.LineString,
vlayer.crs())
outFeat = QgsFeature()
features = vector.features(vlayer, context)
features = QgsProcessingUtils.getFeatures(vlayer, context)
total = 100.0 / QgsProcessingUtils.featureCount(vlayer, context)
for current, feature in enumerate(features):
feedback.setProgress(int(current * total))
@@ -132,7 +132,7 @@ def processAlgorithm(self, context, feedback):
outFeat.initAttributes(len(fields))
outFeat.setFields(fields)

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
for current, f in enumerate(features):
inGeom = f.geometry()
@@ -79,7 +79,7 @@ def processAlgorithm(self, context, feedback):
start_distance = self.getParameterValue(self.START_DISTANCE)
end_distance = self.getParameterValue(self.END_DISTANCE)

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)

for current, input_feature in enumerate(features):
@@ -133,7 +133,7 @@ def layerExtent(self, layer, writer, feedback):
writer.addFeature(feat)

def featureExtent(self, layer, context, writer, feedback):
features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
feat = QgsFeature()
for current, f in enumerate(features):
@@ -102,11 +102,11 @@ def processAlgorithm(self, context, feedback):

if 'disjoint' in predicates:
disjoinSet = []
for feat in vector.features(layer, context):
for feat in QgsProcessingUtils.getFeatures(layer, context):
disjoinSet.append(feat.id())

selectedSet = []
features = vector.features(selectLayer, context)
features = QgsProcessingUtils.getFeatures(selectLayer, context)
total = 100.0 / QgsProcessingUtils.featureCount(selectLayer, context)
for current, f in enumerate(features):
geom = vector.snapToPrecision(f.geometry(), precision)
@@ -134,7 +134,7 @@ def processAlgorithm(self, context, feedback):
if 'disjoint' in predicates:
selectedSet = selectedSet + disjoinSet

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

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

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)

for current, f in enumerate(features):
@@ -145,7 +145,7 @@ def processAlgorithm(self, context, feedback):
self.tr("FieldPyculator code execute error. Field code block can't be executed!\n{0}\n{1}").format(str(sys.exc_info()[0].__name__), str(sys.exc_info()[1])))

# Run
features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
for current, feat in enumerate(features):
feedback.setProgress(int(current * total))
@@ -138,7 +138,7 @@ def processAlgorithm(self, context, feedback):
error = ''
calculationSuccess = True

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)

rownum = 1
@@ -152,7 +152,7 @@ def processAlgorithm(self, context, feedback):
error_exp = None
inFeat = QgsFeature()
outFeat = QgsFeature()
features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
if len(features):
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
for current, inFeat in enumerate(features):
@@ -78,7 +78,7 @@ def processAlgorithm(self, context, feedback):
QgsWkbTypes.multiType(layer.wkbType()),
layer.crs())

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
if len(features) == 0:
raise GeoAlgorithmExecutionException(self.tr('There are no features in the input layer'))

@@ -118,7 +118,7 @@ def processAlgorithm(self, context, feedback):
raise GeoAlgorithmExecutionException(
self.tr('Evaluation error: {0}').format(expression.evalErrorString()))

features = vector.features(layer, context)
features = QgsProcessingUtils.getFeatures(layer, context)
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
for current