Dan*_*ray 10 android location locationmanager
编写GPS日志应用程序〜
我发现报告的getSpeed()方法返回的值非常不可靠.我正在使用,过滤提供的位置以获得最佳准确度.即使在单位数精度水平下,返回的速度通常也非常高.当电话静止不动时,我们说的是200 mp/h(是的,我知道它以米/秒记录).LocationsLocationManagerLocationManager.GPS_PROVIDERonLocationChanged
我正在两个不同型号的Android手机上测试相同的代码库,运行两个不同的操作系统版本,并看到相同的问题,所以我希望这是一个代码问题.
我错过了什么?我试过在一个时间窗口内平均位置,但无济于事.我是否必须根据行驶距离/时间来计算自己的速度值?这将是令人失望的.
正如你所看到的,我没有做什么特别的东西-对精度的过滤不大,甚至在此之后双方AverageSpeed并_bestLocation.getSpeed()有规律unfeasibly高,即使在定位精度好.
public void onLocationChanged(Location location) {
if (location.getAccuracy() < 25f) {
_recentLocations.add(location);
if (_bestLocation == null || location.getAccuracy() <= _bestLocation.getAccuracy())
_bestLocation = location;
}
if ((_bestLocation != null && _bestLocation.getAccuracy() < 10f && _recentLocations.size() >= 10)
|| _recentLocations.size() >= 25)
{
int Count = 0;
float TotalSpeed = 0f;
float AverageSpeed = 0f;
for (int i = 0; i<_recentLocations.size(); i++) {
if (_recentLocations.get(i).hasSpeed()) {
Count++;
TotalSpeed += _recentLocations.get(i).getSpeed();
}
}
if (Count > 0)
AverageSpeed = TotalSpeed / Count;
}
}
Run Code Online (Sandbox Code Playgroud)
Doj*_*ojo 26
我已经在GPS硬件上工作了7年多.准确度读数也不是100%准确.制造商陈述准确性以及用于测量它的系统.CEP,RMS,2DRMS和R95是一些系统.阅读本文以获取更多信息:http://en.wikipedia.org/wiki/Circular_error_probable
准确度数字不包括异常值.例如,如果规定的精度为5米,则在良好信号条件下读取的读数将具有5米的最大误差,95%的时间.关于剩余的5%读数,没有什么可说的.对这些异常值的防护是一种特殊的酱汁,使得基于良好位置的应用程序脱颖而出.
你可以做的一些事情是:
| 归档时间: |
|
| 查看次数: |
12070 次 |
| 最近记录: |