XAML-Map-Control/MapProjections/Shared/WebMercatorProjection.cs

32 lines
945 B
C#
Raw Normal View History

2018-12-20 21:55:12 +01:00
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
2022-01-14 20:22:56 +01:00
// © 2022 Clemens Fischer
2018-12-20 21:55:12 +01:00
// Licensed under the Microsoft Public License (Ms-PL)
2021-07-07 16:52:31 +02:00
using ProjNet.CoordinateSystems;
2018-12-20 21:55:12 +01:00
using System;
2021-11-17 23:46:48 +01:00
#if !UWP
2018-12-20 21:55:12 +01:00
using System.Windows;
#endif
namespace MapControl.Projections
{
/// <summary>
/// Spherical Mercator Projection implemented by setting the CoordinateSystem property of a GeoApiProjection.
/// See "Map Projections - A Working Manual" (https://pubs.usgs.gov/pp/1395/report.pdf), p.41-44.
/// </summary>
public class WebMercatorProjection : GeoApiProjection
{
public WebMercatorProjection()
{
CoordinateSystem = ProjectedCoordinateSystem.WebMercator;
}
public override Vector GetRelativeScale(Location location)
2018-12-20 21:55:12 +01:00
{
var k = 1d / Math.Cos(location.Latitude * Math.PI / 180d); // p.44 (7-3)
return new Vector(k, k);
2018-12-20 21:55:12 +01:00
}
}
}