Android:计算两个位置之间距离的最佳方法

编程入门 行业动态 更新时间:2024-10-20 16:03:33
本文介绍了Android:计算两个位置之间距离的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我在这个主题上进行了一些研究,但有很多意见并没有给出清晰的图像。我的问题是这样的:我正在开发一个基于gps的Android应用程序,至于我想知道我的当前位置由Androids LocationManager指定的位置和其他位置之间的距离。我尝试了Haversine公式,一个余弦定律公式,然后我发现Android SDK给了我一个简单的函数Location.distanceTo(Location) - 我不确定这个函数运行在什么方法上。 所以,重点在于,在大多数情况下,这些位置之间的实际距离不会大于aprox,这对我来说会很有用。 100-200M?也许我应该检查Vincenty的公式?真的很慢吗?有人可以请我解释一下我应该选择什么? 不要使用distanceTo。使用distanceBetween方法,因为它听起来像你已经有了坐标,这就是你用这个方法所需要的全部: Location.distanceBetween()Javadoc

i researched a little in this topic, but there are many opinions that don't exactly give a clear image. My problem is this: I'm developing a gps-based app for Android, in wich i want to know distance between my current location specified by Androids LocationManager, and other location in real time. I tried Haversine formula, a Law of Cosines formula, then I discovered, that Android SDK gives me a simple function Location.distanceTo(Location) - i'm not sure what method does this function runs on. So, the point is, wich one will be good for me to use, in situations when real distance between these locations most of the time won't be larger than aprox. 100-200m? Maybe i should check Vincenty's formula? Is it realy that slow? Can someone please explain me what should I choose?

解决方案

Don't use distanceTo. Use the distanceBetween method as it sounds like you already have the coordinates and that's all you need with this method: Location.distanceBetween() Javadoc

更多推荐

Android:计算两个位置之间距离的最佳方法

本文发布于:2023-11-12 20:21:44,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:距离   位置   两个   方法   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!