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


Python core.QgsFeatureStore类代码示例

本文整理汇总了Python中qgis.core.QgsFeatureStore的典型用法代码示例。如果您正苦于以下问题:Python QgsFeatureStore类的具体用法?Python QgsFeatureStore怎么用?Python QgsFeatureStore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testProxyFeatureSink

    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')
开发者ID:alexbruy,项目名称:QGIS,代码行数:28,代码来源:test_qgsfeaturesink.py

示例2: testFromIterator

    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])
开发者ID:alexbruy,项目名称:QGIS,代码行数:11,代码来源:test_qgsfeaturesink.py


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