[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


Hello!

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 
should
be drawn before features for a following FeatureTypeStyle element are 
drawn.
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 
coming
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 
patch
for ticket #1602 (r11717).

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

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

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

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
affected.

Matthijs




More information about the mapserver-dev mailing list