I really like this class but the implementation of GetHashCode produces high collisions.
public override int GetHashCode()
{
return (latitude+longitude).GetHashCode();
}
Indeed with the current code any two coordinates with the same latitudinal longitudinal sum with cause collisions. So, these all have the same hash.
Coordinate(-1,6)
Coordinate(0,5)
Coordinate(1,4)
Coordinate(2,3)
Coordinate(3,2)
Coordinate(4,1)
Coordinate(5,0)
Coordinate(6,-1)
You get the idea....
Anyhow, something like the following will resolve the issue.
public override int GetHashCode()
{
int hash = 13;
hash = (hash * 7) + latitude.GetHashCode();
hash = (hash * 7) + longitude.GethashCode();
return hash;
}