mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Moved code to reduce feature envy.
This commit is contained in:
parent
e589d0eb6f
commit
4f4587fd4d
2 changed files with 21 additions and 4 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package fr.free.nrw.commons.location;
|
package fr.free.nrw.commons.location;
|
||||||
|
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
import android.net.Uri;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -11,15 +12,15 @@ public class LatLng {
|
||||||
private final double latitude;
|
private final double latitude;
|
||||||
private final double longitude;
|
private final double longitude;
|
||||||
private final float accuracy;
|
private final float accuracy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts latitude and longitude.
|
* Accepts latitude and longitude.
|
||||||
* North and South values are cut off at 90°
|
* North and South values are cut off at 90°
|
||||||
*
|
*
|
||||||
* @param latitude the latitude
|
* @param latitude the latitude
|
||||||
* @param longitude the longitude
|
* @param longitude the longitude
|
||||||
* @param accuracy the accuracy
|
* @param accuracy the accuracy
|
||||||
*
|
*
|
||||||
* Examples:
|
* Examples:
|
||||||
* the Statue of Liberty is located at 40.69° N, 74.04° W
|
* the Statue of Liberty is located at 40.69° N, 74.04° W
|
||||||
* The Statue of Liberty could be constructed as LatLng(40.69, -74.04, 1.0)
|
* The Statue of Liberty could be constructed as LatLng(40.69, -74.04, 1.0)
|
||||||
|
|
@ -43,7 +44,7 @@ public class LatLng {
|
||||||
public static LatLng from(@NonNull Location location) {
|
public static LatLng from(@NonNull Location location) {
|
||||||
return new LatLng(location.getLatitude(), location.getLongitude(), location.getAccuracy());
|
return new LatLng(location.getLatitude(), location.getLongitude(), location.getAccuracy());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a hash code for the longitude and longitude
|
* creates a hash code for the longitude and longitude
|
||||||
*/
|
*/
|
||||||
|
|
@ -153,4 +154,8 @@ public class LatLng {
|
||||||
public double getLatitude() {
|
public double getLatitude() {
|
||||||
return latitude;
|
return latitude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Uri getGmmIntentUri() {
|
||||||
|
return Uri.parse("geo:0,0?q=" + latitude + "," + longitude);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,18 @@ public class Place {
|
||||||
this.distance = distance;
|
this.distance = distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasWikipediaLink() {
|
||||||
|
return !(siteLinks == null || Uri.EMPTY.equals(siteLinks.getWikipediaLink()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasWikidataLink() {
|
||||||
|
return !(siteLinks == null || Uri.EMPTY.equals(siteLinks.getWikidataLink()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasCommonsLink() {
|
||||||
|
return !(siteLinks == null || Uri.EMPTY.equals(siteLinks.getCommonsLink()));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o instanceof Place) {
|
if (o instanceof Place) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue