2019-03-27 18:39:59 +01:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2020-01-09 19:40:10 +01:00
|
|
|
|
// © 2020 Clemens Fischer
|
2019-03-27 18:39:59 +01:00
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-26 19:08:20 +01:00
|
|
|
|
public override Point LocationToMap(Location location)
|
2019-03-27 18:39:59 +01:00
|
|
|
|
{
|
2020-04-02 18:06:39 +02:00
|
|
|
|
var xScale = Wgs84MetersPerDegree * Math.Cos(Center.Latitude * Math.PI / 180d);
|
2019-03-27 18:39:59 +01:00
|
|
|
|
|
|
|
|
|
|
return new Point(
|
2020-03-26 19:08:20 +01:00
|
|
|
|
xScale * (location.Longitude - Center.Longitude),
|
2020-04-02 18:06:39 +02:00
|
|
|
|
Wgs84MetersPerDegree * location.Latitude);
|
2019-03-27 18:39:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-03-26 19:08:20 +01:00
|
|
|
|
public override Location MapToLocation(Point point)
|
2019-03-27 18:39:59 +01:00
|
|
|
|
{
|
2020-04-02 18:06:39 +02:00
|
|
|
|
var xScale = Wgs84MetersPerDegree * Math.Cos(Center.Latitude * Math.PI / 180d);
|
2019-03-27 18:39:59 +01:00
|
|
|
|
|
|
|
|
|
|
return new Location(
|
2020-04-02 18:06:39 +02:00
|
|
|
|
point.Y / Wgs84MetersPerDegree,
|
2020-03-26 19:08:20 +01:00
|
|
|
|
point.X / xScale + Center.Longitude);
|
2019-03-27 18:39:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|