Skip to content

Commit

Permalink
Add context argument to vector.features
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 26, 2017
1 parent f3cfb8b commit adc7cf0
Show file tree
Hide file tree
Showing 109 changed files with 174 additions and 173 deletions.
Expand Up @@ -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)
features = vector.features(vectorLayer, context)
for f in features:
writer.addFeature(f)

Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/AddTableField.py
Expand Up @@ -99,7 +99,7 @@ def processAlgorithm(self, context, feedback):
writer = output.getVectorWriter(fields, layer.wkbType(),
layer.crs())
outFeat = QgsFeature()
features = vector.features(layer)
features = vector.features(layer, context)
total = 100.0 / len(features)
for current, feat in enumerate(features):
feedback.setProgress(int(current * total))
Expand Down
Expand Up @@ -69,7 +69,7 @@ def processAlgorithm(self, context, feedback):
writer = output.getVectorWriter(fields, vlayer.wkbType(),
vlayer.crs())
outFeat = QgsFeature()
features = vector.features(vlayer)
features = vector.features(vlayer, context)
total = 100.0 / len(features)
for current, feat in enumerate(features):
feedback.setProgress(int(current * total))
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/BasicStatistics.py
Expand Up @@ -129,7 +129,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, request)
features = vector.features(layer, context, request)

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

request = QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry).setSubsetOfAttributes([fieldName], layer.fields())
stat = QgsStatisticalSummary()
features = vector.features(layer, request)
features = vector.features(layer, context, request)
count = len(features)
total = 100.0 / float(count)
for current, ft in enumerate(features):
Expand Down
Expand Up @@ -110,7 +110,7 @@ def processAlgorithm(self, context, feedback):
request = QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry).setSubsetOfAttributes([fieldName],
layer.fields())
stat = QgsStringStatisticalSummary()
features = vector.features(layer, request)
features = vector.features(layer, context, request)
count = len(features)
total = 100.0 / float(count)
for current, ft in enumerate(features):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/Boundary.py
Expand Up @@ -83,7 +83,7 @@ def processAlgorithm(self, context, feedback):
output_wkb,
layer.crs())

features = vector.features(layer)
features = vector.features(layer, context)
total = 100.0 / len(features)

for current, input_feature in enumerate(features):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/BoundingBox.py
Expand Up @@ -72,7 +72,7 @@ def processAlgorithm(self, context, feedback):
QgsWkbTypes.Polygon,
layer.crs())

features = vector.features(layer)
features = vector.features(layer, context)
total = 100.0 / len(features)

for current, input_feature in enumerate(features):
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/qgis/Buffer.py
Expand Up @@ -30,16 +30,16 @@
from processing.tools import vector


def buffering(feedback, writer, distance, field, useField, layer, dissolve,
segments, endCapStyle=1, joinStyle=1, mitreLimit=2):
def buffering(feedback, context, writer, distance, field, useField, layer, dissolve, segments, endCapStyle=1,
joinStyle=1, mitreLimit=2):

if useField:
field = layer.fields().lookupField(field)

outFeat = QgsFeature()

current = 0
features = vector.features(layer)
features = vector.features(layer, context)
total = 100.0 / float(len(features))

# With dissolve
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/Centroids.py
Expand Up @@ -73,7 +73,7 @@ def processAlgorithm(self, context, feedback):
QgsWkbTypes.Point,
layer.crs())

features = vector.features(layer)
features = vector.features(layer, context)
total = 100.0 / len(features)
for current, input_feature in enumerate(features):
output_feature = input_feature
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/qgis/CheckValidity.py
Expand Up @@ -95,11 +95,11 @@ def processAlgorithm(self, context, feedback):
if method != 0:
settings.setValue(settings_method_key, method)
try:
self.doCheck(feedback)
self.doCheck(context, feedback)
finally:
settings.setValue(settings_method_key, initial_method_setting)

def doCheck(self, feedback):
def doCheck(self, context, feedback):
layer = dataobjects.getLayerFromString(
self.getParameterValue(self.INPUT_LAYER))

Expand Down Expand Up @@ -136,7 +136,7 @@ def doCheck(self, feedback):
layer.crs())
error_count = 0

features = vector.features(layer)
features = vector.features(layer, context)
total = 100.0 / len(features)
for current, inFeat in enumerate(features):
geom = inFeat.geometry()
Expand Down
5 changes: 3 additions & 2 deletions python/plugins/processing/algs/qgis/Clip.py
Expand Up @@ -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, QgsFeatureRequest().setSubsetOfAttributes([])):
for maskFeat in vector.features(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
Expand All @@ -96,7 +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, QgsFeatureRequest().setFilterRect(clip_geom.boundingBox()))]
input_features = [f for f in vector.features(source_layer, context,
QgsFeatureRequest().setFilterRect(clip_geom.boundingBox()))]

