From ba1a5724eef0a3421fdb02b254c9c74ce4cb91e9 Mon Sep 17 00:00:00 2001 From: Clemens Date: Tue, 22 Feb 2022 23:09:19 +0100 Subject: [PATCH] Updated MapImageLayer --- MapControl/Shared/BoundingBox.cs | 6 ++++++ MapControl/Shared/MapImageLayer.cs | 15 +++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/MapControl/Shared/BoundingBox.cs b/MapControl/Shared/BoundingBox.cs index a8baabbc..ecb4d26b 100644 --- a/MapControl/Shared/BoundingBox.cs +++ b/MapControl/Shared/BoundingBox.cs @@ -30,6 +30,12 @@ namespace MapControl East = east; } + public BoundingBox(BoundingBox boundingBox, double longitudeOffset) + : this(boundingBox.South, boundingBox.West + longitudeOffset, + boundingBox.North, boundingBox.East + longitudeOffset) + { + } + public double West { get; set; } public double East { get; set; } diff --git a/MapControl/Shared/MapImageLayer.cs b/MapControl/Shared/MapImageLayer.cs index 8f03249c..1eb4fb2b 100644 --- a/MapControl/Shared/MapImageLayer.cs +++ b/MapControl/Shared/MapImageLayer.cs @@ -214,24 +214,19 @@ namespace MapControl private void AdjustBoundingBox(double longitudeOffset) { - if (Math.Abs(longitudeOffset) > 180d && - BoundingBox != null && - BoundingBox.West < BoundingBox.East && // not an azimuthal projection - BoundingBox.South < BoundingBox.North) + if (Math.Abs(longitudeOffset) > 180d && BoundingBox != null) { var offset = 360d * Math.Sign(longitudeOffset); - BoundingBox = new BoundingBox( - BoundingBox.South, BoundingBox.West + offset, - BoundingBox.North, BoundingBox.East + offset); + BoundingBox = new BoundingBox(BoundingBox, offset); foreach (var image in Children.OfType()) { - var bbox = GetBoundingBox(image); + var imageBoundingBox = GetBoundingBox(image); - if (bbox != null) + if (imageBoundingBox != null) { - SetBoundingBox(image, new BoundingBox(bbox.South, bbox.West + offset, bbox.North, bbox.East + offset)); + SetBoundingBox(image, new BoundingBox(imageBoundingBox, offset)); } } }