【问题标题】:What is the best way to calculate distance from GPS in Android Phone?在 Android 手机中计算与 GPS 距离的最佳方法是什么?
【发布时间】:2017-05-27 04:11:22
【问题描述】:

我正在开发一个应用程序,该应用程序每 60 秒捕获一次用户的纬度和经度,并计算用户行进的距离。 有时我的手机在同一个位置超过一小时,但 GPS 跳到不同的位置,导致距离计算错误。

如何减少gps跳动,提高距离精度?

【问题讨论】:

  • GPS 跳跃取决于您手机使用的 GPS 天线的质量。这意味着,更好的手机将是它的 GPS 天线,因此更好的准确性。否则,您可以使用一些逻辑来计算距离,但这会耽误您的时间。

标签: android gps android-gps


【解决方案1】:

GPS 的准确性在整个会话期间不会保持一致。但有办法克服这一点。即使用户没有改变位置,纬度,经度值仍然会在连续的时期内有所不同。查看以下方式如何修改这些异常。

// for location updates
private int locationupdate = 8000; //in milliseconds
private int locationdistance = 10; // in meters

在创建位置请求时,请根据您的要求提及setSmallestDisplacementsetInterval,如下所示

protected void createLocationRequest() {
    locationRequest = new LocationRequest();
    locationRequest.setInterval(locationupdate); //in milliseconds
    locationRequest.setFastestInterval(5000); //in milliseconds
    locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    locationRequest.setSmallestDisplacement(locationdistance);
}

查看this link了解更多信息

【讨论】:

    【解决方案2】:

    你必须检查位置的准确性,如果不够好,请不要使用它。

    can't find the exact current location in android

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-19
      • 1970-01-01
      • 2014-02-03
      • 2021-10-19
      • 2023-01-30
      相关资源
      最近更新 更多