Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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.

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

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.

share|improve this answer
    
hi Zach, this is great but it seems that once you have done that the layer in question becomes disabled... any idea why and if this can be avoided? –  Barnabe Jul 19 '11 at 8:37
    
i have seen the same issue (disabled layer post curl rest API call) here geoserver-devel.821594.n3.nabble.com/… –  Barnabe Jul 19 '11 at 8:38
    
answer might be this: jira.codehaus.org/browse/… –  Barnabe Jul 19 '11 at 8:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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