2017-06-25 23:05:48 +02:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2019-03-27 18:39:59 +01:00
|
|
|
|
// © 2019 Clemens Fischer
|
2017-06-25 23:05:48 +02:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2018-03-06 22:22:58 +01:00
|
|
|
|
#if !WINDOWS_UWP
|
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()
|
|
|
|
|
|
: 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;
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|