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

使用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.

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

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法