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
|
2024-05-19 17:24:18 +02:00
|
|
|
|
using System.Windows;
|
2024-05-27 17:30:58 +02:00
|
|
|
|
#elif AVALONIA
|
|
|
|
|
|
using Avalonia;
|
2024-05-19 17:24:18 +02:00
|
|
|
|
#endif
|
2018-12-20 21:55:12 +01:00
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-19 17:24:18 +02:00
|
|
|
|
public override Point 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)
|
|
|
|
|
|
|
2024-05-19 17:24:18 +02:00
|
|
|
|
return new Point(k, k);
|
2018-12-20 21:55:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|