2

我正在使用 FusedLocationAPI 获取高精度位置更新(更新间隔为 2 秒,最快间隔为 5 秒)。它在大多数情况下都能正常工作。但是,有时它会给出 1200m 的精度。

我明白一开始它可能会发生。但是,我遇到的问题是,我得到了一段时间的公平(~20m 精度)更新,然后突然切换到~1200m 精度。

这怎么会在 Fused API 中发生?

4

2 回答 2

2

有时候这种情况会发生。此外,错误的定位可能会连续 5 分钟到达。为了尝试过滤此类坐标,我使用了Location Strategies文章中描述的方法(请参阅维护当前最佳估计部分)。

private static final int TWO_MINUTES = 1000 * 60 * 2;

/** Determines whether one Location reading is better than the current Location fix
 * @param location  The new Location that you want to evaluate
 * @param currentBestLocation  The current Location fix, to which you want to compare the new one
 */
protected boolean isBetterLocation(Location location, Location currentBestLocation) {
    if (currentBestLocation == null) {
        // A new location is always better than no location
        return true;
    }

    // Check whether the new location fix is newer or older
    long timeDelta = location.getTime() - currentBestLocation.getTime();
    boolean isSignificantlyNewer = timeDelta > TWO_MINUTES;
    boolean isSignificantlyOlder = timeDelta < -TWO_MINUTES;
    boolean isNewer = timeDelta > 0;

    // If it's been more than two minutes since the current location, use the new location
    // because the user has likely moved
    if (isSignificantlyNewer) {
        return true;
        // If the new location is more than two minutes older, it must be worse
    } else if (isSignificantlyOlder) {
        return false;
    }

    // Check whether the new location fix is more or less accurate
    int accuracyDelta = (int) (location.getAccuracy() - currentBestLocation.getAccuracy());
    boolean isLessAccurate = accuracyDelta > 0;
    boolean isMoreAccurate = accuracyDelta < 0;
    boolean isSignificantlyLessAccurate = accuracyDelta > 200;

    // Check if the old and new location are from the same provider
    boolean isFromSameProvider = isSameProvider(location.getProvider(),
            currentBestLocation.getProvider());

    // Determine location quality using a combination of timeliness and accuracy
    if (isMoreAccurate) {
        return true;
    } else if (isNewer && !isLessAccurate) {
        return true;
    } else if (isNewer && !isSignificantlyLessAccurate && isFromSameProvider) {
        return true;
    }
    return false;
}

/** Checks whether two providers are the same */
private boolean isSameProvider(String provider1, String provider2) {
    if (provider1 == null) {
        return provider2 == null;
    }
    return provider1.equals(provider2);
}

它是为与标准的 Android Location API 一起使用而设计的,但它可以工作。我只是对其进行了一些更正,因为所有修复程序都具有相同的提供程序。它允许我过滤大约 30% 的“坏”位置修复。

于 2017-09-13T10:07:03.397 回答
0

原始 GPS 数据的距离测量总是有噪声,因为基础数据通常不准确。这些跳跃是由于位置测量不准确造成的。为了实现准确的距离测量,您可能需要过滤数据中的噪声。

您可以探索的一些有用的过滤技术是:

  1. 使用卡尔曼滤波器平滑位置数据 - 参见教程
  2. 使用 Google maps snap-to-roads APIOSRM 匹配服务捕捉到道路。

如果您正在寻找能够提供准确位置数据和距离测量的端到端解决方案,您还可以尝试适用于 Android 或 iOS 的 HyperTrack SDK。您可以在他们的博客上了解他们如何过滤位置以提高准确性。

于 2017-09-20T06:23:50.227 回答