ThinkGeo.com    |     Documentation    |     Premium Support

About WmtsLayer

Hello

I want to add a local Wmtslayer to my project use this code,and got error message,Program crashes. But the same service is normal in arcgis map. I don’t know what the problem is.
this is server xml Server Wmts.xml (11.1 KB)

      map.MapUnit = GeographyUnit.Meter;
       // map.CurrentExtent = new RectangleShape(1254901.87822449, 6785639.16296541, 1734313.72055747, 6441979.14333386);
      //  map.CurrentExtent = new RectangleShape(-80, 60, 80, -60);

        ThinkGeo.MapSuite.Layers.WmtsLayer wmtsLayer = new ThinkGeo.MapSuite.Layers.WmtsLayer();
        wmtsLayer.DrawingExceptionMode = DrawingExceptionMode.DrawException;
        wmtsLayer.WmtsSeverEncodingType = ThinkGeo.MapSuite.Layers.WmtsSeverEncodingType.Kvp;
        wmtsLayer.ServerUris.Add(new Uri("http://localhost:9009/arctiler/ogc/services/GoogleEarthSatelliteMap/WMTS?"));
        wmtsLayer.ActiveLayerName = "GoogleEarthSatelliteMap";
        wmtsLayer.ActiveStyleName = "default";
        wmtsLayer.TileMatrixSetName = "AZMap_GoogleEarthSatelliteMap";
        wmtsLayer.OutputFormat = "image/jpg";

        wmtsLayer.SendingWebRequest += WmtsLayer_SendingWebRequest;
        wmtsLayer.Open();

        LayerOverlay layerOverlay = new LayerOverlay();
        layerOverlay.Layers.Add(wmtsLayer);

        map.Overlays.Add(layerOverlay);
        map.CurrentExtent = layerOverlay.GetBoundingBox();
        map.Refresh();

private void WmtsLayer_SendingWebRequest(object sender, SendingWebRequestEventArgs e)
{
System.Diagnostics.Debug.WriteLine(e.WebRequest.RequestUri.ToString());
}
show log:
http://localhost:9009/arctiler/ogc/services/GoogleEarthSatelliteMap/WMTS??service=WMTS&request=GetTile&version=1.0.0&layer=GoogleEarthSatelliteMap&style=default&format=image/jpg&TileMatrixSet=AZMap_GoogleEarthSatelliteMap&TileMatrix=AZMap_GoogleEarthSatelliteMap:0&TileRow=3&TileCol=11
http://localhost:9009/arctiler/ogc/services/GoogleEarthSatelliteMap/WMTS??service=WMTS&request=GetTile&version=1.0.0&layer=GoogleEarthSatelliteMap&style=default&format=image/jpg&TileMatrixSet=AZMap_GoogleEarthSatelliteMap&TileMatrix=AZMap_GoogleEarthSatelliteMap:0&TileRow=4&TileCol=15
http://localhost:9009/arctiler/ogc/services/GoogleEarthSatelliteMap/WMTS??service=WMTS&request=GetTile&version=1.0.0&layer=GoogleEarthSatelliteMap&style=default&format=image/jpg&TileMatrixSet=AZMap_GoogleEarthSatelliteMap&TileMatrix=AZMap_GoogleEarthSatelliteMap:0&TileRow=4&TileCol=11
http://localhost:9009/arctiler/ogc/services/GoogleEarthSatelliteMap/WMTS??service=WMTS&request=GetTile&version=1.0.0&layer=GoogleEarthSatelliteMap&style=default&format=image/jpg&TileMatrixSet=AZMap_GoogleEarthSatelliteMap&TileMatrix=AZMap_GoogleEarthSatelliteMap:0&TileRow=3&TileCol=12
http://localhost:9009/arctiler/ogc/services/GoogleEarthSatelliteMap/WMTS??service=WMTS&request=GetTile&version=1.0.0&layer=GoogleEarthSatelliteMap&style=default&format=image/jpg&TileMatrixSet=AZMap_GoogleEarthSatelliteMap&TileMatrix=AZMap_GoogleEarthSatelliteMap:0&TileRow=3&TileCol=13
http://localhost:9009/arctiler/ogc/services/GoogleEarthSatelliteMap/WMTS??service=WMTS&request=GetTile&version=1.0.0&layer=GoogleEarthSatelliteMap&style=default&format=image/jpg&TileMatrixSet=AZMap_GoogleEarthSatelliteMap&TileMatrix=AZMap_GoogleEarthSatelliteMap:0&TileRow=4&TileCol=12
http://localhost:9009/arctiler/ogc/services/GoogleEarthSatelliteMap/WMTS??service=WMTS&request=GetTile&version=1.0.0&layer=GoogleEarthSatelliteMap&style=default&format=image/jpg&TileMatrixSet=AZMap_GoogleEarthSatelliteMap&TileMatrix=AZMap_GoogleEarthSatelliteMap:0&TileRow=3&TileCol=14
http://localhost:9009/arctiler/ogc/services/GoogleEarthSatelliteMap/WMTS??service=WMTS&request=GetTile&version=1.0.0&layer=GoogleEarthSatelliteMap&style=default&format=image/jpg&TileMatrixSet=AZMap_GoogleEarthSatelliteMap&TileMatrix=AZMap_GoogleEarthSatelliteMap:0&TileRow=4&TileCol=13
http://localhost:9009/arctiler/ogc/services/GoogleEarthSatelliteMap/WMTS??service=WMTS&request=GetTile&version=1.0.0&layer=GoogleEarthSatelliteMap&style=default&format=image/jpg&TileMatrixSet=AZMap_GoogleEarthSatelliteMap&TileMatrix=AZMap_GoogleEarthSatelliteMap:0&TileRow=4&TileCol=1

