如何根据一点经纬度和给定半径找到基于无线电的位置。假设,我给出了 30 作为半径,而不是在 30 半径内找到特定给定纬度和经度的结果。我试过下面的代码:
$lat = '37.421998'; // latitude of centre of bounding circle in degrees
$lon = '-122.084000'; // longitude of centre of bounding circle in degrees
$rad = 30; // radius of bounding circle in kilometers
$R = 6371; // earth's mean radius, km
// first-cut bounding box (in degrees)
$maxLat = $lat + rad2deg($rad/$R);
$minLat = $lat - rad2deg($rad/$R);
$maxLon = $lon + rad2deg(asin($rad/$R) / cos(deg2rad($lat)));
$minLon = $lon - rad2deg(asin($rad/$R) / cos(deg2rad($lat)));
$results = DB::select('Select …Run Code Online (Sandbox Code Playgroud)