2

I am setting the SLD Body of a WMS layer on the client side. I set the style in JSON and I have some functions that convert the JSON to SLD (OpenLayers functions). It works fine for displaying the layer with all its colors.

But when I use a legend (GetLegendGraphic from GeoServer), I have a limit in the size of the SLD Body. The limit of characters is about 20.000. When I perform the GetLegendGraphic request and the url is longer than (about) 20.000 characters, an error occurs and the legend is not displayed. BUT the layer is still correctly displayed (as you can see in the images below).

Below the 20.000 characters, the legend works fine.

I find it strange that the layer is correctly displayed and the legend isn't. Both are fetched via GeoServer requests.

Could you help me solve this?

I wanted a way to accept long strings in the GetLegendGraphic or a way to compress the string with the SLD body (so that it has fewer characters).

EXAMPLES:

SLD Body with 18006 characters (this shows a correct legend)

GOOD

SLD Body with 24245 characters (this does not show the legend, still draws the layer correctly)

BAD

4
  • 3
    What's your server setup? It's probably not actually a GeoServer issue, but rather a Tomcat/Jetty/Apache/??? issue.
    – stuporglue
    Commented Jan 22, 2015 at 20:30
  • 1
    Also, can you prepare the SLD body and then save it to the server as a named style so you can just refer to the style, or is it dynamic somehow?
    – stuporglue
    Commented Jan 22, 2015 at 20:32
  • 2
    Hi @stuporglue. Your tip about configuring the Tomcat server solved the problem. We increased the 'maxPostSize' in the Tomcat configuration. Thank you so much. You deserve some points for giving the answer. Thanks. :D
    – joaorodr84
    Commented Jan 22, 2015 at 22:43
  • 1
    Glad to help out!
    – stuporglue
    Commented Jan 23, 2015 at 6:14

1 Answer 1

1

You could post the sld to a php-file which writes a sld-file on the server(considering some security aspects). Then you could point to this file:

Example: 4 times the same layer, getlegendgraphic with 4 different sld's:

http://suite.opengeo.org/geoserver/wms?TRANSPARENT=true&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&SLD=https://raw.githubusercontent.com/boundlessgeo/suite-data/master/default/styles/states.sld&EXCEPTIONS=application/vnd.ogc.se_xml&LAYER=usa:states&FORMAT=image/png&width=150&height=50

http://suite.opengeo.org/geoserver/wms?TRANSPARENT=true&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&SLD=https://raw.githubusercontent.com/ROGUE-JCTD/COPECO-Layers/master/Layers/edificios/polygon.sld&EXCEPTIONS=application/vnd.ogc.se_xml&LAYER=usa:states&FORMAT=image/png&width=150&height=50

http://suite.opengeo.org/geoserver/wms?TRANSPARENT=true&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&SLD=https://raw.githubusercontent.com/opengeogroep/NLExtract/master/top10nl/style/sld/jw_van_aalst/Top10NL-Gebouw_vlak_(kas).sld&EXCEPTIONS=application/vnd.ogc.se_xml&LAYER=usa:states&FORMAT=image/png&width=150&height=50

http://suite.opengeo.org/geoserver/wms?TRANSPARENT=true&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetLegendGraphic&SLD=https://gist.githubusercontent.com/dwins/425748/raw/67e7c243b23a20f9bc78cb1b26b30834a6925b52/planet_polygon.sld.xml&EXCEPTIONS=application/vnd.ogc.se_xml&LAYER=usa:states&FORMAT=image/png&width=150&height=50

Or as user stuporglue mentioned you could use geoservers rest interface but there you would have to consider how to erase unused styles again: http://docs.geoserver.org/stable/en/user/rest/examples/curl.html

1
  • Thanks @Thomas, but the solution proposed by stuporglue worked like a charm. :)
    – joaorodr84
    Commented Jan 23, 2015 at 1:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.