GPS coordinates in degrees to calculate distances

Why don’t you use CLLocations distanceFromLocation: method? It will tell you the precise distance between the receiver and another CLLocation.

CLLocation *locationA = [[CLLocation alloc] initWithLatitude:12.123456 longitude:12.123456];
CLLocation *locationB = [[CLLocation alloc] initWithLatitude:21.654321 longitude:21.654321];

CLLocationDistance distanceInMeters = [locationA distanceFromLocation:locationB];

// CLLocation is aka double

[locationA release];
[locationB release];

It’s as easy as that.

Leave a Comment