Opened 18 years ago

Closed 12 years ago

#1602 closed enhancement (fixed)

SLD parser to support multiple NamedLayers

Reported by: bartvde@… Owned by: assefa
Priority: high Milestone: 6.2 release
Component: WMS Server Version: 4.8
Severity: minor Keywords:
Cc: julho@…

Description

E-mail from Assefa:

Bart,

 Right now the sld parser would apply the style on your layer using the 
first NamedLayer found in the SLD and ignore the 2nd one (and 
susequent). The reason being only that It was not being thought when 
originally implemented.  You should add an enhacement bug on it. 

Later,

 
 

 


Eijnden, B. van den (Bart) wrote:

>Hi list,
>
>is the following SLD supposed to work with Mapserver? I can't get it to
>work. What I am trying to do is to display a layer with its default style
>with on top some custom labels for that same layer. I can get it to work
>using 2 separate WMS client layers, but ofcourse this would be far more
>efficient in one pass.
>
><StyledLayerDescriptor version='1.0.0'>
>  <NamedLayer>
>    <Name>NL-prov</Name>
>    <NamedStyle>
>      <Name></Name>
>    </NamedStyle>
>  </NamedLayer>
>  <NamedLayer>
>    <Name>NL-prov</Name>
>      <UserStyle>
>        <FeatureTypeStyle>
>          <Rule>
>            <TextSymbolizer>
>              <Label>OMSCHR</Label>
>              <Font>
>                <CssParameter name='font-color'>#000000</CssParameter>
>                <CssParameter name='font-family'>arial</CssParameter>
>                <CssParameter name='font-size'>10</CssParameter>
>              </Font>
>            </TextSymbolizer>
>          </Rule>
>        </FeatureTypeStyle>
>      </UserStyle>
>    </NamedLayer>
></StyledLayerDescriptor>

Change History (16)

comment:1 by assefa, 13 years ago

Milestone: 6.2 release
Owner: changed from mapserverbugs to assefa

Re-reading this since It was mentioned on the mailing list recently ...

I am not sure if the sld is intended to work like described in this bug. The way I see it is that the sld (or style parameter) is sent to replace the current style. The client has also the ability to retrieve the current style and use that as part of it's sld. The way the code is structured right now, this is not going to fit well in it. Is there somewhere is the specs where this behavior (keep current style + add other style) is described?

comment:2 by pramsey, 13 years ago

Are you sure it can't work that way? It seems equivalent to

LAYERS=foo,foo&STYLES=foo_style1,foo_style2

and surely that's legal?

comment:3 by assefa, 13 years ago

I agrees It means that but I guess the question is how to interpret it:

LAYERS=foo,foo&STYLES=foo_style1,foo_style2

For me it means "Draw the same layer using 2 different set of classes". In terms of MapServer, I would tend to see 2 separate (duplicate), with first one using style one and the 2nd layer using style2

The way It is reported on the mailing list by Hollingbery Julian, the desired result, in term of MapServer, is to have only one layer and all styles/classes (from style 1 and style 2) in this layer. It is assumed in this case that all classes will have expressions, except maybe the last class that can then be used to be a "catch all" class (order in which the styles are given matters)

The way it is initially reported in this bug is to actually update, in term of MapServer, the existing classes to add label stuff for example to the classes. That is not intuitive in my opinion.

As I mentioned, interpretation 1 (duplicate layer) seems to be the more intuitive way for me. Interpretation 2 can also be valid. Both cases can be implemented.

Do you know how Geoserver handles this?

comment:4 by jdeolive, 13 years ago

GeoServer behaviour is interpretation 1, if I understand it correctly. That is the layer will be loaded and rendered multiple times separately, once for each style applied to it.

comment:5 by assefa, 13 years ago

Thanks Justin for the info.

comment:6 by julho, 13 years ago

I might agree that this ticket may not be according to spec, since it is about overriding only part of the server's standard style. However, what we are after is to use the standard style on all objects in a layer, *except* those specified by a <ogc:filter>. This can still be discussed: My opinion is that the SLD spec hints at this use case. I have assumed that a fix which would fix our problem would also result in a fix to #1602, but since I do not know the code, I may be completely wrong about this. In that case, our request may be a separate ticket..?

Reproducing (for completeness) from my post to the mailing list, my SLD is:

<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc">

<NamedLayer>

<Name>Jordstykke</Name>

<UserStyle>

<FeatureTypeStyle>

<Rule>

<ogc:Filter>

<And>

<ogc:PropertyIsEqualTo>

<ogc:PropertyName>landsejerlavskode</ogc:PropertyName> <ogc:Literal>90552</ogc:Literal>

</ogc:PropertyIsEqualTo> <ogc:PropertyIsEqualTo>

<ogc:PropertyName>matrikelnummer</ogc:PropertyName> <ogc:Literal>7fv</ogc:Literal>

</ogc:PropertyIsEqualTo>

</And>

</ogc:Filter>

<PolygonSymbolizer>

<Fill>

<CssParameter name="fill">#0000FF</CssParameter>

