mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Added MapProjection.CenterChanged method
This commit is contained in:
parent
2817ecda7d
commit
31b38d5049
6 changed files with 67 additions and 89 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,14 +17,9 @@
|
|||
CrsId = crsId;
|
||||
}
|
||||
|
||||
public override Location Center
|
||||
protected override void CenterChanged()
|
||||
{
|
||||
get => base.Center;
|
||||
protected internal set
|
||||
{
|
||||
base.Center = value;
|
||||
CentralMeridian = value.Longitude;
|
||||
}
|
||||
CentralMeridian = Center.Longitude;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,28 +29,18 @@ namespace MapControl
|
|||
}
|
||||
}
|
||||
|
||||
public override Location Center
|
||||
protected override void CenterChanged()
|
||||
{
|
||||
get => base.Center;
|
||||
protected internal set
|
||||
var zone = (int)Math.Floor(Center.Longitude / 6d) + 31;
|
||||
var hemisphere = Center.Latitude >= 0d ? Hemisphere.North : Hemisphere.South;
|
||||
|
||||
if (Zone != zone || Hemisphere != hemisphere)
|
||||
{
|
||||
if (!base.Center.Equals(value))
|
||||
SetZone(zone, hemisphere);
|
||||
|
||||
if (!string.IsNullOrEmpty(autoCrsId))
|
||||
{
|
||||
base.Center = value;
|
||||
|
||||
var lon = Location.NormalizeLongitude(value.Longitude);
|
||||
var zone = (int)Math.Floor(lon / 6d) + 31;
|
||||
var hemisphere = value.Latitude >= 0d ? Hemisphere.North : Hemisphere.South;
|
||||
|
||||
if (Zone != zone || Hemisphere != hemisphere)
|
||||
{
|
||||
SetZone(zone, hemisphere);
|
||||
|
||||
if (!string.IsNullOrEmpty(autoCrsId))
|
||||
{
|
||||
CrsId = autoCrsId;
|
||||
}
|
||||
}
|
||||
CrsId = autoCrsId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue