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?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
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
Looking into the Android source for distanceTo(Location), you can see that the result is based on the "Inverse Formula" of geodesy:
Which is based on using the "Inverse Formula" (section 4)
Furthermore, the two methods distanceTo and distanceBetween use the same underlying method. They just have alternative forms of input/output.
For completeness, the full source of this computation is included below, but I encourage you to check out the Location class in android.location for yourself. (P.S. I did not check the correctness of the Android computation. This would be a good exercise!)