mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-08 16:05:50 +00:00
Added ViewTransform methods
This commit is contained in:
parent
eee71e9190
commit
26e9b21816
6 changed files with 25 additions and 12 deletions
|
|
@ -38,6 +38,22 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public Matrix ViewToMapMatrix { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a Point in projected map coordinates to a Point in view coordinates.
|
||||
/// </summary>
|
||||
public Point MapToView(Point point) => MapToViewMatrix.Transform(point);
|
||||
|
||||
/// <summary>
|
||||
/// Transforms a Point in view coordinates to a Point in projected map coordinates.
|
||||
/// </summary>
|
||||
public Point ViewToMap(Point point) => ViewToMapMatrix.Transform(point);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an axis-aligned bounding box in projected map coordinates that contains
|
||||
/// a rectangle in view coordinates.
|
||||
/// </summary>
|
||||
public Rect ViewToMapBounds(Rect rect) => TransformBounds(ViewToMapMatrix, rect);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a ViewTransform from a map center point in projected coordinates,
|
||||
/// a view conter point, a scaling factor from projected coordinates to view coordinates
|
||||
|
|
@ -101,13 +117,10 @@ namespace MapControl
|
|||
|
||||
// Transform view bounds to tile pixel bounds.
|
||||
//
|
||||
return transform.TransformBounds(new Rect(0d, 0d, viewWidth, viewHeight));
|
||||
return TransformBounds(transform, new Rect(0d, 0d, viewWidth, viewHeight));
|
||||
}
|
||||
}
|
||||
|
||||
public static class MatrixExtension
|
||||
{
|
||||
public static Rect TransformBounds(this Matrix transform, Rect rect)
|
||||
private static Rect TransformBounds(Matrix transform, Rect rect)
|
||||
{
|
||||
#if AVALONIA
|
||||
return rect.TransformToAABB(transform);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue