diff --git a/MapControl/Shared/MapTileLayer.cs b/MapControl/Shared/MapTileLayer.cs index 528d6986..9dc051a5 100644 --- a/MapControl/Shared/MapTileLayer.cs +++ b/MapControl/Shared/MapTileLayer.cs @@ -146,7 +146,7 @@ namespace MapControl Children.Add(tile.Image); } - TileImageLoader.LoadTiles(Tiles, TileSource, SourceName); + LoadTiles(Tiles, SourceName); } } diff --git a/MapControl/Shared/MapTileLayerBase.cs b/MapControl/Shared/MapTileLayerBase.cs index ec0d4f13..746d5be8 100644 --- a/MapControl/Shared/MapTileLayerBase.cs +++ b/MapControl/Shared/MapTileLayerBase.cs @@ -19,7 +19,7 @@ namespace MapControl { public interface ITileImageLoader { - void LoadTiles(IEnumerable tiles, TileSource tileSource, string sourceName); + void LoadTiles(IEnumerable tiles, TileSource tileSource, string cacheName); } public abstract class MapTileLayerBase : Panel, IMapLayer @@ -189,5 +189,10 @@ namespace MapControl protected abstract void UpdateTileLayer(bool tileSourceChanged); protected abstract void SetRenderTransform(); + + protected virtual void LoadTiles(IEnumerable tiles, string cacheName) + { + TileImageLoader.LoadTiles(tiles, TileSource, cacheName); + } } } diff --git a/MapControl/Shared/TileImageLoader.cs b/MapControl/Shared/TileImageLoader.cs index 739f5390..d1e8907b 100644 --- a/MapControl/Shared/TileImageLoader.cs +++ b/MapControl/Shared/TileImageLoader.cs @@ -30,7 +30,7 @@ namespace MapControl public static TimeSpan DefaultCacheExpiration { get; set; } = TimeSpan.FromDays(1); /// - /// Format string for creating cache keys from the sourceName argument passed to LoadTilesAsync, + /// Format string for creating cache keys from the cacheName argument passed to LoadTilesAsync, /// the ZoomLevel, XIndex, and Y properties of a Tile, and the image file extension. /// The default value is "{0}/{1}/{2}/{3}{4}". /// @@ -56,10 +56,10 @@ namespace MapControl /// /// Loads all pending tiles from the tiles collection. - /// If tileSource.UriFormat starts with "http" and sourceName is a non-empty string, + /// If tileSource.UriFormat starts with "http" and cacheName is a non-empty string, /// tile images will be cached in the TileImageLoader's Cache (if that is not null). /// - public void LoadTiles(IEnumerable tiles, TileSource tileSource, string sourceName) + public void LoadTiles(IEnumerable tiles, TileSource tileSource, string cacheName) { tileQueue.Clear(); @@ -70,9 +70,9 @@ namespace MapControl if (Cache != null && tileSource.UriFormat != null && tileSource.UriFormat.StartsWith("http") && - !string.IsNullOrEmpty(sourceName)) + !string.IsNullOrEmpty(cacheName)) { - loadTile = tile => LoadCachedTileAsync(tile, tileSource, sourceName); + loadTile = tile => LoadCachedTileAsync(tile, tileSource, cacheName); } else { @@ -109,7 +109,7 @@ namespace MapControl Interlocked.Decrement(ref taskCount); } - private static async Task LoadCachedTileAsync(Tile tile, TileSource tileSource, string sourceName) + private static async Task LoadCachedTileAsync(Tile tile, TileSource tileSource, string cacheName) { var uri = tileSource.GetUri(tile.XIndex, tile.Y, tile.ZoomLevel); @@ -122,7 +122,7 @@ namespace MapControl extension = ".jpg"; } - var cacheKey = string.Format(CacheKeyFormat, sourceName, tile.ZoomLevel, tile.XIndex, tile.Y, extension); + var cacheKey = string.Format(CacheKeyFormat, cacheName, tile.ZoomLevel, tile.XIndex, tile.Y, extension); await LoadCachedTileAsync(tile, uri, cacheKey).ConfigureAwait(false); } diff --git a/MapControl/Shared/WmtsTileLayer.cs b/MapControl/Shared/WmtsTileLayer.cs index 413616d1..0e429ccc 100644 --- a/MapControl/Shared/WmtsTileLayer.cs +++ b/MapControl/Shared/WmtsTileLayer.cs @@ -162,15 +162,15 @@ namespace MapControl } var tileSource = TileSource as WmtsTileSource; - var sourceName = SourceName; + var cacheName = SourceName; if (tileSource != null && tileMatrixSet != null) { tileSource.TileMatrixSet = tileMatrixSet; - if (sourceName != null) + if (cacheName != null) { - sourceName += "/" + tileMatrixSet.Identifier + cacheName += "/" + tileMatrixSet.Identifier .Replace(':', '_') .Replace(';', '_') .Replace(',', '_') @@ -179,7 +179,7 @@ namespace MapControl } } - TileImageLoader.LoadTiles(tiles, tileSource, sourceName); + LoadTiles(tiles, cacheName); } private async void OnLoaded(object sender, RoutedEventArgs e) diff --git a/MapControl/Shared/WmtsTileSource.cs b/MapControl/Shared/WmtsTileSource.cs index 203f2f48..f5309b91 100644 --- a/MapControl/Shared/WmtsTileSource.cs +++ b/MapControl/Shared/WmtsTileSource.cs @@ -14,7 +14,10 @@ namespace MapControl { Uri uri = null; - if (UriFormat != null && TileMatrixSet != null && zoomLevel >= 0 && zoomLevel < TileMatrixSet.TileMatrixes.Count) + if (UriFormat != null && + TileMatrixSet != null && + zoomLevel >= 0 && + zoomLevel < TileMatrixSet.TileMatrixes.Count) { uri = new Uri(UriFormat .Replace("{TileMatrixSet}", TileMatrixSet.Identifier)