2013-04-18 23:35:02 +02:00
|
|
|
package net.osmand.data;
|
|
|
|
|
2015-11-15 17:02:25 +01:00
|
|
|
import net.osmand.FloatMath;
|
|
|
|
|
2015-08-31 14:30:20 +02:00
|
|
|
import java.io.Serializable;
|
2013-04-18 23:35:02 +02:00
|
|
|
|
2015-08-31 14:30:20 +02:00
|
|
|
public class LatLon implements Serializable {
|
2013-04-18 23:35:02 +02:00
|
|
|
private final double longitude;
|
|
|
|
private final double latitude;
|
|
|
|
|
|
|
|
public LatLon(double latitude, double longitude) {
|
|
|
|
this.latitude = latitude;
|
|
|
|
this.longitude = longitude;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
final int prime = 31;
|
|
|
|
int result = 1;
|
|
|
|
long temp;
|
|
|
|
temp = Double.doubleToLongBits(latitude);
|
|
|
|
result = prime * result + (int) (temp ^ (temp >>> 32));
|
|
|
|
temp = Double.doubleToLongBits(longitude);
|
|
|
|
result = prime * result + (int) (temp ^ (temp >>> 32));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj)
|
|
|
|
return true;
|
|
|
|
if (obj == null)
|
|
|
|
return false;
|
|
|
|
if (getClass() != obj.getClass())
|
|
|
|
return false;
|
|
|
|
LatLon other = (LatLon) obj;
|
2015-11-15 17:02:25 +01:00
|
|
|
|
|
|
|
if (Float.floatToIntBits((float) latitude) != Float.floatToIntBits((float) other.latitude))
|
|
|
|
return false;
|
|
|
|
if (Float.floatToIntBits((float) longitude) != Float.floatToIntBits((float) other.longitude))
|
|
|
|
return false;
|
|
|
|
/*
|
2013-04-18 23:35:02 +02:00
|
|
|
if (Double.doubleToLongBits(latitude) != Double.doubleToLongBits(other.latitude))
|
|
|
|
return false;
|
|
|
|
if (Double.doubleToLongBits(longitude) != Double.doubleToLongBits(other.longitude))
|
|
|
|
return false;
|
2015-11-15 17:02:25 +01:00
|
|
|
*/
|
2013-04-18 23:35:02 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return "Lat " + ((float)latitude) + " Lon " + ((float)longitude); //$NON-NLS-1$ //$NON-NLS-2$
|
|
|
|
}
|
|
|
|
|
|
|
|
public double getLatitude() {
|
|
|
|
return latitude;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double getLongitude() {
|
|
|
|
return longitude;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|