【问题标题】:How to use geo/s2 library to determine a LatLong lies inside a radius from another LatLong in Go?如何使用 geo/s2 库来确定 LatLong 位于 Go 中另一个 LatLong 的半径内?
【发布时间】:2019-06-30 18:59:18
【问题描述】:

我已经尝试过这段代码,找不到任何适用于 Go 的 geo/s2 示例

package main

import (
    "fmt"
    "github.com/golang/geo/s2"
)

func main(){
    rect := s2.RectFromLatLng(s2.LatLngFromDegrees(12.9279,77.6271))
    rect = rect.AddPoint(s2.LatLngFromDegrees(12.9081,77.6476))
    isThere := rect.ContainsLatLng(s2.LatLngFromDegrees(12.9177,77.6233))

    fmt.Printf("%+v", rect.Hi())
    fmt.Printf("%+v", rect.Lo())
    println(isThere)

}

【问题讨论】:

  • 我认为你需要 Cap.ContainsPoint。 github.com/golang/geo/blob/…
  • 谢谢@Not_a_Golfer,Cap.ContainsPoint 是一个
  • 也许将您的解决方案添加为答案,以便将来寻找它的人可以找到它?

标签: go geo s2


【解决方案1】:

[这不是我的回答,但是很多人连cmets都不看,可能会漏掉信息]

正如@not-a-golfer 所说的in this comment 你应该使用https://github.com/golang/geo/blob/e41ca803f92c4c1770133cfa5b4fc8249a7dbe82/s2/cap.go#L178

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多