Get Distance between two GeoPoint
package test.easytask.geo;
import android.location.Location;
import com.google.android.maps.GeoPoint;
public class GeoUtil {
public static double getDistance(GeoPoint pointStart, GeoPoint pointEnd) {
final double DEG_RATE = 1E6;
double startLatitude = pointStart.getLatitudeE6() / DEG_RATE;
double startLongitude= pointStart.getLongitudeE6() / DEG_RATE;
double endLatitude = pointEnd.getLatitudeE6() / DEG_RATE;
double endLongitude= pointEnd.getLongitudeE6() / DEG_RATE;
float[] result = new float[1];
Location.distanceBetween(startLatitude, startLongitude, endLatitude, endLongitude, result);
return result[0];
}
}
Related examples in the same category