Updated MapImageLayer

This commit is contained in:
Clemens 2022-02-22 23:09:19 +01:00
parent 7e335112cd
commit ba1a5724ee
2 changed files with 11 additions and 10 deletions

View file

@ -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; }

View file

@ -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<Image>())
{
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));
}
}
}