Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kCLLocationAccuracyBestForNavigation vs kCLLocationAccuracyBest

I am building a speedometer app that shows the current speed a user is traveling. I would like to display the most accurate speed possible and therefore I am trying to figure out if I should use kCLLocationAccuracyBestForNavigation or kCLLocationAccuracyBest.

According to Apple's documentation, kCLLocationAccuracyBestForNavigation uses the highest possible accuracy and combine it with additional sensor data while kCLLocationAccuracyBest uses the highest level of accuracy but has no mention of sensor data. Does anyone know what this additional sensor data is and if it is used for calculating a more accurate speed?

I'm getting the speed from a CLLocation object.

  func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
    for location in locations {
      let speed = location.speed
      ...
    }
  }
like image 285
chickenparm Avatar asked Aug 23 '17 16:08

chickenparm


2 Answers

kCLLocationAccuracyBestForNavigation uses accelerometer, gyro, wifi and cell towers.

As you are aiming to get best precision of speed I suggest you to use this constant.

Remember that this is also the most battery consuming.

Your callback seems correct to what you're expecting.

like image 85
GIJOW Avatar answered Nov 02 '22 07:11

GIJOW


I have a suspicion!

My GPS tracker is using kCLLocationAccuracyBestForNavigation (with CLActivityTypeOther). To me it seems like kCLLocationAccuracyBestForNavigation would cause the location manager to also look up map data. When I ride my bike, the location manager sometimes reports locations that match the road beside me. But I am a not riding on that road...

Next I'll try kCLLocationAccuracyBest and see, whether or not this constant stops that rubbish.

like image 31
Anticro Avatar answered Nov 02 '22 08:11

Anticro