4

Hi Zhangming,

I guess the problem is parse capability met problem.

The problem is we cannot test it because it’s a local WMTS server, please open the test service so we can debug to see where is the problem.

Regards,

Ethan

Try this one:
http://t0.tianditu.com/cia_w/wmts?service=WMTS&version=1.0.0&request=GetCapabilities

// ThinkGeo.MapSuite.Wpf.WmtsLayer
private Collection MakeTileValidInCapabilities(Collection cells, TileMatrix tileMatrix)
{
Collection collection = new Collection();
if (this.wmtsServerLayers[0].2kI=.Count != 0)
{
foreach (uUI= current in this.wmtsServerLayers[0].2kI=)
{
if (tileMatrix.Id == current.jxQ=)
{
foreach (TileMatrixCell current2 in cells)
{
if (double.Parse(current2.Column.ToString(CultureInfo.InvariantCulture)) >= current.w0I= && double.Parse(current2.Column.ToString(CultureInfo.InvariantCulture)) <= current.xUI= && double.Parse(current2.Row.ToString(CultureInfo.InvariantCulture)) >= current.v0I= && double.Parse(current2.Row.ToString(CultureInfo.InvariantCulture)) <= current.wUI=)
{
collection.Add(current2);
}
}
}
}
return collection;
}
return cells;
}
You guys should check the source code of WmtsLayer,especially MakeTileValidInCapabilities method.Why wmtsServerLayers[0] ?
I believe you guys should have a lot of bug to fix.

Please confirm that WmtsLayer is ok after enable tile cache.Thank you.
Sorry for my poor english.

Hi karl_barkmann,

As below is the sample about your server:

 map.MapUnit = GeographyUnit.Meter;

        LayerOverlay layerOverlay = new LayerOverlay();

        WmtsLayer wmtsLayer = new WmtsLayer();
        wmtsLayer.SendingWebRequest += WmtsLayer_SendingWebRequest;
        wmtsLayer.ServerUris.Add(new Uri("https://t0.tianditu.com/cia_w/wmts"));
        wmtsLayer.DrawingExceptionMode = DrawingExceptionMode.DrawException;
        wmtsLayer.WmtsSeverEncodingType = ThinkGeo.MapSuite.Layers.WmtsSeverEncodingType.Kvp;
        wmtsLayer.Open();
        wmtsLayer.ActiveLayerName = "cia";
        wmtsLayer.ActiveStyleName = "default";
        wmtsLayer.TileMatrixSetName = "w";
        wmtsLayer.OutputFormat = "image/png";

        layerOverlay.Layers.Add(wmtsLayer);

        wmtsLayer.Open();
        map.CurrentExtent = new RectangleShape(-20037508.3427892, 20037508.3427892, 20037508.3427892, -20037508.3427892);

        map.Overlays.Add(layerOverlay);
        map.Refresh();

The problem is, when it works the tile request url looks is not suitable the server, please find a valid tile request url and you can adjust the parameters to make it works.

The currently url is for example:
https://t0.tianditu.com/cia_w/wmts?service=WMTS&request=GetTile&version=1.0.0&layer=cia&style=default&format=image/png&TileMatrixSet=w&TileMatrix=w:0&TileRow=0&TileCol=1

Regards,

Ethan