I've made an application calculating distance when walking / running for iPhone.
I've compared my application to other running application, and no one gives the same distance.
Nike GPS : 2.1 Km
Runtastic : 2.5 Km
My App : 2.9 Km
Here the routing to calculate distance :
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
float distInMeter = [newLocation distanceFromLocation:oldLocation]; // which returns in meters
}
and I concatenate distInMeters to another variable.
Why is there a such difference between those applications ? Is there another way to calculate the distance more precisely ?
Thanks for your help.
Such difference can happen because of the way the location manager delivers user positions. Let's say you are walking in a certain direction and the GPS gives you a position totally off from that direction, but the next one is right on track again. If you take into account the one that was off, you are accounting for more distance than the user actually traveled. So you should filter out that one.
Same thing goes if the GPS gives you another position that is farther away than it should be. Let's say the user is jogging at 4 mph, so it would be impossible that the user suddenly started running at 100 mph, so you should filter out that one too.
Basically, you should filter out the ones that are very unlikely to happen, and that way you will get a more precise distance.