diff --git a/MapControl/Shared/MapBase.cs b/MapControl/Shared/MapBase.cs
index 97cac30d..2444eaa1 100644
--- a/MapControl/Shared/MapBase.cs
+++ b/MapControl/Shared/MapBase.cs
@@ -221,7 +221,7 @@ namespace MapControl
if (point.HasValue)
{
- point = ViewTransform.MapToViewMatrix.Transform(point.Value);
+ point = ViewTransform.MapToView(point.Value);
}
return point;
@@ -240,7 +240,7 @@ namespace MapControl
///
public Location ViewToLocation(Point point)
{
- return MapProjection.MapToLocation(ViewTransform.ViewToMapMatrix.Transform(point));
+ return MapProjection.MapToLocation(ViewTransform.ViewToMap(point));
}
///
@@ -248,7 +248,7 @@ namespace MapControl
///
public BoundingBox ViewToBoundingBox(Rect rect)
{
- return MapProjection.MapToBoundingBox(ViewTransform.ViewToMapMatrix.TransformBounds(rect));
+ return MapProjection.MapToBoundingBox(ViewTransform.ViewToMapBounds(rect));
}
///
diff --git a/MapControl/Shared/MapImageLayer.cs b/MapControl/Shared/MapImageLayer.cs
index f44d0b91..fc165c46 100644
--- a/MapControl/Shared/MapImageLayer.cs
+++ b/MapControl/Shared/MapImageLayer.cs
@@ -191,7 +191,7 @@ namespace MapControl
var height = ParentMap.ActualHeight * RelativeImageSize;
var x = (ParentMap.ActualWidth - width) / 2d;
var y = (ParentMap.ActualHeight - height) / 2d;
- var mapRect = ParentMap.ViewTransform.ViewToMapMatrix.TransformBounds(new Rect(x, y, width, height));
+ var mapRect = ParentMap.ViewTransform.ViewToMapBounds(new Rect(x, y, width, height));
boundingBox = ParentMap.MapProjection.MapToBoundingBox(mapRect);
if (boundingBox != null)
diff --git a/MapControl/Shared/MapPanel.cs b/MapControl/Shared/MapPanel.cs
index ccd013db..7975fc3c 100644
--- a/MapControl/Shared/MapPanel.cs
+++ b/MapControl/Shared/MapPanel.cs
@@ -220,7 +220,7 @@ namespace MapControl
private Rect GetViewRect(Rect mapRect)
{
var center = new Point(mapRect.X + mapRect.Width / 2d, mapRect.Y + mapRect.Height / 2d);
- var position = parentMap.ViewTransform.MapToViewMatrix.Transform(center);
+ var position = parentMap.ViewTransform.MapToView(center);
if (parentMap.MapProjection.Type <= MapProjectionType.NormalCylindrical &&
!parentMap.InsideViewBounds(position))
diff --git a/MapControl/Shared/MapPath.cs b/MapControl/Shared/MapPath.cs
index 8c0901af..7e10ef8b 100644
--- a/MapControl/Shared/MapPath.cs
+++ b/MapControl/Shared/MapPath.cs
@@ -114,7 +114,7 @@ namespace MapControl
if (point.HasValue)
{
- point = ParentMap.ViewTransform.MapToViewMatrix.Transform(point.Value);
+ point = ParentMap.ViewTransform.MapToView(point.Value);
}
return point;
diff --git a/MapControl/Shared/ViewTransform.cs b/MapControl/Shared/ViewTransform.cs
index 8bafdffb..83ad25fe 100644
--- a/MapControl/Shared/ViewTransform.cs
+++ b/MapControl/Shared/ViewTransform.cs
@@ -38,6 +38,22 @@ namespace MapControl
///
public Matrix ViewToMapMatrix { get; private set; }
+ ///
+ /// Transforms a Point in projected map coordinates to a Point in view coordinates.
+ ///
+ public Point MapToView(Point point) => MapToViewMatrix.Transform(point);
+
+ ///
+ /// Transforms a Point in view coordinates to a Point in projected map coordinates.
+ ///
+ public Point ViewToMap(Point point) => ViewToMapMatrix.Transform(point);
+
+ ///
+ /// Gets an axis-aligned bounding box in projected map coordinates that contains
+ /// a rectangle in view coordinates.
+ ///
+ public Rect ViewToMapBounds(Rect rect) => TransformBounds(ViewToMapMatrix, rect);
+
///
/// 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);
diff --git a/MapControl/Shared/WmsImageLayer.cs b/MapControl/Shared/WmsImageLayer.cs
index f8ca9475..5408d7ef 100644
--- a/MapControl/Shared/WmsImageLayer.cs
+++ b/MapControl/Shared/WmsImageLayer.cs
@@ -264,7 +264,7 @@ namespace MapControl
{
var width = ParentMap.ActualWidth;
var height = ParentMap.ActualHeight;
- var bbox = ParentMap.ViewTransform.ViewToMapMatrix.TransformBounds(new Rect(0d, 0d, width, height));
+ var bbox = ParentMap.ViewTransform.ViewToMapBounds(new Rect(0d, 0d, width, height));
if (ParentMap.ViewTransform.Rotation != 0d)
{