XAML-Map-Control/MapControl/Shared/WmtsTileSource.cs

30 lines
929 B
C#
Raw Normal View History

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;
namespace MapControl
{
public class WmtsTileSource : TileSource
{
2020-03-21 01:52:17 +01:00
public WmtsTileMatrixSet TileMatrixSet { get; set; }
2020-03-20 18:12:56 +01:00
public override Uri GetUri(int x, int y, int zoomLevel)
{
2020-03-20 21:09:19 +01:00
Uri uri = null;
2020-10-23 23:35:48 +02:00
if (UriFormat != null && TileMatrixSet != null && zoomLevel >= 0 && zoomLevel < TileMatrixSet.TileMatrixes.Count)
2020-03-20 18:12:56 +01:00
{
2020-03-20 21:09:19 +01:00
uri = new Uri(UriFormat
2020-03-21 01:52:17 +01:00
.Replace("{TileMatrixSet}", TileMatrixSet.Identifier)
.Replace("{TileMatrix}", TileMatrixSet.TileMatrixes[zoomLevel].Identifier)
2020-03-20 21:09:19 +01:00
.Replace("{TileCol}", x.ToString())
.Replace("{TileRow}", y.ToString()));
2020-03-20 18:12:56 +01:00
}
2020-03-20 21:09:19 +01:00
return uri;
2020-03-20 18:12:56 +01:00
}
}
}