Question

I am using CLLocation.speed to get the speed of the device moving but I am getting 0 every time. I tried

speed = ([newlocation getDistanceFrom:oldlocation]/[newlocation.timeStamp timeIntervalSinceDate:oldlocation.timeStamp])

The problem is it is giving the wrong speed once in a while.

Was it helpful?

Solution

There is a little configuration that will help you out:

  1. CLLocationManager will not send you an update unless the user moves outside a circle at their current location. You can control the radius of the circle (make it smaller) so you get more refined updates. See distanceFilter.

  2. CLLocationManager has an accuracy control, that you want to set to its finest level. See desiredAccuracy.

Your best bet is simply to continually calculate this "speed" and use a weak low-pass filter to smooth out the results.

See also this question for more information: iPhone CoreLocation: How to get the most accurate speed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top