Android GPS 定位精度问题

Android GPS location accuracy issue

我正在 android 开发 gps 跟踪应用程序。这是我的代码架构:

  1. BackgroundSyncService : 用于获取位置更新的服务 class。这里 GoogleApiClient 被初始化并实现了其他与位置相关的方法。
  2. AppRunCheckerReceiver :一个 BroadcastReceiver class,它将在一个时间间隔内检查我的 BackgroundSyncService 是否为 运行。如果它停止然后它开始。
  3. GpsEnableReceiver : 一个 BroadcastReceiver,它会在 gps 状态改变时触发。它会在一段时间内检查我的 BackgroundSyncService 是否为 运行。如果它停止然后它开始。
  4. InternetConnectionStateReceiver : 一个 BroadcastReceiver,它会在互联网状态改变时触发。它会在一段时间内检查我的 BackgroundSyncService 是否为 运行。如果停止,则开始。

在我的 BackgroundSyncService 服务中,我使用这种方式初始化 GoogleApiClient:

public void setLocationLocationRequest() {

        try {
            googleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
                    .addOnConnectionFailedListener(this).addApi(com.google.android.gms.location.LocationServices.API).build();

            locationRequest = new LocationRequest();
            locationRequest.setInterval(3000);
            locationRequest.setFastestInterval(3000);
            locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
            googleApiClient.connect();
        } catch (Exception e) {

    }

这里的准确度是LocationRequest.PRIORITY_HIGH_ACCURACY,间隔是

locationRequest.setInterval(3000)

here为GoogleApiClient实现代码

This 应用程序 GPS 信息 部分包含纬度经度和精度参数

我的发现:onLocationChanged(Location location) 方法中 我用这种方式检查 Location 对象的准确性:location.getAccuracy()。这里如果精度小于50米,那我接受。

在 85% 的情况下,它就像一个魅力。它从 GPS 向我发送确切位置。但在 15% 的情况下,它会向我发送不准确的位置,例如超过 300 米。

15% 的设备是低成本的中国品牌手机。

我的问题:

  1. 我怎样才能使准确度水平接近 99%。我的代码架构有问题吗?
  2. GPS 精度是否取决于设备配置?如果是,那么我可以为低配置设备做什么?
  3. Uber、Go-JEK 等拼车应用程序如何适用于所有设备?他们是否只有 GPS 的额外编码?
  4. 我申请的是孟加拉国。这里的网速很慢。它对 GPS 精度有负面影响吗?

在此先感谢您的关注。也很抱歉英语不好。

+1 表示有问题的描述。
我希望我们能为您的问题找到最佳答案,并随着时间的推移变得更好,据我所知……这里不会只有一个正确答案。

第一,(第二)

  1. 我怎样才能使准确率接近 99%。我的代码架构有问题吗?

  2. GPS 精度是否取决于设备配置?如果是,那么我可以为低配置设备做什么?

设备配置和代码架构在这里都很重要。如果你已经达到了 85% 的成功率,我认为代码架构是可以的。
就 GPS 而言,视线是设备配置和准确性的重要因素。 尽管低成本手机可以 return 具有清晰视线的准确位置。您可以尝试 运行 2 个周期 more/waiting 以获得更高的准确性。

在最坏的情况下,考虑到它的价值,您还可以尝试使用 LocationManager 和 GPS 提供商技术检索位置,该技术作为 15% 的后备,只是为了比较并确保您正在使用您可以获得最准确的位置。 Location Strategies 写成

In most cases, you'll get better battery performance, as well as more appropriate accuracy, by using the Location Services API.

  1. Uber、Go-JEK 等拼车应用程序如何适用于所有设备?他们是否只有 GPS 的额外编码?
    它们确实有效,但对于在应用程序中接收到的位置,它们并不总是具有最高的准确性。如果我们开发人员有任何位置黑客,我们需要找到它们,可能是第 5 页 google 搜索结果 :) 或从开源环境中受益。对我来说,最佳实践和 android 回购链接就足够了。您已经关注了 Receive location updates

  2. 等帖子
  3. 我申请的是孟加拉国。这里的网速很慢。它对 GPS 精度有负面影响吗?
    互联网和 LocationManager + GPS_PROVIDER

  4. 没有关系

位置更新可以通过以下方式完成:

  1. 您从 GPS 获取的位置比您从网络获取的位置更准确,因此如果您需要准确性,请使用 GPS

  2. 对此不确定,但我认为它与上下文有关,你想要什么类型的位置,比如你想要准确度或最快的位置,所以根据那个选择你的供应商

  3. FusedLocation 提供程序是目前在 android 上获取位置的最高效和最有效的解决方案,它从不同的来源收集位置数据,并根据传递的参数在多长时间内收集您想要更新位置,是否需要高精度 etc.It 为您提供最佳位置。

  4. 是的,您应该使用 FusedLocationProvider 来获取 android 上的位置,因为 google 也推荐这样做,这是获取 [= 上位置的最有效和高效的方法=92=] 现在。

你为什么不尝试创建 Criteria.ACCURACY_HIGH

A constant indicating a high accuracy requirement - may be used for horizontal, altitude, speed or bearing accuracy. For horizontal and vertical position this corresponds roughly to an accuracy of less than 100 meters.

