Hi Panagiotis,
REST is used to avoid the need to go through the GUI.
please, see my feedbacks inlined below...

On Fri, Mar 29, 2019 at 11:13 AM Panagiotis Kountouris <
kountou...@driftnoise.com> wrote:

> Good day list members,
>
> I am trying (amateur level) to use the REST interface, to publish an
> image-mosaic (works) and a single geotiff (still not working) layers via a
> WMS service.
>
> I would kindly ask your feedback if this is the correct way to do that,
> and what am i doing wrong for the single geotiff case:
>
> *For the Image mosaic:* I created with the GUI a workspace ("MYWSP") and
> a datastore (MYMSC) using the ImageMosaic plugin. I set also a data
> location folder where it is updated regularly. For some reason I was not
> able to just update the mosaic. So my workaround was to delete the
> coveragestore, and the files which contain the shp information and the
> *.properties of the mosaic. Then, I recreate it, every time there is new
> data available:
>
> curl -v -u admin:pswd -XDELETE
> http://localhost:8080/geoserver/rest/workspaces/MYWSP/coveragestores/MYMSC?recurse=true
>
> curl -v -u admin:pswd -XPUT -H "Content-type: text/plain" -d
> file:///data/geoserver/data/mosaic
> http://localhost:8080/geoserver/rest/workspaces/MYWSP/coveragestores/MYMSC/external.imagemosaic
>
> This seems to work fine although I am not sure this is the proper way..
>
Could you please provide some more details about "For some reason I was not
able to just update the mosaic"?
(As a note, when doing multiple attempts when creating a new imageMosaic
via REST make sure you don't have partially configured or already existing
layers/stores).

In theory, once you have a workspace defined, you should be able to create
a new ImageMosaic via PUT.
https://docs.geoserver.org/latest/en/user/rest/imagemosaic.html#uploading-a-new-image-mosaic


Afterwards, you may add new granules or update the mosaic, via POST.
https://docs.geoserver.org/latest/en/user/rest/imagemosaic.html#updating-an-image-mosaic-contents



> *For the single geotiff:* I created a datastore (MYGT) using the GeoTIFF
> plugin. With the GUI i can create also a layer "mylayer" which displays the
> single geotiff file. I tried to update via REST the layer but no success:
>
> curl -v -u admin:pswd -XPUT -H "Content-type: image/tiff" --data-binary
> file:///data/geoserver/data/sic/test.tiff
> http://localhost:8080/geoserver/rest/workspaces/MYWSP/coveragestores/MYGT/external.geotiff
> <http://localhost:8080/geoserver/rest/workspaces/MYWSP/coveragestores/MYGT/file.geotiff>
>
> I tried also the file.geotiff instead of the external.geotiff with no
> success. Its unclear to me how one should use those extensions, and I could
> not find any related information.
>
In order to configure a GeoTIFF you just need to send the CURL command with
no need to do other things through the GUI.
Provided that you already have a defined workspace (MYWSP), the sample
commands I tested right now are:

curl -v -u admin:geoserver -XPUT --data-binary @sampledata.tif
http://localhost:8080/geoserver/rest/workspaces/MYWSP/coveragestores/MYGEOTIFF/file.geotiff

curl -v -u admin:geoserver -XPUT -d file://D:/data/geotiff/sampledata.tif
http://localhost:8080/geoserver/rest/workspaces/MYWSP/coveragestores/MYGEOTIFF2/external.geotiff

Quoting form the GeoServer doc:
https://docs.geoserver.org/latest/en/user/rest/api/datastores.html#workspaces-ws-datastores-ds-file-url-external-extension


*These endpoints (file, url, and external) allow a file containing either
spatial data [...] to be added (via a PUT request) into an existing data
store, or will create a new data store if it doesn’t already exist. The
three endpoints are used to specify the method that is used to upload the
file:*

*file—Uploads a file from a local source. The body of the request is the
file itself.*
*url—Uploads a file from an remote source. The body of the request is a URL
pointing to the file to upload. This URL must be visible from the server.*
*external—Uses an existing file on the server. The body of the request is
the absolute path to the existing file.*

Whilst the extension parameter
https://docs.geoserver.org/stable/en/user/rest/api/coveragestores.html#extension

*specifies the type of coverage store. The following extensions are
supported:*

*Extension Coverage store*
*geotiff         GeoTIFF*
*worldimage Georeferenced image (JPEG, PNG, TIFF)*
*imagemosaic Image mosaic*

Please, let us know.
Regards,
Daniele


> Here is the output from the last curl command:
>
> *   Trying 127.0.0.1...
> * TCP_NODELAY set
> * Connected to localhost (127.0.0.1) port 8080 (#0)
> * Server auth using Basic with user 'admin'
> > PUT
> /geoserver/rest/workspaces/MYWSP/coveragestores/MYGT/external.geotiff
> HTTP/1.1
> > Host: localhost:8080
> > Authorization: Basic YWRtaW46czNjcjN0
> > User-Agent: curl/7.52.1
> > Accept: */*
> > Content-type: image/tiff
> > Content-Length: 72
> >
> * upload completely sent off: 72 out of 72 bytes
> < HTTP/1.1 201
> < X-Frame-Options: SAMEORIGIN
> < Content-Disposition: inline;filename=f.txt
> < Content-Type: application/xml
> < Transfer-Encoding: chunked
> < Date: Fri, 29 Mar 2019 08:56:34 GMT
> <
> <coverageStore>
>   <name>MYGT</name>
>   <description>test data</description>
>   <type>GeoTIFF</type>
>   <enabled>true</enabled>
>   <workspace>
>     <name>MYWSP</name>
>   </workspace>
>   <__default>false</__default>
>   <url>file:/data/geoserver/data/sic/test.tif</url>
> * Curl_http_done: called premature == 0
> * Connection #0 to host localhost left intact
>
> It looks that it has a 201 response, but in fact the layer is either
> broken or not publish, and I can not visualize it (I use qgis and loading
> as WMS layer). I am pretty sure I miss something here.. I would be grateful
> for any help on how to proceed with those issues...
>
> Best regards
>
> Panagiotis
>
>
>
> _______________________________________________
> 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
>
> If you want to request a feature or an improvement, also see this:
> https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
>
>
> Geoserver-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>


-- 
Regards,
Daniele Romagnoli
==
GeoServer Professional Services from the experts! Visit http://goo.gl/it488V
for more information.
==

Ing. Daniele Romagnoli
Senior Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy
phone: +39 0584 962313
fax:      +39 0584 1660272

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

-------------------------------------------------------

Con riferimento alla normativa sul trattamento dei dati personali (Reg. UE
2016/679 - Regolamento generale sulla protezione dei dati “GDPR”), si
precisa che ogni circostanza inerente alla presente email (il suo
contenuto, gli eventuali allegati, etc.) è un dato la cui conoscenza è
riservata al/i solo/i destinatario/i indicati dallo scrivente. Se il
messaggio Le è giunto per errore, è tenuta/o a cancellarlo, ogni altra
operazione è illecita. Le sarei comunque grato se potesse darmene notizia.

This email is intended only for the person or entity to which it is
addressed and may contain information that is privileged, confidential or
otherwise protected from disclosure. We remind that - as provided by
European Regulation 2016/679 “GDPR” - copying, dissemination or use of this
e-mail or the information herein by anyone other than the intended
recipient is prohibited. If you have received this email by mistake, please
notify us immediately by telephone or e-mail.
_______________________________________________
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

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


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

Reply via email to