本文整理匯總了Python中django.contrib.gis.gdal.error.OGRIndexError方法的典型用法代碼示例。如果您正苦於以下問題:Python error.OGRIndexError方法的具體用法?Python error.OGRIndexError怎麽用?Python error.OGRIndexError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類django.contrib.gis.gdal.error
的用法示例。
在下文中一共展示了error.OGRIndexError方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _make_feature
# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import OGRIndexError [as 別名]
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 OGRException:
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
# Should have returned a Feature, raise an OGRIndexError.
raise OGRIndexError('Invalid feature id: %s.' % feat_id)
#### Layer properties ####
示例2: __getitem__
# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import OGRIndexError [as 別名]
def __getitem__(self, index):
"""
Gets the Field object at the specified index, which may be either
an integer or the Field's string label. Note that the Field object
is not the field's _value_ -- use the `get` method instead to
retrieve the value (e.g. an integer) instead of a Field instance.
"""
if isinstance(index, six.string_types):
i = self.index(index)
else:
if index < 0 or index > self.num_fields:
raise OGRIndexError('index out of range')
i = index
return Field(self, i)
示例3: index
# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import OGRIndexError [as 別名]
def index(self, field_name):
"Returns the index of the given field name."
i = capi.get_field_index(self.ptr, force_bytes(field_name))
if i < 0:
raise OGRIndexError('invalid OFT field name given: "%s"' % field_name)
return i
示例4: __getitem__
# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import OGRIndexError [as 別名]
def __getitem__(self, index):
"Allows use of the index [] operator to get a layer at the index."
if isinstance(index, six.string_types):
l = capi.get_layer_by_name(self.ptr, force_bytes(index))
if not l:
raise OGRIndexError('invalid OGR Layer name given: "%s"' % index)
elif isinstance(index, int):
if index < 0 or index >= self.layer_count:
raise OGRIndexError('index out of range')
l = capi.get_layer(self._ptr, index)
else:
raise TypeError('Invalid index type: %s' % type(index))
return Layer(l, self)
示例5: __getitem__
# 需要導入模塊: from django.contrib.gis.gdal import error [as 別名]
# 或者: from django.contrib.gis.gdal.error import OGRIndexError [as 別名]
def __getitem__(self, index):
"Allows use of the index [] operator to get a layer at the index."
if isinstance(index, six.string_types):
layer = capi.get_layer_by_name(self.ptr, force_bytes(index))
if not layer:
raise OGRIndexError('invalid OGR Layer name given: "%s"' % index)
elif isinstance(index, int):
if index < 0 or index >= self.layer_count:
raise OGRIndexError('index out of range')
layer = capi.get_layer(self._ptr, index)
else:
raise TypeError('Invalid index type: %s' % type(index))
return Layer(layer, self)