Skip to content

Commit

Permalink
added equals and hashcode to GeoPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
wwerner committed Mar 6, 2010
1 parent 470c8ad commit fb5d31e
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,20 @@ public void setLongitude(double longitude) {
this.longitude = longitude;
}

public double distanceInKilometresTo(GeoPoint to,
DistanceCalculationAlgorithm algorithm) {
return algorithm.distanceInKilometres(this, to);
@Override
public boolean equals(Object obj) {
if (!(obj instanceof GeoPoint))
return false;

GeoPoint p = (GeoPoint) obj;
return (p.getLatitude() == getLatitude() && p.getLongitude() == getLongitude());
}

public double distanceInKilometresTo(GeoPoint to) {
return DEFAULT_ALGORITHM.distanceInKilometres(this, to);
@Override
public int hashCode() {
return Double.valueOf(latitude).hashCode()
^ Double.valueOf(longitude).hashCode();

}

}

0 comments on commit fb5d31e

Please sign in to comment.