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; 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 West { get; set; }
public double East { get; set; } public double East { get; set; }

View file

@ -214,24 +214,19 @@ namespace MapControl
private void AdjustBoundingBox(double longitudeOffset) private void AdjustBoundingBox(double longitudeOffset)
{ {
if (Math.Abs(longitudeOffset) > 180d && if (Math.Abs(longitudeOffset) > 180d && BoundingBox != null)
BoundingBox != null &&
BoundingBox.West < BoundingBox.East && // not an azimuthal projection
BoundingBox.South < BoundingBox.North)
{ {
var offset = 360d * Math.Sign(longitudeOffset); var offset = 360d * Math.Sign(longitudeOffset);
BoundingBox = new BoundingBox( BoundingBox = new BoundingBox(BoundingBox, offset);
BoundingBox.South, BoundingBox.West + offset,
BoundingBox.North, BoundingBox.East + offset);
foreach (var image in Children.OfType<Image>()) 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));
} }
} }
} }