mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-05-07 13:37:47 +00:00
File scoped namespaces
This commit is contained in:
parent
c14377f976
commit
65aba44af6
152 changed files with 11962 additions and 12115 deletions
|
|
@ -8,66 +8,65 @@ using Windows.UI.Xaml.Media.Imaging;
|
|||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
namespace MapControl;
|
||||
|
||||
public static partial class GeoImage
|
||||
{
|
||||
public static partial class GeoImage
|
||||
private static async Task<GeoBitmap> LoadGeoTiff(string sourcePath)
|
||||
{
|
||||
private static async Task<GeoBitmap> LoadGeoTiff(string sourcePath)
|
||||
BitmapSource bitmap;
|
||||
Matrix transform;
|
||||
MapProjection projection = null;
|
||||
|
||||
var file = await StorageFile.GetFileFromPathAsync(FilePath.GetFullPath(sourcePath));
|
||||
|
||||
using var stream = await file.OpenReadAsync();
|
||||
|
||||
var decoder = await BitmapDecoder.CreateAsync(stream);
|
||||
|
||||
bitmap = await ImageLoader.LoadWriteableBitmapAsync(decoder);
|
||||
|
||||
var geoKeyDirectoryQuery = QueryString(GeoKeyDirectoryTag);
|
||||
var pixelScaleQuery = QueryString(ModelPixelScaleTag);
|
||||
var tiePointQuery = QueryString(ModelTiePointTag);
|
||||
var transformationQuery = QueryString(ModelTransformationTag);
|
||||
var metadata = await decoder.BitmapProperties.GetPropertiesAsync(
|
||||
new string[]
|
||||
{
|
||||
pixelScaleQuery,
|
||||
tiePointQuery,
|
||||
transformationQuery,
|
||||
geoKeyDirectoryQuery
|
||||
});
|
||||
|
||||
if (metadata.TryGetValue(pixelScaleQuery, out BitmapTypedValue pixelScaleValue) &&
|
||||
pixelScaleValue.Value is double[] pixelScale &&
|
||||
pixelScale.Length == 3 &&
|
||||
metadata.TryGetValue(tiePointQuery, out BitmapTypedValue tiePointValue) &&
|
||||
tiePointValue.Value is double[] tiePoint &&
|
||||
tiePoint.Length >= 6)
|
||||
{
|
||||
BitmapSource bitmap;
|
||||
Matrix transform;
|
||||
MapProjection projection = null;
|
||||
|
||||
var file = await StorageFile.GetFileFromPathAsync(FilePath.GetFullPath(sourcePath));
|
||||
|
||||
using var stream = await file.OpenReadAsync();
|
||||
|
||||
var decoder = await BitmapDecoder.CreateAsync(stream);
|
||||
|
||||
bitmap = await ImageLoader.LoadWriteableBitmapAsync(decoder);
|
||||
|
||||
var geoKeyDirectoryQuery = QueryString(GeoKeyDirectoryTag);
|
||||
var pixelScaleQuery = QueryString(ModelPixelScaleTag);
|
||||
var tiePointQuery = QueryString(ModelTiePointTag);
|
||||
var transformationQuery = QueryString(ModelTransformationTag);
|
||||
var metadata = await decoder.BitmapProperties.GetPropertiesAsync(
|
||||
new string[]
|
||||
{
|
||||
pixelScaleQuery,
|
||||
tiePointQuery,
|
||||
transformationQuery,
|
||||
geoKeyDirectoryQuery
|
||||
});
|
||||
|
||||
if (metadata.TryGetValue(pixelScaleQuery, out BitmapTypedValue pixelScaleValue) &&
|
||||
pixelScaleValue.Value is double[] pixelScale &&
|
||||
pixelScale.Length == 3 &&
|
||||
metadata.TryGetValue(tiePointQuery, out BitmapTypedValue tiePointValue) &&
|
||||
tiePointValue.Value is double[] tiePoint &&
|
||||
tiePoint.Length >= 6)
|
||||
{
|
||||
transform = new Matrix(pixelScale[0], 0d, 0d, -pixelScale[1], tiePoint[3], tiePoint[4]);
|
||||
}
|
||||
else if (metadata.TryGetValue(transformationQuery, out BitmapTypedValue transformValue) &&
|
||||
transformValue.Value is double[] transformValues &&
|
||||
transformValues.Length == 16)
|
||||
{
|
||||
transform = new Matrix(transformValues[0], transformValues[1],
|
||||
transformValues[4], transformValues[5],
|
||||
transformValues[3], transformValues[7]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("No coordinate transformation found.");
|
||||
}
|
||||
|
||||
if (metadata.TryGetValue(geoKeyDirectoryQuery, out BitmapTypedValue geoKeyDirValue) &&
|
||||
geoKeyDirValue.Value is short[] geoKeyDirectory)
|
||||
{
|
||||
projection = GetProjection(geoKeyDirectory);
|
||||
}
|
||||
|
||||
return new GeoBitmap(bitmap, transform, projection);
|
||||
transform = new Matrix(pixelScale[0], 0d, 0d, -pixelScale[1], tiePoint[3], tiePoint[4]);
|
||||
}
|
||||
else if (metadata.TryGetValue(transformationQuery, out BitmapTypedValue transformValue) &&
|
||||
transformValue.Value is double[] transformValues &&
|
||||
transformValues.Length == 16)
|
||||
{
|
||||
transform = new Matrix(transformValues[0], transformValues[1],
|
||||
transformValues[4], transformValues[5],
|
||||
transformValues[3], transformValues[7]);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("No coordinate transformation found.");
|
||||
}
|
||||
|
||||
if (metadata.TryGetValue(geoKeyDirectoryQuery, out BitmapTypedValue geoKeyDirValue) &&
|
||||
geoKeyDirValue.Value is short[] geoKeyDirectory)
|
||||
{
|
||||
projection = GetProjection(geoKeyDirectory);
|
||||
}
|
||||
|
||||
return new GeoBitmap(bitmap, transform, projection);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue