+(double)distanceBetweenOrderBy:(double) latitude1 :(double) longitude1 :(double) latitude2 :(double) longitude2{
double PI = 3.141592653589793;
double radlat1 = (PI * latitude1 / 180);
double radlat2 = (PI * latitude2 / 180);
double theta = (longitude1 - longitude2);
double radtheta = (PI * theta / 180);
double dist = sin(radlat1)*sin(radlat2) + cos(radlat1)*cos(radlat2)*cos(radtheta);
if (dist > 1) {
dist = 1;
}
dist = acos(dist);
dist = dist * 180 / PI;
dist = dist * 60 * 1.1515;
// km
dist = dist * 1.609344;
return dist;
}
网友评论