Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • How to calculate distance from CLLocationCoordinate2D

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

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


    #define MILE_FROM_MERTER(dist) (dist*0.00062137119)

    +(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 MILE_FROM_MERTER(distance);
    

    }

    iphone

 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: