XAML-Map-Control/MapControl/Shared/EquirectangularProjection.cs

49 lines
1.3 KiB
C#
Raw Normal View History

// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
// © 2019 Clemens Fischer
// Licensed under the Microsoft Public License (Ms-PL)
using System;
#if !WINDOWS_UWP
using System.Windows;
#endif
namespace MapControl
{
/// <summary>
2018-12-20 21:55:12 +01:00
/// Equirectangular Projection.
/// Longitude and Latitude values are transformed identically to X and Y.
/// </summary>
public class EquirectangularProjection : MapProjection
{
public EquirectangularProjection()
: this("EPSG:4326")
{
}
public EquirectangularProjection(string crsId)
{
CrsId = crsId;
2019-10-28 17:44:22 +01:00
HasLatLonBoundingBox = CrsId != "CRS:84";
2018-12-20 21:55:12 +01:00
IsNormalCylindrical = true;
TrueScale = 1d;
}
2018-03-07 22:19:16 +01:00
public override Vector GetMapScale(Location location)
{
2018-03-07 22:19:16 +01:00
return new Vector(
ViewportScale / (Wgs84MetersPerDegree * Math.Cos(location.Latitude * Math.PI / 180d)),
ViewportScale / Wgs84MetersPerDegree);
}
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);
}
}
}