[Geoserver-users] Changing dynamically SLD using php

hi everybody,
I thought it was easier to implement dynamic SLD using php and passing them
the parameters, but it doesn't work (for the moment ;.).

You can check you can create a dynamic SLD changing a GET parameter called
state (for example, change state=Florida) to
http://edit.csic.es/gmap/states_filter.php?state=Arizona

The SLD generated works if you attach it to topp:states Feature Type.

But when I'm trying to dynamically get a GetMap and, adding to the URL
SLD=http://…states_filter.php?state=Florida (or whatever US state), the
result is allways the same (Arizona). I suppose it's because I've attached a
SLD style that higlights Arizona, but I HAVE TO have a SLD associated to the
states feature type, otherwise you can't even create the states Feature
Type.
Here is the URL:

http://edit.csic.es:8080/geoserv/wms?bbox=-127.61950064999999,23.7351786,-64.08177035,50.592523400000005&styles=&Format=application/openlayers&request=GetMap&layers=topp:states&width=800&height=317&srs=EPSG:4326&sld=http://localhost/gmap/states_filter.php?state=Florida

Thanks to everybody,

Pere Roca

--
View this message in context: http://www.nabble.com/Changing-dynamically-SLD-using-php-tf4482349.html#a12781786
Sent from the GeoServer - User mailing list archive at Nabble.com.

pere roca ha scritto:

hi everybody, I thought it was easier to implement dynamic SLD using php and passing them
the parameters, but it doesn't work (for the moment ;.).

You can check you can create a dynamic SLD changing a GET parameter called
state (for example, change state=Florida) to
http://edit.csic.es/gmap/states_filter.php?state=Arizona

The SLD generated works if you attach it to topp:states Feature Type.

But when I'm trying to dynamically get a GetMap and, adding to the URL SLD=http://…states_filter.php?state=Florida (or whatever US state), the
result is allways the same (Arizona). I suppose it's because I've attached a
SLD style that higlights Arizona, but I HAVE TO have a SLD associated to the
states feature type, otherwise you can't even create the states Feature
Type.
Here is the URL:

http://edit.csic.es:8080/geoserv/wms?bbox=-127.61950064999999,23.7351786,-64.08177035,50.592523400000005&styles=&Format=application/openlayers&request=GetMap&layers=topp:states&width=800&height=317&srs=EPSG:4326&sld=http://localhost/gmap/states_filter.php?state=Florida

This URL is wrong in that you specify both SLD and layers. You can't.
When you provide your own SLD, it must be complete of all the layers
you want to be depicted, in other terms, it must be a complete
replacement of the usual layers and styles parameters (which have to
be removed from the request).

The SLD you provide is wrong in that it does not provide a valid name
for the UserLayer, which *must* match a layer name.

So the request must be like this, without neither layers and styles:
http://localhost:8080/geoserver/wms?bbox=-127.61950064999999,23.7351786,-64.08177035,50.592523400000005&format=application/openlayers&request=GetMap&width=800&height=317&srs=EPSG:4326&sld=http://edit.csic.es/gmap/states_filter.php?state=Arizona
and the sld must be like the one you generate, but with the proper layer
name:

<NamedLayer>
<Name>topp:states</Name>

You are probably getting sidetracked by how the styles in the GeoServer
configuration are set up. These are treated in a special way, so that
you can apply them to multiple layers: basically the featuretypestyle
part of the SLD is taken into consideration there.
We have that latitude because the WMS standard does not impose a behaviour on how you handle internal styles (they don't even need
to be specified in SLD format, see MapServer, it uses its own format),
but when working against externally provided SLD, the standard must
be followed by the letter.

Hope this helps
Cheers
Andrea