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

44 lines
1.6 KiB
C#
Raw Normal View History

2026-01-13 23:24:48 +01: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\","
2026-01-13 10:41:04 +01:00
+ "DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563]],"
2026-01-13 19:23:41 +01:00
+ GeoApiProjectionFactory.PrimeMeridianGreenwich + ","
2026-01-13 10:41:04 +01:00
+ GeoApiProjectionFactory.UnitDegree + ","
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],"
2026-01-13 10:41:04 +01:00
+ GeoApiProjectionFactory.UnitMeter + ","
2026-01-13 19:23:41 +01:00
+ GeoApiProjectionFactory.AxisEasting + ","
+ GeoApiProjectionFactory.AxisNorthing + ","
2024-07-12 14:14:42 +02:00
+ "AUTHORITY[\"EPSG\",\"3395\"]]";
2018-12-20 21:55:12 +01:00
}
2026-01-06 11:56:28 +01:00
public override Point RelativeScale(double latitude, double longitude)
2018-12-20 21:55:12 +01:00
{
2026-01-13 23:24:48 +01:00
var k = MapControl.WorldMercatorProjection.ScaleFactor(latitude);
2018-12-20 21:55:12 +01:00
return new Point(k, k);
2018-12-20 21:55:12 +01:00
}
}
}