Figured this out...  by some tweaks to the REST magic words needed.

In case it helps someone else, here's how it finally worked:

1.  Delete the existing coverage (if any)

curl -s -o /dev/null -k -u %CRED% -XDELETE
%HOST%/rest/workspaces/%WS%/coveragestores/%COV%?recurse=true

2. Create the coverage store from the server-resident file (which
automatically creates a coverage as well)

curl -f -k -u %CRED% -XPUT -H "Content-type: text/plain" -d "file://%FILE%"
%HOST%/rest/workspaces/%WS%/coveragestores/%COV%/external.geotiff

3. Set the SRS and enable the coverage:

curl -s -k -u %CRED% -XPUT -H "Content-type: text/xml" -d
"<coverage><srs>EPSG:3005</srs><enabled>true</enabled></coverage>"
%HOST%/rest/workspaces/%WS%/coveragestores/%COV%/coverages/%COV%

(Of course this was done in a cmd script with oodles of baroque error
checking - exercise left for the student)

On a side note, once again I needed to puzzle out the differences between
the GeoServer internal information model (as revealed by the REST API) and
the GUI terminology (which hides some of the internal concepts such as
FeatureTypes and Coverages).  I always feel that a Logical Domain Model
diagram would help with understanding this, and perhaps also some mention
in the UI docs about what is going on under the hood.


On Tue, Aug 1, 2017 at 2:43 PM, Martin Davis <mtncl...@gmail.com> wrote:

> I am trying to create a CoverageStore and Coverage layer from a TIF file
> staged on the Geoserver server, using the REST API.  As per this suggestion
> [1] I'm using an adaption of the technique in:
>
> http://docs.geoserver.org/latest/en/user/rest/workspaces.html#adding-an-
> existing-shapefile
>
> This works - almost.  The resulting coverage is created, but it has no
> Declared SRS, probably because the backing raster file does not have SRS
> information stored in it (i.e. it's a TIF, not a GeoTIFF).
>
> Is there a way I can set the Declared SRS via the REST API?
>
> I've tried the obvious route of POSTing the following partial resource:
>
> <coverage><name>%COV%</name><srs>EPSG:3005</srs></coverage>
>
> to
>
> %HOST%/rest/workspaces/%WS%/coveragestores/%COV%/coverages
>
> but this had no effect.
>
> [1] https://gis.stackexchange.com/questions/37779/adding-a-
> new-coveragestore-in-a-certain-workspace-by-rest
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to