public function pointInPolygon($point, $polygon){ $return = false; foreach($polygon as $k=>$p){ if(!$k) $k_prev = count($polygon)-1; else $k_prev = $k-1;if(($p[1]< $point[1] && $polygon[$k_prev][1]>=$point[1] || $polygon[$k_prev][1]< $point[1] && $p[1]>=$point[1]) && ($p[0]<=$point[0] || $polygon[$k_prev][0]<=$point[0])){ if($p[0]+($point[1]-$p[1])/($polygon[$k_prev][1]-$p[1])*($polygon[$k_prev][0]-$p[0])<$point[0]){ $return = !$return; } } } return $return; }