mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-30 20:34:38 +01:00
Updated LatLonBoxToMap
This commit is contained in:
parent
dbc4c142f7
commit
05032dbd25
|
|
@ -287,7 +287,7 @@ namespace MapControl
|
|||
private void ArrangeElement(FrameworkElement element, BoundingBox boundingBox)
|
||||
{
|
||||
Rect? mapRect;
|
||||
Matrix transform;
|
||||
Matrix? transform = null;
|
||||
|
||||
if (boundingBox is LatLonBox latLonBox)
|
||||
{
|
||||
|
|
@ -296,7 +296,6 @@ namespace MapControl
|
|||
else
|
||||
{
|
||||
mapRect = parentMap.MapProjection.BoundingBoxToMap(boundingBox);
|
||||
transform = new Matrix(1d, 0d, 0d, 1d, 0d, 0d);
|
||||
}
|
||||
|
||||
if (mapRect.HasValue)
|
||||
|
|
@ -307,19 +306,23 @@ namespace MapControl
|
|||
element.Height = viewRect.Height;
|
||||
element.Arrange(viewRect);
|
||||
|
||||
transform.Rotate(parentMap.ViewTransform.Rotation);
|
||||
|
||||
if (element.RenderTransform is MatrixTransform matrixTransform
|
||||
#if WPF
|
||||
&& !matrixTransform.IsFrozen
|
||||
#endif
|
||||
)
|
||||
if (parentMap.ViewTransform.Rotation != 0d)
|
||||
{
|
||||
matrixTransform.Matrix = transform;
|
||||
if (!transform.HasValue)
|
||||
{
|
||||
transform = new Matrix(1d, 0d, 0d, 1d, 0d, 0d);
|
||||
}
|
||||
|
||||
transform.Value.Rotate(parentMap.ViewTransform.Rotation);
|
||||
}
|
||||
|
||||
if (transform.HasValue)
|
||||
{
|
||||
element.SetRenderTransform(new MatrixTransform { Matrix = transform.Value }, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
element.SetRenderTransform(new MatrixTransform { Matrix = transform }, true);
|
||||
element.ClearValue(RenderTransformProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,12 +163,12 @@ namespace MapControl
|
|||
|
||||
/// <summary>
|
||||
/// Transforms a LatLonBox in geographic coordinates to a rotated Rect in projected map coordinates.
|
||||
/// Returns (null, 0d) when the LatLonBox can not be transformed.
|
||||
/// Returns (null, null) when the LatLonBox can not be transformed.
|
||||
/// </summary>
|
||||
public (Rect?, Matrix) LatLonBoxToMap(LatLonBox latLonBox)
|
||||
public (Rect?, Matrix?) LatLonBoxToMap(LatLonBox latLonBox)
|
||||
{
|
||||
Rect? rect = null;
|
||||
Matrix transform;
|
||||
Matrix? transform = null;
|
||||
var sw = LocationToMap(latLonBox.South, latLonBox.West);
|
||||
var se = LocationToMap(latLonBox.South, latLonBox.East);
|
||||
var nw = LocationToMap(latLonBox.North, latLonBox.West);
|
||||
|
|
@ -192,14 +192,14 @@ namespace MapControl
|
|||
|
||||
rect = new Rect(x, y, width, height);
|
||||
|
||||
// Skew matrix with skewX = Atan(-dx2 / dy2) and skewY = Atan(-dy1 / dx1).
|
||||
//
|
||||
transform = new Matrix(1d, -dy1 / dx1, -dx2 / dy2, 1d, 0d, 0d);
|
||||
transform.Rotate(-latLonBox.Rotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform = new Matrix(1d, 0d, 0d, 1d, 0d, 0d);
|
||||
if (dy1 != 0d || dx2 != 0d || latLonBox.Rotation != 0d)
|
||||
{
|
||||
// Skew matrix with skewX = Atan(-dx2 / dy2) and skewY = Atan(-dy1 / dx1).
|
||||
//
|
||||
var t = new Matrix(1d, -dy1 / dx1, -dx2 / dy2, 1d, 0d, 0d);
|
||||
t.Rotate(-latLonBox.Rotation);
|
||||
transform = t;
|
||||
}
|
||||
}
|
||||
|
||||
return (rect, transform);
|
||||
|
|
|
|||
Loading…
Reference in a new issue