如何使用geo / s2库确定LatLong位于Go中另一个LatLong的半径内?

时间:2019-02-06 18:20:38

标签: go geo s2

我已经尝试过此代码,找不到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)

}

1 个答案:

答案 0 :(得分:0)

[这不是我的答案,但是很多人甚至没有评论,甚至可能会错过信息]

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