mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-08 16:05:50 +00:00
Updated MapProjection and MapGraticule
This commit is contained in:
parent
2a45c1165c
commit
cfed3575ac
16 changed files with 392 additions and 355 deletions
|
|
@ -11,6 +11,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Implements a map projection, a transformation between geographic coordinates,
|
||||
/// i.e. latitude and longitude in degrees, and cartesian map coordinates in meters.
|
||||
/// See https://en.wikipedia.org/wiki/Map_projection.
|
||||
/// </summary>
|
||||
#if UWP || WINUI
|
||||
[Windows.Foundation.Metadata.CreateFromString(MethodName = "Parse")]
|
||||
|
|
@ -40,7 +41,7 @@ namespace MapControl
|
|||
/// <summary>
|
||||
/// Gets the WMS 1.3.0 CRS identifier.
|
||||
/// </summary>
|
||||
public string CrsId { get; protected set; } = "";
|
||||
public string CrsId { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the projection is normal cylindrical, see
|
||||
|
|
@ -48,10 +49,16 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public bool IsNormalCylindrical { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The earth ellipsoid semi-major axis, or spherical earth radius respectively, in meters.
|
||||
/// </summary>
|
||||
public double EquatorialRadius { get; set; } = Wgs84EquatorialRadius;
|
||||
public double CentralMeridian { get; set; }
|
||||
public double LatitudeOfOrigin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the grid convergence angle in degrees at the specified geographic coordinates.
|
||||
/// Used for rotating the Rect resulting from BoundingBoxToMap in non-normal-cylindrical
|
||||
/// projections, i.e. Transverse Mercator and Polar Stereographic.
|
||||
/// </summary>
|
||||
public virtual double GridConvergence(double latitude, double longitude) => 0d;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the relative transform at the specified geographic coordinates.
|
||||
|
|
@ -69,13 +76,6 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public abstract Location MapToLocation(double x, double y);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the grid convergence angle in degrees at the specified projected map coordinates.
|
||||
/// Used for rotating the Rect resulting from BoundingBoxToMap in non-normal-cylindrical
|
||||
/// projections, i.e. Transverse Mercator and Polar Stereographic.
|
||||
/// </summary>
|
||||
public virtual double GridConvergence(double x, double y) => 0d;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the relative transform at the specified geographic Location.
|
||||
/// </summary>
|
||||
|
|
@ -114,17 +114,22 @@ namespace MapControl
|
|||
var north = new Point((northWest.X + northEast.X) / 2d, (northWest.Y + northEast.Y) / 2d);
|
||||
var centerX = (south.X + north.X) / 2d;
|
||||
var centerY = (south.Y + north.Y) / 2d;
|
||||
var dx = north.X - south.X;
|
||||
var dy = north.Y - south.Y;
|
||||
var dxW = northWest.X - southWest.X;
|
||||
var dyW = northWest.Y - southWest.Y;
|
||||
var dxE = northEast.X - southEast.X;
|
||||
var dyE = northEast.Y - southEast.Y;
|
||||
var dxS = southEast.X - southWest.X;
|
||||
var dyS = southEast.Y - southWest.Y;
|
||||
var dxN = northEast.X - northWest.X;
|
||||
var dyN = northEast.Y - northWest.Y;
|
||||
var width = (Math.Sqrt(dxS * dxS + dyS * dyS) + Math.Sqrt(dxN * dxN + dyN * dyN)) / 2d;
|
||||
var height = Math.Sqrt(dx * dx + dy * dy);
|
||||
var height = (Math.Sqrt(dxW * dxW + dyW * dyW) + Math.Sqrt(dxE * dxE + dyE * dyE)) / 2d;
|
||||
|
||||
rect = new Rect(centerX - width / 2d, centerY - height / 2d, width, height);
|
||||
rotation = -GridConvergence(centerX, centerY); // invert direction for RotateTransform
|
||||
|
||||
rotation = -GridConvergence( // invert direction for RotateTransform
|
||||
(boundingBox.South + boundingBox.North) / 2d,
|
||||
(boundingBox.West + boundingBox.East) / 2d);
|
||||
}
|
||||
|
||||
return (rect, rotation);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue