比较lat/lng和另一个lat/lng


Compare lat/lng against another lat/lng

我在数据库中存储了场馆及其经纬度。

我也有登录用户的经纬度。

我正在开发一种功能,可以让他们在任何给定的测量范围内找到场地,比如20英里。

是否有可能找到最外层的纬度和长说从用户的纬度和长20英里,然后以某种方式写一个查询,以找到在MySQL的距离圈内的场地?

谢谢。

我发现了一个有效的PHP函数:

function getDistanceBetweenPoints($latitude1, $longitude1, $latitude2, $longitude2, $unit = 'Mi') {
    $theta = $longitude1 - $longitude2;
    $distance = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta)));
    $distance = acos($distance);
    $distance = rad2deg($distance);
    $distance = $distance * 60 * 1.1515; switch($unit) {
        case 'Mi': break; case 'Km' : $distance = $distance * 1.609344;
    }
    return (round($distance,2));
}  

我想这可能对别人有帮助。

我使用这个(从javascript移植到Objective-C) -许多伟大的位置方程在javascript中表示http://www.movable-type.co.uk/scripts/latlong.html