How to use geo/s2 library to determine a LatLong lies inside a radius from another LatLong in Go?

968 Views Asked by At

I have tried this code , couldn't find any examples for geo/s2 for Go

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

There are 1 best solutions below

0
On

[This is not my answer, but many people don't even go through the comments and may miss the information]

As @not-a-golfer said in this comment you should use https://github.com/golang/geo/blob/e41ca803f92c4c1770133cfa5b4fc8249a7dbe82/s2/cap.go#L178