Wednesday, 30 May 2012
Get 4 position bound a position
Get 4 position bound a position
/**
* @author phuc.duong
* @todo G
*/
public function getFourPosition($long, $lat, $distance) {
$earthRadius = 6371;
//latitude in radians
$lat = ($lat * pi()) / 180;
//longitude in radians
$lon = ($long * pi()) / 180;
//angular distance covered on earth's surface
$d = floatval($distance) / $earthRadius;
$arrTemp = array();
$bearing = array(0, 90, 180, 270);
foreach ($bearing as $key => $value) {
$bearing = $value * pi() / 180; //rad
$arrTemp[$key]['Lat'] = asin(sin($lat) * cos($d) + cos($lat) * sin($d) * cos($bearing));
$arrTemp[$key]['Long'] = (($lon + atan2(sin($bearing) * sin($d) * cos($lat), cos($d) - sin($lat) * sin($arrTemp[$key]['Lat']))) * 180) / pi();
$arrTemp[$key]['Lat'] = ($arrTemp[$key]['Lat'] * 180) / pi();
}
return $arrTemp;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment