1

I'm currently using GeoServer REST API in my Django/Python application to make such routine operations as creating workspaces, raster stores and layers. This is how it looks like in my code:

# create "my_workspace" workspace
requests.post("http://localhost:8085/geoserver/rest/workspaces", 
              data="<workspace><name>my_workspace</name></workspace>", 
              headers={"Content-Type": "text/xml"}, 
              auth=("admin", "password")) 

# create raster store
requests.post("http://localhost:8085/geoserver/rest/workspaces/my_workspace/coveragestores?configure=all", 
data="<coverageStore><name>my_layer_store</name><workspace>my_workspace</workspace><enabled>true</enabled><type>ImagePyramid</type><url>file:C:/path_to_data/"</url></coverageStore>", 
headers={"Content-Type": "text/xml"}, auth=("admin", "password"))

# and finally, let's create a layer:
requests.post("http://localhost:8085/geoserver/rest/workspaces/my_workspace/coveragestores/my_layer_store/coverages?recalculate=nativebbox", 
data="<coverage><name>my_layer</name><title>my_layer</title><srs>EPSG:4326</srs></coverage>", 
headers={"Content-Type": "text/xml"}, auth=("admin", "password"))

In the GeoServer UI I see a separate operation to Publish a layer. However, in my case, when I create a layer I see, that I can watch how it looks like, say, in OpenLayers. So, it seems like my layer gets published automatically. And I do not like it. I want to have a separate REST API operation to publish a layer, and I do not want my layer to be automatically published as a result of layer creation operation. So, how can I achieve this?

  • So, are there Publish and Unpublish operations in GeoServer REST API? And how to create a layer in an unpublished state? – Jacobian Dec 5 '16 at 10:12
3

You have to publish it, but mark it "non advertised" so that it does not show up in the capabilities documents, but it's still requestable for those that know the layer name and can build a manual GetMap/OpenLayers client.

See: http://docs.geoserver.org/latest/en/user/data/webadmin/layers.html#edit-layer-publishing

There is an equivalent flag at the REST level, try configuring one from the UI and grab its XML description from REST, you'll see the flag.

  • Right after layer creation, when I go to the layer settings, I see that it is already Enabled and Advertised. So in fact I do not need to publish it, because it is already published. And now I wonder, is it possible to create a layer and not publish it in advance. In other word how should my xml-body look like to do this. And the second corresponding question, is how to publish the layer later on? How should my POST command look like? Will it be the very same creation command just with a liitle bit different xml-body or will it be completely different command, that is reserved for publishing? – Jacobian Dec 5 '16 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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