mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Version 4.16.0. Improved MapProjection.
This commit is contained in:
parent
1f66a9f878
commit
0dbdd4c810
|
|
@ -36,7 +36,7 @@ namespace MapControl
|
|||
{
|
||||
if (point.X == 0d && point.Y == 0d)
|
||||
{
|
||||
return ProjectionCenter;
|
||||
return new Location(ProjectionCenter.Latitude, ProjectionCenter.Longitude);
|
||||
}
|
||||
|
||||
var azimuth = Math.Atan2(point.X, point.Y);
|
||||
|
|
|
|||
|
|
@ -71,18 +71,27 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public static Location GetLocation(Location location, double azimuth, double distance)
|
||||
{
|
||||
var lat1 = location.Latitude * Math.PI / 180d;
|
||||
var sinDistance = Math.Sin(distance);
|
||||
var cosDistance = Math.Cos(distance);
|
||||
var cosAzimuth = Math.Cos(azimuth);
|
||||
var sinAzimuth = Math.Sin(azimuth);
|
||||
var cosLat1 = Math.Cos(lat1);
|
||||
var sinLat1 = Math.Sin(lat1);
|
||||
var sinLat2 = sinLat1 * cosDistance + cosLat1 * sinDistance * cosAzimuth;
|
||||
var lat2 = Math.Asin(Math.Min(Math.Max(sinLat2, -1d), 1d));
|
||||
var dLon = Math.Atan2(sinDistance * sinAzimuth, cosLat1 * cosDistance - sinLat1 * sinDistance * cosAzimuth);
|
||||
var lat = location.Latitude;
|
||||
var lon = location.Longitude;
|
||||
|
||||
return new Location(lat2 * 180d / Math.PI, location.Longitude + dLon * 180d / Math.PI);
|
||||
if (distance > 0d)
|
||||
{
|
||||
var lat1 = lat * Math.PI / 180d;
|
||||
var sinDistance = Math.Sin(distance);
|
||||
var cosDistance = Math.Cos(distance);
|
||||
var cosAzimuth = Math.Cos(azimuth);
|
||||
var sinAzimuth = Math.Sin(azimuth);
|
||||
var cosLat1 = Math.Cos(lat1);
|
||||
var sinLat1 = Math.Sin(lat1);
|
||||
var sinLat2 = sinLat1 * cosDistance + cosLat1 * sinDistance * cosAzimuth;
|
||||
var lat2 = Math.Asin(Math.Min(Math.Max(sinLat2, -1d), 1d));
|
||||
var dLon = Math.Atan2(sinDistance * sinAzimuth, cosLat1 * cosDistance - sinLat1 * sinDistance * cosAzimuth);
|
||||
|
||||
lat = lat2 * 180d / Math.PI;
|
||||
lon += dLon * 180d / Math.PI;
|
||||
}
|
||||
|
||||
return new Location(lat, lon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace MapControl
|
|||
{
|
||||
if (point.X == 0d && point.Y == 0d)
|
||||
{
|
||||
return ProjectionCenter;
|
||||
return new Location(ProjectionCenter.Latitude, ProjectionCenter.Longitude);
|
||||
}
|
||||
|
||||
var azimuth = Math.Atan2(point.X, point.Y);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace MapControl
|
|||
{
|
||||
if (point.X == 0d && point.Y == 0d)
|
||||
{
|
||||
return ProjectionCenter;
|
||||
return new Location(ProjectionCenter.Latitude, ProjectionCenter.Longitude);
|
||||
}
|
||||
|
||||
var s = TrueScale * 180d / Math.PI;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace MapControl
|
|||
{
|
||||
if (point.X == 0d && point.Y == 0d)
|
||||
{
|
||||
return ProjectionCenter;
|
||||
return new Location(ProjectionCenter.Latitude, ProjectionCenter.Longitude);
|
||||
}
|
||||
|
||||
var azimuth = Math.Atan2(point.X, point.Y);
|
||||
|
|
|
|||
Loading…
Reference in a new issue