[Geoserver-users] Applying a remote SLD to a Openlayer GetMap request

I'm having some trouble getting this to work. I have a couple hundred
layers which show different things, but which are all styled based on
a "class" attribute. I would like to store a single SLD under the
Geoserver www/styles dir, and call upon it via URL when any of the
layers are displayed. To that end, I styled one of the layers the way
I wanted it to look, and then copied the SLD for it out of the
data_dir/styles dir, and into the www one. I then tried to test it by
adding, "&SLD=http://localhost:8080/geoserver/www/styles/class.sld" to
the end of a regular WMS request for another layer. It didn't do
anything, so I tested to make sure that the SLD URL worked properly -
it does. Are there some things that I should do differently to
implement this sort of remote-styling?

Thanks,

Roger
--
Roger André
GIS Developer/Analyst
Enterprise Management Solutions
CH2M HILL
Tel: 425.233.3042

Hi Roger,

Can you include the SLD you are using by any chance? GeoServer can have some funny behavior sometimes depending on NamedLayer elements in a style matching the LAYERS parameter of the request. Having both would help.

Thanks,

-Justin

Roger Andre wrote:

I'm having some trouble getting this to work. I have a couple hundred
layers which show different things, but which are all styled based on
a "class" attribute. I would like to store a single SLD under the
Geoserver www/styles dir, and call upon it via URL when any of the
layers are displayed. To that end, I styled one of the layers the way
I wanted it to look, and then copied the SLD for it out of the
data_dir/styles dir, and into the www one. I then tried to test it by
adding, "&SLD=http://localhost:8080/geoserver/www/styles/class.sld" to
the end of a regular WMS request for another layer. It didn't do
anything, so I tested to make sure that the SLD URL worked properly -
it does. Are there some things that I should do differently to
implement this sort of remote-styling?

Thanks,

Roger

--
Justin Deoliveira
The Open Planning Project
jdeolive@anonymised.com

Hi Justin,

Here's all the info I can think of that might be useful. Let me know
if you need something else.

- The layer I'm displaying is called: "topp:suit_area_h_crop6_diss"
(yeah, I was lazy and haven't created a new namespace to replace the
topp one).

- The layer contains an attribute field named, "class" which has
values that look like this:
class_0
class_1
class_2
class_3
class_4
class_5
class_6
class_7

- The SLD file is located at:
http://localhost:8080/geoserver/www/styles/generic_crop_class.sld
(verified http access)

- I simplified the SLD and removed some of the <Rules> for this
message, so it looks like this now:

<?xml version="1.0" encoding="UTF-8"?>

<StyledLayerDescriptor version="1.0.0"

  xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"

  xmlns="http://www.opengis.net/sld&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;

  xmlns:xlink="http://www.w3.org/1999/xlink&quot;

  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;

<NamedLayer>

    <Name>generic_crop_class</Name>

    <UserStyle>

      <Name>generic_crop_class</Name>

      <Title>geoserver style</Title>

      <Abstract>Generated by GeoServer</Abstract>

      <FeatureTypeStyle>

<Rule>

   <Name>Class 0</Name>

   <ogc:Filter>

     <ogc:PropertyIsEqualTo>

       <ogc:PropertyName>class</ogc:PropertyName>

        <ogc:Literal>class_0</ogc:Literal>

     </ogc:PropertyIsEqualTo>

   </ogc:Filter>

   <PolygonSymbolizer>

     <Fill>

       <CssParameter name="fill">#fef7c0</CssParameter>

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

     </Fill>

     <Stroke>

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

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

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

     </Stroke>

   </PolygonSymbolizer>

</Rule>

      </FeatureTypeStyle>

    </UserStyle>

  </NamedLayer>

</StyledLayerDescriptor>

- I'm attempting to use it in the WMS request with the following URL:
http://localhost:8080/geoserver/wms?bbox=-20.9006165504456,-37.336982917785676,53.899058246612604,19.587803077697775&styles=&Format=application/openlayers&request=GetMap&layers=topp:suit_area_h_crop6_diss&width=800&height=571&srs=EPSG:4326&SLD=http://localhost:8080/geoserver/www/styles/generic_crop_class.sld

- I also created a featuretype style in Geoserver for another,
similar, crop layer, and copied and pasted the SLD shown here into the
editor (only took the section between
<FeatureTypeStyle></FeatureTypeStyle> tags). This was to see if the
Rule worked properly, which it does.

Thanks for taking a look at this,

Roger
--

On Sat, Mar 1, 2008 at 7:25 AM, Justin Deoliveira
<jdeolive@anonymised.com> wrote:

Hi Roger,

Can you include the SLD you are using by any chance? GeoServer can have
some funny behavior sometimes depending on NamedLayer elements in a
style matching the LAYERS parameter of the request. Having both would help.

Thanks,

-Justin

