Skip to content
Permalink
Browse files

simplified features method in vector tools

  • Loading branch information
volaya committed Nov 5, 2013
1 parent 7985c4e commit e43b8a53117b87e8cbaa6cce564c0ff299591f11
Showing with 5 additions and 23 deletions.
  1. +5 −23 python/plugins/processing/tools/vector.py
@@ -43,34 +43,16 @@ class Features:

def __init__(self, layer):
self.layer = layer
self.iter = layer.getFeatures()
self.selection = False
self.iter = layer.getFeatures()
if ProcessingConfig.getSetting(ProcessingConfig.USE_SELECTED):
self.selected = layer.selectedFeatures()
if len(self.selected) > 0:
selected = layer.selectedFeatures()
if len(selected) > 0:
self.selection = True
self.idx = 0
self.iter = iter(selected)

def __iter__(self):
return self

def next(self):
if self.selection:
if self.idx < len(self.selected):
feature = self.selected[self.idx]
self.idx += 1
return feature
else:
raise StopIteration()
else:
if self.iter.isClosed():
raise StopIteration()
f = QgsFeature()
if self.iter.nextFeature(f):
return f
else:
self.iter.close()
raise StopIteration()
return self.iter

def __len__(self):
if self.selection:

0 comments on commit e43b8a5

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