- avoid index out of range for func IsPointInPolygon

This commit is contained in:
gazebo
2019-01-25 11:56:01 +08:00
parent c48782569f
commit 5ce6ace219

View File

@@ -2,6 +2,9 @@ package utils
// http://ju.outofmemory.cn/entry/130555
func IsPointInPolygon(x float64, y float64, points [][2]float64) bool {
if len(points) == 0 {
return false
}
count := 0
x1, y1 := points[0][0], points[0][1]
x1Part := (y1 > y) || ((x1-x > 0) && (y1 == y))