mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-08 16:05:50 +00:00
Updated TileSources
This commit is contained in:
parent
44d48eadde
commit
1222a4a8c2
5 changed files with 61 additions and 148 deletions
|
|
@ -1,35 +1,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public class WmtsTileSource : UriTileSource
|
||||
public class WmtsTileSource(WmtsTileMatrixSet tileMatrixSet) : TileSource
|
||||
{
|
||||
private readonly List<WmtsTileMatrix> tileMatrixes;
|
||||
private readonly string uriFormat = tileMatrixSet.UriTemplate
|
||||
.Replace("{TileMatrix}", "{0}")
|
||||
.Replace("{TileCol}", "{1}")
|
||||
.Replace("{TileRow}", "{2}");
|
||||
|
||||
public WmtsTileSource(WmtsTileMatrixSet tileMatrixSet)
|
||||
{
|
||||
UriTemplate = tileMatrixSet.UriTemplate;
|
||||
tileMatrixes = tileMatrixSet.TileMatrixes;
|
||||
}
|
||||
private readonly List<WmtsTileMatrix> tileMatrixes = tileMatrixSet.TileMatrixes;
|
||||
|
||||
public override Uri GetUri(int zoomLevel, int column, int row)
|
||||
{
|
||||
Uri uri = null;
|
||||
|
||||
if (zoomLevel < tileMatrixes.Count)
|
||||
{
|
||||
var uriBuilder = new StringBuilder(UriTemplate);
|
||||
|
||||
uriBuilder.Replace("{TileMatrix}", tileMatrixes[zoomLevel].Identifier);
|
||||
uriBuilder.Replace("{TileCol}", column.ToString());
|
||||
uriBuilder.Replace("{TileRow}", row.ToString());
|
||||
|
||||
uri = new Uri(uriBuilder.ToString());
|
||||
}
|
||||
|
||||
return uri;
|
||||
return zoomLevel < tileMatrixes.Count
|
||||
? new Uri(string.Format(uriFormat, tileMatrixes[zoomLevel].Identifier, column, row))
|
||||
: null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue