// IndexCells returns two cellunions. The first is a list of parents, which are all the cells upto // the min level that contain this geometry. The second is the cover, which are the smallest // possible cells required to cover the region. This makes it easier at query time to query only the // parents or only the cover or both depending on whether it is a within, contains or intersects // query. func indexCells(g types.Geo) (parents, cover s2.CellUnion, err error) { if g.Stride() != 2 { return nil, nil, x.Errorf("Covering only available for 2D co-ordinates.") } switch v := g.T.(type) { case *geom.Point: p, c := indexCellsForPoint(v, MinCellLevel, MaxCellLevel) return p, c, nil case *geom.Polygon: l, err := loopFromPolygon(v) if err != nil { return nil, nil, err } cover := coverLoop(l, MinCellLevel, MaxCellLevel, MaxCells) parents := getParentCells(cover, MinCellLevel) return parents, cover, nil default: return nil, nil, x.Errorf("Cannot index geometry of type %T", v) } }