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

57 lines
2.1 KiB
C#
Raw Normal View History

2018-12-20 21:55:12 +01:00
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
2025-01-01 18:57:55 +01:00
// Copyright © Clemens Fischer
2018-12-20 21:55:12 +01:00
// Licensed under the Microsoft Public License (Ms-PL)
using System;
2024-05-22 11:25:32 +02:00
#if WPF
using System.Windows;
#elif AVALONIA
using Avalonia;
#endif
2018-12-20 21:55:12 +01:00
namespace MapControl.Projections
{
/// <summary>
/// Elliptical Mercator Projection implemented by setting the WKT property of a GeoApiProjection.
/// See "Map Projections - A Working Manual" (https://pubs.usgs.gov/pp/1395/report.pdf), p.44-45.
/// </summary>
public class WorldMercatorProjection : GeoApiProjection
{
public WorldMercatorProjection()
{
2022-01-24 20:43:22 +01:00
CoordinateSystemWkt
= "PROJCS[\"WGS 84 / World Mercator\","
2022-01-21 00:17:01 +01:00
+ "GEOGCS[\"WGS 84\","
+ "DATUM[\"WGS_1984\","
2022-01-21 23:26:21 +01:00
+ "SPHEROID[\"WGS 84\",6378137,298.257223563,"
+ "AUTHORITY[\"EPSG\",\"7030\"]],"
2022-01-21 00:17:01 +01:00
+ "AUTHORITY[\"EPSG\",\"6326\"]],"
2022-01-21 23:26:21 +01:00
+ "PRIMEM[\"Greenwich\",0,"
+ "AUTHORITY[\"EPSG\",\"8901\"]],"
+ "UNIT[\"degree\",0.0174532925199433,"
+ "AUTHORITY[\"EPSG\",\"9122\"]],"
2022-01-21 00:17:01 +01:00
+ "AUTHORITY[\"EPSG\",\"4326\"]],"
+ "PROJECTION[\"Mercator_1SP\"],"
+ "PARAMETER[\"latitude_of_origin\",0],"
+ "PARAMETER[\"central_meridian\",0],"
+ "PARAMETER[\"scale_factor\",1],"
+ "PARAMETER[\"false_easting\",0],"
+ "PARAMETER[\"false_northing\",0],"
2022-01-21 23:26:21 +01:00
+ "UNIT[\"metre\",1,"
+ "AUTHORITY[\"EPSG\",\"9001\"]],"
2022-01-21 00:17:01 +01:00
+ "AXIS[\"Easting\",EAST],"
+ "AXIS[\"Northing\",NORTH],"
2024-07-12 14:14:42 +02:00
+ "AUTHORITY[\"EPSG\",\"3395\"]]";
2018-12-20 21:55:12 +01:00
}
public override Point GetRelativeScale(Location location)
2018-12-20 21:55:12 +01:00
{
var lat = location.Latitude * Math.PI / 180d;
var eSinLat = Wgs84Eccentricity * Math.Sin(lat);
var k = Math.Sqrt(1d - eSinLat * eSinLat) / Math.Cos(lat); // p.44 (7-8)
return new Point(k, k);
2018-12-20 21:55:12 +01:00
}
}
}