mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-21 16:10:20 +01:00
Updated azimuthal projections
This commit is contained in:
parent
1bf4cab071
commit
2e27fc740d
|
|
@ -30,28 +30,36 @@ namespace MapControl
|
|||
{
|
||||
var p = GetProjectedPoint(latitude, longitude);
|
||||
|
||||
if (Math.Abs(p.CosC) >= 1d)
|
||||
if (p.CosC == 1d)
|
||||
{
|
||||
return new Matrix(1d, 0d, 0d, 1d, 0d, 0d);
|
||||
}
|
||||
|
||||
if (p.CosC == -1d)
|
||||
{
|
||||
return new Matrix(1d, 0d, 0d, double.PositiveInfinity, 0d, 0d);
|
||||
}
|
||||
|
||||
var c = Math.Acos(p.CosC);
|
||||
var k = c / Math.Sin(c); // p.195 (25-2)
|
||||
|
||||
var scale = new Matrix(1d, 0d, 0d, k, 0d, 0d); // h == 1
|
||||
scale.Rotate(-Math.Atan2(p.Y, p.X) * 180d / Math.PI);
|
||||
return scale;
|
||||
return p.RelativeScale(1d, k);
|
||||
}
|
||||
|
||||
public override Point? LocationToMap(double latitude, double longitude)
|
||||
{
|
||||
var p = GetProjectedPoint(latitude, longitude);
|
||||
|
||||
if (Math.Abs(p.CosC) >= 1d)
|
||||
if (p.CosC == 1d) // p.195 "If cos c = 1, ... k' = 1, and x = y = 0."
|
||||
{
|
||||
return new Point();
|
||||
}
|
||||
|
||||
if (p.CosC == -1)
|
||||
{
|
||||
return null; // p.195 "If cos c = -1, the point ... is plotted as a circle of radius πR."
|
||||
}
|
||||
|
||||
var c = Math.Acos(p.CosC);
|
||||
var k = c / Math.Sin(c); // p.195 (25-2)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
using System;
|
||||
#if WPF
|
||||
using System.Windows.Media;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
|
|
@ -32,10 +35,23 @@ namespace MapControl
|
|||
var sinPhi1 = Math.Sin(phi1);
|
||||
var cosLambda = Math.Cos(dLambda);
|
||||
var sinLambda = Math.Sin(dLambda);
|
||||
var cosC = sinPhi1 * sinPhi + cosPhi1 * cosPhi * cosLambda; // (5-3)
|
||||
|
||||
X = cosPhi * sinLambda;
|
||||
Y = cosPhi1 * sinPhi - sinPhi1 * cosPhi * cosLambda;
|
||||
CosC = sinPhi1 * sinPhi + cosPhi1 * cosPhi * cosLambda; // (5-3)
|
||||
CosC = Math.Min(Math.Max(cosC, -1d), 1d); // protect against rounding errors
|
||||
}
|
||||
|
||||
public Matrix RelativeScale(double radialScale, double perpendicularScale)
|
||||
{
|
||||
var scale = new Matrix(radialScale, 0d, 0d, perpendicularScale, 0d, 0d);
|
||||
|
||||
if (radialScale != perpendicularScale)
|
||||
{
|
||||
scale.Rotate(-Math.Atan2(Y, X) * 180d / Math.PI);
|
||||
}
|
||||
|
||||
return scale;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ namespace MapControl
|
|||
var k = 1d / p.CosC; // p.165 (22-3)
|
||||
var h = k * k; // p.165 (22-2)
|
||||
|
||||
var scale = new Matrix(h, 0d, 0d, k, 0d, 0d);
|
||||
scale.Rotate(-Math.Atan2(p.Y, p.X) * 180d / Math.PI);
|
||||
return scale;
|
||||
return p.RelativeScale(h, k);
|
||||
}
|
||||
|
||||
public override Point? LocationToMap(double latitude, double longitude)
|
||||
|
|
|
|||
|
|
@ -29,11 +29,8 @@ namespace MapControl
|
|||
public override Matrix RelativeScale(double latitude, double longitude)
|
||||
{
|
||||
var p = GetProjectedPoint(latitude, longitude);
|
||||
var h = p.CosC; // p.149 (20-5)
|
||||
|
||||
var scale = new Matrix(h, 0d, 0d, 1d, 0d, 0d); // k == 1
|
||||
scale.Rotate(-Math.Atan2(p.Y, p.X) * 180d / Math.PI);
|
||||
return scale;
|
||||
return p.RelativeScale(p.CosC, 1d); // p.149 (20-5), k == 1
|
||||
}
|
||||
|
||||
public override Point? LocationToMap(double latitude, double longitude)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace MapControl
|
|||
var p = GetProjectedPoint(latitude, longitude);
|
||||
var k = 2d / (1d + p.CosC); // p.157 (21-4), k0 == 1
|
||||
|
||||
return new Matrix(k, 0d, 0d, k, 0d, 0d);
|
||||
return p.RelativeScale(k, k);
|
||||
}
|
||||
|
||||
public override Point? LocationToMap(double latitude, double longitude)
|
||||
|
|
|
|||
Loading…
Reference in a new issue