• Blog posts

    Bio

    By David Crowther

    GeoServer

    Question:

    Is it possible to apply multiple filters in the same Rule using Geoserver SLD styling?

    Answer:

    Yes it is, and below we outline a Use Case of when this can be useful.

    Here we have an LLPG Project using Cadline’s webGIS – MapThat – to show several BLPU Layers.

    The Community Extents layer uses Geoserver to publish the BLPU Extent polygons from the LLPG as a styled WMS.

    GeoServer

    The layer uses a CQL filter to only display Extent Polygons that have specific BLPU_CLASS values. These are BLPU Class values related to Cemetery, Recycling and Places of Worship.

    GeoServer

    To style these features we are using an SLD that has a RULE for each set of BLPU_CLASS values, where each of the RULES in the SLD use an OGC FILTER to create styling items based on 1 BLPU_CLASS .e.g. CC06 for the Cemetery features.

    GeoServer

    GeoServer

    The issue is that the Places of Worship features are classified using more than 1 BLPU_CLASS. In this case they are where BLPU_CLASS = ‘CC07’ or ‘ZW’. And if we were to add individual Rules for each BLPU_CLASS, we would create 2 legend values for the Places of Worship features.

    GeoServer

    So, we need to remove one of the RULES and update the existing Places of Worship Rules to style both BLPU_CLASS ‘CC07’ and ‘ZW’ at the same time.

    To do this we can add an OR statement into the OGC FILTER part of the RULE, which then allows us to repeat the PROPERTY IS EQUAL TO, so that we can search for two Values!

    GeoServer

    Note – the OGC:Or is started before and ended after the PROPERTY IS EQUAL TO sections.

    This will mean that the SLD legend now only has 1 entry for Places of Worship, but it will be styling both the ‘CC07’ and ‘ZW’ features at the same time.

    GeoServer

    So, if we now display the WMS layer in MapThat, we have one legend item for Places of Worship, styling the two separate features with the same style in the map!

    GeoServer

Comments

0 comments

Please sign in to leave a comment.