mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
gis: Switched back to non-generator __getitem__, since even specific-item index returned generator.
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@5633 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
5f7c6f758b
commit
f7a23a103a
@ -48,19 +48,17 @@ class Layer(object):
|
||||
index = end - index
|
||||
if index < 0 or index >= self.num_feat:
|
||||
raise IndexError, 'index out of range'
|
||||
yield make_feature(index)
|
||||
return make_feature(index)
|
||||
else:
|
||||
# A slice was given
|
||||
start, stop, stride = index.indices(end)
|
||||
for offset in xrange(start,stop,stride):
|
||||
yield make_feature(offset)
|
||||
return [make_feature(offset) for offset in range(start,stop,stride)]
|
||||
|
||||
def __iter__(self):
|
||||
"Iterates over each Feature in the Layer."
|
||||
# Resetting the Layer before beginning iteration
|
||||
lgdal.OGR_L_ResetReading(self._layer)
|
||||
|
||||
return self.__getitem__(slice(self.num_feat))
|
||||
#TODO: is OGR's GetNextFeature faster here?
|
||||
for i in range(self.num_feat):
|
||||
yield self.__getitem__(i)
|
||||
|
||||
def __len__(self):
|
||||
"The length is the number of features."
|
||||
|
Loading…
x
Reference in New Issue
Block a user