mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-05 14:37:01 +00:00
Equality methods
This commit is contained in:
parent
23a8e49efb
commit
2686cda333
9 changed files with 47 additions and 91 deletions
|
|
@ -28,8 +28,7 @@ namespace MapControl
|
|||
|
||||
public override Point? LocationToMap(double latitude, double longitude)
|
||||
{
|
||||
if (Location.Equals(latitude, Center.Latitude) &&
|
||||
Location.Equals(longitude, Center.Longitude))
|
||||
if (Center.Equals(latitude, longitude))
|
||||
{
|
||||
return new Point();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ namespace MapControl
|
|||
|
||||
public override Point? LocationToMap(double latitude, double longitude)
|
||||
{
|
||||
if (Location.Equals(latitude, Center.Latitude) &&
|
||||
Location.Equals(longitude, Center.Longitude))
|
||||
if (Center.Equals(latitude, longitude))
|
||||
{
|
||||
return new Point();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,32 +30,15 @@ namespace MapControl
|
|||
public double Latitude { get; }
|
||||
public double Longitude { get; }
|
||||
|
||||
public bool Equals(Location location)
|
||||
{
|
||||
return location != null &&
|
||||
Equals(Latitude, location.Latitude) &&
|
||||
Equals(Longitude, location.Longitude);
|
||||
}
|
||||
public bool Equals(double latitude, double longitude) => Latitude == latitude && Longitude == longitude;
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return Equals(obj as Location);
|
||||
}
|
||||
public bool Equals(Location location) => location != null && Equals(location.Latitude, location.Longitude);
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Latitude.GetHashCode() ^ Longitude.GetHashCode();
|
||||
}
|
||||
public override bool Equals(object obj) => Equals(obj as Location);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format(CultureInfo.InvariantCulture, "{0},{1}", Latitude, Longitude);
|
||||
}
|
||||
public override int GetHashCode() => Latitude.GetHashCode() ^ Longitude.GetHashCode();
|
||||
|
||||
public static bool CoordinateEquals(double coordinate1, double coordinate2)
|
||||
{
|
||||
return Math.Abs(coordinate1 - coordinate2) < 1e-9;
|
||||
}
|
||||
public override string ToString() => string.Format(CultureInfo.InvariantCulture, "{0:0.########},{1:0.########}", Latitude, Longitude);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Location instance from a string containing a comma-separated pair of floating point numbers.
|
||||
|
|
@ -66,7 +49,7 @@ namespace MapControl
|
|||
|
||||
if (!string.IsNullOrEmpty(location))
|
||||
{
|
||||
values = location.Split(new char[] { ',' });
|
||||
values = location.Split([',']);
|
||||
}
|
||||
|
||||
if (values?.Length != 2)
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ namespace MapControl
|
|||
|
||||
public override Point? LocationToMap(double latitude, double longitude)
|
||||
{
|
||||
if (Location.Equals(latitude, Center.Latitude) &&
|
||||
Location.Equals(longitude, Center.Longitude))
|
||||
if (Center.Equals(latitude, longitude))
|
||||
{
|
||||
return new Point();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@ namespace MapControl
|
|||
|
||||
public override Point? LocationToMap(double latitude, double longitude)
|
||||
{
|
||||
if (Location.Equals(latitude, Center.Latitude) &&
|
||||
Location.Equals(longitude, Center.Longitude))
|
||||
if (Center.Equals(latitude, longitude))
|
||||
{
|
||||
return new Point();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ namespace MapControl
|
|||
{
|
||||
var extension = Path.GetExtension(uri.LocalPath).ToLower();
|
||||
|
||||
if (string.IsNullOrEmpty(extension) || extension.Equals(".jpeg"))
|
||||
if (string.IsNullOrEmpty(extension) || extension == ".jpeg")
|
||||
{
|
||||
extension = ".jpg";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,17 +49,16 @@ namespace MapControl
|
|||
{
|
||||
public const string DefaultCrsId = "AUTO2:42001";
|
||||
|
||||
private readonly string autoCrsId;
|
||||
public Wgs84AutoUtmProjection()
|
||||
: this(DefaultCrsId)
|
||||
{
|
||||
// XAML needs parameterless constructor
|
||||
}
|
||||
|
||||
public Wgs84AutoUtmProjection(string crsId = DefaultCrsId)
|
||||
public Wgs84AutoUtmProjection(string crsId)
|
||||
: base(31, true)
|
||||
{
|
||||
autoCrsId = crsId;
|
||||
|
||||
if (!string.IsNullOrEmpty(autoCrsId))
|
||||
{
|
||||
CrsId = autoCrsId;
|
||||
}
|
||||
CrsId = crsId;
|
||||
}
|
||||
|
||||
public override Location Center
|
||||
|
|
@ -77,12 +76,9 @@ namespace MapControl
|
|||
|
||||
if (Zone != zone || IsNorth != north)
|
||||
{
|
||||
var crsId = CrsId;
|
||||
SetZone(zone, north);
|
||||
|
||||
if (!string.IsNullOrEmpty(autoCrsId))
|
||||
{
|
||||
CrsId = autoCrsId;
|
||||
}
|
||||
CrsId = crsId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue