dsjpqpdm620596 2018-02-08 12:15
浏览 237
已采纳

使用golang / geo / s2查找给定区域中是否存在latlng

I am trying to find if a given LatLng exists in a Desired area. I am using github.com/golang/geo/s2.

rect := s2.RectFromLatLng(s2.LatLng{0.0, 0.0})
rect = rect.AddPoint(s2.LatLng{2.0, 2.0})
isThere := rect.ContainsLatLng(s2.LatLng{1.0, 1.0})
fmt.Printf("%+v", rect.Hi())
fmt.Printf("%+v", rect.Lo())
println(isThere)

I'm expecting it to return true but it gives false. Also, rect.Hi() and rect.Lo() are same.

Could someone help me understand it better, what I am doing wrong?

Thanks

  • 写回答

1条回答 默认 最新

  • dsgdfh302506 2018-02-08 12:31
    关注

    s2.LatLng creates a point based on radian and not in degree, you should try using s2.LatLngFromDegrees() API.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?