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

32 lines
1,020 B
C#
Raw Normal View History

2021-01-13 21:19:27 +01:00
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
2024-02-03 21:01:53 +01:00
// Copyright © 2024 Clemens Fischer
2020-03-20 18:12:56 +01:00
// Licensed under the Microsoft Public License (Ms-PL)
using System;
namespace MapControl
{
public class WmtsTileSource : TileSource
{
2020-03-21 01:52:17 +01:00
public WmtsTileMatrixSet TileMatrixSet { get; set; }
2022-11-22 19:15:34 +01:00
public override Uri GetUri(int column, int row, int zoomLevel)
2020-03-20 18:12:56 +01:00
{
2020-03-20 21:09:19 +01:00
Uri uri = null;
if (UriTemplate != null &&
2022-08-19 08:38:48 +02:00
TileMatrixSet != null && TileMatrixSet.TileMatrixes.Count > zoomLevel &&
2022-11-22 19:15:34 +01:00
column >= 0 && row >= 0 && zoomLevel >= 0)
2020-03-20 18:12:56 +01:00
{
uri = new Uri(UriTemplate
2020-03-21 01:52:17 +01:00
.Replace("{TileMatrixSet}", TileMatrixSet.Identifier)
.Replace("{TileMatrix}", TileMatrixSet.TileMatrixes[zoomLevel].Identifier)
2022-11-22 19:15:34 +01:00
.Replace("{TileCol}", column.ToString())
.Replace("{TileRow}", row.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
}
}
}