如何计算在Android应用程序的两点之间的距离 [英] how to calculate the distance between two points in android app

查看:111
本文介绍了如何计算在Android应用程序的两点之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

<一个href="http://$c$c.google.com/p/krvarma-android-samples/source/browse/#svn/trunk/GPSSample%253Fstate%253Dclosed" rel="nofollow">http://$c$c.google.com/p/krvarma-android-samples/source/browse/#svn/trunk/GPSSample%253Fstate%253Dclosed

这篇关于如何计算在Android应用程序的两点之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