if not input_features:
continue
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/qgis/ConvexHull.py
Expand Up @@ -112,15 +112,15 @@ def processAlgorithm(self, context, feedback):

fid = 0
val = None
features = vector.features(layer)
features = vector.features(layer, context)
if useField:
unique = layer.uniqueValues(index)
current = 0
total = 100.0 / (len(features) * len(unique))
for i in unique:
first = True
hull = []
features = vector.features(layer)
features = vector.features(layer, context)
for f in features:
idVar = f[fieldName]
if str(idVar).strip() == str(i).strip():
Expand Down Expand Up @@ -149,7 +149,7 @@ def processAlgorithm(self, context, feedback):
else:
hull = []
total = 100.0 / layer.featureCount()
features = vector.features(layer)
features = vector.features(layer, context)
for current, f in enumerate(features):
inGeom = f.geometry()
points = vector.extractPoints(inGeom)
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/Delaunay.py
Expand Up @@ -84,7 +84,7 @@ def processAlgorithm(self, context, feedback):
ptDict = {}
ptNdx = -1
c = voronoi.Context()
features = vector.features(layer)
features = vector.features(layer, context)
total = 100.0 / len(features)
for current, inFeat in enumerate(features):
geom = QgsGeometry(inFeat.geometry())
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/DeleteColumn.py
Expand Up @@ -85,7 +85,7 @@ def processAlgorithm(self, context, feedback):
writer = self.getOutputFromName(self.OUTPUT).getVectorWriter(fields,
layer.wkbType(), layer.crs())

features = vector.features(layer)
features = vector.features(layer, context)
total = 100.0 / len(features)

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

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

total = 100.0 / len(features)
geoms = dict()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/DeleteHoles.py
Expand Up @@ -81,7 +81,7 @@ def processAlgorithm(self, context, feedback):
layer.wkbType(),
layer.crs())

features = vector.features(layer)
features = vector.features(layer, context)
total = 100.0 / len(features)

for current, f in enumerate(features):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/DensifyGeometries.py
Expand Up @@ -87,7 +87,7 @@ def processAlgorithm(self, context, feedback):
self.OUTPUT).getVectorWriter(layer.fields().toList(),
layer.wkbType(), layer.crs())

features = vector.features(layer)
features = vector.features(layer, context)
total = 100.0 / len(features)
for current, f in enumerate(features):
feature = f
Expand Down
Expand Up @@ -81,7 +81,7 @@ def processAlgorithm(self, context, feedback):
self.OUTPUT).getVectorWriter(layer.fields().toList(),
layer.wkbType(), layer.crs())

features = vector.features(layer)
features = vector.features(layer, context)
total = 100.0 / len(features)
for current, f in enumerate(features):
feature = f
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/Difference.py
Expand Up @@ -79,7 +79,7 @@ def processAlgorithm(self, context, feedback):

outFeat = QgsFeature()
index = vector.spatialindex(layerB)
selectionA = vector.features(layerA)
selectionA = vector.features(layerA, context)
total = 100.0 / len(selectionA)
for current, inFeatA in enumerate(selectionA):
geom = inFeatA.geometry()
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/Dissolve.py
Expand Up @@ -86,7 +86,7 @@ def processAlgorithm(self, context, feedback):
vlayerA.crs())

outFeat = QgsFeature()
features = vector.features(vlayerA)
features = vector.features(vlayerA, context)
total = 100.0 / len(features)

if not useField:
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/DropGeometry.py
Expand Up @@ -75,7 +75,7 @@ def processAlgorithm(self, context, feedback):
QgsCoordinateReferenceSystem())

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

for current, input_feature in enumerate(features):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/EquivalentNumField.py
Expand Up @@ -77,7 +77,7 @@ def processAlgorithm(self, context, feedback):
outFeat = QgsFeature()
classes = {}

features = vector.features(vlayer)
features = vector.features(vlayer, context)
total = 100.0 / len(features)
for current, feature in enumerate(features):
feedback.setProgress(int(current * total))
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/ExecuteSQL.py
Expand Up @@ -151,7 +151,7 @@ def processAlgorithm(self, context, feedback):
vLayer.wkbType() if geometry_type != 1 else 1,
vLayer.crs())

features = vector.features(vLayer)
features = vector.features(vLayer, context)
total = 100.0 / len(features)
outFeat = QgsFeature()
for current, inFeat in enumerate(features):
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/Explode.py
Expand Up @@ -70,7 +70,7 @@ def processAlgorithm(self, context, feedback):
writer = output.getVectorWriter(fields, QgsWkbTypes.LineString,
vlayer.crs())
outFeat = QgsFeature()
features = vector.features(vlayer)
features = vector.features(vlayer, context)
total = 100.0 / len(features)
for current, feature in enumerate(features):
feedback.setProgress(int(current * total))
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/algs/qgis/ExportGeometryInfo.py