mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Create LatLng object
This commit is contained in:
parent
3b3a338ccd
commit
63f52ebd5e
1 changed files with 43 additions and 0 deletions
43
app/src/main/java/fr/free/nrw/commons/nearby/LatLng.java
Normal file
43
app/src/main/java/fr/free/nrw/commons/nearby/LatLng.java
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
package fr.free.nrw.commons.nearby;
|
||||
|
||||
import android.os.Parcel;
|
||||
|
||||
public class LatLng {
|
||||
|
||||
public final double latitude;
|
||||
public final double longitude;
|
||||
|
||||
LatLng(double latitude, double longitude) {
|
||||
if(-180.0D <= longitude && longitude < 180.0D) {
|
||||
this.longitude = longitude;
|
||||
} else {
|
||||
this.longitude = ((longitude - 180.0D) % 360.0D + 360.0D) % 360.0D - 180.0D;
|
||||
}
|
||||
this.latitude = Math.max(-90.0D, Math.min(90.0D, latitude));
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
boolean var1 = true;
|
||||
byte var2 = 1;
|
||||
long var3 = Double.doubleToLongBits(this.latitude);
|
||||
int var5 = 31 * var2 + (int)(var3 ^ var3 >>> 32);
|
||||
var3 = Double.doubleToLongBits(this.longitude);
|
||||
var5 = 31 * var5 + (int)(var3 ^ var3 >>> 32);
|
||||
return var5;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
if(this == o) {
|
||||
return true;
|
||||
} else if(!(o instanceof LatLng)) {
|
||||
return false;
|
||||
} else {
|
||||
LatLng var2 = (LatLng)o;
|
||||
return Double.doubleToLongBits(this.latitude) == Double.doubleToLongBits(var2.latitude) && Double.doubleToLongBits(this.longitude) == Double.doubleToLongBits(var2.longitude);
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "lat/lng: (" + this.latitude + "," + this.longitude + ")";
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue