Alberto,

rather than filtering the output, you could also include a predicate in 
the XPath to select only the CoverageId elements you want:

$ curl -s 
'http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities'
 
| xpath -q -e '//wcs:CoverageId/text()[contains(.,"Sample")]'
nurc__Arc_Sample
nurc__Img_Sample

This example is not strictly what you want if you only want to match a 
substring at the end of the CoverageId text. xpath appears to support 
only XPath 1.0 so does not support ends-with() (from XPath 2.0), but you 
can make your own with this ugly but effective construct:

$ curl -s 
'http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities'
 
| xpath -q -e 
'//wcs:CoverageId/text()[substring(.,string-length(.)-string-length("Sample")+1)="Sample"]'
 

nurc__Arc_Sample
nurc__Img_Sample

In your case this would be:

curl -s 
'http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities'
 
| xpath -q -e 
'//wcs:CoverageId/text()[substring(.,string-length(.)-string-length("RGB")+1)="RGB"]'

Kind regards,
Ben.

On 16/04/16 09:01, Ben Caradoc-Davies wrote:
> Alberto,
>
> the canonical way to discover resources via OGC web services is with a
> GetCapabilities request. In the case of WCS, you can discover the names
> of all enabled coverages. Use curl or any other HTTP client to retrieve
> the capabilities document, then parse it as XML with your language or
> tool of choice to extract the coverage names.
>
> For example, for the release configuration of GeoServer, with curl
> output piped into the xpath tool (from the libxml-xpath-perl package on
> Debian; what is your platform?):
>
> curl -s
> "http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities";
> | xpath -q -e '//wcs:CoverageId/text()'
>
> Output:
>
> nurc__Arc_Sample
> nurc__Img_Sample
> nurc__mosaic
> sf__sfdem
>
> Filter this output to obtain a list of coverages whose names end in
> "RGB". You can do exactly the same thing in Java, Python, or any other
> general purpose language with HTTP and XML parsing support.
>
> Kind regards,
> Ben.
>
> On 16/04/16 04:43, Alberto Callejas Delgado wrote:
>> Dear GeoServer users,
>>
>> I am working with the rest api and I need to get a list of coverages from
>> GeoServer via cURL but just those which are RGB products (layer name ending
>> in "RGB")
>>
>> I read in here that almost everything you can do in the GUI can be done
>> using cURL.
>>
>> Please, could anybody point me to the right way to find out a solution?
>>
>> Thank you very much,
>>
>> Alberto
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Find and fix application performance issues faster with Applications Manager
>> Applications Manager provides deep performance insights into multiple tiers 
>> of
>> your business applications. It resolves application problems quickly and
>> reduces your MTTR. Get your free trial!
>> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
>>
>>
>>
>> _______________________________________________
>> Geoserver-users mailing list
>> Geoserver-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>
>

-- 
Ben Caradoc-Davies <b...@transient.nz>
Director
Transient Software Limited <http://transient.nz/>
New Zealand

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to