2018-08-15 23:29:03 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2021-01-13 21:19:27 +01:00
|
|
|
|
// © 2021 Clemens Fischer
|
2018-08-15 23:29:03 +02:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
#if WINDOWS_UWP
|
|
|
|
|
|
using Windows.UI.Xaml.Media;
|
|
|
|
|
|
#else
|
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2018-12-09 17:14:32 +01:00
|
|
|
|
namespace MapControl.MBTiles
|
2018-08-15 23:29:03 +02:00
|
|
|
|
{
|
2019-11-17 00:10:08 +01:00
|
|
|
|
public class MBTileSource : TileSource, IDisposable
|
2018-08-15 23:29:03 +02:00
|
|
|
|
{
|
2019-11-11 20:11:35 +01:00
|
|
|
|
public MBTileData TileData { get; }
|
2018-08-15 23:29:03 +02:00
|
|
|
|
|
2019-11-14 23:21:08 +01:00
|
|
|
|
public MBTileSource(MBTileData tiledata)
|
2018-08-15 23:29:03 +02:00
|
|
|
|
{
|
2019-11-11 20:11:35 +01:00
|
|
|
|
TileData = tiledata;
|
2019-07-18 21:09:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-08-15 23:29:03 +02:00
|
|
|
|
public void Dispose()
|
|
|
|
|
|
{
|
2019-11-17 00:10:08 +01:00
|
|
|
|
Dispose(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (disposing)
|
|
|
|
|
|
{
|
|
|
|
|
|
TileData.Dispose();
|
|
|
|
|
|
}
|
2018-08-15 23:29:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<ImageSource> LoadImageAsync(int x, int y, int zoomLevel)
|
|
|
|
|
|
{
|
2019-11-11 20:11:35 +01:00
|
|
|
|
var buffer = await TileData.ReadImageBufferAsync(x, y, zoomLevel);
|
2018-08-15 23:29:03 +02:00
|
|
|
|
|
2018-08-16 19:45:50 +02:00
|
|
|
|
return buffer != null ? await ImageLoader.LoadImageAsync(buffer) : null;
|
2018-08-15 23:29:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|