mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-07 15:36:20 +00:00
Version 4: Upgrade to VS 2017
This commit is contained in:
parent
2aafe32e00
commit
ec47f225b3
142 changed files with 1828 additions and 18384 deletions
54
MapControl/Shared/EquirectangularProjection.cs
Normal file
54
MapControl/Shared/EquirectangularProjection.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2017 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
#if WINDOWS_UWP
|
||||
using Windows.Foundation;
|
||||
#else
|
||||
using System.Windows;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Transforms map coordinates according to the 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;
|
||||
}
|
||||
|
||||
public override Point GetMapScale(Location location)
|
||||
{
|
||||
return new Point(
|
||||
ViewportScale / (MetersPerDegree * Math.Cos(location.Latitude * Math.PI / 180d)),
|
||||
ViewportScale / MetersPerDegree);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public override Location TranslateLocation(Location location, Point translation)
|
||||
{
|
||||
return new Location(
|
||||
location.Latitude - translation.Y / ViewportScale,
|
||||
location.Longitude + translation.X / ViewportScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue