From 5ce6ace219c20f3319b7ef17fe5603b14ed71a65 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 25 Jan 2019 11:56:01 +0800 Subject: [PATCH] - avoid index out of range for func IsPointInPolygon --- utils/utils_geo.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/utils_geo.go b/utils/utils_geo.go index ce6e174a..3d67a6d6 100644 --- a/utils/utils_geo.go +++ b/utils/utils_geo.go @@ -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))