2025-02-27 18:46:32 +01:00
|
|
|
|
using ProjNet.CoordinateSystems;
|
2018-12-20 21:55:12 +01:00
|
|
|
|
using System;
|
2024-05-22 11:25:32 +02:00
|
|
|
|
#if WPF
|
2026-01-20 09:48:16 +01:00
|
|
|
|
using System.Windows.Media;
|
2024-05-19 17:24:18 +02:00
|
|
|
|
#endif
|
2018-12-20 21:55:12 +01:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl.Projections
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
2026-01-15 11:04:11 +01:00
|
|
|
|
/// Spherical Mercator Projection implemented by setting the CoordinateSystem property of a ProjNetMapProjection.
|
2018-12-20 21:55:12 +01:00
|
|
|
|
/// See "Map Projections - A Working Manual" (https://pubs.usgs.gov/pp/1395/report.pdf), p.41-44.
|
|
|
|
|
|
/// </summary>
|
2026-01-15 11:04:11 +01:00
|
|
|
|
public class WebMercatorProjection : ProjNetMapProjection
|
2018-12-20 21:55:12 +01:00
|
|
|
|
{
|
|
|
|
|
|
public WebMercatorProjection()
|
|
|
|
|
|
{
|
|
|
|
|
|
CoordinateSystem = ProjectedCoordinateSystem.WebMercator;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-20 09:48:16 +01:00
|
|
|
|
public override Matrix RelativeScale(double latitude, double longitude)
|
2018-12-20 21:55:12 +01:00
|
|
|
|
{
|
2025-12-13 07:28:45 +01:00
|
|
|
|
var k = 1d / Math.Cos(latitude * Math.PI / 180d); // p.44 (7-3)
|
2018-12-20 21:55:12 +01:00
|
|
|
|
|
2026-01-20 09:48:16 +01:00
|
|
|
|
return new Matrix(k, 0d, 0d, k, 0d, 0d);
|
2018-12-20 21:55:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|