如何计算在Android应用程序的两点之间的距离应用程序、两点、距离、Android

2023-09-05 23:43:30 作者:记忆抹黑我的世界

在我的应用程序,我想计算距离一个人从一个地方到另一个旅行。对于我现在用的是半正矢公式,

in my app i am trying to calculate the distance a person traveling from one place to the other. For that i am using 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 

越来越出发地和到达的地方,我计算公里的距离的经度和纬度。但也有人说,这个距离​​计算只有当气道行驶,并得到,如果用户通过移动道路各不相同。

getting the latitude and longitude of starting place and reaching place i am calculating the distance in kms. But others say that this distance calculation works only if travelled by airways and get varies if user travels by roadways.

如果是这样我怎么能得到一个正确的距离,同时通过公路方式出行。

If it is so how can i get a correct distance while traveling through road ways.

请帮我的朋友

推荐答案

我发现样品code以下链接来计算距离经历的道路。

i found the sample code in the following link to calculate the distance going through roads.

http://$c$c.google.com/p/krvarma-android-samples/source/browse/#svn/trunk/GPSSample%253Fstate%253Dclosed