mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-14 04:30:11 +01:00
Updated Auto-UTM projections
This commit is contained in:
parent
8630c6ed70
commit
b16d2b8c9b
|
|
@ -3,7 +3,7 @@
|
|||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// ETRS89 UTM Projection with zone number.
|
||||
/// ETRS89 Universal Transverse Mercator Projection.
|
||||
/// </summary>
|
||||
public class Etrs89UtmProjection : TransverseMercatorProjection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ namespace MapControl
|
|||
break;
|
||||
|
||||
case Wgs84AutoUtmProjection.DefaultCrsId:
|
||||
projection = new Wgs84AutoUtmProjection();
|
||||
projection = new Wgs84AutoUtmProjection("");
|
||||
break;
|
||||
|
||||
case Wgs84AutoTmProjection.DefaultCrsId:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// NAD27 UTM Projection with zone number.
|
||||
/// NAD27 Universal Transverse Mercator Projection.
|
||||
/// </summary>
|
||||
public class Nad27UtmProjection : TransverseMercatorProjection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// NAD83 UTM Projection with zone number.
|
||||
/// NAD83 Universal Transverse Mercator Projection.
|
||||
/// </summary>
|
||||
public class Nad83UtmProjection : TransverseMercatorProjection
|
||||
{
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ namespace MapControl
|
|||
{
|
||||
/// <summary>
|
||||
/// Transverse Mercator Projection.
|
||||
/// See https://en.wikipedia.org/wiki/Transverse_Mercator_projection.
|
||||
/// See https://en.wikipedia.org/wiki/Transverse_Mercator_projection
|
||||
/// and https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system.
|
||||
/// </summary>
|
||||
public class TransverseMercatorProjection : MapProjection
|
||||
{
|
||||
|
|
|
|||
61
MapControl/Shared/Wgs84AutoUtmProjection.cs
Normal file
61
MapControl/Shared/Wgs84AutoUtmProjection.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
using System;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
/// <summary>
|
||||
/// WGS84 Universal Transverse Mercator Projection with
|
||||
/// automatic zone selection from projection center.
|
||||
/// </summary>
|
||||
public class Wgs84AutoUtmProjection : Wgs84UtmProjection
|
||||
{
|
||||
public const string DefaultCrsId = "AUTO2:42001";
|
||||
|
||||
private readonly string autoCrsId;
|
||||
|
||||
public Wgs84AutoUtmProjection()
|
||||
: this(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 internal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,8 +3,7 @@
|
|||
namespace MapControl
|
||||
{
|
||||
/// <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 : TransverseMercatorProjection
|
||||
{
|
||||
|
|
@ -42,47 +41,4 @@ namespace MapControl
|
|||
FalseNorthing = north ? 0d : 1e7;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WGS84 UTM Projection with automatic zone selection from projection center.
|
||||
/// </summary>
|
||||
public class Wgs84AutoUtmProjection : Wgs84UtmProjection
|
||||
{
|
||||
public const string DefaultCrsId = "AUTO2:42001";
|
||||
|
||||
public Wgs84AutoUtmProjection()
|
||||
: this(DefaultCrsId)
|
||||
{
|
||||
// XAML needs parameterless constructor
|
||||
}
|
||||
|
||||
public Wgs84AutoUtmProjection(string crsId)
|
||||
: base(31, true)
|
||||
{
|
||||
CrsId = crsId;
|
||||
}
|
||||
|
||||
public override Location Center
|
||||
{
|
||||
get => base.Center;
|
||||
protected internal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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…
Reference in a new issue