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;
|
|
|
|
|
|
|
2025-12-01 13:59:18 +01:00
|
|
|
|
public WmtsTileSource(string uriTemplate, WmtsTileMatrixSet tileMatrixSet)
|
2025-11-29 08:25:18 +01:00
|
|
|
|
{
|
|
|
|
|
|
UriTemplate = uriTemplate.Replace("{TileMatrixSet}", tileMatrixSet.Identifier);
|
2025-12-01 13:59:18 +01:00
|
|
|
|
tileMatrixes = tileMatrixSet.TileMatrixes;
|
2025-11-29 08:25:18 +01:00
|
|
|
|
}
|
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;
|
|
|
|
|
|
|
2025-12-01 14:01:35 +01:00
|
|
|
|
if (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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|