[mapserver-dev] SLD rendering order of multiple rules in a single layer

Matthijs Laan matthijslaan at b3partners.nl
Mon Aug 1 13:31:39 EDT 2011


Reading the SLD spec OGC 02-070, on page 25 it says

   "a map styler is expected to process all FeatureTypeStyles in the order
    that they appear, regardless, plotting one instance over top of another"

Regarding Rules it says on page 26:

   "stylers should attempt to render the higher-priority rules over top of
    the lower-priority rules (exactly what this means is implementation-
    specific)" (the first Rule has the highest priority)

I guess you can interpret this that all features for a FeatureTypeStyle 
be drawn before features for a following FeatureTypeStyle element are 
For multiple Rules this is less clear, but apparently similar although with
the order reversed.

I have a single layer where one feature should be drawn on top of another
using different styles (I cannot influence the ordering of the features 
from the source).

I would expect to realize this with two different Rule elements, where the
Rule for the feature I want drawn on top would appear later in the 
document as
child of a different FeatureTypeStyle or UserStyle element than the 
first Rule
(except when the two Rules have the same FeatureTypeStyle parent- 'on 
top' Rule
would be the first element).

However I can only make this work when the 'draw-last' Rule is a parent of
another NamedLayer element with the same Name later in the SLD, per the 
for ticket #1602 (r11717).

I would like to have this work with a single NamedLayer. For GeoServer 
two FeatureTypeStyle elements under a single UserStyle works (but not 
NamedLayer/UserStyle elements or two Rules under a single 

So working with 6.1-dev is:
<UserStyle>...<FeatureTypeStyle>...<Rule><Name> bottom </Name>...</Rule><//>
<UserStyle>...<FeatureTypeStyle>...<Rule><Name> top </Name>...</Rule><//>

I would like to have work:
<UserStyle> ...
<FeatureTypeStyle>...<Rule><Name> bottom </Name>...</Rule></>
<FeatureTypeStyle>...<Rule><Name> top </Name>...</Rule></>

My questions are:
- Is my interpretation of the spec correct? Should this work?
- Would a patch similar to r11717 but for multiple FeatureTypeStyles work
   (inserting a new layer in the generated temporary mapfile?)

I'll try to look into making a patch. I don't think it can be as simple 
as r11717
unfortunately... That patch adds a new mapfile layer with a generated 
name and changes
the duplicate SLD NamedLayer's Name to the generated name so the other 
code isn't


More information about the mapserver-dev mailing list