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


Python core.QgsRendererRegistry类代码示例

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


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

示例1: testAddRenderer

    def testAddRenderer(self):
        """ test adding renderers to registry """
        clearRegistry()

        # add a renderer
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(TestRenderer('test2')))
        self.assertTrue('test2' in QgsRendererRegistry.instance().renderersList())

        # try adding it again - should be rejected due to duplicate name
        self.assertFalse(QgsRendererRegistry.instance().addRenderer(TestRenderer('test2')))
        self.assertTrue('test2' in QgsRendererRegistry.instance().renderersList())
开发者ID:,项目名称:,代码行数:11,代码来源:

示例2: testInstance

    def testInstance(self):
        """ test retrieving global instance """
        self.assertTrue(QgsRendererRegistry.instance())

        # instance should be initially populated with some default renderers
        self.assertTrue('singleSymbol' in QgsRendererRegistry.instance().renderersList())

        # register a renderer to the singleton, to test that the same instance is always returned
        self.assertFalse('test' in QgsRendererRegistry.instance().renderersList())
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(TestRenderer('test')))
        self.assertTrue('test' in QgsRendererRegistry.instance().renderersList())
开发者ID:,项目名称:,代码行数:11,代码来源:

示例3: testRetrieveRenderer

    def testRetrieveRenderer(self):
        """ test retrieving renderer by name """
        clearRegistry()

        # try non-existant renderer
        self.assertFalse(QgsRendererRegistry.instance().rendererMetadata('test4'))

        # now add it
        r = TestRenderer('test4')
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r))

        # try retrieving it
        result = QgsRendererRegistry.instance().rendererMetadata('test4')
        self.assertTrue(result)
        self.assertEqual(result.name(), 'test4')
开发者ID:,项目名称:,代码行数:15,代码来源:

示例4: testRenderersByLayerType

    def testRenderersByLayerType(self):
        """ test retrieving compatible renderers by layer type """
        clearRegistry()

        # add some renderers
        r1 = TestRenderer('test1', QgsRendererAbstractMetadata.PointLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r1))
        r2 = TestRenderer('test2', QgsRendererAbstractMetadata.LineLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r2))
        r3 = TestRenderer('test3', QgsRendererAbstractMetadata.PolygonLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r3))
        r4 = TestRenderer('test4', QgsRendererAbstractMetadata.PointLayer | QgsRendererAbstractMetadata.LineLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r4))

        # make some layers
        point_layer = QgsVectorLayer("Point?field=fldtxt:string",
                                     "pointlayer", "memory")
        line_layer = QgsVectorLayer("LineString?field=fldtxt:string",
                                    "linelayer", "memory")
        polygon_layer = QgsVectorLayer("Polygon?field=fldtxt:string",
                                       "polylayer", "memory")

        # test subsets
        self.assertEqual(QgsRendererRegistry.instance().renderersList(point_layer), ['singleSymbol', 'test1', 'test4'])
        self.assertEqual(QgsRendererRegistry.instance().renderersList(line_layer), ['singleSymbol', 'test2', 'test4'])
        self.assertEqual(QgsRendererRegistry.instance().renderersList(polygon_layer), ['singleSymbol', 'test3'])
开发者ID:,项目名称:,代码行数:26,代码来源:

示例5: testRenderersList

    def testRenderersList(self):
        """ test getting list of renderers from registry """
        clearRegistry()

        self.assertEqual(QgsRendererRegistry.instance().renderersList(), ["singleSymbol"])

        # add some renderers
        r1 = TestRenderer("test1", QgsRendererAbstractMetadata.PointLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r1))
        r2 = TestRenderer("test2", QgsRendererAbstractMetadata.LineLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r2))
        r3 = TestRenderer("test3", QgsRendererAbstractMetadata.PolygonLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r3))
        r4 = TestRenderer("test4", QgsRendererAbstractMetadata.PointLayer | QgsRendererAbstractMetadata.LineLayer)
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(r4))

        self.assertEqual(
            QgsRendererRegistry.instance().renderersList(), ["singleSymbol", "test1", "test2", "test3", "test4"]
        )

        # test subsets
        self.assertEqual(
            QgsRendererRegistry.instance().renderersList(QgsRendererAbstractMetadata.PointLayer),
            ["singleSymbol", "test1", "test4"],
        )
        self.assertEqual(
            QgsRendererRegistry.instance().renderersList(QgsRendererAbstractMetadata.LineLayer),
            ["singleSymbol", "test2", "test4"],
        )
        self.assertEqual(
            QgsRendererRegistry.instance().renderersList(QgsRendererAbstractMetadata.PolygonLayer),
            ["singleSymbol", "test3"],
        )
        self.assertEqual(
            QgsRendererRegistry.instance().renderersList(
                QgsRendererAbstractMetadata.LineLayer | QgsRendererAbstractMetadata.PolygonLayer
            ),
            ["singleSymbol", "test2", "test3", "test4"],
        )
开发者ID:,项目名称:,代码行数:39,代码来源:

示例6: testRemoveRenderer

    def testRemoveRenderer(self):
        """ test removing renderers from registry """
        clearRegistry()

        # try removing non-existant renderer
        self.assertFalse(QgsRendererRegistry.instance().removeRenderer('test3'))

        # now add it
        self.assertTrue(QgsRendererRegistry.instance().addRenderer(TestRenderer('test3')))
        self.assertTrue('test3' in QgsRendererRegistry.instance().renderersList())

        # try removing it again - should be ok this time
        self.assertTrue(QgsRendererRegistry.instance().removeRenderer('test3'))
        self.assertFalse('test3' in QgsRendererRegistry.instance().renderersList())

        # try removing it again - should be false since already removed
        self.assertFalse(QgsRendererRegistry.instance().removeRenderer('test3'))
开发者ID:,项目名称:,代码行数:17,代码来源:

示例7: clearRegistry

def clearRegistry():
    # clear registry to start with
    for r in QgsRendererRegistry.instance().renderersList():
        if r == 'singleSymbol':
            continue
        QgsRendererRegistry.instance().removeRenderer(r)
开发者ID:,项目名称:,代码行数:6,代码来源:


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