Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to connect to a WebMapServer with the Geotools WMS classes. My problem is, that the resonse-object "capabilities" doesn't contain all layers. When I'm doing the request in a browser, I can see all layers.

URL url = null;
      try {
        url = new URL("http://www.test.de/wms?service=wms&version=1.1.1&request=GetCapabilities");
      } catch (MalformedURLException e) {
      }

      WebMapServer wms = null;
      try {
        wms = new WebMapServer(url);
      }
catch(Exception e){}

WMSCapabilities capabilities = wms.getCapabilities();

      Layer[] layers = WMSUtils.getNamedLayers(capabilities);

      List<Layer> alle = capabilities.getLayerList();

The GetCapabilities.xml is (part of the document):

<?xml version="1.0" encoding="UTF-8"?>
<WMT_MS_Capabilities version="1.1.1">
<Service>
    <Name>OGC:WMS</Name>
    <Title>Titel</Title>
    <Abstract>  abstract.</Abstract>
    <KeywordList>
        <Keyword>WMS</Keyword>
    </KeywordList>
     <Layer queryable="0" opaque="0" noSubsets="0">
        <Title>Rasterdaten</Title>
        <Name>Rasterdaten</Name>
        <SRS>EPSG:31467</SRS>
        <BoundingBox SRS="EPSG:31467" minx="3340000" miny="5230000" maxx="3615000" maxy="5550000"/>
        <LatLonBoundingBox minx="7.60" miny="47.40" maxx="10.00" maxy="50.00"/>
        <Layer queryable="0">
            <Name>DOP_RGB</Name>
            <Title>DOP_RGB</Title>
            <LatLonBoundingBox minx="7.60" miny="47.40" maxx="10.00" maxy="50.00"/>
        </Layer>
    </Layer>    
      <Layer>
        <Name>Touristik</Name>
        <Title>Touristik</Title>
        <SRS>epsg:31467</SRS>
        <BoundingBox SRS="EPSG:31467" minx="3340000" miny="5230000" maxx="3615000" maxy="5550000"/><LatLonBoundingBox minx="7.33273" miny="47.4683" maxx="10.6673" maxy="49.8177" />
        <Layer>
          <Name>Radwege</Name>
          <Title>Radwege</Title>
          <SRS>EPSG:31467</SRS>
          <BoundingBox SRS="EPSG:31467" minx="3340000" miny="5230000" maxx="3615000" maxy="5550000"/><LatLonBoundingBox minx="7.33273" miny="47.4683" maxx="10.6673" maxy="49.8177" />
                  <Layer queryable="0">
                   <Name>DTK50-grl</Name>
                   <Title>DTK50-grl</Title>
                   <LatLonBoundingBox minx="7.60" miny="47.40" maxx="10.00" maxy="50.00"/>
                  </Layer>
         </Layer>
         <Layer queryable="0" opaque="0" noSubsets="0">
            <Title>Thematische Linien</Title>
            <Name>Thematische Linien</Name>
            <SRS>EPSG:31467</SRS>
            <BoundingBox SRS="EPSG:31467" minx="3340000" miny="5230000" maxx="3615000" maxy="5550000"/>
                  <Layer queryable="0">
                    <Name>DTK50-gll</Name>
                    <Title>DTK50-gll</Title>
                    <LatLonBoundingBox minx="7.60" miny="47.40" maxx="10.00" maxy="50.00"/>
                  </Layer>
                  <Layer queryable="0">
                    <Name>DTK50-bll</Name>
                    <Title>DTK50-bll</Title>
                    <LatLonBoundingBox minx="7.60" miny="47.40" maxx="10.00" maxy="50.00"/>
                  </Layer>       
         </Layer>       
     </Layer>
</Capability>

The node "Rasterdaten" isn't shown in the capabilities-object. Does anybody know, why??

Thanks for helping.

share|improve this question

1 Answer 1

Might be a bit late to be answering this, but the reasoning for the WMSUtils.getNamedLayers(capabilities) not returning all the layers is give at the following link http://docs.geotools.org/latest/userguide/extension/wms/wms.html

WMSUtils The concept of a Layer in WMS is a bit strange. Not all layers are useful (some are abstract and cannot be used, some are used as folders, and some do not even bother to have names - perhaps they are used for documentation?). Rather than figure all this out yourself we recommend using the WMSUtils utility class. To retrieve all the layers that can be requested (ie they have a name) try the following:

Layer[] layers = WMSUtils.getNamedLayers(capabilities);
share|improve this answer
    
Could you please point out which part of the link talks about this issue? I could not find it. –  Devdatta Tengshe Oct 28 '13 at 17:07
    
@DevdattaTengshe - WMSUtils The concept of a Layer in WMS is a bit strange. Not all layers are useful (some are abstract and cannot be used, some are used as folders, and some do not even bother to have names - perhaps they are used for documentation?). Rather than figure all this out yourself we recommend using the WMSUtils utility class. To retrieve all the layers that can be requested (ie they have a name) try the following: Layer[] layers = WMSUtils.getNamedLayers(capabilities); –  k9ty Oct 28 '13 at 17:19
1  
You could edit your answer and add this information there. –  Devdatta Tengshe Oct 28 '13 at 17:24
    
@DevdattaTengshe There you go :) Hope that is better. –  k9ty Oct 28 '13 at 17:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.