本文整理汇总了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;未经允许,请勿转载。 |
请发表评论