Added Auto Transverse Mercator Projection

This commit is contained in:
ClemensFischer 2026-01-10 00:31:27 +01:00
parent 2686cda333
commit 8630c6ed70
5 changed files with 51 additions and 18 deletions

View file

@ -36,6 +36,10 @@ namespace MapControl
projection = new Wgs84AutoUtmProjection();
break;
case Wgs84AutoTmProjection.DefaultCrsId:
projection = new Wgs84AutoTmProjection();
break;
case OrthographicProjection.DefaultCrsId:
projection = new OrthographicProjection();
break;

View file

@ -8,8 +8,8 @@ using Avalonia;
namespace MapControl
{
/// <summary>
/// Universal Transverse Mercator Projection.
/// See https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system.
/// Transverse Mercator Projection.
/// See https://en.wikipedia.org/wiki/Transverse_Mercator_projection.
/// </summary>
public class TransverseMercatorProjection : MapProjection
{
@ -17,7 +17,7 @@ namespace MapControl
public double Flattening { get; set; } = Wgs84Flattening;
public double ScaleFactor { get; set; } = 0.9996;
public double CentralMeridian { get; set; }
public double FalseEasting { get; set; } = 5e5;
public double FalseEasting { get; set; }
public double FalseNorthing { get; set; }
public TransverseMercatorProjection()

View file

@ -0,0 +1,31 @@
namespace MapControl
{
/// <summary>
/// WGS84 Auto Transverse Mercator Projection.
/// </summary>
public class Wgs84AutoTmProjection : TransverseMercatorProjection
{
public const string DefaultCrsId = "AUTO2:42002";
public Wgs84AutoTmProjection()
: this(DefaultCrsId)
{
// XAML needs parameterless constructor
}
public Wgs84AutoTmProjection(string crsId)
{
CrsId = crsId;
}
public override Location Center
{
get => base.Center;
protected internal set
{
base.Center = value;
CentralMeridian = value.Longitude;
}
}
}
}

View file

@ -4,6 +4,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.
/// </summary>
public class Wgs84UtmProjection : TransverseMercatorProjection
{
@ -66,7 +67,7 @@ namespace MapControl
get => base.Center;
protected internal set
{
if (!Equals(base.Center, value))
if (!base.Center.Equals(value))
{
base.Center = value;

View file

@ -5,6 +5,7 @@ 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.
/// </summary>
public class Wgs84UtmProjection : GeoApiProjection
{
@ -41,17 +42,16 @@ namespace MapControl.Projections
/// </summary>
public class Wgs84AutoUtmProjection : Wgs84UtmProjection
{
private readonly string autoCrsId;
public Wgs84AutoUtmProjection()
: this(MapControl.Wgs84AutoUtmProjection.DefaultCrsId)
{
// XAML needs parameterless constructor
}
public Wgs84AutoUtmProjection(string crsId = MapControl.Wgs84AutoUtmProjection.DefaultCrsId)
public Wgs84AutoUtmProjection(string crsId)
: base(31, true)
{
autoCrsId = crsId;
if (!string.IsNullOrEmpty(autoCrsId))
{
CrsId = autoCrsId;
}
CrsId = crsId;
}
public override Location Center
@ -59,7 +59,7 @@ namespace MapControl.Projections
get => base.Center;
protected set
{
if (!Equals(base.Center, value))
if (!base.Center.Equals(value))
{
base.Center = value;
@ -69,12 +69,9 @@ namespace MapControl.Projections
if (Zone != zone || IsNorth != north)
{
var crsId = CrsId;
SetZone(zone, north);
if (!string.IsNullOrEmpty(autoCrsId))
{
CrsId = autoCrsId;
}
CrsId = crsId;
}
}
}