ThinkGeo.com    |     Documentation    |     Premium Support

Problems with WmtsTiledOverlay and WmtsLayer

Hey,

I’m having some issues showing map from WMTS service. I managed to get WmtsLayer to partially work but WmtsTiledOverlay… not at all.

I’m using ThinkGeo.Core 13.0.0-beta249 with ThinkGeo.UI.WPF 13.0.0-beta289.

Please see code below:

XAML:
<wpf:MapView x:Name="Map" Loaded="Map_OnLoaded" ></wpf:MapView>

C#

    private void Map_OnLoaded(object sender, RoutedEventArgs e)
    {
        Map.MapUnit = GeographyUnit.Meter;

        var wmtsLayer = new WmtsLayer
        {
            DrawingExceptionMode = DrawingExceptionMode.DrawException,
            WmtsSeverEncodingType = WmtsSeverEncodingType.Kvp
        };
        wmtsLayer.ServerUris.Add(new Uri("http://www.openbasiskaart.nl/mapcache/wmts"));
        wmtsLayer.ActiveLayerName = "osm-epsg3857";
        wmtsLayer.ActiveStyleName = "default";
        wmtsLayer.TileMatrixSetName = "epsg3857";
        wmtsLayer.OutputFormat = "image/png";

        var layerOverlay = new LayerOverlay();
        layerOverlay.Layers.Add(wmtsLayer);
        Map.Overlays.Add(layerOverlay);
        Map.Refresh();

        /*
        var wmtsOverlay = new WmtsTiledOverlay
        {
            DrawingExceptionMode = DrawingExceptionMode.DrawException,
            WmtsServerEncodingType = WmtsSeverEncodingType.Kvp
        };
        wmtsOverlay.ServerUris.Add(new Uri("http://www.openbasiskaart.nl/mapcache/wmts"));
        wmtsOverlay.Parameters.Add("LAYER", "osm-epsg3857");
        wmtsOverlay.Parameters.Add("STYLE", "default");
        wmtsOverlay.Parameters.Add("TILEMATRIXSET", "epsg3857");
        wmtsOverlay.Parameters.Add("FORMAT", "image/png");
        wmtsOverlay.InitializeConnection();

        Map.Overlays.Add(wmtsOverlay);
        Map.Refresh();
        */
    }

Using code that is commented out, the WmtsTiledOverlay approach, I can’t get anything visible on the map. Using the WmtsLayer I do have a map but it’s missing some tiles… or something :frowning: ? Also, when zooming in existing tiles disappear and new ones are not loaded.

Here’s a screenshot running above code.

And here, for reference, is screenshot using same service/layer/style via QGIS.

Thanks.

Thanks Mikko,
The WmtsTiledOverlay do have some issue. We will restructure the WmtsTiledOverlay in next release. Right now you could use WmtsLayer and put it to a LayerOverlay like your current code.

We will let you know once the restructure for the WmtsTiledOverlay get done.

Thanks

Frank

1 Like

Hey Frank,

Thanks for the information. After struggling a little I managed to get both WMS and WMTS working. I now use WmsRasterLayer and WmtsLayer and then add those to separate Overlays.

This seems to work but there’s still something that is not quite right…

For example, I didn’t at first realize you could add TileCache to WmtsLayer since it’s not an option for most of the layers. When using WmtsLayer, if you set TileCache for Overlay (as you normally would), it just stops drawing the map. Usually this can be reproduced just by rapidly zooming in and out.

Same code with TileCache attached to WmtsLayer instead works perfectly.

Other thing is that I’d expect WMTS to be faster than WMS. But after several tests with different pieces of code and different services, it seems that WMS is quite OK but WMTS is really underperforming, being constantly way slower than WMS.

Anyway it’s good to know that issues related to WMTS are being resolved. I can post example code about performance issues if it makes any difference?

Thanks Mikko,
Could post or send the performance issues to support@thinkgeo.com? We could look into more detail.

Thanks

Frank

Hey,

As I posted before I’m currently using either WmsRasterLayer or WmtsLayer added to LayerOverlay, which is then added to WPF MapView.

All this is working nicely but WMTS suffers from performance issues. Here’s screencaps from the actual solution.

WMS


WMTS

But now when I took that working layer code and tried to reduce it to a simple example I could post to you, I just can’t get these same layers working. Using exact same service endpoint, layer, style and crs/tilematrix.

And no matter how long I try to “spot the difference”, I can’t :smiley:

So before I can post anything about performance issues I’d need to figure out, with your help preferably, why attached code example produces these outcomes :frowning: ?

WMS


WMTS

Solution here WpfApp1.zip (11.4 KB)

Thanks.

Thanks Mikko,
I can re-produce this one. I am looking into more details.

Thanks

Frank

Thanks Mikko,
I looked into this one. This because you use the same cache folder. There also some other small issues. I re-build the sample project. It works now.

WpfApp1.zip (11.2 KB)

The WMTS performance issue is an known issue. This because the tilematrix may not match the one for the map. One tile request may need send 4 request to the WMTS server. We are looking into this one see if there any more enhancement we could do.

Thanks

Frank

Hey, thanks.

I double checked and to me it seems that I did not use same folder. Or I did use same root but different cacheId which then translates to different path? Also, I did remove cache when ever “WMS” or “WMTS” buttons were pressed. But to be extra sure I disabled the caching and removed any cache that was left behind.

Doing that did not fix the issue, not even after I copy/pasted the overlay/layer code you provided. On my application the same code still produced effect posted above while the same code in your solution worked nicely.

You did use different target .NET version and some beta build that is not readily available via NuGet UI though…?

Thanks Mikko,
Yes. I was trying to use your project even with the different cache folder. The issue still existing. Then I created a new project with the same code but .Net framework target to 4.6.2 and latest mapsuite V12 beta. Then it works. So I think the cache folder may be not the root reason. I am re-thinking this one. It may related with .Net 4.8. I am going to test it with .Net 4.8.

Also a quick update. We re-build the WmtsTiledOverlay. We are testing it. It will be available next week.

Thanks

Frank

Thanks Mikko,
We have rebuild WmtsTiledOverlay. The daily build process will push the change to the beta release tonight. You can try it tomorrow.

Here is the code to load the wmts overlay.
private void Window_Loaded(object sender, RoutedEventArgs e)
{
mapView.MapUnit = GeographyUnit.Meter;

            var wmtsOverlay = new WmtsTiledOverlay(new Uri[] { new Uri("http://www.openbasiskaart.nl/mapcache/wmts") }, WmtsSeverEncodingType.Kvp);
            wmtsOverlay.DrawingExceptionMode = DrawingExceptionMode.DrawException;
            wmtsOverlay.ActiveLayerName = "osm-epsg3857";
            wmtsOverlay.ActiveStyleName = "default";
            wmtsOverlay.TileMatrixSetName = "epsg3857";
            wmtsOverlay.OutputFormat = "image/png";
            wmtsOverlay.TileCache = new FileRasterTileCache("C:\\temp\\wmtsOverlay");
            mapView.Overlays.Add(wmtsOverlay);
            mapView.Refresh();          
        }

Thanks

Frank

1 Like

Hey Frank,

I got latest core and wpf packages. After trying out WmtsTiledOverlay I can’t see any significant improvement over previous package or WmtsLayer attached to LayerOverlay :frowning:

Thanks.

Thanks Mikko,
Yes. There is no difference for the performance. The previous WmtsTiledOverlay not work at all. We rebuild the WmtsTiledOverlay. It will use the same WmtsLayer class. The WMTS performance issue is an known issue. This because the WMTS service has separate tilematrix definition. It may not match the one for the map. One tile request may need send 4 requests to the WMTS server. We have not yet find a good way to handle this. Right now enable the cache is what we could do for the performance. .

Thanks

Frank

1 Like