Updated TileImageLoader and ImageFileCache for WinUI

This commit is contained in:
Clemens 2021-06-28 23:35:03 +02:00
parent 9ebc88204b
commit a9475f79fe
7 changed files with 90 additions and 75 deletions

View file

@ -111,30 +111,30 @@ namespace MapControl
Interlocked.Decrement(ref taskCount);
}
private static async Task LoadTileAsync(Tile tile, TileSource tileSource, string cacheName)
private static Task LoadTileAsync(Tile tile, TileSource tileSource, string cacheName)
{
if (cacheName == null)
{
await LoadTileAsync(tile, tileSource).ConfigureAwait(false);
return LoadTileAsync(tile, tileSource);
}
else
var uri = tileSource.GetUri(tile.XIndex, tile.Y, tile.ZoomLevel);
if (uri == null)
{
var uri = tileSource.GetUri(tile.XIndex, tile.Y, tile.ZoomLevel);
if (uri != null)
{
var extension = Path.GetExtension(uri.LocalPath);
if (string.IsNullOrEmpty(extension) || extension == ".jpeg")
{
extension = ".jpg";
}
var cacheKey = string.Format("{0}/{1}/{2}/{3}{4}", cacheName, tile.ZoomLevel, tile.XIndex, tile.Y, extension);
await LoadCachedTileAsync(tile, uri, cacheKey).ConfigureAwait(false);
}
return Task.CompletedTask;
}
var extension = Path.GetExtension(uri.LocalPath);
if (string.IsNullOrEmpty(extension) || extension == ".jpeg")
{
extension = ".jpg";
}
var cacheKey = string.Format("{0}/{1}/{2}/{3}{4}", cacheName, tile.ZoomLevel, tile.XIndex, tile.Y, extension);
return LoadCachedTileAsync(tile, uri, cacheKey);
}
private static DateTime GetExpiration(TimeSpan? maxAge)