Roger Andre wrote:
> I'm having some trouble getting this to work. I have a couple hundred
> layers which show different things, but which are all styled based on
> a "class" attribute. I would like to store a single SLD under the
> Geoserver www/styles dir, and call upon it via URL when any of the
> layers are displayed. To that end, I styled one of the layers the way
> I wanted it to look, and then copied the SLD for it out of the
> data_dir/styles dir, and into the www one. I then tried to test it by
> adding, "&SLD=http://localhost:8080/geoserver/www/styles/class.sld&quot; to
> the end of a regular WMS request for another layer. It didn't do
> anything, so I tested to make sure that the SLD URL worked properly -
> it does. Are there some things that I should do differently to
> implement this sort of remote-styling?
>
> Thanks,
>
> Roger

--
Justin Deoliveira
The Open Planning Project
jdeolive@anonymised.com

--
Roger André
GIS Developer/Analyst
Enterprise Management Solutions
CH2M HILL
Tel: 425.233.3042

Roger Andre ha scritto:

- The layer I'm displaying is called: "topp:suit_area_h_crop6_diss"
(yeah, I was lazy and haven't created a new namespace to replace the
topp one).

...

<NamedLayer>

    <Name>generic_crop_class</Name>

Afaik this is the issue, when you provide an external SLD, it
has to be a full definition of the map, both layer and style wise.
Try changing "generic_crop_class" with "topp:suit_area_h_crop6_diss",
this should work.

Cheers
Andrea

I see, that's interesting. So there is no way to apply a generic SLD
to multiple layers, and since applying an external SLD imposes a
performance hit (according to one of the docs on Codehaus), the best
option then remains to create a separate. internal style for each
layer.

Thanks,

Roger
--

On Mon, Mar 3, 2008 at 1:00 AM, Andrea Aime <aaime@anonymised.com> wrote:

Roger Andre ha scritto:
> - The layer I'm displaying is called: "topp:suit_area_h_crop6_diss"
> (yeah, I was lazy and haven't created a new namespace to replace the
> topp one).

...

> <NamedLayer>
>
> <Name>generic_crop_class</Name>
>

Afaik this is the issue, when you provide an external SLD, it
has to be a full definition of the map, both layer and style wise.
Try changing "generic_crop_class" with "topp:suit_area_h_crop6_diss",
this should work.

Cheers
Andrea

Roger Andre ha scritto:

I see, that's interesting. So there is no way to apply a generic SLD
to multiple layers, and since applying an external SLD imposes a
performance hit (according to one of the docs on Codehaus), the best
option then remains to create a separate. internal style for each
layer.

Yeah, you get an hit in that the SLD has to be retrieved and parsed.
Depending on how complex the SLD is, that may be negligible or visible.
And yes, the SLD standard afaik does not allow for a generic style to
be passed around, you always have to assign it to a layer.
&sld is useful is you have the need to dynamically generate styles, like
in the case where an external app does some attribute analisys and builds a style on the fly.

Cheers
Andrea

Yeah, you get an hit in that the SLD has to be retrieved and parsed.
Depending on how complex the SLD is, that may be negligible or visible.
And yes, the SLD standard afaik does not allow for a generic style to
be passed around, you always have to assign it to a layer.
&sld is useful is you have the need to dynamically generate styles, like
in the case where an external app does some attribute analisys and builds a style on the fly.

I thought this was part of the component WMS stuff? What did we end up implementing for that? Anything?

Anyways, there is some stuff going on right now to redo component WMS and perhaps recommend some improvements, i think this is on the table.

-Justin

Cheers
Andrea

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

!DSPAM:4007,47cc261f154102143011171!

--
Justin Deoliveira
The Open Planning Project
jdeolive@anonymised.com

Justin Deoliveira ha scritto:

Yeah, you get an hit in that the SLD has to be retrieved and
parsed. Depending on how complex the SLD is, that may be negligible
or visible. And yes, the SLD standard afaik does not allow for a
generic style to be passed around, you always have to assign it to
a layer. &sld is useful is you have the need to dynamically
generate styles, like in the case where an external app does some
attribute analisys and builds a style on the fly.

I thought this was part of the component WMS stuff? What did we end
up implementing for that? Anything?

We did implement component wms pretty much fully for the kml-ows5 first
part of the work, the one that took place in November on the 1.6.x
branch, so yes, we're able to style data coming from a remote WFS.

Anyways, component wms refers only to the ability to connect to a remote
wfs and style it (from the spec, component wms is defined as
"Essentially a portrayal engine that can symbolize feature data obtained
from one or more remote WFS/WCSes", page 12).

What I'm referring to in my above description has nothing to do with
it, it's just one of the standard way the &sld parameter is to be used
as described by OGC 02-07 (SLD v1.0) page 7, 8 and 9, in particular
(from page 9):

"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”.

When an SLD is used as a style library, the STYLES CGI parameter is
interpreted in the usual way in the GetMap request, except that the
handling of the style names is organized so that the styles defined in
the SLD take precedence over the named styles stored within the map
server. The user-defined SLD styles can be given names and they can be
marked as being the default style for a layer. To be more specific, if a
style named “CenterLine” is referenced for a layer and a style with that
name is defined for the corresponding layer in the SLD, then the SLD
style definition is used. Otherwise, the standard named-style mechanism
built into the map server is used. If the use of a default style is
specified and a style is marked as being the default for the
corresponding layer in the SLD, then the default style from the SLD is
used; otherwise, the standard default style in the map server is used."

Hope this helps
Cheers
Andrea