I've been playing around with this myself. If you have any thoughts I would be interested.
var point = s.Point{Lat: 51.4622952, Lng: -0.1994539}
rc := &s2.RegionCoverer{MaxLevel: 20, MaxCells: 10}
covering := s.S2CellIdsCoveringGivenRadius(500, point, rc)
for _, c := range covering {
queryRedis(c)
}
pipeline := redisRepo.Pipeline()
var results []*redis.StringSliceCmd
for _, c := range covering {
results = append(results, createQuery(c, pipeline))
}
cmds, err := pipeline.Exec()
if err != nil {
panic(err)
}
func createQuery(c s2.CellID, pipeline redis.Pipeliner) *redis.StringSliceCmd {
// perform a range lookup in the DB from bmin key to bmax key, cur is our DB cursor
//var cell s2.CellID
result := pipeline.ZRangeByScore("branches", redis.ZRangeBy{
Min: strconv.FormatInt(int64(c.RangeMin()), 10),
Max: strconv.FormatInt(int64(c.RangeMax()), 10),
})
if result.Err() != nil {
panic(result.Err())
}
return result
}