2019-03-27 18:39:59 +01:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
|
|
|
|
|
// © 2019 Clemens Fischer
|
|
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2019-12-13 22:31:44 +01:00
|
|
|
|
#if !WINDOWS_UWP
|
2019-03-27 18:39:59 +01:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
public class AutoEquirectangularProjection : MapProjection
|
|
|
|
|
|
{
|
|
|
|
|
|
public AutoEquirectangularProjection()
|
|
|
|
|
|
{
|
2019-12-12 19:23:41 +01:00
|
|
|
|
CrsId = "AUTO2:42004";
|
2019-03-27 18:39:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Point LocationToPoint(Location location)
|
|
|
|
|
|
{
|
2019-04-05 19:13:58 +02:00
|
|
|
|
var xScale = Wgs84MetersPerDegree * Math.Cos(ProjectionCenter.Latitude * Math.PI / 180d);
|
2019-03-27 18:39:59 +01:00
|
|
|
|
|
|
|
|
|
|
return new Point(
|
|
|
|
|
|
xScale * (location.Longitude - ProjectionCenter.Longitude),
|
2019-04-05 19:13:58 +02:00
|
|
|
|
Wgs84MetersPerDegree * location.Latitude);
|
2019-03-27 18:39:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Location PointToLocation(Point point)
|
|
|
|
|
|
{
|
2019-04-05 19:13:58 +02:00
|
|
|
|
var xScale = Wgs84MetersPerDegree * Math.Cos(ProjectionCenter.Latitude * Math.PI / 180d);
|
2019-03-27 18:39:59 +01:00
|
|
|
|
|
|
|
|
|
|
return new Location(
|
2019-04-05 19:13:58 +02:00
|
|
|
|
point.Y / Wgs84MetersPerDegree,
|
2019-03-27 18:39:59 +01:00
|
|
|
|
point.X / xScale + ProjectionCenter.Longitude);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|