Dear Daniele,

first I would like to thank you for your quick response and the very informative and helpful email. That cleared up lot of things! Secondly accept my apologies for taking me some time to apply your suggestions into my case.

For the ImageMosaic: I think (unfortunately I didn't use code revision yet since I am experimenting before go to production; hence not sure if that was my bug) I mixed up how I define the http request and the end points. Thanks to your email is much clearer now.

To update the mosaic (either add new granules or update the existing ones) my understanding is that I actually do not need to delete any previous shape index (that is the *.properties and *.shp files). Using the

curl -v -u admin:pswd -XPOST -H "Content-type: text/plain" -d "file:///data/geoserver/data/mosaic" "http://localhost:8080/geoserver/rest/workspaces/MYWSP/coveragestores/MYMSC/external.imagemosaic";

seems it does the job with no extra action.

Regarding the Geotiff maybe my finding could be relevant for other users so I am posting my solution:

I discovered (by comparing layer properties using the gui as well) that after the curl command

curl -v -u admin:pswd -XPUT --data-binary "file:///data/geoserver/data/sic/test.tiff" "http://localhost:8080/geoserver/rest/workspaces/MYWSP/coveragestores/MYGEOTIFF/external.geotiff"; <http://localhost:8080/geoserver/rest/workspaces/MYWSP/coveragestores/MYGEOTIFF/file.geotiff>


the declared srs was undefined. Hence I had to force to use a projection by:

curl -v -u admin:pswd -XPUT -H "Content-type: text/xml" -d "<coverage><srs>EPSG:XXXX</srs><projectionPolicy>FORCE_DECLARED</projectionPolicy><enabled>true</enabled></coverage>" $SIC_URL/coverages/${SIC_FILE%.*}

Then the Geotiff layer was displayed with not problem :)

Many thanks again for your help!

Best regards

Panagiotis


On 01.04.19 14:22, Daniele Romagnoli wrote:
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 <mailto: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:/
/
/
/ExtensionCoverage store/
/geotiff      GeoTIFF/
/worldimageGeoreferenced image (JPEG, PNG, TIFF)/
/imagemosaicImage 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
    <mailto: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.

--
Dr. Panagiotis Kountouris

Chief Research Officer
Drift & Noise Polar Services GmbH
www.driftnoise.com
Stavendamm 17
28195 Bremen, Germany

Office: +49 421 223 70 660
Mobile: +49 176 79 07 11 36

_______________________________________________
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