Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. function check_GeoLocation($gps_user,$gps_spot,$r){
  2.  
  3. if($r==0){
  4.  
  5. return 1;
  6.  
  7. }
  8.  
  9. if(count($gps_user)>1){
  10.  
  11. $gps_user[0]=$gps_user[0]*pi()/180;
  12.  
  13. $gps_user[1]=$gps_user[1]*pi()/180;
  14.  
  15. $gps_spot[0]=$gps_spot[0]*pi()/180;
  16.  
  17. $gps_spot[1]=$gps_spot[1]*pi()/180;
  18.  
  19.  
  20.  
  21. $dlat=$gps_user[0]-$gps_spot[0];
  22.  
  23. $dlon=$gps_user[1]-$gps_spot[1];
  24.  
  25. $a = pow((sin($dlat/2)),2) + cos($gps_user[0]) * cos($gps_spot[0]) * pow((sin($dlon/2)),2);
  26.  
  27. $c = 2 * atan2( sqrt($a), sqrt(1-$a) );
  28.  
  29. $d = 6373 * $c;
  30.  
  31.  
  32.  
  33.  
  34. if($d<=$r){
  35.  
  36. return 1;
  37.  
  38. }else{
  39.  
  40. return 0;
  41.  
  42. }
  43.  
  44. }else{
  45.  
  46. return 0;
  47.  
  48. }
  49.  
  50. }
  51.  
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement