2020-03-20 18:12:56 +01:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|
|
|
|
|
// <20> 2020 Clemens Fischer
|
|
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public class WmtsTileSource : TileSource
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IList<WmtsTileMatrix> tileMatrixes;
|
|
|
|
|
|
|
2020-03-20 20:40:13 +01:00
|
|
|
|
public WmtsTileSource(string uriFormat, IList<WmtsTileMatrix> tileMatrixes)
|
|
|
|
|
|
: base(uriFormat)
|
2020-03-20 18:12:56 +01:00
|
|
|
|
{
|
2020-03-20 20:40:13 +01:00
|
|
|
|
this.tileMatrixes = tileMatrixes;
|
2020-03-20 18:12:56 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Uri GetUri(int x, int y, int zoomLevel)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (zoomLevel < 0 || zoomLevel >= tileMatrixes.Count)
|
|
|
|
|
|
{
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var url = UriFormat
|
|
|
|
|
|
.Replace("{TileMatrix}", tileMatrixes[zoomLevel].Identifier)
|
|
|
|
|
|
.Replace("{TileCol}", x.ToString())
|
|
|
|
|
|
.Replace("{TileRow}", y.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
return new Uri(url);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|