当前位置: 首页>>代码示例>>Python>>正文


Python feature.Feature方法代码示例

本文整理汇总了Python中django.contrib.gis.gdal.feature.Feature方法的典型用法代码示例。如果您正苦于以下问题:Python feature.Feature方法的具体用法?Python feature.Feature怎么用?Python feature.Feature使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.contrib.gis.gdal.feature的用法示例。


在下文中一共展示了feature.Feature方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _make_feature

# 需要导入模块: from django.contrib.gis.gdal import feature [as 别名]
# 或者: from django.contrib.gis.gdal.feature import Feature [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 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
        # Should have returned a Feature, raise an OGRIndexError.
        raise OGRIndexError('Invalid feature id: %s.' % feat_id)

    # #### Layer properties #### 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:25,代码来源:layer.py

示例2: _make_feature

# 需要导入模块: from django.contrib.gis.gdal import feature [as 别名]
# 或者: from django.contrib.gis.gdal.feature import Feature [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 #### 
开发者ID:VirtualPlants,项目名称:tissuelab,代码行数:24,代码来源:layer.py

示例3: __getitem__

# 需要导入模块: from django.contrib.gis.gdal import feature [as 别名]
# 或者: from django.contrib.gis.gdal.feature import Feature [as 别名]
def __getitem__(self, index):
        "Gets the Feature at the specified index."
        if isinstance(index, six.integer_types):
            # An integer index was given -- we cannot do a check based on the
            # number of features because the beginning and ending feature IDs
            # are not guaranteed to be 0 and len(layer)-1, respectively.
            if index < 0:
                raise OGRIndexError('Negative indices are not allowed on OGR Layers.')
            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.') 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:17,代码来源:layer.py

示例4: __iter__

# 需要导入模块: from django.contrib.gis.gdal import feature [as 别名]
# 或者: from django.contrib.gis.gdal.feature import Feature [as 别名]
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) 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:8,代码来源:layer.py

示例5: get_fields

# 需要导入模块: from django.contrib.gis.gdal import feature [as 别名]
# 或者: from django.contrib.gis.gdal.feature import Feature [as 别名]
def get_fields(self, field_name):
        """
        Returns a list containing the given field name for every Feature
        in the Layer.
        """
        if field_name not in self.fields:
            raise GDALException('invalid field name: %s' % field_name)
        return [feat.get(field_name) for feat in self] 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:10,代码来源:layer.py

示例6: get_geoms

# 需要导入模块: from django.contrib.gis.gdal import feature [as 别名]
# 或者: from django.contrib.gis.gdal.feature import Feature [as 别名]
def get_geoms(self, geos=False):
        """
        Returns a list containing the OGRGeometry for every Feature in
        the Layer.
        """
        if geos:
            from django.contrib.gis.geos import GEOSGeometry
            return [GEOSGeometry(feat.geom.wkb) for feat in self]
        else:
            return [feat.geom for feat in self] 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:12,代码来源:layer.py


注:本文中的django.contrib.gis.gdal.feature.Feature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。