本文整理匯總了Golang中github.com/dgraph-io/dgraph/types.Geo.Stride方法的典型用法代碼示例。如果您正苦於以下問題:Golang Geo.Stride方法的具體用法?Golang Geo.Stride怎麽用?Golang Geo.Stride使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/dgraph-io/dgraph/types.Geo
的用法示例。
在下文中一共展示了Geo.Stride方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: indexCells
// 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)
}
}