Skip to content

Instantly share code, notes, and snippets.

@prl900
Created July 29, 2017 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prl900/17a5278129df0d58f92df663d7bbdb63 to your computer and use it in GitHub Desktop.
Save prl900/17a5278129df0d58f92df663d7bbdb63 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/golang/geo/s2"
)
func main() {
// Definition of LatLng slice
latlngs := []s2.LatLng{s2.LatLngFromDegrees(-33.0, 143.0),
s2.LatLngFromDegrees(-33.0, 151.0),
s2.LatLngFromDegrees(-27.0, 147.0)}
// Polyline
pline := s2.PolylineFromLatLngs(latlngs)
rc := &s2.RegionCoverer{MaxLevel: 5, MaxCells: 4}
cells := rc.CellUnion(pline)
fmt.Println("Cells:", cells)
// Loop
points := []s2.Point{s2.PointFromLatLng(latlngs[0]), s2.PointFromLatLng(latlngs[1]), s2.PointFromLatLng(latlngs[2])}
loop := s2.LoopFromPoints(points)
rc = &s2.RegionCoverer{MaxLevel: 5, MaxCells: 4}
cells = rc.CellUnion(loop)
fmt.Println("Cells:", cells)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment