mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Changed SourceUri to SourcePath
This commit is contained in:
parent
b04ed4eebe
commit
9cb37ba921
3 changed files with 33 additions and 41 deletions
|
|
@ -3,6 +3,7 @@
|
|||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Media;
|
||||
|
|
@ -12,14 +13,20 @@ namespace MapControl
|
|||
{
|
||||
public partial class GeoImage
|
||||
{
|
||||
private static async Task<Tuple<BitmapSource, Matrix>> ReadGeoTiff(Uri sourceUri)
|
||||
private static async Task<Tuple<BitmapSource, Matrix>> ReadGeoTiff(string sourcePath)
|
||||
{
|
||||
return await Task.Run(() =>
|
||||
{
|
||||
BitmapSource bitmap = BitmapFrame.Create(sourceUri, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
||||
var metadata = (BitmapMetadata)bitmap.Metadata;
|
||||
BitmapSource bitmap;
|
||||
Matrix transform;
|
||||
|
||||
using (var stream = File.OpenRead(sourcePath))
|
||||
{
|
||||
bitmap = BitmapFrame.Create(stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad);
|
||||
}
|
||||
|
||||
var metadata = (BitmapMetadata)bitmap.Metadata;
|
||||
|
||||
if (metadata.GetQuery(PixelScaleQuery) is double[] pixelScale && pixelScale.Length == 3 &&
|
||||
metadata.GetQuery(TiePointQuery) is double[] tiePoint && tiePoint.Length >= 6)
|
||||
{
|
||||
|
|
@ -31,7 +38,7 @@ namespace MapControl
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("No coordinate transformation found in \"" + sourceUri + "\".");
|
||||
throw new ArgumentException("No coordinate transformation found in \"" + sourcePath + "\".");
|
||||
}
|
||||
|
||||
if (metadata.GetQuery(NoDataQuery) is string noData && int.TryParse(noData, out int noDataValue))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue