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

36 lines
1 KiB
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;
using System.Collections.Generic;
namespace MapControl
{
public class WmtsTileSource : TileSource
{
2020-03-21 01:52:17 +01:00
public WmtsTileSource(string uriFormat)
2020-03-20 20:40:13 +01:00
: base(uriFormat)
2020-03-20 18:12:56 +01:00
{
}
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-03-21 01:52:17 +01:00
if (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
}
}
}