mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-21 08:00:17 +01:00
28 lines
822 B
C#
28 lines
822 B
C#
using ProjNet.CoordinateSystems;
|
|
using System;
|
|
#if WPF
|
|
using System.Windows.Media;
|
|
#endif
|
|
|
|
namespace MapControl.Projections
|
|
{
|
|
/// <summary>
|
|
/// Spherical Mercator Projection implemented by setting the CoordinateSystem property of a ProjNetMapProjection.
|
|
/// See "Map Projections - A Working Manual" (https://pubs.usgs.gov/pp/1395/report.pdf), p.41-44.
|
|
/// </summary>
|
|
public class WebMercatorProjection : ProjNetMapProjection
|
|
{
|
|
public WebMercatorProjection()
|
|
{
|
|
CoordinateSystem = ProjectedCoordinateSystem.WebMercator;
|
|
}
|
|
|
|
public override Matrix RelativeScale(double latitude, double longitude)
|
|
{
|
|
var k = 1d / Math.Cos(latitude * Math.PI / 180d); // p.44 (7-3)
|
|
|
|
return new Matrix(k, 0d, 0d, k, 0d, 0d);
|
|
}
|
|
}
|
|
}
|