mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 06:26:41 +00:00
Version 4.12.2 Updated MapImages and MBTiles
This commit is contained in:
parent
f74d700006
commit
a25cc91c2f
9 changed files with 103 additions and 208 deletions
|
|
@ -25,9 +25,19 @@ namespace MapControl.MBTiles
|
|||
connection = new SQLiteConnection("Data Source=" + Path.GetFullPath(file));
|
||||
}
|
||||
|
||||
public Task OpenAsync()
|
||||
public async Task OpenAsync()
|
||||
{
|
||||
return connection.OpenAsync();
|
||||
await connection.OpenAsync();
|
||||
|
||||
using (var command = new SQLiteCommand("create table if not exists metadata (name string, value string)", connection))
|
||||
{
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
|
||||
using (var command = new SQLiteCommand("create table if not exists tiles (zoom_level integer, tile_column integer, tile_row integer, tile_data blob)", connection))
|
||||
{
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
|
|
@ -68,11 +78,6 @@ namespace MapControl.MBTiles
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var command = new SQLiteCommand("create table if not exists metadata (name string, value string)", connection))
|
||||
{
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
|
||||
using (var command = new SQLiteCommand("insert or replace into metadata (name, value) values (@n, @v)", connection))
|
||||
{
|
||||
foreach (var keyValue in metadata)
|
||||
|
|
@ -117,11 +122,6 @@ namespace MapControl.MBTiles
|
|||
{
|
||||
try
|
||||
{
|
||||
using (var command = new SQLiteCommand("create table if not exists tiles (zoom_level integer, tile_column integer, tile_row integer, tile_data blob)", connection))
|
||||
{
|
||||
await command.ExecuteNonQueryAsync();
|
||||
}
|
||||
|
||||
using (var command = new SQLiteCommand("insert or replace into tiles (zoom_level, tile_column, tile_row, tile_data) values (@z, @x, @y, @b)", connection))
|
||||
{
|
||||
command.Parameters.AddWithValue("@z", zoomLevel);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@ using System.Windows;
|
|||
|
||||
namespace MapControl.MBTiles
|
||||
{
|
||||
/// <summary>
|
||||
/// MapTileLayer that uses an MBTiles SQLite Database. See https://wiki.openstreetmap.org/wiki/MBTiles.
|
||||
/// </summary>
|
||||
public class MBTileLayer : MapTileLayer
|
||||
{
|
||||
public static readonly DependencyProperty FileProperty = DependencyProperty.Register(
|
||||
|
|
|
|||
|
|
@ -16,48 +16,47 @@ namespace MapControl.MBTiles
|
|||
{
|
||||
private readonly MBTileData tileData;
|
||||
|
||||
public string Name { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
public int? MinZoom { get; private set; }
|
||||
public int? MaxZoom { get; private set; }
|
||||
|
||||
public MBTileSource(string file)
|
||||
{
|
||||
tileData = new MBTileData(file);
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
public int? MinZoom { get; private set; }
|
||||
public int? MaxZoom { get; private set; }
|
||||
|
||||
public async Task Initialize()
|
||||
{
|
||||
await tileData.OpenAsync();
|
||||
|
||||
var metadata = await tileData.ReadMetadataAsync();
|
||||
|
||||
string name;
|
||||
string description;
|
||||
string minzoom;
|
||||
string maxzoom;
|
||||
string s;
|
||||
int minZoom;
|
||||
int maxZoom;
|
||||
|
||||
if (metadata.TryGetValue("name", out name))
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
Name = (metadata.TryGetValue("name", out s)) ? s : null;
|
||||
|
||||
if (metadata.TryGetValue("description", out description))
|
||||
{
|
||||
Description = description;
|
||||
}
|
||||
Description = (metadata.TryGetValue("description", out s)) ? s : null;
|
||||
|
||||
if (metadata.TryGetValue("minzoom", out minzoom) && int.TryParse(minzoom, out minZoom))
|
||||
if (metadata.TryGetValue("minzoom", out s) && int.TryParse(s, out minZoom))
|
||||
{
|
||||
MinZoom = minZoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
MinZoom = null;
|
||||
}
|
||||
|
||||
if (metadata.TryGetValue("maxzoom", out maxzoom) && int.TryParse(maxzoom, out maxZoom))
|
||||
if (metadata.TryGetValue("maxzoom", out s) && int.TryParse(s, out maxZoom))
|
||||
{
|
||||
MaxZoom = maxZoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
MaxZoom = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@
|
|||
<Reference Include="System.Data.SQLite, Version=1.0.111.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\System.Data.SQLite.Core.1.0.111.0\lib\net46\System.Data.SQLite.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue