如何在 Android 上通过 GPS 跟踪距离? [英] How to track distance via GPS on Android?

查看:30
本文介绍了如何在 Android 上通过 GPS 跟踪距离?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将如何跟踪用户行进的距离?我不一定关心存储航路点,尽管无论如何这可能是计算距离所必需的.到目前为止,我正在创建一个 LocationManager 并注册一个 onLocationChanged 侦听器,然后在侦听器触发时计算两点之间的原始距离.

How would I go about tracking the distance a user travels? I don't necessarily care about storing waypoints, although that may be necessary to calculate distance anyway. So far, I am creating a LocationManager and regsitering an onLocationChanged listener, and then calculating the raw distance between two points when the listener fires.

这里的问题是,如果我让应用程序在桌子上静坐 10 到 15 分钟,它会说我已经旅行了 0.5 英里.我应该如何检查准确性并确定要使用的点?

The problem here is that if I leave the app sit still on a desk for 10, 15 minutes, it will say I have traveled .5 miles. How should I go about checking for accuracy and determining which points to use?

或者,甚至更好 - 是否有一个 SDK 或 .jar 可以包含在我的项目中并调用它们的函数以使整个事情变得更容易?

Or, even better - is there an SDK or .jar I can just include in my project and call their functions to make this whole thing easier?

感谢您的宝贵时间.

推荐答案

我不是 Android 程序员,但我在自己的嵌入式处理器中实现了此功能,其处理能力远低于运行 Andriod 的任何处理器.

I am not an Android programmer but have implemented this functionality in my own embedded processor with far less processing capability than anything that runs Andriod.

这与 GPS 确定的定位精度无关.如果你有一个固定的 GPS 接收器,它可以完美"地看到天空,并随着时间的推移绘制它报告的位置,那么你会看到它在真实位置周围徘徊,向任何方向移动几米.如果您以非常小的步长累积行进的距离,围绕真实位置,您最终会得到显然将您带到月球并返回的距离.

This is nothing to do with the accuracy of a fix as determined by the GPS. If you have a stationary GPS receiver with "perfect" visibility of the sky and plot its reported position over time then you will see it wander around the true location, moving some metres an any direction. If you accumulate the distance travelled, in very small steps, around the true position you will end up with the distance travelled apparently taking you to the moon and back.

您需要设置一个大于 GPS 定位精度的移动阈值,然后仅在您确定已从上一个移动步骤中添加的点移动时才添加行进距离.

You need to set a movement threshold that is greater than the position accuracy of your GPS fix, and then only add in the distance travelled when you are sure that you have moved from the point at which you added in the last movement step.

这篇关于如何在 Android 上通过 GPS 跟踪距离?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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