获取设备移动的速度
我正在使用 CLLocation.speed 来获取设备移动的速度,但每次都得到 0。我试过了,
speed = ([newlocation getDistanceFrom:oldlocation]/[newlocation.timeStamp timeIntervalSinceDate:oldlocation.timeStamp])
问题是它偶尔会给出错误的速度。
I am using CLLocation.speed
to get the speed of the device moving but I am getting 0 every time. I tried
speed = ([newlocation getDistanceFrom:oldlocation]/[newlocation.timeStamp timeIntervalSinceDate:oldlocation.timeStamp])
The problem is it is giving the wrong speed once in a while.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个小配置可以帮助您:
CLLocationManager
不会向您发送更新,除非用户移动到其当前位置的圆圈之外。您可以控制圆的半径(使其更小),以便获得更精细的更新。请参阅 distanceFilter。CLLocationManager
有一个精度控制,您希望将其设置为最精细的级别。请参阅 desiredAccuracy。最好的选择就是不断计算这个“速度”并使用弱低通滤波器来平滑结果。
另请参阅此问题以获取更多信息:iPhone CoreLocation:如何获取最准确的速度。
There is a little configuration that will help you out:
CLLocationManager
will not send you an update unless the user moves outside a circle at their current location. You can control the radius of the circle (make it smaller) so you get more refined updates. See distanceFilter.CLLocationManager
has an accuracy control, that you want to set to its finest level. See desiredAccuracy.Your best bet is simply to continually calculate this "speed" and use a weak low-pass filter to smooth out the results.
See also this question for more information: iPhone CoreLocation: How to get the most accurate speed.