mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 23:15:14 +00:00
Updated MapsforgeTiles projects
This commit is contained in:
parent
105e812afa
commit
a9f0ccc78b
13 changed files with 196 additions and 138 deletions
17
MapsforgeTiles/WPF/MapsforgeTileSource.WPF.cs
Normal file
17
MapsforgeTiles/WPF/MapsforgeTileSource.WPF.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace MapControl.MapsforgeTiles
|
||||
{
|
||||
public partial class MapsforgeTileSource
|
||||
{
|
||||
private static BitmapSource CreateImage(int[] pixels)
|
||||
{
|
||||
var size = (int)Math.Sqrt(pixels.Length);
|
||||
var image = BitmapSource.Create(size, size, 96d, 96d, PixelFormats.Bgra32, null, pixels, size * 4);
|
||||
image.Freeze();
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
using MapsforgeWrapper;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace MapControl.MapsforgeTiles
|
||||
{
|
||||
public class MapsforgeTileSource(string theme, int cacheCapacity = 200) : TileSource
|
||||
{
|
||||
private readonly TileRenderer renderer = new(theme, cacheCapacity);
|
||||
|
||||
public static void Initialize(string mapFilePath, float dpiScale)
|
||||
{
|
||||
TileRenderer.Initialize(mapFilePath, dpiScale);
|
||||
}
|
||||
|
||||
public override Task<ImageSource> LoadImageAsync(int zoomLevel, int column, int row)
|
||||
{
|
||||
var pixels = renderer.RenderTile(zoomLevel, column, row);
|
||||
ImageSource image = pixels != null ? CreateImage(pixels) : null;
|
||||
|
||||
return Task.FromResult(image);
|
||||
}
|
||||
|
||||
private static BitmapSource CreateImage(int[] pixels)
|
||||
{
|
||||
var size = (int)Math.Sqrt(pixels.Length);
|
||||
var image = BitmapSource.Create(size, size, 96d, 96d, PixelFormats.Bgra32, null, pixels, size * 4);
|
||||
image.Freeze();
|
||||
return image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,10 +5,37 @@
|
|||
<DefineConstants>WPF</DefineConstants>
|
||||
<RootNamespace>MapControl.MapsforgeTiles</RootNamespace>
|
||||
<AssemblyTitle>XAML Map Control Mapsforge Library for WPF</AssemblyTitle>
|
||||
<GeneratePackageOnBuild>$(GeneratePackage)</GeneratePackageOnBuild>
|
||||
<PackageId>XAML.MapControl.MapsforgeTiles.WPF</PackageId>
|
||||
<Title>$(AssemblyTitle)</Title>
|
||||
<Description>Mapsforge support library for XAML Map Control</Description>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MapControl\WPF\MapControl.WPF.csproj" />
|
||||
<ProjectReference Include="..\MapsforgeWrapper\MapsforgeWrapper.csproj" />
|
||||
<Compile Include="..\Shared\*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MapControl\WPF\MapControl.WPF.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="IKVM" Version="8.15.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<IkvmReference Include="..\target\mapsforge-0.27.0-jar-with-dependencies.jar" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="$(OutDir)\mapsforge.dll">
|
||||
<Pack>true</Pack>
|
||||
<PackagePath>lib\net10.0-windows7.0</PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent"
|
||||
Outputs="..\target\mapsforge-0.27.0-jar-with-dependencies.jar">
|
||||
<Exec Command="mvn package" WorkingDirectory=".."/>
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue