Server IP : 80.241.246.6 / Your IP : 216.73.216.188 Web Server : Apache/2.4.25 (Debian) System : Linux kharagauli 4.9.0-19-amd64 #1 SMP Debian 4.9.320-2 (2022-06-30) x86_64 User : www-data ( 33) PHP Version : 7.0.33-0+deb9u12 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/kharagauli_new/Citizens_feedback/ |
Upload File : |
<?php // $res=isInside($border, $target); $fn='pages/poligon.data'; $border=json_decode(file_get_contents($fn),true); // $target=array('lat'=> 41.7103872, 'lng'=> 44.8167936); // tbilisi // $target=array('lat'=> 42.0196, 'lng'=> 43.1993); // kharagauli // $target=array('lat'=> 41.9663, 'lng'=> 43.4502); // near function getDistance($x1,$y1,$x2,$y2){ $x=abs($x1-$x2); $y=abs($y1-$y2); $d=$x*$x+$y*$y; $d=sqrt($d); return $d; } function isInside($border, $target){ $degree = 0; $border[]=$border[0]; for ($i=0; $i<count($border) - 1; $i++){ $a = $border[$i]; $b = $border[$i + 1]; # calculate distance of vector $A = getDistance($a['lat'], $a['lng'], $b['lat'], $b['lng']); $B = getDistance($target['lat'], $target['lng'], $a['lat'], $a['lng']); $C = getDistance($target['lat'], $target['lng'], $b['lat'], $b['lng']); //echo 'A,B,C=',$A,' ',$B,' ',$C,' = '; # calculate direction of vector $ta_x = $a['lat'] - $target['lat']; $ta_y = $a['lng'] - $target['lng']; $tb_x = $b['lat'] - $target['lat']; $tb_y = $b['lng'] - $target['lng']; $cross = $tb_y * $ta_x - $tb_x * $ta_y; $clockwise = (($cross > 0)?1:-1); # calculate sum of angles $degree = $degree + $clockwise*rad2deg(acos(($B * $B + $C * $C - $A * $A) / (2.0 * $B * $C))); //echo $degree.'<br><br>'; } if(abs(round($degree) - 360) <= 3) return 1; return 0; } // $res=isInside($border, $target); ?>