Reputation: 709
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.
Upvotes: 1
Views: 1967
Reputation: 70983
There is a little configuration that will help you out:
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.
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.
Upvotes: 1