Updated WmtsTileSource

This commit is contained in:
ClemensFischer 2025-11-29 08:25:18 +01:00
parent 286926e1ea
commit 2ec4d8fa60
3 changed files with 12 additions and 12 deletions

View file

@ -1,5 +1,4 @@
using System;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
#if WPF

View file

@ -131,12 +131,7 @@ namespace MapControl
}
else if (UpdateChildLayers(tileMatrixSet))
{
var tileSource = new WmtsTileSource
{
UriTemplate = TileUriTemplate,
TileMatrixSet = tileMatrixSet
};
var tileSource = new WmtsTileSource(tileMatrixSet, TileUriTemplate);
var cacheName = SourceName;
if (!string.IsNullOrEmpty(cacheName))

View file

@ -1,24 +1,30 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace MapControl
{
public class WmtsTileSource : UriTileSource
{
public WmtsTileMatrixSet TileMatrixSet { get; set; }
private readonly IList<WmtsTileMatrix> tileMatrixes;
public WmtsTileSource(WmtsTileMatrixSet tileMatrixSet, string uriTemplate)
{
tileMatrixes = tileMatrixSet.TileMatrixes;
UriTemplate = uriTemplate.Replace("{TileMatrixSet}", tileMatrixSet.Identifier);
}
public override Uri GetUri(int zoomLevel, int column, int row)
{
Uri uri = null;
if (UriTemplate != null &&
TileMatrixSet != null &&
TileMatrixSet.TileMatrixes.Count > zoomLevel)
tileMatrixes != null &&
tileMatrixes.Count > zoomLevel)
{
var uriBuilder = new StringBuilder(UriTemplate);
uriBuilder.Replace("{TileMatrixSet}", TileMatrixSet.Identifier);
uriBuilder.Replace("{TileMatrix}", TileMatrixSet.TileMatrixes[zoomLevel].Identifier);
uriBuilder.Replace("{TileMatrix}", tileMatrixes[zoomLevel].Identifier);
uriBuilder.Replace("{TileCol}", column.ToString());
uriBuilder.Replace("{TileRow}", row.ToString());