<CssParameter name="fill-opacity">1</CssParameter>

</Fill>

<Stroke>

<CssParameter name="stroke">#FF0000</CssParameter>

<CssParameter name="stroke-width">3</CssParameter>

</Stroke>

</PolygonSymbolizer>

</Rule>

</FeatureTypeStyle>

</UserStyle>

</NamedLayer>

<NamedLayer>

<Name>Jordstykke</Name> <NamedStyle>

<Name>default</Name>

</NamedStyle>

</NamedLayer>

</StyledLayerDescriptor>

Regards Julian Hollingbery

comment:7 by assefa, 13 years ago

Hi Julian,

I briefly recheck the sld spec. this morning to find hints you mentioned but could not see them. I might have missed them. What I have seen for example in sld v1.0 (section 6.4) is that they described how giving the same layer twice with 2 different styles can be used as a trick to do cased lines. This tend to confirm that interpretation 1 (from previous comments) is what the sld spec hints at.

I am not sure if another bug is needed here. As I mentioned, interpretation 1 seems to be what the specs hints at. In the case of the SLD given in your example, It means 2 layers, first one drawn with the styles defined in the SLD, the 2nd layer (same as 1st) drawn on top using the default styles). I don't think there can be 2 different interpretations for the same sld.

comment:8 by julho, 13 years ago

The important thing for me is to be able to highlight a given object (specified by the <ogc:filter>), while rendering the remaining objects in the layer with the servers standard style. I have tried doing this (on Mapserver 5.6.6) by combining my SLD with repeating the layer name in the LAYERS parameter, but I cannot make it work. Can you give me an example? For instance, I have tried something like http://kmsloadudv5.kmsext.dk/cgi-bin/mapserv?map=/data/mapserver/data/maps/test_sld_ora.map&version=1.1.1&service=WMS&request=GetMap&bgcolor=0xEEEEEE&srs=EPSG:25832&bbox=700000,6185000,701000,6186000&width=650&height=550&exceptions=application/vnd.ogc.se_inimage&format=image/png&layers=Jordstykke,Jordstykke&styles=&SLD_BODY=%3CStyledLayerDescriptor%20version=%221.0.0%22%20xmlns=...

For the record, the hints I was talking about, are: SLD 1.0, p.5: "WMS uses the “painter’s model” and plots each successive layer in the LAYER list over top of the previously rendered layers. [...] It is possible for the same layer to appear more than once, although rarely with the same style."

This supports the usage where the same layer occurs multiple times in the WMS request.

p.7: "The NamedLayer and NamedStyle elements correspond to the LAYERS and STYLES of the CGI parameters and the “painter’s model” is also used for Z-ordering."

This establishes a one-to-one relation between the LAYERS parameter and the NamedLayer element of the SLD. My interpretation would be to say that if the same NamedLayer occurs twice in the SLD, it should work just as if it had occurred twice in the LAYERS parameter.

p.10: "To make the HTTP-GET methods more practical for use, the SLD can also be used in one of two different modes depending on whether the LAYERS parameter is present in the request. If it is not present, then all layers identified in the SLD document are rendered with all defined styles, which is equivalent to the XML-POST method of usage. If the LAYERS parameter is present, then only the layers identified by that parameter are rendered and the SLD is used as a “style library”."

I think that this is not how MapServer operates, since it never allows an empty LAYERS parameter.

comment:9 by julho, 13 years ago

Cc: julho@… added

in reply to:  8 comment:10 by assefa, 13 years ago

Replying to julho:

This supports the usage where the same layer occurs multiple times in the WMS request.

p.7: "The NamedLayer and NamedStyle elements correspond to the LAYERS and STYLES of the CGI parameters and the “painter’s model” is also used for Z-ordering."

Correct. This is what I mentioned all along as "interpretation 1". It is not implemented in MapServer right now but can be added.

I think that this is not how MapServer operates, since it never allows an empty LAYERS parameter.

This is already described in http://trac.osgeo.org/mapserver/ticket/1166

Both of these tickets can be fixed in trunk and/or the 5.x branch.

comment:11 by assefa, 13 years ago

Hi Julian,

I will attache a patch that should work with against mapserver 6.0-svn. I will commit it after the 6.0 release. Will it be possible for you to do you own build and try it out before it is committed. Let me know.

comment:12 by julho, 13 years ago

Hi assefa,

it is possible for me, but it may take two or three weeks, as I have some other dependencies. Will this be a problem for you?

/julian

comment:13 by assefa, 13 years ago

Hi Julian,

Not a problem for me. I will commit a version as soon as Mapserver 6.0 is out and we can go from there when you are ready for testing.

Assefa

comment:14 by assefa, 13 years ago

first pass added in r11717 and r11718.

comment:15 by pramsey, 12 years ago

Assefa, is this ticket complete? Should it be closed?

comment:16 by assefa, 12 years ago

Resolution: fixed
Status: newclosed

closing. The fix as described was committed a while ago.

Note: See TracTickets for help on using tickets.