2017-06-25 23:05:48 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2020-01-09 19:40:10 +01:00
|
|
|
|
// © 2020 Clemens Fischer
|
2017-06-25 23:05:48 +02:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2019-12-12 19:23:41 +01:00
|
|
|
|
using System.Globalization;
|
2019-12-13 16:59:31 +01:00
|
|
|
|
#if WINDOWS_UWP
|
|
|
|
|
|
using Windows.Foundation;
|
|
|
|
|
|
#else
|
2017-06-25 23:05:48 +02:00
|
|
|
|
using System.Windows;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2018-12-20 21:55:12 +01:00
|
|
|
|
/// Equirectangular Projection.
|
2017-06-25 23:05:48 +02:00
|
|
|
|
/// Longitude and Latitude values are transformed identically to X and Y.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class EquirectangularProjection : MapProjection
|
|
|
|
|
|
{
|
|
|
|
|
|
public EquirectangularProjection()
|
|
|
|
|
|
{
|
2019-12-12 19:23:41 +01:00
|
|
|
|
CrsId = "EPSG:4326";
|
2017-06-25 23:05:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-12-12 19:23:41 +01:00
|
|
|
|
public override double TrueScale
|
2017-06-25 23:05:48 +02:00
|
|
|
|
{
|
2019-12-12 19:23:41 +01:00
|
|
|
|
get { return 1d; }
|
2017-06-25 23:05:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-03-07 22:19:16 +01:00
|
|
|
|
public override Vector GetMapScale(Location location)
|
2017-06-25 23:05:48 +02:00
|
|
|
|
{
|
2018-03-07 22:19:16 +01:00
|
|
|
|
return new Vector(
|
2019-04-05 19:13:58 +02:00
|
|
|
|
ViewportScale / (Wgs84MetersPerDegree * Math.Cos(location.Latitude * Math.PI / 180d)),
|
|
|
|
|
|
ViewportScale / Wgs84MetersPerDegree);
|
2017-06-25 23:05:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Point LocationToPoint(Location location)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Point(location.Longitude, location.Latitude);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override Location PointToLocation(Point point)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Location(point.Y, point.X);
|
|
|
|
|
|
}
|
2019-12-12 19:23:41 +01:00
|
|
|
|
|
|
|
|
|
|
public override string GetBboxValue(Rect rect)
|
|
|
|
|
|
{
|
|
|
|
|
|
return string.Format(CultureInfo.InvariantCulture,
|
|
|
|
|
|
CrsId != "CRS:84" ? "{1},{0},{3},{2}" : "{0},{1},{2},{3}",
|
|
|
|
|
|
rect.X, rect.Y, (rect.X + rect.Width), (rect.Y + rect.Height));
|
|
|
|
|
|
}
|
2017-06-25 23:05:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|