Node is saved as draft in My Content >> Draft
-
How to calculate distance from CLLocationCoordinate2D
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);
}
0 Comment(s)