简体   繁体   English

在Android手机中计算GPS距离的最佳方法是什么?

[英]What is the best way to calculate distance from GPS in Android Phone?

I'm developing an app that capture user latitude and longitude for every 60 seconds and calculate the distance travelled by user. 我正在开发一个应用程序,每60秒捕获用户的经度和经度,并计算用户行进的距离。 Sometime my phone is at the same location for more than one hour but the GPS jumps to different location that leads to wrong distance calculation. 有时我的手机在同一个位置超过一个小时,但GPS会跳到不同的位置导致错误的距离计算。

How to reduce the gps jump and improve distance accuracy? 如何减少gps跳跃并提高距离精度?

The accuracy of GPS will not be uniform across the session. GPS的准确性在整个会话期间将不一致。 But there are means to overcome this. 但有办法克服这一点。 Even if user is not changing the location, still the latitide , longitude value will differ in successive periods. 即使用户没有改变位置,仍然是latitide,经度值在连续的时间段内会有所不同。 Check out the following way how to modify these anomaly. 请查看以下方法如何修改这些异常。

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

While creating a location request, mention the setSmallestDisplacement as well as setInterval as per your requirement as shown below 创建位置请求时,请根据您的要求提及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);
}

Check out this link for more information 有关更多信息,请查看此链接

You have to check the location accuracy if not's good enough don't use it. 你必须检查位置的准确性,如果不够好就不要使用它。

can't find the exact current location in android 在android中找不到确切的当前位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM