使用CLLocationManager计算的距离始终为更多

时间:2016-09-25 21:44:21

标签: ios swift

我已经在App Store上测试了大部分大距离计算应用程序,并且所有这些应用程序都存在计算里程与汽车里程表不匹配的相同问题。

这是我的代码,如果不正确的话。有没有办法获得100%准确的距离?

       if lastLocation != nil
         {
           if locations.last?.horizontalAccuracy <= 10 && locations.last?.speed > 0 && locations.last?.horizontalAccuracy > 0
             {    
                 let currentLocation = locations.last! as CLLocation;                       

                    if currentLocation != lastLocation
                    {
                        traveledDistance = currentLocation.distance(from: lastLocation)
                    }
             }
          }
       else
         {
         if  locations.last?.horizontalAccuracy <= 10
           {
             lastLocation = locations.last! as CLLocation
           }
         }

0 个答案:

没有答案