diff --git a/MapControl/Shared/BoundingBox.cs b/MapControl/Shared/BoundingBox.cs
index eef8c479..61b244fa 100644
--- a/MapControl/Shared/BoundingBox.cs
+++ b/MapControl/Shared/BoundingBox.cs
@@ -16,9 +16,7 @@ namespace MapControl
public class BoundingBox
{
private double south;
- private double west;
private double north;
- private double east;
public BoundingBox()
{
@@ -32,48 +30,40 @@ namespace MapControl
East = east;
}
+ public double West { get; set; }
+
+ public double East { get; set; }
+
public double South
{
get { return south; }
set { south = Math.Min(Math.Max(value, -90d), 90d); }
}
- public double West
- {
- get { return west; }
- set { west = value; }
- }
-
public double North
{
get { return north; }
set { north = Math.Min(Math.Max(value, -90d), 90d); }
}
- public double East
- {
- get { return east; }
- set { east = value; }
- }
-
public virtual double Width
{
- get { return east - west; }
+ get { return East - West; }
}
public virtual double Height
{
- get { return north - south; }
+ get { return North - South; }
}
public bool HasValidBounds
{
- get { return south < north && west < east; }
+ get { return South < North && West < East; }
}
public virtual BoundingBox Clone()
{
- return new BoundingBox(south, west, north, east);
+ return new BoundingBox(South, West, North, East);
}
public static BoundingBox Parse(string s)
diff --git a/MapControl/Shared/MapPanel.cs b/MapControl/Shared/MapPanel.cs
index 52ef6a20..6e1db748 100644
--- a/MapControl/Shared/MapPanel.cs
+++ b/MapControl/Shared/MapPanel.cs
@@ -244,13 +244,14 @@ namespace MapControl
if (parentMap != null)
{
- pos = parentMap.MapProjection.LocationToViewportPoint(location);
+ var projection = parentMap.MapProjection;
+ pos = projection.LocationToViewportPoint(location);
- if (parentMap.MapProjection.IsCylindrical &&
+ if (projection.IsCylindrical &&
(pos.X < 0d || pos.X > parentMap.RenderSize.Width ||
pos.Y < 0d || pos.Y > parentMap.RenderSize.Height))
{
- pos = parentMap.MapProjection.LocationToViewportPoint(new Location(
+ pos = projection.LocationToViewportPoint(new Location(
location.Latitude,
Location.NearestLongitude(location.Longitude, parentMap.Center.Longitude)));
}
@@ -310,7 +311,7 @@ namespace MapControl
var center = new Point(rect.X + rect.Width / 2d, rect.Y + rect.Height / 2d);
var pos = projection.ViewportTransform.Transform(center);
- if (parentMap.MapProjection.IsCylindrical &&
+ if (projection.IsCylindrical &&
(pos.X < 0d || pos.X > parentMap.RenderSize.Width ||
pos.Y < 0d || pos.Y > parentMap.RenderSize.Height))
{
diff --git a/MapControl/Shared/MapProjection.cs b/MapControl/Shared/MapProjection.cs
index 880559e9..41ddcf19 100644
--- a/MapControl/Shared/MapProjection.cs
+++ b/MapControl/Shared/MapProjection.cs
@@ -25,8 +25,6 @@ namespace MapControl
public const double Wgs84EquatorialRadius = 6378137d;
public const double MetersPerDegree = Wgs84EquatorialRadius * Math.PI / 180d;
- private Matrix inverseViewportTransformMatrix;
-
///
/// Gets or sets the WMS 1.3.0 CRS Identifier.
///
@@ -58,6 +56,11 @@ namespace MapControl
///
public Matrix ViewportTransform { get; private set; }
+ ///
+ /// Gets the transform matrix from viewport coordinates to cartesian map coordinates (pixels).
+ ///
+ public Matrix InverseViewportTransform { get; private set; }
+
///
/// Gets the scaling factor from cartesian map coordinates to viewport coordinates.
///
@@ -115,7 +118,7 @@ namespace MapControl
///
public Location ViewportPointToLocation(Point point)
{
- return PointToLocation(inverseViewportTransformMatrix.Transform(point));
+ return PointToLocation(InverseViewportTransform.Transform(point));
}
///
@@ -123,7 +126,7 @@ namespace MapControl
///
public BoundingBox ViewportRectToBoundingBox(Rect rect)
{
- var transform = new MatrixTransform { Matrix = inverseViewportTransformMatrix };
+ var transform = new MatrixTransform { Matrix = InverseViewportTransform };
return RectToBoundingBox(transform.TransformBounds(rect));
}
@@ -139,9 +142,8 @@ namespace MapControl
var matrix = CreateTransformMatrix(center, ViewportScale, -ViewportScale, heading, viewportCenter);
ViewportTransform = matrix;
-
matrix.Invert();
- inverseViewportTransformMatrix = matrix;
+ InverseViewportTransform = matrix;
}
///
diff --git a/MapControl/WPF/XmlDocument.WPF.cs b/MapControl/WPF/XmlDocument.WPF.cs
index cd50e016..9249453a 100644
--- a/MapControl/WPF/XmlDocument.WPF.cs
+++ b/MapControl/WPF/XmlDocument.WPF.cs
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace MapControl
{
- public class XmlDocument : System.Xml.XmlDocument
+ internal class XmlDocument : System.Xml.XmlDocument
{
public static XmlDocument LoadFromUri(Uri uri)
{