Closed glesage closed 11 years ago
This is an improvement:
double latitudeDistance = lat - currentLoc.latitude;
double longitudeDistance = lon - currentLoc.longitude;
return (sqrt(pow(latitudeDistance,2) + pow(longitudeDistance*1.3, 2))) * 5;
The "1.3" is how much a degree of lon is 1.3 times less than a lat where I am (here in Chicago)
I might have to implement a lat/lon difference calculator depending on the user's location...
Actually CLLocation has a "distanceFromLocation" callback.. will look into that
http://stackoverflow.com/questions/5198996/cllocation-distancefromlocation
Fixed:
CLLocationCoordinate2D object_loc_coord = CLLocationCoordinate2DMake(lat, lon);
CLLocation *object_location = [[CLLocation alloc] initWithLatitude:object_loc_coord.latitude longitude:object_loc_coord.longitude];
CLLocation *user_location = [[CLLocation alloc] initWithLatitude:user_loc_coord.latitude longitude:user_loc_coord.longitude];
return [object_location distanceFromLocation:user_location];
Distance calculations for each arobject is incorrect. For one thing, the formulae:
Is location dependent and invalid.