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

32 lines
936 B
C#
Raw Normal View History

2025-02-27 18:46:32 +01:00
using System;
2025-10-29 18:59:19 +01:00
using System.Text;
2020-03-20 18:12:56 +01:00
namespace MapControl
{
2025-11-13 15:32:01 +01:00
public class WmtsTileSource : UriTileSource
2020-03-20 18:12:56 +01:00
{
2020-03-21 01:52:17 +01:00
public WmtsTileMatrixSet TileMatrixSet { get; set; }
2025-09-14 21:02:21 +02:00
public override Uri GetUri(int zoomLevel, int column, int row)
2020-03-20 18:12:56 +01:00
{
2020-03-20 21:09:19 +01:00
Uri uri = null;
if (UriTemplate != null &&
2025-08-03 17:29:40 +02:00
TileMatrixSet != null &&
TileMatrixSet.TileMatrixes.Count > zoomLevel)
2020-03-20 18:12:56 +01:00
{
2025-10-29 18:59:19 +01:00
var uriBuilder = new StringBuilder(UriTemplate);
uriBuilder.Replace("{TileMatrixSet}", TileMatrixSet.Identifier);
uriBuilder.Replace("{TileMatrix}", TileMatrixSet.TileMatrixes[zoomLevel].Identifier);
uriBuilder.Replace("{TileCol}", column.ToString());
uriBuilder.Replace("{TileRow}", row.ToString());
uri = new Uri(uriBuilder.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
}
}
}