1 package rigeo 2 3 import ( 4 "github.com/dsoprea/go-logging" 5 "github.com/golang/geo/s2" 6 ) 7 8 // S2CellFromCoordinates returns an `S2` cell for the given real-world 9 // coordinates. 10 func S2CellFromCoordinates(latitude, longitude float64) s2.CellID { 11 ll := s2.LatLngFromDegrees(latitude, longitude) 12 cellId := s2.CellIDFromLatLng(ll) 13 14 if cellId.IsValid() == false { 15 log.Panicf("S2TokenFromCoordinates: final cell-ID not valid: (%.6f,%.6f) -> (%d)", latitude, longitude, uint64(cellId)) 16 } 17 18 return cellId 19 } 20