Hey folks,

I'm having some weird issues with using an external SLD in library
mode in 2.1b2. I have geoserverlayer layer "mylayer", and a library
SLD that defines two styles for it, "style1" and "style2":

<namedlayer>
  <name>mylayer</name>
  <userstyle>
    <name>style1</name>
  </userstyle>
  <userstyle>
    <name>style2</name>
  </userstyle>
</namedlayer>

(actual featuretypestyles omitted for clarity)

Now, I want to request this layer twice, with once with style1 and
once with style2:

REQUEST=GetMap&SLD=http://blahblah/my.sld&LAYERS=mylayer,mylayer&STYLES=style1,style2

I then get a crash:

2010-12-08 10:52:27,443 ERROR [geoserver.ows] -
java.lang.ArrayIndexOutOfBoundsException: 1
    at 
org.geoserver.wms.map.GetMapKvpRequestReader.processLibrarySld(GetMapKvpRequestReader.java:537)

Looks like it wants the number of layers I ask for and the number
defined in my SLD to be the same.  Ok fine, so I rewrite the SLD to
look like this (which, as best I can tell from the SLD spec, is
valid):

<namedlayer>
  <name>mylayer</name>
  <userstyle>
    <name>style1</name>
  </userstyle>
</namedlayer>
<namedlayer>
  <name>mylayer</name>
  <userstyle>
    <name>style2</name>
  </userstyle>
</namedlayer>

Now there is no crash, but no matter what you ask geoserver for, it
always returns mylayer styled with style2...at least, when you try
GetMap. If you use this exact same setup with GetLegendGraphic, then
returns the correct legend for the requested style (style1 or style2)

My workaround, for the moment, is to define mylayer twice in the SLD,
but with both styles defined each time. In other words:

<namedlayer>
  <name>mylayer</name>
  <userstyle>
    <name>style1</name>
  </userstyle>
  <userstyle>
    <name>style2</name>
  </userstyle>
</namedlayer>
<namedlayer>
  <name>mylayer</name>
  <userstyle>
    <name>style1</name>
  </userstyle>
  <userstyle>
    <name>style2</name>
  </userstyle>
</namedlayer>

So, my question is this: do I really need as many <NamedLayer>s as
there are layers listed in LAYERS in my GetMap requests? If so, do I
really need to duplicate all my styles in each <NamedLayer>? GetMap
says yes, but GetLegendGraphic says no. :)

[ On a side note I would like to smack whoever decided that the WMS
spec doesn't need an XML POST version of GetLegendGraphic. If it
weren't for that I would just use POST requests with my UserStyles
included in the request and this whole thing would be a lot easier.
Sigh... ]

------------------------------------------------------------------------------
This SF Dev2Dev email is sponsored by:

WikiLeaks The End of the Free Internet
http://p.sf.net/sfu/therealnews-com
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to