难道位置#distanceTo(位置)取位置#getAccuracy()考虑? [英] Does Location#distanceTo(Location) take Location#getAccuracy() into account?

查看:1210
本文介绍了难道位置#distanceTo(位置)取位置#getAccuracy()考虑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个 LocationListener的,是以最准确和precise最近的位置的位置。我打算用这个code我的 LocationListener的

I want to write a LocationListener that takes the most accurate and precise recent location as its location. I'm intending to use this code in my LocationListener:

    @Override
    public void onLocationChanged(Location location) {
        if(location.distanceTo(mLocation)>location.getAccuracy()){
            mLocation = location;
        }
    }

我打算这是什么做的是更新的位置,如果用户的旧位置的之外的的可能的地点的循环,新的位置指示。因此,举例来说,如果我们的最后一次测量是GPS信号,新的一个是手机信号塔,老地点是在手机信号塔的范围内,我们不更新;另一方面,如果该小区发射塔是足够远,我们知道用​​户已经移动并记录

What I intend this to do is update the location if the user's old location is outside the circle of "possible locations" that the new location indicates. So, for example, if our last measurement was a GPS signal and the new one is a cell tower, and the old location was in range of the cell tower, we don't update; on the other hand, if the cell tower is sufficiently distant, we know the user has moved and record that.

但是, distanceTo(位置)函数声明其返回的大致的在位置之间米的距离。是否已经采取的准确性考虑?它会给我一个precise足够的身影让我以这种方式使用?

However, the distanceTo(Location) function states it returns the approximate distance in metres between locations. Does it already take the accuracy into account? Will it give me a precise enough figure to let me use in this way?

推荐答案

简短的回答是否定的, Location.distanceTo(位置)不采取 Location.getAccuracy()价值考虑在内时,测量距离。

Short answer is no, Location.distanceTo(Location) does not take Location.getAccuracy() value into account when measuring distance.

下面是用于计算 Location.distanceTo距离Android平台实际code(位置)
<一href=\"https://github.com/android/platform_frameworks_base/blob/master/location/java/android/location/Location.java#L272\" rel=\"nofollow\">https://github.com/android/platform_frameworks_base/blob/master/location/java/android/location/Location.java#L272

它采用Vincenty的反式( http://www.ngs.noaa.gov/ PUBS_LIB / inverse.pdf - 基于给定的纬度和经度(精度第4)不考虑)

It uses Vincenty's Inverse Formula (http://www.ngs.noaa.gov/PUBS_LIB/inverse.pdf - Section 4) based on the given latitude and longitude (accuracy not considered).

至于你更新了真正的用户位置的方法是否将precise不够,它实际上取决于GPS灵敏度,准确度和precision,这可以从设备显著变化到设备。

As to whether your method of updating the "true" user location will be "precise enough", it really depends on GPS sensitivity, accuracy, and precision, which can vary significantly from device to device.

Location.getAccuracy()也差异很大,取决于贴牌,通常设备我见过高估精度(即设备给出准确估值不止一个精确值比真实准确度)低估的准确性。

The accuracy estimate value from Location.getAccuracy() can also vary widely depending on the OEM, and typically devices I've seen overestimate accuracy (i.e., the device gives an accuracy value greater than the true accuracy) more than underestimate accuracy.

您可能会想看看我创建了一个应用程序GPS基准( http://www.gpsbenchmark.com/ ),这有助于快速基准位置提供精度(GPS和网络)在Android设备上,以及估计精度的精度。我还共同撰写了一篇关于这个话题( http://journals.cambridge.org/repo_A82eaJIy )根据一些Java ME的设备GPS基准测试结果,和大部分材料也与Android相关。

You might want to check out an app I created "GPS Benchmark" (http://www.gpsbenchmark.com/) which helps quickly benchmark location provider accuracy (GPS and Network) on Android devices, as well as "estimated accuracy" accuracy. I also co-authored a paper on this topic (http://journals.cambridge.org/repo_A82eaJIy) based on GPS benchmarking results from some Java ME devices, and most of the material is also relevant to Android.

这篇关于难道位置#distanceTo(位置)取位置#getAccuracy()考虑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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