From bfb5a978ee729461adb04f192c5b891307a6f87d Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Tue, 3 Sep 2024 08:29:51 +0200 Subject: [PATCH] Update GeoImage.cs --- MapControl/Shared/GeoImage.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/MapControl/Shared/GeoImage.cs b/MapControl/Shared/GeoImage.cs index 52e52979..9ef34b35 100644 --- a/MapControl/Shared/GeoImage.cs +++ b/MapControl/Shared/GeoImage.cs @@ -41,7 +41,6 @@ namespace MapControl private BitmapSource bitmapSource; private Matrix transformMatrix; private MapProjection mapProjection; - private BoundingBox boundingBox; public static readonly DependencyProperty SourcePathProperty = DependencyPropertyHelper.RegisterAttached("SourcePath", null, @@ -76,10 +75,17 @@ namespace MapControl await geoImage.LoadGeoImageAsync(sourcePath); + var p1 = geoImage.transformMatrix.Transform(new Point()); + var p2 = geoImage.transformMatrix.Transform(geoImage.BitmapSize); + + var boundingBox = geoImage.mapProjection != null + ? geoImage.mapProjection.MapToBoundingBox(new Rect(p1, p2)) + : new BoundingBox(p1.Y, p1.X, p2.Y, p2.X); + image.Source = geoImage.bitmapSource; image.Stretch = Stretch.Fill; - MapPanel.SetBoundingBox(image, geoImage.boundingBox); + MapPanel.SetBoundingBox(image, boundingBox); } catch (Exception ex) { @@ -108,13 +114,6 @@ namespace MapControl { await LoadGeoTiffAsync(sourcePath); } - - var p1 = transformMatrix.Transform(new Point()); - var p2 = transformMatrix.Transform(BitmapSize); - - boundingBox = mapProjection != null - ? mapProjection.MapToBoundingBox(new Rect(p1, p2)) - : new BoundingBox(p1.Y, p1.X, p2.Y, p2.X); } private async Task LoadWorldFileImageAsync(string sourcePath, string worldFilePath)