Added MapProjection.CenterChanged method

This commit is contained in:
ClemensFischer 2026-01-17 16:06:50 +01:00
parent 2817ecda7d
commit 31b38d5049
6 changed files with 67 additions and 89 deletions

View file

@ -41,6 +41,14 @@ namespace MapControl
set;
}
/// <summary>
/// Creates a MapProjection instance from a CRS identifier string.
/// </summary>
public static MapProjection Parse(string crsId)
{
return Factory.GetProjection(crsId);
}
/// <summary>
/// Gets the type of the projection.
/// </summary>
@ -54,7 +62,24 @@ namespace MapControl
/// <summary>
/// Gets or sets an optional projection center.
/// </summary>
public virtual Location Center { get; protected internal set; } = new Location();
public Location Center
{
get => field ??= new Location();
protected internal set
{
var longitude = Location.NormalizeLongitude(value.Longitude);
if (field == null || !field.Equals(value.Latitude, longitude))
{
field = new Location(value.Latitude, longitude);
CenterChanged();
}
}
}
protected virtual void CenterChanged()
{
}
/// <summary>
/// Gets the relative map scale at the specified geographic coordinates.
@ -158,13 +183,5 @@ namespace MapControl
{
return CrsId;
}
/// <summary>
/// Creates a MapProjection instance from a CRS identifier string.
/// </summary>
public static MapProjection Parse(string crsId)
{
return Factory.GetProjection(crsId);
}
}
}