我创建了一个函数来查看lat / lon是否在多边形内。我得到了这些注意:未定义的变量:xx.xx但是它传递了一个lat / lons数组,它的值是undefined而不是数组。我很困惑,请帮忙。该行是第二个/最后一个if语句
public function checkCoordinates($lat, $lon, $polylat, $polylon) {
$j = count($polylat)-1;//number of sides and -1 because its an array
$result = true;
for($i=0;$i<count($polylat);$i++){
if($polylat[$i]<$lat && $polylat[$j]>=$lat
|| $polylat[$j]<$lat && $polylat[$i]>=$lat){ //if the latitude at the beggining is bigger than and at the end is smaller than or vise versa
if($polylon[$i]+($lat-$polylat[$i])/($$polylat[$j]-$polylat[$i])*($polylon[$j]-$polylon[$i])<$lon){ //
$result = false;
}
}
$j=$i;
}
return $result;
}
答案 0 :(得分:0)
我没有注意到额外的$,这解释了它