How to calculate the distance between two points in an Android Application

In my application, I try to calculate the distance a person travels from one place to another. For this purpose, I use the haversine formula,

R = earth’s radius (mean radius = 6,371km)
Δlat = lat2− lat1
Δlong = long2− long1
a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2)
c = 2.atan2(√a, √(1−a))
d = R.c 

To get the latitude and longitude of the starting and arriving places, I am calculating the distance in KMS. But others say that this distance calculation is valid only when the airway is traveling, and it will change if the user travels on the road

If so, how can I get the right distance when crossing the road

Please help my friend

resolvent:

This method is in the standard API (location. Distancebetween method) http://developer.android.com/reference/android/location/Location.html

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>