- avoid index out of range for func IsPointInPolygon
This commit is contained in:
@@ -2,6 +2,9 @@ package utils
|
|||||||
|
|
||||||
// http://ju.outofmemory.cn/entry/130555
|
// http://ju.outofmemory.cn/entry/130555
|
||||||
func IsPointInPolygon(x float64, y float64, points [][2]float64) bool {
|
func IsPointInPolygon(x float64, y float64, points [][2]float64) bool {
|
||||||
|
if len(points) == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
count := 0
|
count := 0
|
||||||
x1, y1 := points[0][0], points[0][1]
|
x1, y1 := points[0][0], points[0][1]
|
||||||
x1Part := (y1 > y) || ((x1-x > 0) && (y1 == y))
|
x1Part := (y1 > y) || ((x1-x > 0) && (y1 == y))
|
||||||
|
|||||||
Reference in New Issue
Block a user