2019-03-27 18:39:59 +01:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2022-01-14 20:22:56 +01:00
|
|
|
|
// © 2022 Clemens Fischer
|
2019-03-27 18:39:59 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2021-11-17 23:17:11 +01:00
|
|
|
|
#if !WINUI && !UWP
|
2019-03-27 18:39:59 +01:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
2022-02-23 23:19:32 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Auto-Equirectangular Projection - AUTO2:42004.
|
|
|
|
|
|
/// Equidistant cylindrical projection with standard parallel and central meridian set by the Center property.
|
|
|
|
|
|
/// See "Map Projections - A Working Manual" (https://pubs.usgs.gov/pp/1395/report.pdf), p.90-91.
|
|
|
|
|
|
/// </summary>
|
2019-03-27 18:39:59 +01:00
|
|
|
|
public class AutoEquirectangularProjection : MapProjection
|
|
|
|
|
|
{
|
2022-01-19 16:43:00 +01:00
|
|
|
|
public const string DefaultCrsId = "AUTO2:42004";
|
|
|
|
|
|
|
2019-03-27 18:39:59 +01:00
|
|
|
|
public AutoEquirectangularProjection()
|
|
|
|
|
|
{
|
2022-01-19 16:43:00 +01:00
|
|
|
|
CrsId = DefaultCrsId;
|
2022-02-23 23:19:32 +01:00
|
|
|
|
IsNormalCylindrical = true;
|
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
|
|
|
|
{
|
|
|
|
|
|
return new Point(
|
2022-03-02 22:03:18 +01:00
|
|
|
|
Wgs84MeterPerDegree * (location.Longitude - Center.Longitude) * Math.Cos(Center.Latitude * Math.PI / 180d),
|
|
|
|
|
|
Wgs84MeterPerDegree * 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
|
|
|
|
{
|
|
|
|
|
|
return new Location(
|
2022-03-02 22:03:18 +01:00
|
|
|
|
point.Y / Wgs84MeterPerDegree,
|
|
|
|
|
|
point.X / (Wgs84MeterPerDegree * Math.Cos(Center.Latitude * Math.PI / 180d)) + Center.Longitude);
|
2019-03-27 18:39:59 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|