Exemplo n.º 1
0
 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,
     then each feature of the layer will be incremented through until the
     a Feature is found matching the given feature ID.
     """
     if self._random_read:
         # If the Layer supports random reading, return.
         with suppress(GDALException):
             return Feature(capi.get_feature(self.ptr, feat_id), self)
     else:
         # Random access isn't supported, have to increment through
         # each feature until the given feature ID is encountered.
         for feat in self:
             if feat.fid == feat_id:
                 return feat
     # Should have returned a Feature, raise an OGRIndexError.
     raise OGRIndexError('Invalid feature id: %s.' % feat_id)
Exemplo n.º 2
0
 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,
     then each feature of the layer will be incremented through until the
     a Feature is found matching the given feature ID.
     """
     if self._random_read:
         # If the Layer supports random reading, return.
         with suppress(GDALException):
             return Feature(capi.get_feature(self.ptr, feat_id), self)
     else:
         # Random access isn't supported, have to increment through
         # each feature until the given feature ID is encountered.
         for feat in self:
             if feat.fid == feat_id:
                 return feat
     # Should have returned a Feature, raise an IndexError.
     raise IndexError('Invalid feature id: %s.' % feat_id)
Exemplo n.º 3
0
 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,
     then each feature of the layer will be incremented through until the
     a Feature is found matching the given feature ID.
     """
     if self._random_read:
         # If the Layer supports random reading, return.
         try:
             return Feature(capi.get_feature(self.ptr, feat_id), self)
         except GDALException:
             pass
     else:
         # Random access isn't supported, have to increment through
         # each feature until the given feature ID is encountered.
         for feat in self:
             if feat.fid == feat_id:
                 return feat
Exemplo n.º 4
0
 def _make_feature(self, offset):
     "Helper routine for __getitem__ that makes a feature from an offset."
     return Feature(get_feature(self._ptr, offset), self._ldefn)
Exemplo n.º 5
0
 def _make_feature(self, offset):
     "Helper routine for __getitem__ that makes a feature from an offset."
     return Feature(get_feature(self._ptr, offset), self._ldefn)
 def __iter__(self):
     # adpted from Layer.__iter__
     for pk in self._pkorder:
         rawft = capi.get_feature(self._ptr, self._pk2ftnum[pk])
         yield Feature(rawft, self._ldefn)
Exemplo n.º 7
0
from ctypes import byref, c_double