Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function check_GeoLocation($gps_user,$gps_spot,$r){
- if($r==0){
- return 1;
- }
- if(count($gps_user)>1){
- $gps_user[0]=$gps_user[0]*pi()/180;
- $gps_user[1]=$gps_user[1]*pi()/180;
- $gps_spot[0]=$gps_spot[0]*pi()/180;
- $gps_spot[1]=$gps_spot[1]*pi()/180;
- $dlat=$gps_user[0]-$gps_spot[0];
- $dlon=$gps_user[1]-$gps_spot[1];
- $a = pow((sin($dlat/2)),2) + cos($gps_user[0]) * cos($gps_spot[0]) * pow((sin($dlon/2)),2);
- $c = 2 * atan2( sqrt($a), sqrt(1-$a) );
- $d = 6373 * $c;
- if($d<=$r){
- return 1;
- }else{
- return 0;
- }
- }else{
- return 0;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement