[GIS] How to generate SLD programmatically

geoserverjavaopenlayers-2sld

Is there any api,pulgin for generating SLD?

Note:
I want to generate SLD programatically. I have property stored in database from which i would like to generate sld. I also want to generate various different tag according to geometry type like polygon, line or point.

Currently I am going xml way.

Edit:

I am looking for all the ways that I could generate SLD. So I have tagged the question with java and openlayers. It may be client side by openlayers or server side by java. I don't want to concatenate string or genrate xml. Is there any other way then this?

I have layers with multiple columns or I have multiple tables with multiple columns. Now I want to set predefined parameters like point size point color or polygon size and color in database and create SLD.

I want to use SLD with openlayers. Generating xml is fine but I wanted to know if there are other good ways.

var sld = '<StyledLayerDescriptor version ="1.0.0" ...> more xml here </StyledLayerDescriptor>';  

wms = new OpenLayers.Layer.WMS.Post(
   "name",
   "http://localhost:8080/geoserver/wms",
   {
      'layers': 'myNs:layername',
      format: 'image/jpeg',
      sld_body: sld
   },
   {
      unsupportedBrowsers: []
   }
);

Best Answer

You can create SLD programmatically using the GeoTools SLD module. For more details work through the tutorial particularly the Creating styles By Hand section.

Related Question