XAML-Map-Control/MapControl/Shared/WmtsTileSource.cs
2025-12-02 15:29:45 +01:00

23 lines
721 B
C#

using System;
using System.Collections.Generic;
namespace MapControl
{
public class WmtsTileSource(WmtsTileMatrixSet tileMatrixSet) : TileSource
{
private readonly string uriFormat = tileMatrixSet.UriTemplate
.Replace("{TileMatrix}", "{0}")
.Replace("{TileCol}", "{1}")
.Replace("{TileRow}", "{2}");
private readonly List<WmtsTileMatrix> tileMatrixes = tileMatrixSet.TileMatrixes;
public override Uri GetUri(int zoomLevel, int column, int row)
{
return zoomLevel < tileMatrixes.Count
? new Uri(string.Format(uriFormat, tileMatrixes[zoomLevel].Identifier, column, row))
: null;
}
}
}