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.

I have a system built on PostGIS/GeoServer/OpenLayers. Data (a ship's voyage track) is inserted into the database in real-time - a bunch of variables and point geometry type. This is served up via (primarily) WFS to OpenLayers.

I dynamically publish the layer for a new voyage using REST. When done this way, the bounding box (according to the config page) is set to 0,0,-1,-1 for both native and lat/long.

What I'd like to do is set this to a reasonable value programmatically - effectively automating going in and using the 'Compute from Data'/'Compute from Native Bounds' links on the layer config page.

My preference is to do this via a RESTful call, however this doesn't seem to be supported in the current version of the standard API. Any other alternative solutions are more than welcome.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

This is already an old question, but I haven't found many example documenting this on he Web. On GeoServer version 2.5.1 the following should work (it should also work with older versions). :

Example XML

<layerGroup>

<workspace>workspace</workspace>
<name>014531_layer_group</name>
<layers>
<layer>014531_layer</layer>
<layer>014531_layer_watermark</layer>
</layers>
<styles>
<style>raster</style>
<style>sld_watermark</style>
</styles>
<bounds>
<minx>12.91</minx>
<miny>-6.97</miny>
<maxx>14.32</maxx>
<maxy>-5.44</maxy>
<crs>EPSG:4326</crs>
</bounds>
</layerGroup>

Example REST statement

sudo curl -v -u user:pwd -XPOST -d @yourxmlfile.xml -H "Content-type: text/xml" http://localhost:8080/geoserver/rest/layergroups

It doesn't take the bounding box of the underlying layer, but you could retrieve it by using a Selenium script

share|improve this answer
    
Thanks very much for the response, looks good! –  Caligari Jun 25 at 4:31
add comment

Configure one layer by hand and see what the parameters in the REST xml representation are, then do the same when configuring the new layer (or as an update, after configuring it). Always remember to add true to your representations, otherwise the layer will be disabled

share|improve this answer
add comment

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.