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