Skip to content

Commit

Permalink
simplified features method in vector tools
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Nov 6, 2013
1 parent 7985c4e commit e43b8a5
Showing 1 changed file with 5 additions and 23 deletions.
28 changes: 5 additions & 23 deletions python/plugins/processing/tools/vector.py
Expand Up @@ -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:
Expand Down

0 comments on commit e43b8a5

Please sign in to comment.