jteal8

Need help adding a WMTSLayer from service.

Discussion created by jteal8 on Nov 28, 2013
Latest reply on Aug 5, 2016 by Nitin_MMI
Hi guys.

I may be way off base here but I'm trying to add a layer from a WMTS connection. I'm using the .Net SDK (C#).

So far  I can connect to the Server using IWMTSConnection and then create a WMTSLayer with WMTSConnection() but I can only ever use the first WMTSLayer as an ILayer. I can iterate over the whole structure and pull layer descriptions using IWMTSServiceDescription with IWMTSLayerDescription. But Im at a loss creating a connection where I can use a specific LayerName/Identifier.

Is there a way to either specify the LayerName perhaps when creating the IWMTSConnection or creating the WMTSLayer, that will allow me access other WMTSLayers?

Heres a cut down version of what I currently have:

    IWMTSLayer wmtsLayer = new WMTSLayerClass();
    IDataLayer dLayer = new WMTSLayerClass();
   
    IPropertySet propSet = new PropertySetClass();
    propSet.SetProperty("URL", "http://localhost/erdas-iws/ogc/wmts/?Service=WMTS&Request=GetCapabilities");

    IWMTSConnectionFactory wmtsConnFactory = new WMTSConnectionFactoryClass();
    IWMTSConnection wmtsConnection = wmtsConnFactory.Open(propSet, 0, null);

    ESRI.ArcGIS.GISClient.IWMTSServiceDescription wmtsServiceDescription = wmtsConnection as IWMTSServiceDescription;
    wmtsLayer.WMTSConnection(wmtsConnection);
                 
    for (int i = 0; i < wmtsServiceDescription.LayerDescriptionCount; i++)
    {
          IWMTSLayerDescription layerDescription = wmtsServiceDescription.get_LayerDescription(i);
          if (layerDescription.Identifier.Equals(Wmts_Name, StringComparison.InvariantCultureIgnoreCase))
          {
               //We have a match
               //Maybe need something here to open the correct WMTSLayer?
          } 
     }

     if (wmtsLayer != null)
     {
          IMxDocument mxDocument = (IMxDocument)mxApp.Document;
          mxDocument.FocusMap.AddLayer((ILayer)wmtsLayer);
          return true;
     }


Any help on this is greatly appreciate.

Thanks.

Outcomes