mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-05-07 13:37:47 +00:00
WMTS tile handling
This commit is contained in:
parent
6d359a5a91
commit
0e27e95c6f
11 changed files with 100 additions and 71 deletions
35
MapControl/Shared/TileCollection.cs
Normal file
35
MapControl/Shared/TileCollection.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2022 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public class TileCollection : List<Tile>
|
||||
{
|
||||
/// <summary>
|
||||
/// Get a matching Tile from a TileCollection or create a new one.
|
||||
/// </summary>
|
||||
public Tile GetTile(int zoomLevel, int x, int y, int columnCount)
|
||||
{
|
||||
var tile = this.FirstOrDefault(t => t.ZoomLevel == zoomLevel && t.X == x && t.Y == y);
|
||||
|
||||
if (tile == null)
|
||||
{
|
||||
tile = new Tile(zoomLevel, x, y, columnCount);
|
||||
|
||||
var equivalentTile = this.FirstOrDefault(
|
||||
t => t.IsLoaded && t.ZoomLevel == tile.ZoomLevel && t.Column == tile.Column && t.Row == tile.Row);
|
||||
|
||||
if (equivalentTile != null)
|
||||
{
|
||||
tile.SetImageSource(equivalentTile.Image.Source, false); // no opacity animation
|
||||
}
|
||||
}
|
||||
|
||||
return tile;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue