Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to calculate distance from CLLocationCoordinate2D

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 978
    Comment on it

    Using the following code we can calculate the distance between two CLLocationCoordinate2D.

    +(double)calculateDistance:(CLLocationCoordinate2D) f to: (CLLocationCoordinate2D) t
    {
    
        //    CLLocation *locA = [[CLLocation alloc] initWithLatitude:f.latitude longitude:f.longitude];
        CLLocation *locA = [[CLLocation alloc] initWithCoordinate: f altitude:1 horizontalAccuracy:1 verticalAccuracy:-1 timestamp:nil];
    
        //    CLLocation *locB = [[CLLocation alloc] initWithLatitude:t.longitude longitude:t.longitude];
        CLLocation *locB = [[CLLocation alloc] initWithCoordinate: t altitude:1 horizontalAccuracy:1 verticalAccuracy:-1 timestamp:nil];
    
        CLLocationDistance distance = [locA distanceFromLocation:locB];
    
        return dist*0.00062137119;
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: