3

Say I have a layer L in Geoserver to which i attach a style S (in the GS backend i published L using S). Of course, If I use the style editor in the GS backend and change the SLD for S and then 'submit' the new style, my layer looks different next time I load it in a browser.

Now, I am planning to re-generate the SLD for S regularly directly into the Geoserver styles folder using php : each time the database has a new entry, it is queried, the appropriate style/legend is calculated and my php is parsed and prints the SLD code for S in the styles folder, overwriting the previous version of S in the process. It does not work, i.e. if I modify or overwrite S directly in the styles folder and then reload my layer in a browser the style is not updated.

Hence my question: what does the 'submit' button in the GS backend style editor do and how can it be simulated using code instead of manually.

Hope this makes sense. Thanks for your help. B

2 Answers 2

3

U can use the geoserver restful interface to change all the catalog objects on-the-fly including styles. Check the documentation for examples, its quite straigthfoward.

curl -u admin:geoserver -XPUT -H 'Content-type: application/vnd.ogc.sld+xml' -d @roads.sld http://localhost:8080/geoserver/rest/styles/roads_style

where "roads.sld" is a file with all the SLD xml content.

2
  • 2
    Hi Pedro. Could you extend your answer with a short example maybe?
    – underdark
    Jul 2, 2011 at 16:48
  • Thanks! just where i needed to look. i think i can call curl from inside PostgreSQL. ideal!
    – Barnabe
    Jul 6, 2011 at 16:46
3

The link to the rest interface curl examples: http://docs.geoserver.org/2.0.0/user/extensions/rest/rest-config-examples-curl.html If you upload the stylesheet through the rest API, it will be reloaded.

3

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.