Android 试图向我们掩盖硬件的真实性,但实际上只有两个位置提供者:GPS 和网络。 GPS 定位速度很慢,并非所有设备都有,但它是准确的。网络定位更快,几乎所有设备都支持,但不太准确。

Google 通过 fused location provider.

改进了其地图和位置管理

与融合位置 provider.The 方法交互的主要入口点必须与 GoogleApiClient 结合使用。


代码:

 new GoogleApiClient.Builder(context)
         .addApi(LocationServices.API)
         .addConnectionCallbacks(this)
         .addOnConnectionFailedListener(this)
         .build()

gps –> (GPS, AGPS): Name of the GPS location provider. This provider determines location using satellites. Depending on conditions, this provider may take a while to return a location fix. Requires the permission android.permission.ACCESS_FINE_LOCATION.

network –> (AGPS, CellID, WiFi MACID): Name of the network location provider. This provider determines location based on availability of cell tower and WiFi access points. Results are retrieved by means of a network lookup. Requires either of the permissions android.permission.ACCESS_COARSE_LOCATION or android.permission.ACCESS_FINE_LOCATION.


其他选项:

getLastKnownLocation()

getLastKnownLocation() 这个 returns 最后一个已知位置...在您重新安装应用程序后,它不会有任何最后一个已知位置...所以它会导致 NPE.. .而是使用下面的代码

public Location getLocation() {
    try {
        locationManager = (LocationManager) mContext
                .getSystemService(LOCATION_SERVICE);

        // getting GPS status
        isGPSEnabled = locationManager
                .isProviderEnabled(LocationManager.GPS_PROVIDER);

        // getting network status
        isNetworkEnabled = locationManager
                .isProviderEnabled(LocationManager.NETWORK_PROVIDER);

        if (!isGPSEnabled && !isNetworkEnabled) {
            // no network provider is enabled
        } else {
            this.canGetLocation = true;
            //here is the if-else change so code avoids falling into both loops
         // if GPS Enabled get lat/long using GPS Services
            if (isGPSEnabled) {
                if (location == null) {
                    locationManager.requestLocationUpdates(
                            LocationManager.GPS_PROVIDER,
                            MIN_TIME_BW_UPDATES,
                            MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                    Log.d("GPS", "GPS Enabled");
                    if (locationManager != null) {
                        location = locationManager
                                .getLastKnownLocation(LocationManager.GPS_PROVIDER);
                        if (location != null) {
                            latitude = location.getLatitude();
                            longitude = location.getLongitude();
                        }
                    }
                }
            } else if (isNetworkEnabled) {
                locationManager.requestLocationUpdates(
                        LocationManager.NETWORK_PROVIDER,
                        MIN_TIME_BW_UPDATES,
                        MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
                Log.d("Network", "Network Enabled");
                if (locationManager != null) {
                    location = locationManager
                            .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
                    if (location != null) {
                        latitude = location.getLatitude();
                        longitude = location.getLongitude();
                    }
                }
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }

    return location;
}

查看我找到的几个最佳示例:

它对我有用...应该也对您有用...

  1. How can i make accuracy level near 99%. Is there any problem on my code architecture?

这是真实的场景。您无法确保所有位置提供程序都将按预期工作。你应该要求最好的职位。

  1. a) Does GPS accuracy depends on device configuration?

是的。一些设备可能有旧的 GPS 芯片组,它们只能跟踪 GPS 信号(美国),因为还有其他定位系统,如 Galileo(欧洲)、GLONASS(俄罗斯)、QZSS(日本)和北斗(中国)。芯片组对这些类型的支持越多,您跟踪更多卫星的机会就越大。 TTFF(首次修复时间)也取决于 gps 接收器有多少个通道。

b) If YES then what can i do for low configuration device?

由于这是一个硬件问题,您不能在这里做任何事情。但其他位置源可以弥补 GPS 数据的不足,例如 AGPS(辅助 GPS)、wifi 和蜂窝定位。还有一些付费选项提供了一个数据库,可以使用 wifi 接入点和 cellid 定位您的设备(他们声称他们提供了 wifi 上的最佳解决方案,但我不确定,因为我不使用它。您可以查看 http://combain.com ). Wifi 和 cellid 还取决于周围有多少个 wifi 接入点和手机信号塔以及它们距离多远(信号强度)。如果你需要 50m 的精度,蜂窝定位无关但 wifi 有机会接近这个值。

2009 年的一些研究结果 [3]

  • 3G iPhone 带 A-GPS ~ 8 米
  • 3G iPhone 带 wifi ~ 74 米
  • 3G iPhone w/ 蜂窝定位 ~ 600 米
  1. How Uber, Go-JEK etc. ride sharing apps works for all device? Is they have extra coding for GPS only?

他们可能有特定的定位策略,但它将基于在 GPS 中断期间使用其他来源。

  1. My application is for Bangladesh. Here internet is slow. Is it has negative impact on GPS accuracy?

其他答案声称互联网与 GPS 无关。是的,它确实与 GPS 无关,但与位置有关。 AGPS 使用互联网获取 3 种类型的数据(卫星信号、历书和星历表),这些数据有助于 GPS 更快地提供定位。如果星历表和历书已过时或设备从先前的定位移动了数百公里,则称为冷启动,在没有 AGPS 的情况下大约需要 12-15 分钟。

Fused location provider已经知道如何使用这些配置提供最佳解决方案,所以你应该祝福它。

参考文献: