當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。