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
...
}
}
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With