Skip to content
Permalink
Browse files
Port some more code to new API
  • Loading branch information
nyalldawson committed Apr 26, 2017
1 parent 13f0813 commit a4cd66f8d8e8c9bc55caaa2ef519301637110dc9
@@ -153,8 +153,9 @@ def processAlgorithm(self, context, feedback):
inFeat = QgsFeature()
outFeat = QgsFeature()
features = QgsProcessingUtils.getFeatures(layer, context)
if len(features):
total = 100.0 / QgsProcessingUtils.featureCount(layer, context)
count = QgsProcessingUtils.featureCount(layer, context)
if count > 0:
total = 100.0 / count
for current, inFeat in enumerate(features):
rownum = current + 1

@@ -5,6 +5,7 @@

from processing.tools.vector import TableWriter
from collections import defaultdict
from qgis.core import QgsProcessingUtils
from processing.core.GeoAlgorithmExecutionException import GeoAlgorithmExecutionException
from processing.tools import dataobjects

@@ -20,8 +21,8 @@
writer = TableWriter(Frequency, None, fields + ['FREQ'])

counts = {}
feats = processing.features(layer)
nFeats = len(feats)
feats = QgsProcessingUtils.getFeatures(layer, context)
nFeats = QgsProcessingUtils.featureCount(layer, context)
counts = defaultdict(int)
for i, feat in enumerate(feats):
feedback.setProgress(int(100 * i / nFeats))
@@ -5,7 +5,7 @@
##Biggest parts=output vector

from processing.tools import dataobjects
from qgis.core import QgsGeometry, QgsWkbTypes
from qgis.core import QgsGeometry, QgsWkbTypes, QgsProcessingUtils
from operator import itemgetter

To_keep = int(To_keep)
@@ -21,7 +21,7 @@
QgsWkbTypes.MultiPolygon, polyPrder.crs())


for n, feat in enumerate(processing.features(polyLayer)):
for n, feat in enumerate(QgsProcessingUtils.getFeatures(polyLayer, context)):
feedback.setProgress(int(100 * n / count))
geom = feat.geometry()
if geom.isMultipart():
@@ -5,7 +5,7 @@
##N_unique_values=output vector

from qgis.PyQt.QtCore import QVariant
from qgis.core import QgsFeature, QgsField
from qgis.core import QgsFeature, QgsField, QgsProcessingUtils
from processing.tools.vector import VectorWriter
from processing.tools import dataobjects

@@ -20,8 +20,8 @@

outFeat = QgsFeature()
classes = {}
feats = processing.features(layer)
nFeat = len(feats)
feats = QgsProcessingUtils.getFeatures(layer, context)
nFeat = QgsProcessingUtils.featureCount(layer, context)
for n, inFeat in enumerate(feats):
feedback.setProgress(int(100 * n / nFeat))
attrs = inFeat.attributes()

0 comments on commit a4cd66f

Please sign in to comment.