2025-02-27 18:46:32 +01:00
|
|
|
|
using System;
|
2025-11-29 08:25:18 +01:00
|
|
|
|
using System.Collections.Generic;
|
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
|
|
|
|
{
|
2025-11-29 08:25:18 +01:00
|
|
|
|
private readonly IList<WmtsTileMatrix> tileMatrixes;
|
|
|
|
|
|
|
|
|
|
|
|
public WmtsTileSource(WmtsTileMatrixSet tileMatrixSet, string uriTemplate)
|
|
|
|
|
|
{
|
|
|
|
|
|
tileMatrixes = tileMatrixSet.TileMatrixes;
|
|
|
|
|
|
UriTemplate = uriTemplate.Replace("{TileMatrixSet}", tileMatrixSet.Identifier);
|
|
|
|
|
|
}
|
2020-03-21 01:52:17 +01:00
|
|
|
|
|
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;
|
|
|
|
|
|
|
2022-08-23 17:20:16 +02:00
|
|
|
|
if (UriTemplate != null &&
|
2025-11-29 08:25:18 +01:00
|
|
|
|
tileMatrixes != null &&
|
|
|
|
|
|
tileMatrixes.Count > zoomLevel)
|
2020-03-20 18:12:56 +01:00
|
|
|
|
{
|
2025-10-29 18:59:19 +01:00
|
|
|
|
var uriBuilder = new StringBuilder(UriTemplate);
|
|
|
|
|
|
|
2025-11-29 08:25:18 +01:00
|
|
|
|
uriBuilder.Replace("{TileMatrix}", tileMatrixes[zoomLevel].Identifier);
|
2025-10-29 18:59:19 +01:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|