added navigation to location from map
This commit is contained in:
@@ -108,6 +108,25 @@ public class Location implements Parcelable {
|
||||
return long1 + "," + lat1;
|
||||
}
|
||||
|
||||
public double getDistance(Location other) {
|
||||
double dlon = other.getLong() - getLong();
|
||||
double dlat = other.getLat() - getLong();
|
||||
double a = Math.pow(Math.sin(dlat / 2), 2)
|
||||
+ Math.cos(getLat()) * Math.cos(other.getLong())
|
||||
* Math.pow(Math.sin(dlon / 2),2);
|
||||
|
||||
double c = 2 * Math.asin(Math.sqrt(a));
|
||||
|
||||
// Radius of earth in kilometers. Use 3956
|
||||
// for miles
|
||||
double r = 6371;
|
||||
|
||||
// calculate the result
|
||||
double distance = c * r;
|
||||
|
||||
return Math.floor(distance);
|
||||
}
|
||||
|
||||
public GeoPoint convertToGeoPoint() {
|
||||
return new GeoPoint(this.getLat(),this.getLong());
|
||||
}
|
||||
|
||||
@@ -2,8 +2,20 @@ package com.a1.nextlocation.data;
|
||||
|
||||
import org.osmdroid.views.overlay.Polyline;
|
||||
|
||||
public enum CurrentRoute {
|
||||
/**
|
||||
* singleton to keep track of different global data
|
||||
*/
|
||||
public enum StaticData {
|
||||
INSTANCE;
|
||||
private double distanceTraveled = 0;
|
||||
|
||||
public void addDistance(double d) {
|
||||
distanceTraveled += d;
|
||||
}
|
||||
|
||||
public double getDistanceTraveled() {
|
||||
return distanceTraveled;
|
||||
}
|
||||
|
||||
private Polyline currentRoute;
|
||||
|
||||
Reference in New Issue
Block a user