I have a dataset where multiple attributes need to be shown with the same symbol. I can achieve this using multiple 'PropertyIsEqualTo' operators nested within 'Or' logical operators, see below example;
<ogc:Or>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>CURRENT_ST</ogc:PropertyName>
<ogc:Literal>AB-LOC</ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>CURRENT_ST</ogc:PropertyName>
<ogc:Literal>ABD</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Or>
This seems a little inefficient, especially considering I have about 10 different symbol types each with about 10 contributing attributes.
Ideally you would just clean the attribute data up, or add a symbol field that grouped them together but that is not an option in this case.
Is there a more efficient way of doing this?
For example being able to list the attributes something like the below would be great;
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>CURRENT_ST</ogc:PropertyName>
<ogc:Literal>'AB-LOC','ABD','ABC','DEF'</ogc:Literal>
</ogc:PropertyIsEqualTo>
Best Answer
Geoserver provides a set of non-standard SLD functions in addition of the standard SLD features. The 'IN' operator is part of these non-standard functions. Something like that should work:
Note that in the function
in4
,4
corresponds to the number of arguments you specify. Change it according to the number of values in your list. The OGC Filter 1.0 standard used in SLD 1.0 restrains a fixed number of arguments, that's why thein
function is provided as a serie ofinX
whereX
is the actual number of arguments you have to apply.You can have a look to this documentation page and example: http://docs.geoserver.org/stable/en/user/styling/sld-tipstricks/mixed-geometries.html#geometrytype-function