• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python core.QgsConditionalStyle类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_MatchesTrueForFields

 def test_MatchesTrueForFields(self):
     feature = QgsFeature()
     fields = QgsFields()
     fields.append(QgsField("testfield", QVariant.Int))
     feature.setFields(fields, True)
     feature["testfield"] = 20
     style = QgsConditionalStyle('"testfield" = @value')
     assert style.matches(20, feature)
开发者ID:siliconsmiley,项目名称:QGIS,代码行数:8,代码来源:test_qgsconditionalstyle.py


示例2: test_MatchesTrueForFields

 def test_MatchesTrueForFields(self):
     feature = QgsFeature()
     fields = QgsFields()
     fields.append(QgsField("testfield", QVariant.Int))
     feature.setFields(fields, True)
     feature["testfield"] = 20
     style = QgsConditionalStyle('"testfield" = @value')
     context = QgsExpressionContextUtils.createFeatureBasedContext(feature, fields)
     assert style.matches(20, context)
开发者ID:lyming531,项目名称:QGIS,代码行数:9,代码来源:test_qgsconditionalstyle.py


示例3: test_MatchingStylesReturnsListOfCorrectStyles

 def test_MatchingStylesReturnsListOfCorrectStyles(self):
     styles = []
     style = QgsConditionalStyle("@value > 10")
     style.setName("1")
     styles.append(style)
     style = QgsConditionalStyle("@value > 10")
     style.setName("2")
     styles.append(style)
     style = QgsConditionalStyle("@value < 5")
     style.setName("3")
     styles.append(style)
     context = self.new_context()
     out = QgsConditionalStyle.matchingConditionalStyles(styles, 20, context)
     assert len(out) == 2
     out[0].name() == "1"
     out[1].name() == "2"
开发者ID:,项目名称:,代码行数:16,代码来源:


示例4: hazard_class_style

def hazard_class_style(layer, classification, display_null=False):
    """Set colors to the layer according to the hazard.

    :param layer: The layer to style.
    :type layer: QgsVectorLayer

    :param display_null: If we should display the null hazard zone. Default to
        False.
    :type display_null: bool

    :param classification: The hazard classification to use.
    :type classification: dict safe.definitions.hazard_classifications
    """
    categories = []

    # Conditional styling
    attribute_table_styles = []

    for hazard_class, (color, label) in list(classification.items()):
        if hazard_class == not_exposed_class['key'] and not display_null:
            # We don't want to display the null value (not exposed).
            # We skip it.
            continue

        symbol = QgsSymbol.defaultSymbol(layer.geometryType())
        symbol.setColor(color)
        if is_line_layer(layer):
            symbol.setWidth(line_width_exposure)
        category = QgsRendererCategory(hazard_class, symbol, label)
        categories.append(category)

        style = QgsConditionalStyle()
        style.setName(hazard_class)
        style.setRule("hazard_class='%s'" % hazard_class)
        style.setBackgroundColor(transparent)
        symbol = QgsSymbol.defaultSymbol(QgsWkbTypes.PointGeometry)
        symbol.setColor(color)
        symbol.setSize(3)
        style.setSymbol(symbol)
        attribute_table_styles.append(style)

    layer.conditionalStyles().setFieldStyles(
        'hazard_class', attribute_table_styles)
    renderer = QgsCategorizedSymbolRenderer(
        hazard_class_field['field_name'], categories)
    layer.setRenderer(renderer)
开发者ID:inasafe,项目名称:inasafe,代码行数:46,代码来源:style.py


示例5: test_MatchesTrueForFields

 def test_MatchesTrueForFields(self):
     style = QgsConditionalStyle('"testfield" = @value')
     context = self.new_context()
     assert style.matches(20, context)
开发者ID:,项目名称:,代码行数:4,代码来源:


示例6: test_MatchesReturnsTrueForComplexMatch

 def test_MatchesReturnsTrueForComplexMatch(self):
     style = QgsConditionalStyle("@value > 10 and @value = 20")
     context = QgsExpressionContextUtils.createFeatureBasedContext(QgsFeature(), QgsFields())
     assert style.matches(20, context)
开发者ID:,项目名称:,代码行数:4,代码来源:


示例7: test_MatchesReturnsTrueForComplexMatch

 def test_MatchesReturnsTrueForComplexMatch(self):
     style = QgsConditionalStyle("@value > 10 and @value = 20")
     assert style.matches(20)
开发者ID:siliconsmiley,项目名称:QGIS,代码行数:3,代码来源:test_qgsconditionalstyle.py


示例8: test_MatchesReturnsTrueForSimpleMatch

 def test_MatchesReturnsTrueForSimpleMatch(self):
     style = QgsConditionalStyle("@value > 10")
     assert style.matches(20)
开发者ID:siliconsmiley,项目名称:QGIS,代码行数:3,代码来源:test_qgsconditionalstyle.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python core.QgsContextHelp类代码示例发布时间:2022-05-26
下一篇:
Python core.QgsComposition类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap