Exemple #1
0
 def __iter__(self):
     capi.reset_reading(self._ptr)
     for i in xrange(self.num_feat):
         feat = Feature(capi.get_next_feature(self._ptr), self._ldefn)
         if not self.__filter(feat):
             continue
         yield feat
Exemple #2
0
 def __iter__(self):
     "Iterates over each Feature in the Layer."
     # ResetReading() must be called before iteration is to begin.
     capi.reset_reading(self._ptr)
     for i in range(self.num_feat):
         yield Feature(capi.get_next_feature(self._ptr), self)
Exemple #3
0
 def __iter__(self):
     "Iterates over each Feature in the Layer."
     # ResetReading() must be called before iteration is to begin.
     capi.reset_reading(self._ptr)
     for i in xrange(self.num_feat):
         yield Feature(capi.get_next_feature(self._ptr), self)
Exemple #4
0
            return self._make_feature(index)
        elif isinstance(index, slice):
            # A slice was given
            start, stop, stride = index.indices(self.num_feat)
            return [self._make_feature(fid) for fid in range(start, stop, stride)]
        else:
            raise TypeError('Integers and slices may only be used when indexing OGR Layers.')

    def __iter__(self):
<<<<<<< HEAD
        "Iterates over each Feature in the Layer."
=======
        "Iterate over each Feature in the Layer."
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
        # ResetReading() must be called before iteration is to begin.
        capi.reset_reading(self._ptr)
        for i in range(self.num_feat):
            yield Feature(capi.get_next_feature(self._ptr), self)

    def __len__(self):
        "The length is the number of features."
        return self.num_feat

    def __str__(self):
        "The string name of the layer."
        return self.name

    def _make_feature(self, feat_id):
        """
        Helper routine for __getitem__ that constructs a Feature from the given
        Feature ID.  If the OGR Layer does not support random-access reading,
from ctypes import byref, c_double