I create programmatically a layer in PostGIS and Geoserver. I give the option to the user to choose the geometry and the attributes and then I create the table in PostGIS and add it in an existing store in Geoserver.
The layer, as initialized, it gets a global Bounding Box.
Then the user is able to add specific data. What I want is to be able to recalculate the Bounding Box depending on the data, so when I show the map on Leaflet to show only the selected area.
I need to do that programmatically using the Rest API.
I haven't found anything like this for single layers (not layergroups) and also for WMS layers.
Does anyone has any experience on it?
Best Answer
You need to
PUT
an updatedFeatureType
document with the new bounding box set in it.So your workflow is something like:
Then edit the Bounding box to your new value and delete the lat/lon bounding box and
PUT
it back:GeoServer will automatically recalculate the lat/lon bounding box for you. There is also a recalculate parameter you can use to force the recalculation of the bounding boxes if you prefer but this may be much slower if you have a large table.