How can I use a different image (OnlineResource) depending on the attribute value? I have a feature with a 'number' attribute, I need to do something like: if number = 0 then OnlineResource = image 1 else OnlineResource = image 2
Asked
Active
Viewed 948 times
2 Answers
1
you can try creating a rule with the tag (empty) instead of the ogc:Filter ... </ogc:Filter> tag
An else rule applies when, after scale and filters are applied, no other rule applies.
<FeatureTypeStyle>
<Rule>
<Name>local-road</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>number</ogc:PropertyName>
<ogc:Literal>0</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
...
</Graphic>
</PointSymbolizer>
</Rule>
<!-- this is the else rule -->
<Rule>
<Name>else</Name>
<ElseFilter></ElseFilter>
<PointSymbolizer>
<Graphic>
...
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>

GioiGio
- 11
- 1
0
You can use two rules with filters in your SLD:
<FeatureTypeStyle>
<Rule>
<Name>local-road</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>local-road</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#009933</CssParameter>
<CssParameter name="stroke-width">2</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
<Rule>
<Name>secondary</Name>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>type</ogc:PropertyName>
<ogc:Literal>secondary</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#0055CC</CssParameter>
<CssParameter name="stroke-width">3</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>

Ian Turton
- 10,018
- 1
- 28
- 47