mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Code style
This commit is contained in:
parent
0a86a31203
commit
2a7ef947ff
7 changed files with 47 additions and 19 deletions
|
|
@ -2,8 +2,8 @@ package fr.free.nrw.commons.location;
|
|||
|
||||
public class LatLng {
|
||||
|
||||
public final double latitude;
|
||||
public final double longitude;
|
||||
private final double latitude;
|
||||
private final double longitude;
|
||||
private final float accuracy;
|
||||
|
||||
/** Accepts latitude and longitude.
|
||||
|
|
@ -95,4 +95,31 @@ public class LatLng {
|
|||
return formatCoordinate(this.latitude) + " " + this.getNorthSouth() + ", "
|
||||
+ formatCoordinate(this.longitude) + " " + this.getEastWest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the location accuracy in meter.
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public float getAccuracy() {
|
||||
return accuracy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the longitude in degrees.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public double getLongitude() {
|
||||
return longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the latitude in degrees.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public double getLatitude() {
|
||||
return latitude;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,8 +109,8 @@ public class NearbyController {
|
|||
nearbyBaseMarker.title(place.name);
|
||||
nearbyBaseMarker.position(
|
||||
new com.mapbox.mapboxsdk.geometry.LatLng(
|
||||
place.location.latitude,
|
||||
place.location.longitude));
|
||||
place.location.getLatitude(),
|
||||
place.location.getLongitude()));
|
||||
nearbyBaseMarker.place(place);
|
||||
nearbyBaseMarker.icon(icon);
|
||||
|
||||
|
|
|
|||
|
|
@ -122,8 +122,8 @@ public class NearbyInfoDialog extends OverlayDialog {
|
|||
Bundle bundle = new Bundle();
|
||||
bundle.putString(ARG_TITLE, place.name);
|
||||
bundle.putString(ARG_DESC, place.description);
|
||||
bundle.putDouble(ARG_LATITUDE, place.location.latitude);
|
||||
bundle.putDouble(ARG_LONGITUDE, place.location.longitude);
|
||||
bundle.putDouble(ARG_LATITUDE, place.location.getLatitude());
|
||||
bundle.putDouble(ARG_LONGITUDE, place.location.getLongitude());
|
||||
bundle.putParcelable(ARG_SITE_LINK, place.siteLinks);
|
||||
mDialog.setArguments(bundle);
|
||||
DialogUtil.showSafely(fragmentActivity, mDialog);
|
||||
|
|
@ -138,7 +138,8 @@ public class NearbyInfoDialog extends OverlayDialog {
|
|||
@OnClick(R.id.link_preview_directions_button)
|
||||
void onDirectionsClick() {
|
||||
//Open map app at given position
|
||||
Uri gmmIntentUri = Uri.parse("geo:0,0?q=" + location.latitude + "," + location.longitude);
|
||||
Uri gmmIntentUri = Uri.parse(
|
||||
"geo:0,0?q=" + location.getLatitude() + "," + location.getLongitude());
|
||||
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
|
||||
|
||||
if (mapIntent.resolveActivity(getActivity().getPackageManager()) != null) {
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ public class NearbyListFragment extends ListFragment {
|
|||
Place place = (Place) listview.getItemAtPosition(position);
|
||||
LatLng placeLatLng = place.location;
|
||||
|
||||
double latitude = placeLatLng.latitude;
|
||||
double longitude = placeLatLng.longitude;
|
||||
double latitude = placeLatLng.getLatitude();
|
||||
double longitude = placeLatLng.getLongitude();
|
||||
|
||||
Timber.d("Item at position %d has coords: Lat: %f Long: %f", position, latitude, longitude);
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
MapboxMapOptions options = new MapboxMapOptions()
|
||||
.styleUrl(Style.OUTDOORS)
|
||||
.camera(new CameraPosition.Builder()
|
||||
.target(new LatLng(curLatLng.latitude, curLatLng.longitude))
|
||||
.target(new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude()))
|
||||
.zoom(11)
|
||||
.build());
|
||||
|
||||
|
|
@ -125,11 +125,11 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
|||
*/
|
||||
public void addCurrentLocationMarker(MapboxMap mapboxMap) {
|
||||
MarkerOptions currentLocationMarker = new MarkerOptions()
|
||||
.position(new LatLng(curLatLng.latitude, curLatLng.longitude));
|
||||
.position(new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude()));
|
||||
mapboxMap.addMarker(currentLocationMarker);
|
||||
|
||||
List<LatLng> circle = createCircleArray(curLatLng.latitude, curLatLng.longitude,
|
||||
curLatLng.accuracy * 2, 100);
|
||||
List<LatLng> circle = createCircleArray(curLatLng.getLatitude(), curLatLng.getLongitude(),
|
||||
curLatLng.getAccuracy() * 2, 100);
|
||||
|
||||
mapboxMap.addPolygon(
|
||||
new PolygonOptions()
|
||||
|
|
|
|||
|
|
@ -74,8 +74,8 @@ public class NearbyPlaces {
|
|||
|
||||
String query = wikidataQuery
|
||||
.replace("${RAD}", String.format(Locale.ROOT, "%.2f", radius))
|
||||
.replace("${LAT}", String.format(Locale.ROOT, "%.4f", cur.latitude))
|
||||
.replace("${LONG}", String.format(Locale.ROOT, "%.4f", cur.longitude))
|
||||
.replace("${LAT}", String.format(Locale.ROOT, "%.4f", cur.getLatitude()))
|
||||
.replace("${LONG}", String.format(Locale.ROOT, "%.4f", cur.getLongitude()))
|
||||
.replace("${LANG}", lang);
|
||||
|
||||
Timber.v("# Wikidata query: \n" + query);
|
||||
|
|
|
|||
|
|
@ -38,10 +38,10 @@ public class LengthUtils {
|
|||
}
|
||||
|
||||
private static double computeAngleBetween(LatLng from, LatLng to) {
|
||||
return distanceRadians(Math.toRadians(from.latitude),
|
||||
Math.toRadians(from.longitude),
|
||||
Math.toRadians(to.latitude),
|
||||
Math.toRadians(to.longitude));
|
||||
return distanceRadians(Math.toRadians(from.getLatitude()),
|
||||
Math.toRadians(from.getLongitude()),
|
||||
Math.toRadians(to.getLatitude()),
|
||||
Math.toRadians(to.getLongitude()));
|
||||
}
|
||||
|
||||
private static double distanceRadians(double lat1, double lng1, double lat2, double lng2) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue