计算在Android的两个定位点之间的速度 [英] Calculate speed between two location points in Android

查看:235
本文介绍了计算在Android的两个定位点之间的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这看起来应该是很简单,但我似乎无法得到如何使用Android的定位服务来计算我的速度一个明显的例子。

所有我想要做的是计算基于我的previous和当前的GPS位置我的速度。 getSpeed​​()不起作用,因为它需要在使用setSpeed​​()的一些点进行设置。

那么,有没有样品code,在那里,我可以在Eclipse反对我运行一个GPX文件的Andr​​oid模拟器中运行,这会告诉我我的步伐,在任何措施(米,英尺,英里等,没有按' ŧ事 - 我可以一直将它转换为我所需要的)

在此先感谢,
亚历克斯


解决方案

  

getSpeed​​()不工作,因为它需要在某些时候使用setSpeed​​()。设置


(如果你使用的是实际设备 - )。无,速度由GPS芯片组来确定,它应当比获得两个连续位置之间的距离和时间更准确。你并不需要 setSpeed​​()。呼叫 hasSpeed​​() ,查看速度是有效的。


(如果你使用的不是实际的设备)
 我已经使用模拟位置提供者在这里可以设置要与 setSpeed​​()位置对象良好的成功在米/秒

下面是这样做的一些方法:

This seems like it should be simple enough, but I can't seem to get a clear example of how to calculate my speed using Android's Location Services.

All I want to do is calculate my speed based on my previous and current GPS position. getSpeed() doesn't work, because it needs to be set at some point using setSpeed().

So is there any sample code out there that I can run in Eclipse against my Android emulator running a GPX file, that will show me my pace in any measure (meters, feet, miles, etc., doesn't matter - I can always convert this to what I need).

Thanks in advance, Alex

解决方案

getSpeed() doesn't work, because it needs to be set at some point using setSpeed().

(In case you are using an actual device -- ). No, the speed is determined by the GPS chipset and it should be more accurate than getting the distance and time between two consecutive locations. You do not need to setSpeed() . Call hasSpeed() to see if the speed is valid.


(In case you're not using an actual device) I've had good success using the mock location provider where you can set the Location object you want with setSpeed() in meters/second

Here are some ways of doing this :

这篇关于计算在Android的两个定位点之间的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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