本文整理汇总了Python中qgis.core.QgsFeatureStore.features方法的典型用法代码示例。如果您正苦于以下问题:Python QgsFeatureStore.features方法的具体用法?Python QgsFeatureStore.features怎么用?Python QgsFeatureStore.features使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsFeatureStore
的用法示例。
在下文中一共展示了QgsFeatureStore.features方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testProxyFeatureSink
# 需要导入模块: from qgis.core import QgsFeatureStore [as 别名]
# 或者: from qgis.core.QgsFeatureStore import features [as 别名]
def testProxyFeatureSink(self):
fields = QgsFields()
fields.append(QgsField('fldtxt', QVariant.String))
fields.append(QgsField('fldint', QVariant.Int))
store = QgsFeatureStore(fields, QgsCoordinateReferenceSystem())
proxy = QgsProxyFeatureSink(store)
self.assertEqual(proxy.destinationSink(), store)
self.assertEqual(len(store), 0)
f = QgsFeature()
f.setAttributes(["test", 123])
f.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(100, 200)))
proxy.addFeature(f)
self.assertEqual(len(store), 1)
self.assertEqual(store.features()[0]['fldtxt'], 'test')
f2 = QgsFeature()
f2.setAttributes(["test2", 457])
f2.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(200, 200)))
f3 = QgsFeature()
f3.setAttributes(["test3", 888])
f3.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(300, 200)))
proxy.addFeatures([f2, f3])
self.assertEqual(len(store), 3)
self.assertEqual(store.features()[1]['fldtxt'], 'test2')
self.assertEqual(store.features()[2]['fldtxt'], 'test3')
示例2: testFromIterator
# 需要导入模块: from qgis.core import QgsFeatureStore [as 别名]
# 或者: from qgis.core.QgsFeatureStore import features [as 别名]
def testFromIterator(self):
"""
Test adding features from an iterator
:return:
"""
layer = createLayerWithFivePoints()
store = QgsFeatureStore(layer.fields(), layer.crs())
self.assertTrue(store.addFeatures(layer.getFeatures()))
vals = [f['fldint'] for f in store.features()]
self.assertEqual(vals, [123, 457, 888, -1, 0])