If you don't mind having your styles reliant on nonstandard functionality,
then you could use parameter substitution.  See the documentation:

http://docs.geoserver.org/stable/en/user/styling/sld-extensions/substitution.html

--
David Winslow
OpenGeo - http://opengeo.org/

On Wed, May 11, 2011 at 8:00 AM, Jon-Paul Dobson <[email protected]>wrote:

> Hi Hari,
>
> Th ultimate aim is to be able to colour layer symbols on-the-fly. So for
> example I may have a layer based on a Shape file for which the symbols are
> circles. I need to be able to change the colour of each circle
> programmatically. I do not want to use predefined styles for this as there
> are potentially any number of colours to choose from. I also do not want to
> alter a single SLD file as the colours may be different for each user that
> is logged into the application. If I altered the SLD file then every user
> would see the same colours.
>
> Any ideas about this? Is this even possible?
>
> I guess you could also create a temporary SLD file, populate appropriately,
> assign the layer to this SLD file, then delete the temporary SLD file but I
> think there would be performance problems with this and it seems a bit
> hacky.
>
> Ideally there should be a way to pass the raw SLD XML directly to geoserver
> without needing to save the SLD to a file but I don't think this is
> possible. This is how ESRI ArcIMS use to work using it's AXL.
>
> I'll certainly check out the link you provided so thanks for that.
>
> Regards,
> Jon-Paul.
>
>
> On Wed, May 11, 2011 at 12:39 PM, Harikumar Reddy <[email protected]>wrote:
>
>> Hi Jon-Paul,
>>
>> Can you please explain a bit more about your requirement. i will try to
>> think of possibility. Geoserver has been enhanced a lot since version 2.x.
>>
>> You can check out presentation by Andrea Aime from OpenGeo. It has really
>> very useful information regarding SLD.
>>
>> http://2010.foss4g.org/presentations_show.php?id=3588
>>
>> Regards,
>> Hari.
>>
>>
>> On Wed, May 11, 2011 at 4:15 PM, Jon-Paul Dobson <[email protected]>wrote:
>>
>>> Hi Harikumar,
>>>
>>> Thanks for the detailed answer. The problem is that the style I want to
>>> use isn't known until run-time, so it would not be possible to use
>>> pre-defined styles. I want to for example change a symbols colour based on a
>>> database field value which can change over time. This means it wouldn't be
>>> be possible to use a fixed SLD file. Do you know if it's possible to do this
>>> at all? Is there a way to pass the SLD XML directly to GeoServer without
>>> needing to use file?
>>>
>>> Best regards,
>>> Jon-Paul.
>>>
>>>   On Wed, May 11, 2011 at 11:01 AM, Harikumar Reddy <[email protected]
>>> > wrote:
>>>
>>>> Hi,
>>>>
>>>> I may not provide more insight than given below (provided information
>>>> whatever is known to me)., but i hope you will get clarity how to implement
>>>> dynamic sld for gis layers for multi lingual webgis applications.
>>>>
>>>> We can assign more than one styles to a GIS layer (but default SLD will
>>>> be selected during geoserver layers configuration..for ex:- polygon for
>>>> polygon layers, line for road layers, or point for point features). You may
>>>> write need to write code in the program similar to given below.
>>>>
>>>> Note: even though default SLD is configured in Geoserver, required sld
>>>> to be applied should be present in geoserver. naming of such sld like given
>>>> below will not confuse developers while coding.
>>>>
>>>> The slds respective to each layer as follows.
>>>>
>>>>    *layer*
>>>>
>>>> *sld*
>>>>
>>>> * *
>>>>
>>>> *English*
>>>>
>>>> *Hindi
>>>> *
>>>>
>>>>
>>>>  gis:gis_sea
>>>>
>>>> gis_sea
>>>>
>>>> gis:gis_country
>>>>
>>>> gis_country
>>>>
>>>> gis:gis_footprint
>>>>
>>>> gis_footprint
>>>>
>>>> gis:gis_buildings
>>>>
>>>> gis_buildings
>>>>
>>>>
>>>>
>>>>  gis:gis_city
>>>>
>>>> gis_city_en
>>>>
>>>> gis_city_hnd
>>>>
>>>> gis:gis_district
>>>>
>>>> gis_district_en
>>>>
>>>> gis_district_hnd
>>>>
>>>> gis:gis_towns
>>>>
>>>> gis_towns_en
>>>>
>>>> gis_towns_hnd
>>>>
>>>> gis:gis_roads
>>>>
>>>> gis_roads_en
>>>>
>>>> gis_roads_hnd
>>>>
>>>> if require, pass specific sld's as in order to apply dynamic styles to
>>>> the respective layer locale selected.
>>>>
>>>> Eq 1 :
>>>> ....
>>>> ....
>>>> map = new OpenLayers.Map ("map",options);
>>>>   var layers ='gis:gis_ind,'+
>>>> 'gis_footprint,'+
>>>>     'gms_landmarks,'+
>>>>     'gis:gis_towns,'+
>>>>     'gis:gis_roads,'+
>>>>     'gms:gms_point_of_interest';
>>>> var slds ='gis_ind,' +
>>>>    'gis_footprint,'+
>>>>      'gms_landmarks,'+
>>>>      'gis_towns_'+ locale +','+
>>>>      'gis_roads_'+ locale +','+
>>>>      'gms_POI_'+ locale;
>>>>         var layer = new OpenLayers.Layer.WMS( "ind WMS", wmsUrl,{
>>>>            layers: layers,
>>>>              styles: slds,
>>>>              srs: 'EPSG:4326',format: 'image/png'},{'attribution': '©
>>>> 2009 Mapview'},{buffer: 0});
>>>>   map.addLayer( layer );
>>>>
>>>> Eq 2 :
>>>> ....
>>>> ....
>>>> map = new OpenLayers.Map ("map",options);
>>>>     var layer1 = new OpenLayers.Layer.WMS( "Layer1", wmsUrl,{
>>>>            layers: 'gis:gis_ind',
>>>>              styles: 'gis_ind',
>>>>              srs: 'EPSG:4326',format: 'image/png'},{'attribution': '©
>>>> 2009 Mapview'},{buffer: 0});
>>>> var layer2 = new OpenLayers.Layer.WMS( "Layer2", wmsUrl,{
>>>>            layers: 'gis:gis_towns',
>>>>              styles: 'gis_towns_'+ locale,
>>>>              srs: 'EPSG:4326',format: 'image/png'},{'attribution': '©
>>>> 2009 Mapview'},{buffer: 0});
>>>>   map.addLayers( [layer1, layer2] );
>>>> In this example, the locale javascript object gets the respective
>>>> language as 'en' or 'ar' and applies language specific style to the layer.
>>>>
>>>>
>>>> @ Hari
>>>>
>>>>
>>>>   On Wed, May 11, 2011 at 2:13 PM, Jon-Paul Dobson <
>>>> [email protected]> wrote:
>>>>
>>>>>   Hi,
>>>>>
>>>>> Is there anyway to change layer styles on-the-fly other than to alter
>>>>> the .SLD xml file? In our application I want to allow users to have the
>>>>> ability to set personal layer styles e.g. colour, symbol etc.Is this
>>>>> possible at all?
>>>>>
>>>>> If the only way to change styles is to alter the .SLD file, then this
>>>>> means that layer styles must be set at the global level and personal
>>>>> preferences per user would not be possible.
>>>>>
>>>>> Regards,
>>>>> Jon-Paul.
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Achieve unprecedented app performance and reliability
>>>>> What every C/C++ and Fortran developer should know.
>>>>> Learn how Intel has extended the reach of its next-generation tools
>>>>> to help boost performance applications - inlcuding clusters.
>>>>> http://p.sf.net/sfu/intel-dev2devmay
>>>>> _______________________________________________
>>>>> Geoserver-users mailing list
>>>>> [email protected]
>>>>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>>>>
>>>>>
>>>>
>>>
>>
>
>
> ------------------------------------------------------------------------------
> Achieve unprecedented app performance and reliability
> What every C/C++ and Fortran developer should know.
> Learn how Intel has extended the reach of its next-generation tools
> to help boost performance applications - inlcuding clusters.
> http://p.sf.net/sfu/intel-dev2devmay
> _______________________________________________
> Geoserver-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>
>
------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to