mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Updated Auto-UTM projections
This commit is contained in:
parent
8630c6ed70
commit
b16d2b8c9b
13 changed files with 132 additions and 98 deletions
|
|
@ -3,7 +3,7 @@
|
|||
namespace MapControl.Projections
|
||||
{
|
||||
/// <summary>
|
||||
/// ED50 UTM Projection with zone number.
|
||||
/// ED50 Universal Transverse Mercator Projection.
|
||||
/// </summary>
|
||||
public class Ed50UtmProjection : GeoApiProjection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
namespace MapControl.Projections
|
||||
{
|
||||
/// <summary>
|
||||
/// ETRS89 UTM Projection with zone number.
|
||||
/// ETRS89 Universal Transverse Mercator Projection.
|
||||
/// </summary>
|
||||
public class Etrs89UtmProjection : GeoApiProjection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
namespace MapControl.Projections
|
||||
{
|
||||
/// <summary>
|
||||
/// NAD27 UTM Projection with zone number.
|
||||
/// Appears to be less accurate than MapControl.Nad27UtmProjection.
|
||||
/// NAD27 Universal Transverse Mercator Projection.
|
||||
/// </summary>
|
||||
public class Nad27UtmProjection : GeoApiProjection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
namespace MapControl.Projections
|
||||
{
|
||||
/// <summary>
|
||||
/// NAD83 UTM Projection with zone number.
|
||||
/// NAD83 Universal Transverse Mercator Projection.
|
||||
/// </summary>
|
||||
public class Nad83UtmProjection : GeoApiProjection
|
||||
{
|
||||
|
|
|
|||
59
MapProjections/Shared/Wgs84AutoUtmProjection.cs
Normal file
59
MapProjections/Shared/Wgs84AutoUtmProjection.cs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
|
||||
namespace MapControl.Projections
|
||||
{
|
||||
/// <summary>
|
||||
/// WGS84 Universal Transverse Mercator Projection with
|
||||
/// automatic zone selection from projection center.
|
||||
/// </summary>
|
||||
public class Wgs84AutoUtmProjection : Wgs84UtmProjection
|
||||
{
|
||||
private readonly string autoCrsId;
|
||||
|
||||
public Wgs84AutoUtmProjection()
|
||||
: this(MapControl.Wgs84AutoUtmProjection.DefaultCrsId)
|
||||
{
|
||||
// XAML needs parameterless constructor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When the crsId parameter is null or empty, the projection will use EPSG:32***.
|
||||
/// </summary>
|
||||
public Wgs84AutoUtmProjection(string crsId)
|
||||
: base(31, true)
|
||||
{
|
||||
autoCrsId = crsId;
|
||||
|
||||
if (!string.IsNullOrEmpty(autoCrsId))
|
||||
{
|
||||
CrsId = autoCrsId;
|
||||
}
|
||||
}
|
||||
|
||||
public override Location Center
|
||||
{
|
||||
get => base.Center;
|
||||
protected set
|
||||
{
|
||||
if (!base.Center.Equals(value))
|
||||
{
|
||||
base.Center = value;
|
||||
|
||||
var lon = Location.NormalizeLongitude(value.Longitude);
|
||||
var zone = (int)Math.Floor(lon / 6d) + 31;
|
||||
var north = value.Latitude >= 0d;
|
||||
|
||||
if (Zone != zone || IsNorth != north)
|
||||
{
|
||||
SetZone(zone, north);
|
||||
|
||||
if (!string.IsNullOrEmpty(autoCrsId))
|
||||
{
|
||||
CrsId = autoCrsId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,8 +4,7 @@ using System;
|
|||
namespace MapControl.Projections
|
||||
{
|
||||
/// <summary>
|
||||
/// WGS84 UTM Projection with zone number and north/south flag.
|
||||
/// See https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system.
|
||||
/// WGS84 Universal Transverse Mercator Projection.
|
||||
/// </summary>
|
||||
public class Wgs84UtmProjection : GeoApiProjection
|
||||
{
|
||||
|
|
@ -36,45 +35,4 @@ namespace MapControl.Projections
|
|||
CoordinateSystem = ProjectedCoordinateSystem.WGS84_UTM(Zone, IsNorth);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WGS84 UTM Projection with automatic zone selection from projection center.
|
||||
/// </summary>
|
||||
public class Wgs84AutoUtmProjection : Wgs84UtmProjection
|
||||
{
|
||||
public Wgs84AutoUtmProjection()
|
||||
: this(MapControl.Wgs84AutoUtmProjection.DefaultCrsId)
|
||||
{
|
||||
// XAML needs parameterless constructor
|
||||
}
|
||||
|
||||
public Wgs84AutoUtmProjection(string crsId)
|
||||
: base(31, true)
|
||||
{
|
||||
CrsId = crsId;
|
||||
}
|
||||
|
||||
public override Location Center
|
||||
{
|
||||
get => base.Center;
|
||||
protected set
|
||||
{
|
||||
if (!base.Center.Equals(value))
|
||||
{
|
||||
base.Center = value;
|
||||
|
||||
var lon = Location.NormalizeLongitude(value.Longitude);
|
||||
var zone = (int)Math.Floor(lon / 6d) + 31;
|
||||
var north = value.Latitude >= 0d;
|
||||
|
||||
if (Zone != zone || IsNorth != north)
|
||||
{
|
||||
var crsId = CrsId;
|
||||
SetZone(zone, north);
|
||||
CrsId = crsId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue