Adding coverages using REST

View: New views
5 Messages — Rating Filter:   Alert me  

Adding coverages using REST

by Jon Britton-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
Is there a simple way of adding a coverage using the REST API?  I'd like to be able to just upload a GeoTIFF and have GeoServer put everything in the right place and work out the necessary settings, is this possible?
I see from the REST cUrl documentation that you can do something like with with Shapefiles.
Cheers,
Jon

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geoserver-users mailing list
Geoserver-users@...
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Re: Adding coverages using REST

by Atle Frenvik Sveen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2009-10-30 at 12:48 +0000, Jon Britton wrote:
> Hi,
> Is there a simple way of adding a coverage using the REST API?  I'd
> like to be able to just upload a GeoTIFF and have GeoServer put
> everything in the right place and work out the necessary settings, is
> this possible?
> I see from the REST cUrl documentation that you can do something like
> with with Shapefiles.
> Cheers,
> Jon

It is just as simple as adding a shapefile, follow the example for
shapefiles, and look at the REST API documentation and you should be
ready to go.

I've made a groovy function to upload geotiffs which may be of interest:

-atle

def addGeotiff(File file, def workspace, def coverageStore, def
georesturl, def user, def pass){

    //setup the restclient
    def rest = new RESTClient(georesturl)
    //do the authing
    rest.auth.basic user, pass
    //encode as tiff file
    rest.encoder.'image/tiff' = this.&encodeTifFile
    //put it
    def res = rest.put(   path: "/geoserver/rest/workspaces/"+ workspace
+"/coveragestores/" + coverageStore + "/file.geotiff",
        body: file,
        requestContentType: 'image/tiff'
    ).getStatus()
    return res

}

