mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-05-07 13:37:47 +00:00
File scoped namespaces
This commit is contained in:
parent
c14377f976
commit
65aba44af6
152 changed files with 11962 additions and 12115 deletions
|
|
@ -6,66 +6,65 @@ using System.Windows.Media;
|
|||
using Avalonia;
|
||||
#endif
|
||||
|
||||
namespace MapControl
|
||||
namespace MapControl;
|
||||
|
||||
/// <summary>
|
||||
/// Spherical Mercator Projection - EPSG:3857.
|
||||
/// See "Map Projections - A Working Manual" (https://pubs.usgs.gov/publication/pp1395), p.41-44.
|
||||
/// </summary>
|
||||
public class WebMercatorProjection : MapProjection
|
||||
{
|
||||
/// <summary>
|
||||
/// Spherical Mercator Projection - EPSG:3857.
|
||||
/// See "Map Projections - A Working Manual" (https://pubs.usgs.gov/publication/pp1395), p.41-44.
|
||||
/// </summary>
|
||||
public class WebMercatorProjection : MapProjection
|
||||
public const string DefaultCrsId = "EPSG:3857";
|
||||
|
||||
public WebMercatorProjection() // parameterless constructor for XAML
|
||||
: this(DefaultCrsId)
|
||||
{
|
||||
public const string DefaultCrsId = "EPSG:3857";
|
||||
}
|
||||
|
||||
public WebMercatorProjection() // parameterless constructor for XAML
|
||||
: this(DefaultCrsId)
|
||||
public WebMercatorProjection(string crsId)
|
||||
{
|
||||
IsNormalCylindrical = true;
|
||||
CrsId = crsId;
|
||||
}
|
||||
|
||||
public override Matrix RelativeTransform(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);
|
||||
}
|
||||
|
||||
public override Point LocationToMap(double latitude, double longitude)
|
||||
{
|
||||
return new Point(
|
||||
EquatorialRadius * Math.PI / 180d * longitude,
|
||||
EquatorialRadius * Math.PI / 180d * LatitudeToY(latitude));
|
||||
}
|
||||
|
||||
public override Location MapToLocation(double x, double y)
|
||||
{
|
||||
return new Location(YToLatitude(
|
||||
y / EquatorialRadius * 180d / Math.PI),
|
||||
x / EquatorialRadius * 180d / Math.PI);
|
||||
}
|
||||
|
||||
public static double LatitudeToY(double latitude)
|
||||
{
|
||||
if (latitude <= -90d)
|
||||
{
|
||||
return double.NegativeInfinity;
|
||||
}
|
||||
|
||||
public WebMercatorProjection(string crsId)
|
||||
if (latitude >= 90d)
|
||||
{
|
||||
IsNormalCylindrical = true;
|
||||
CrsId = crsId;
|
||||
return double.PositiveInfinity;
|
||||
}
|
||||
|
||||
public override Matrix RelativeTransform(double latitude, double longitude)
|
||||
{
|
||||
var k = 1d / Math.Cos(latitude * Math.PI / 180d); // p.44 (7-3)
|
||||
return Math.Log(Math.Tan((latitude + 90d) * Math.PI / 360d)) * 180d / Math.PI;
|
||||
}
|
||||
|
||||
return new Matrix(k, 0d, 0d, k, 0d, 0d);
|
||||
}
|
||||
|
||||
public override Point LocationToMap(double latitude, double longitude)
|
||||
{
|
||||
return new Point(
|
||||
EquatorialRadius * Math.PI / 180d * longitude,
|
||||
EquatorialRadius * Math.PI / 180d * LatitudeToY(latitude));
|
||||
}
|
||||
|
||||
public override Location MapToLocation(double x, double y)
|
||||
{
|
||||
return new Location(YToLatitude(
|
||||
y / EquatorialRadius * 180d / Math.PI),
|
||||
x / EquatorialRadius * 180d / Math.PI);
|
||||
}
|
||||
|
||||
public static double LatitudeToY(double latitude)
|
||||
{
|
||||
if (latitude <= -90d)
|
||||
{
|
||||
return double.NegativeInfinity;
|
||||
}
|
||||
|
||||
if (latitude >= 90d)
|
||||
{
|
||||
return double.PositiveInfinity;
|
||||
}
|
||||
|
||||
return Math.Log(Math.Tan((latitude + 90d) * Math.PI / 360d)) * 180d / Math.PI;
|
||||
}
|
||||
|
||||
public static double YToLatitude(double y)
|
||||
{
|
||||
return 90d - Math.Atan(Math.Exp(-y * Math.PI / 180d)) * 360d / Math.PI;
|
||||
}
|
||||
public static double YToLatitude(double y)
|
||||
{
|
||||
return 90d - Math.Atan(Math.Exp(-y * Math.PI / 180d)) * 360d / Math.PI;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue