Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Id to PointLatLng type #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions GMap.NET/GMap.NET.Core/PointLatLng.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,23 @@ public struct PointLatLng
bool _notEmpty;

public PointLatLng(double lat, double lng)
: this(Guid.Empty, lat, lng)
{
_lat = lat;
_lng = lng;
_notEmpty = true;
}

public PointLatLng(Guid id, double lat, double lng)
{
Id = id;
_lat = lat;
_lng = lng;
_notEmpty = true;
}

public Guid Id { get; }

/// <summary>
/// returns true if coordinates wasn't assigned
/// </summary>
Expand Down Expand Up @@ -76,7 +87,7 @@ public double Lng

public static bool operator ==(PointLatLng left, PointLatLng right)
{
return left.Lng == right.Lng && left.Lat == right.Lat;
return left.Id == right.Id && left.Lng == right.Lng && left.Lat == right.Lat;
}

public static bool operator !=(PointLatLng left, PointLatLng right)
Expand All @@ -102,7 +113,7 @@ public override bool Equals(object obj)
}

var tf = (PointLatLng)obj;
return tf.Lng == Lng && tf.Lat == Lat && tf.GetType().Equals(GetType());
return tf.Id == Id && tf.Lng == Lng && tf.Lat == Lat && tf.GetType().Equals(GetType());
}

public void Offset(PointLatLng pos)
Expand All @@ -118,12 +129,12 @@ public void Offset(double lat, double lng)

public override int GetHashCode()
{
return Lng.GetHashCode() ^ Lat.GetHashCode();
return Id.GetHashCode() ^ Lng.GetHashCode() ^ Lat.GetHashCode();
}

public override string ToString()
{
return string.Format(CultureInfo.CurrentCulture, "{{Lat={0}, Lng={1}}}", Lat, Lng);
return string.Format(CultureInfo.CurrentCulture, "{{Id={0}, Lat={1}, Lng={2}}}", Id, Lat, Lng);
}
}
}