Hi,
as part of the NY code sprint I'm working on variable substitution
in SLD, that is, the ability to name some parameters in SLD and then
pass their values from the query string.
For SLD I'm gong to use Michael's "env" filter function, that
can be called like this from within the SLD:
<Function name="env">
<Literal>myParam</Literal>
</Function>
or like this:
<Function name="env">
<Literal>myParam</Literal>
<Literal>15</Literal>
</Function>
where 15 is the default value in case myParam was not available
in the environment map.
That map is setup per thread and I intend to fill it with key/value
pairs coming from the request string:
&env=myParam:2;otherParam:abcd;...
using the same syntax we already use for FORMAT_OPTIONS
How does this sound?
Cheers
Andrea
It seems great! Just like something that was discussed here some time ago..
http://old.nabble.com/Dynamic-Symbolizers---CQL-Expressions-ts21419779.html#
a21419779
Regards,
P Mendes
-----Mensagem original-----
De: Andrea Aime [mailto:aaime@anonymised.com]
Enviada: segunda-feira, 22 de Fevereiro de 2010 15:55
Para: Geoserver-devel
Assunto: [Geoserver-devel] Variable substitution in SLD
Hi,
as part of the NY code sprint I'm working on variable substitution
in SLD, that is, the ability to name some parameters in SLD and then
pass their values from the query string.
For SLD I'm gong to use Michael's "env" filter function, that
can be called like this from within the SLD:
<Function name="env">
<Literal>myParam</Literal>
</Function>
or like this:
<Function name="env">
<Literal>myParam</Literal>
<Literal>15</Literal>
</Function>
where 15 is the default value in case myParam was not available
in the environment map.
That map is setup per thread and I intend to fill it with key/value
pairs coming from the request string:
&env=myParam:2;otherParam:abcd;...
using the same syntax we already use for FORMAT_OPTIONS
How does this sound?
Cheers
Andrea
----------------------------------------------------------------------------
--
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geoserver-devel mailing list
Geoserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-devel
Pedro Mendes wrote:
It seems great! Just like something that was discussed here some time ago..
http://old.nabble.com/Dynamic-Symbolizers---CQL-Expressions-ts21419779.html#
a21419779
Yep. That's the main reason I chose this topic for the sprint, it is not taking much time to implement and I've seen people looking for it
Cheers
Andrea
Andrea Aime wrote:
Hi,
as part of the NY code sprint I'm working on variable substitution
in SLD, that is, the ability to name some parameters in SLD and then
pass their values from the query string.
Ok, implemented it (patch at http://jira.codehaus.org/browse/GEOS-3825).
Here is how a parametrized SLD looks like:
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
<NamedLayer>
<Name>layer</Name>
<UserStyle>
<Name>Parametrized style</Name>
<FeatureTypeStyle>
<Rule>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>
<ogc:Function name="env">
<ogc:Literal>name</ogc:Literal>
<ogc:Literal>square</ogc:Literal>
</ogc:Function>
</WellKnownName>
<Fill>
<CssParameter name="fill">
#<ogc:Function name="env">
<ogc:Literal>color</ogc:Literal>
<ogc:Literal>FF0000</ogc:Literal>
</ogc:Function>
</CssParameter>
</Fill>
</Mark>
<Size>
<ogc:Function name="env">
<ogc:Literal>size</ogc:Literal>
<ogc:Literal>6</ogc:Literal>
</ogc:Function>
</Size>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
I've parametrized 3 elements, the mark name, the fill color
and the mark size, all with fallbacks so that the sld still
works even when none of the params is specified.
The syntax is obviously verbose, but compliant (well, minus
calling a function in the WellKnownName element, OGC
decided that should just be a literal).
A WMS request specifying none of the params will looks like
the attached bugsites-basic.png file, whilst adding in the
request env=color:0000FF;size:8;name:circle will result in
bugsites-params.png.
Of course you can put a param in any place where a function
can be called, which means css params, sizes, and even in
the rule filters (but not in the scale denominators).
I just need some feedback on the case sensitiveness issue
reported in the jira above before committing (and eventually
see how other people feel about it).
Cheers
Andrea
(attachments)