//request encoder for tif file (modified from
http://agileice.blogspot.com/2009/08/groovy-restclient-and-putting-zip-files.html)
def encodeTifFile( Object data ) throws UnsupportedEncodingException {
    if ( data instanceof File ) {
        def entity = new org.apache.http.entity.FileEntity((File)
data,"image/tiff");
        entity.setContentType("image/tiff");
        return entity
    } else {
        throw new IllegalArgumentException("Don't know how to encode
${data.class.name} as a tif file" );
    }
}



> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________ Geoserver-users mailing list Geoserver-users@... https://lists.sourceforge.net/lists/listinfo/geoserver-users
--
Atle Frenvik Sveen
Geomatikk IKT AS
tel: 45 27 86 89
mail. atle.frenvik.sveen@...

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geoserver-users mailing list
Geoserver-users@...
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Parent Message unknown Re: Adding coverages using REST

by Atle Frenvik Sveen-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2009-10-30 at 14:54 +0000, Jon Britton wrote:
> Hi,
>
>
> Thanks for your reply, it's very helpful, but where can I get
> RESTClient?
>
The RESTClient is part of the Groovy HTTPBuilder, which can be found at
http://groovy.codehaus.org/modules/http-builder/home.html



> Also, would it be possible to have a copy of all of your REST code?

What I sent you is at the moment as far as i've come on using the REST
API, and further development from my side will be related to my company,
so I guess you have to make do with what I sent you, but please don't
hesitate to ask if you have any problems.

-atle

>
> Thanks!
>
>
> Jon
>
> 2009/10/30 Atle Frenvik Sveen <atle.frenvik.sveen@...>
>        
>         On Fri, 2009-10-30 at 12:48 +0000, Jon Britton wrote:
>         > Hi,
>         > Is there a simple way of adding a coverage using the REST
>         API?  I'd
>         > like to be able to just upload a GeoTIFF and have GeoServer
>         put
>         > everything in the right place and work out the necessary
>         settings, is
>         > this possible?
>         > I see from the REST cUrl documentation that you can do
>         something like
>         > with with Shapefiles.
>         > Cheers,
>         > Jon
>        
>        
>         It is just as simple as adding a shapefile, follow the example
>         for
>         shapefiles, and look at the REST API documentation and you
>         should be
>         ready to go.
>        
>         I've made a groovy function to upload geotiffs which may be of
>         interest:
>        
>         -atle
>        
>         def addGeotiff(File file, def workspace, def coverageStore,
>         def
>         georesturl, def user, def pass){
>        
>            //setup the restclient
>            def rest = new RESTClient(georesturl)
>            //do the authing
>            rest.auth.basic user, pass
>            //encode as tiff file
>            rest.encoder.'image/tiff' = this.&encodeTifFile
>            //put it
>            def res = rest.put(   path: "/geoserver/rest/workspaces/"+
>         workspace
>         +"/coveragestores/" + coverageStore + "/file.geotiff",
>                body: file,
>                requestContentType: 'image/tiff'
>            ).getStatus()
>            return res
>        
>         }
>        
>         //request encoder for tif file (modified from
>         http://agileice.blogspot.com/2009/08/groovy-restclient-and-putting-zip-files.html)
>         def encodeTifFile( Object data ) throws
>         UnsupportedEncodingException {
>            if ( data instanceof File ) {
>                def entity = new
>         org.apache.http.entity.FileEntity((File)
>         data,"image/tiff");
>                entity.setContentType("image/tiff");
>                return entity
>            } else {
>                throw new IllegalArgumentException("Don't know how to
>         encode
>         ${data.class.name} as a tif file" );
>        
>            }
>         }
>        
>        
>        
>         >
>         ------------------------------------------------------------------------------
>         > Come build with us! The BlackBerry(R) Developer Conference
>         in SF, CA
>         > is the only developer event you need to attend this year.
>         Jumpstart your
>         > developing skills, take BlackBerry mobile applications to
>         market and stay
>         > ahead of the curve. Join us from November 9 - 12, 2009.
>         Register now!
>         > http://p.sf.net/sfu/devconference
>         > _______________________________________________
>         Geoserver-users mailing list
>         Geoserver-users@...
>         https://lists.sourceforge.net/lists/listinfo/geoserver-users
>         --
>        
>         Atle Frenvik Sveen
>         Geomatikk IKT AS
>         tel: 45 27 86 89
>         mail. atle.frenvik.sveen@...
>
>
--
Atle Frenvik Sveen
Geomatikk IKT AS
tel: 45 27 86 89
mail. atle.frenvik.sveen@...

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geoserver-users mailing list
Geoserver-users@...
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Re: Adding coverages using REST

by Jon Britton-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Okay, that's fair enough. I managed to find RESTClient and get your code working anyway. Thanks very much for your help!
Jon

On 2 Nov 2009 07:22, "Atle Frenvik Sveen" <atle.frenvik.sveen@...> wrote:

On Fri, 2009-10-30 at 14:54 +0000, Jon Britton wrote: > Hi, > >

> Thanks for your reply, it's very helpful, but where can I get > RESTClient? >

The RESTClient is part of the Groovy HTTPBuilder, which can be found at
http://groovy.codehaus.org/modules/http-builder/home.html

> Also, would it be possible to have a copy of all of your REST code?

What I sent you is at the moment as far as i've come on using the REST
API, and further development from my side will be related to my company,
so I guess you have to make do with what I sent you, but please don't
hesitate to ask if you have any problems.

-atle

> > Thanks! > > > Jon > > 2009/10/30 Atle Frenvik Sveen <atle.frenvik.sveen@...> > ...

--

Atle Frenvik Sveen Geomatikk IKT AS tel: 45 27 86 89 mail. atle.frenvik.sveen@...


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geoserver-users mailing list
Geoserver-users@...
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Re: Adding coverages using REST

by Justin Deoliveira-6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Atle,

Any interest in making this a GeoServer community module? The barrier of
entry is quite low, you simply just add it into svn and can improve on
it as you see fit. I have a feeling that if put in the public repository
it would attract collaborators. Just a thought.

-Justin

Atle Frenvik Sveen wrote:

> On Fri, 2009-10-30 at 14:54 +0000, Jon Britton wrote:
>> Hi,
>>
>>
>> Thanks for your reply, it's very helpful, but where can I get
>> RESTClient?
>>
> The RESTClient is part of the Groovy HTTPBuilder, which can be found at
> http://groovy.codehaus.org/modules/http-builder/home.html
>
>
>
>> Also, would it be possible to have a copy of all of your REST code?
>
> What I sent you is at the moment as far as i've come on using the REST
> API, and further development from my side will be related to my company,
> so I guess you have to make do with what I sent you, but please don't
> hesitate to ask if you have any problems.
>
> -atle
>
>> Thanks!
>>
>>
>> Jon
>>
>> 2009/10/30 Atle Frenvik Sveen <atle.frenvik.sveen@...>
>>        
>>         On Fri, 2009-10-30 at 12:48 +0000, Jon Britton wrote:
>>         > Hi,
>>         > Is there a simple way of adding a coverage using the REST
>>         API?  I'd
>>         > like to be able to just upload a GeoTIFF and have GeoServer
>>         put
>>         > everything in the right place and work out the necessary
>>         settings, is
>>         > this possible?
>>         > I see from the REST cUrl documentation that you can do
>>         something like
>>         > with with Shapefiles.
>>         > Cheers,
>>         > Jon
>>        
>>        
>>         It is just as simple as adding a shapefile, follow the example
>>         for
>>         shapefiles, and look at the REST API documentation and you
>>         should be
>>         ready to go.
>>        
>>         I've made a groovy function to upload geotiffs which may be of
>>         interest:
>>        
>>         -atle
>>        
>>         def addGeotiff(File file, def workspace, def coverageStore,
>>         def
>>         georesturl, def user, def pass){
>>        
>>            //setup the restclient
>>            def rest = new RESTClient(georesturl)
>>            //do the authing
>>            rest.auth.basic user, pass
>>            //encode as tiff file
>>            rest.encoder.'image/tiff' = this.&encodeTifFile
>>            //put it
>>            def res = rest.put(   path: "/geoserver/rest/workspaces/"+
>>         workspace
>>         +"/coveragestores/" + coverageStore + "/file.geotiff",
>>                body: file,
>>                requestContentType: 'image/tiff'
>>            ).getStatus()
>>            return res
>>        
>>         }
>>        
>>         //request encoder for tif file (modified from
>>         http://agileice.blogspot.com/2009/08/groovy-restclient-and-putting-zip-files.html)
>>         def encodeTifFile( Object data ) throws
>>         UnsupportedEncodingException {
>>            if ( data instanceof File ) {
>>                def entity = new
>>         org.apache.http.entity.FileEntity((File)
>>         data,"image/tiff");
>>                entity.setContentType("image/tiff");
>>                return entity
>>            } else {
>>                throw new IllegalArgumentException("Don't know how to
>>         encode
>>         ${data.class.name} as a tif file" );
>>        
>>            }
>>         }
>>        
>>        
>>        
>>         >
>>         ------------------------------------------------------------------------------
>>         > Come build with us! The BlackBerry(R) Developer Conference
>>         in SF, CA
>>         > is the only developer event you need to attend this year.
>>         Jumpstart your
>>         > developing skills, take BlackBerry mobile applications to
>>         market and stay
>>         > ahead of the curve. Join us from November 9 - 12, 2009.
>>         Register now!
>>         > http://p.sf.net/sfu/devconference
>>         > _______________________________________________
>>         Geoserver-users mailing list
>>         Geoserver-users@...
>>         https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>         --
>>        
>>         Atle Frenvik Sveen
>>         Geomatikk IKT AS
>>         tel: 45 27 86 89
>>         mail. atle.frenvik.sveen@...
>>
>>

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geoserver-users mailing list
Geoserver-users@...
https://lists.sourceforge.net/lists/listinfo/geoserver-users