Minor changes

This commit is contained in:
ClemensFischer 2025-12-22 17:23:15 +01:00
parent 2b3a8606c0
commit 7cdbca9c8c
2 changed files with 23 additions and 24 deletions

View file

@ -34,7 +34,7 @@ namespace MapControl
return Math.Log(scale * 360d * MapProjection.Wgs84MeterPerDegree / 256d, 2d);
}
public static TimeSpan ImageFadeDuration { get; set; } = TimeSpan.FromSeconds(0.1);
public static TimeSpan ImageFadeDuration { get; set; } = TimeSpan.FromSeconds(0.2);
public static readonly DependencyProperty AnimationDurationProperty =
DependencyPropertyHelper.Register<MapBase, TimeSpan>(nameof(AnimationDuration), TimeSpan.FromSeconds(0.3));

View file

@ -188,41 +188,40 @@ namespace MapControl
}
var cacheKey = $"{cacheName}/{tile.ZoomLevel}/{tile.Column}/{tile.Row}{extension}";
byte[] buffer = null;
try
{
var cachedBuffer = await Cache.GetAsync(cacheKey).ConfigureAwait(false);
if (cachedBuffer != null)
{
return cachedBuffer;
}
buffer = await Cache.GetAsync(cacheKey).ConfigureAwait(false);
}
catch (Exception ex)
{
Logger?.LogError(ex, "Cache.GetAsync({cacheKey})", cacheKey);
}
(var buffer, var maxAge) = await ImageLoader.GetHttpResponseAsync(uri).ConfigureAwait(false);
if (buffer != null)
if (buffer == null)
{
try
{
var options = new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow =
!maxAge.HasValue ? DefaultCacheExpiration
: maxAge.Value < MinCacheExpiration ? MinCacheExpiration
: maxAge.Value > MaxCacheExpiration ? MaxCacheExpiration
: maxAge.Value
};
(buffer, var maxAge) = await ImageLoader.GetHttpResponseAsync(uri).ConfigureAwait(false);
await Cache.SetAsync(cacheKey, buffer, options).ConfigureAwait(false);
}
catch (Exception ex)
if (buffer != null)
{
Logger?.LogError(ex, "Cache.SetAsync({cacheKey})", cacheKey);
try
{
var options = new DistributedCacheEntryOptions
{
AbsoluteExpirationRelativeToNow =
!maxAge.HasValue ? DefaultCacheExpiration
: maxAge.Value < MinCacheExpiration ? MinCacheExpiration
: maxAge.Value > MaxCacheExpiration ? MaxCacheExpiration
: maxAge.Value
};
await Cache.SetAsync(cacheKey, buffer, options).ConfigureAwait(false);
}
catch (Exception ex)
{
Logger?.LogError(ex, "Cache.SetAsync({cacheKey})", cacheKey);
}
}
}