I am experimenting using nutiteq , as i found it a better alternative working on 3d maps.I want to learn every bit of it.So I am making a simple project where I can calculate the speed distance and time from its current location simultaneously on its tracking. I applied some logics but failed.Can any of you help me.
public final static double AVERAGE_RADIUS_OF_EARTH = 6371;
public int calculateDistance(double userLat, double userLng, double venueLat, double venueLng) {
double latDistance = Math.toRadians(userLat - venueLat);
double lngDistance = Math.toRadians(userLng - venueLng);
double a = (Math.sin(latDistance / 2) * Math.sin(latDistance / 2)) +
(Math.cos(Math.toRadians(userLat))) *
(Math.cos(Math.toRadians(venueLat))) *
(Math.sin(lngDistance / 2)) *
(Math.sin(lngDistance / 2));
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
return (int) (Math.round(AVERAGE_RADIUS_OF_EARTH * c));
}
This is what I have used so far and is calling this function onLocationChange.
Please help. Thanks in advance
This is my code and is working well: