mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Compare commits
4 commits
2ec4d8fa60
...
ab1695b107
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab1695b107 | ||
|
|
90cc3621bb | ||
|
|
7263e9e1e4 | ||
|
|
a223c32466 |
|
|
@ -28,8 +28,8 @@ namespace MapControl
|
|||
public static readonly DependencyProperty CapabilitiesUriProperty =
|
||||
DependencyPropertyHelper.Register<WmtsTileLayer, Uri>(nameof(CapabilitiesUri));
|
||||
|
||||
public static readonly DependencyProperty TileUriTemplateProperty =
|
||||
DependencyPropertyHelper.Register<WmtsTileLayer, string>(nameof(TileUriTemplate));
|
||||
public static readonly DependencyProperty UriTemplateProperty =
|
||||
DependencyPropertyHelper.Register<WmtsTileLayer, string>(nameof(UriTemplate));
|
||||
|
||||
public static readonly DependencyProperty LayerProperty =
|
||||
DependencyPropertyHelper.Register<WmtsTileLayer, string>(nameof(Layer));
|
||||
|
|
@ -55,10 +55,10 @@ namespace MapControl
|
|||
/// The Uri template string used for the UriTemplate property of WmtsTileSource instances.
|
||||
/// Usually set internally from WmtsCapabilities requested by a Loaded event handler.
|
||||
/// </summary>
|
||||
public string TileUriTemplate
|
||||
public string UriTemplate
|
||||
{
|
||||
get => (string)GetValue(TileUriTemplateProperty);
|
||||
set => SetValue(TileUriTemplateProperty, value);
|
||||
get => (string)GetValue(UriTemplateProperty);
|
||||
set => SetValue(UriTemplateProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -129,9 +129,9 @@ namespace MapControl
|
|||
Children.Clear();
|
||||
CancelLoadTiles();
|
||||
}
|
||||
else if (UpdateChildLayers(tileMatrixSet))
|
||||
else if (UpdateChildLayers(tileMatrixSet.TileMatrixes))
|
||||
{
|
||||
var tileSource = new WmtsTileSource(tileMatrixSet, TileUriTemplate);
|
||||
var tileSource = new WmtsTileSource(UriTemplate, tileMatrixSet);
|
||||
var cacheName = SourceName;
|
||||
|
||||
if (!string.IsNullOrEmpty(cacheName))
|
||||
|
|
@ -151,13 +151,13 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
private bool UpdateChildLayers(WmtsTileMatrixSet tileMatrixSet)
|
||||
private bool UpdateChildLayers(IList<WmtsTileMatrix> tileMatrixSet)
|
||||
{
|
||||
// Multiply scale by 1.001 to avoid floating point precision issues
|
||||
// and get all WmtsTileMatrixes with Scale <= maxScale.
|
||||
//
|
||||
var maxScale = 1.001 * ParentMap.ViewTransform.Scale;
|
||||
var tileMatrixes = tileMatrixSet.TileMatrixes.Where(matrix => matrix.Scale <= maxScale).ToList();
|
||||
var tileMatrixes = tileMatrixSet.Where(matrix => matrix.Scale <= maxScale).ToList();
|
||||
|
||||
if (tileMatrixes.Count == 0)
|
||||
{
|
||||
|
|
@ -189,10 +189,10 @@ namespace MapControl
|
|||
|
||||
foreach (var tileMatrix in tileMatrixes)
|
||||
{
|
||||
// Pass index of tileMatrix in tileMatrixSet.TileMatrixes as zoom level to WmtsTileMatrixLayer ctor.
|
||||
// Pass index of tileMatrix in tileMatrixSet as zoom level to WmtsTileMatrixLayer ctor.
|
||||
//
|
||||
var layer = layers.FirstOrDefault(layer => layer.WmtsTileMatrix == tileMatrix) ??
|
||||
new WmtsTileMatrixLayer(tileMatrix, tileMatrixSet.TileMatrixes.IndexOf(tileMatrix));
|
||||
new WmtsTileMatrixLayer(tileMatrix, tileMatrixSet.IndexOf(tileMatrix));
|
||||
|
||||
if (layer.UpdateTiles(ParentMap.ViewTransform, ParentMap.ActualWidth, ParentMap.ActualHeight))
|
||||
{
|
||||
|
|
@ -226,7 +226,7 @@ namespace MapControl
|
|||
}
|
||||
|
||||
Layer = capabilities.Layer;
|
||||
TileUriTemplate = capabilities.UriTemplate;
|
||||
UriTemplate = capabilities.UriTemplate;
|
||||
|
||||
UpdateTileCollection();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,19 +8,17 @@ namespace MapControl
|
|||
{
|
||||
private readonly IList<WmtsTileMatrix> tileMatrixes;
|
||||
|
||||
public WmtsTileSource(WmtsTileMatrixSet tileMatrixSet, string uriTemplate)
|
||||
public WmtsTileSource(string uriTemplate, WmtsTileMatrixSet tileMatrixSet)
|
||||
{
|
||||
tileMatrixes = tileMatrixSet.TileMatrixes;
|
||||
UriTemplate = uriTemplate.Replace("{TileMatrixSet}", tileMatrixSet.Identifier);
|
||||
tileMatrixes = tileMatrixSet.TileMatrixes;
|
||||
}
|
||||
|
||||
public override Uri GetUri(int zoomLevel, int column, int row)
|
||||
{
|
||||
Uri uri = null;
|
||||
|
||||
if (UriTemplate != null &&
|
||||
tileMatrixes != null &&
|
||||
tileMatrixes.Count > zoomLevel)
|
||||
if (zoomLevel < tileMatrixes.Count)
|
||||
{
|
||||
var uriBuilder = new StringBuilder(UriTemplate);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue