On Wed, Mar 16, 2011 at 11:09 PM, David Winslow <[email protected]> wrote:
> I don't think that the OGC filter spec allows using a function to determine
> a propertyname the way you describe.  I believe GeoServer's if/then/else
> could help if you really want to avoid repeating your styles (it is
> implemented as a filter function).
> However, the new SQL views functionality should make it pretty easy - you
> can make a parameterized view
> (http://docs.geoserver.org/stable/en/user/data/sqlview.html#parameters-and-validation)
> and build your layer off of a SQL query like:
> SELECT the_geom, %year% as year from my_real_table;
> and include "viewparams=year:y2005" in requests to specify the year to use.
> Your SLD would simply reference the "year" property.

Yep, this should work. Just one word of caution about templating the return part
of the sql view: the structure of the returned record must be the same no matter
what the param values are.

In this case the colums have the same data type and David was smart to alias
them so that the column name would not change either, so it should work.

Just a reminder that in general one cannot add/remove column or change their
nature using the viewparams (GS feature type handling will break if
you do that),
so using viewparams in the select part of the query must be done with care

Cheers
Andera

> --
> David Winslow
> OpenGeo - http://opengeo.org/
> On Wed, Mar 16, 2011 at 11:24 PM, N L <[email protected]> wrote:
>>
>> Hello!
>>
>> I've got a layer with several columns like "y2005","y2006","y2007" and so
>> on which represent population for a particular year.
>> I want to be able to pass the column name to SLD in WMS request to tell
>> the server to colour the features according to the year that user has
>> defined.
>>
>> Is there any way to pass this parameter to the server?
>> Or do i have to make tons of sld styles which are almost the same and the
>> only difference is the value of  <ogc:PropertyName> tag.
>>
>> Thank you.
>>
>>
>> ------------------------------------------------------------------------------
>> Colocation vs. Managed Hosting
>> A question and answer guide to determining the best fit
>> for your organization - today and in the future.
>> http://p.sf.net/sfu/internap-sfd2d
>> _______________________________________________
>> Geoserver-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>
>
>
> ------------------------------------------------------------------------------
> Colocation vs. Managed Hosting
> A question and answer guide to determining the best fit
> for your organization - today and in the future.
> http://p.sf.net/sfu/internap-sfd2d
> _______________________________________________
> Geoserver-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>
>



-- 
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy

phone: +39 0584 962313
fax:      +39 0584 962313
mob:    +39 333 8128928

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-------------------------------------------------------

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to