本文整理匯總了Golang中github.com/dgraph-io/dgraph/types.Geo.MarshalText方法的典型用法代碼示例。如果您正苦於以下問題:Golang Geo.MarshalText方法的具體用法?Golang Geo.MarshalText怎麽用?Golang Geo.MarshalText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/dgraph-io/dgraph/types.Geo
的用法示例。
在下文中一共展示了Geo.MarshalText方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: formDataPolygon
func formDataPolygon(t *testing.T, p *geom.Polygon) string {
d, err := wkb.Marshal(p, binary.LittleEndian)
require.NoError(t, err)
var g types.Geo
require.NoError(t, g.UnmarshalBinary(d))
gb, err := g.MarshalText()
require.NoError(t, err)
return string(gb)
}
示例2: formData
func formData(t *testing.T, str string) string {
p, err := loadPolygon(str)
require.NoError(t, err)
d, err := wkb.Marshal(p, binary.LittleEndian)
require.NoError(t, err)
var g types.Geo
require.NoError(t, g.UnmarshalBinary(d))
gb, err := g.MarshalText()
require.NoError(t, err)
return string(gb)
}
示例3: TestSchema
func TestSchema(t *testing.T) {
dir, dir2, _ := populateGraph(t)
defer os.RemoveAll(dir)
defer os.RemoveAll(dir2)
query := `
{
debug(_uid_:0x1) {
_xid_
name
gender
alive
loc
friend {
name
}
friend {
}
}
}
`
gq, _, err := gql.Parse(query)
require.NoError(t, err)
ctx := context.Background()
sg, err := ToSubGraph(ctx, gq)
require.NoError(t, err)
ch := make(chan error)
go ProcessGraph(ctx, sg, nil, ch)
err = <-ch
require.NoError(t, err)
var l Latency
gr, err := sg.ToProtocolBuffer(&l)
require.NoError(t, err)
require.EqualValues(t, "debug", gr.Children[0].Attribute)
require.EqualValues(t, 1, gr.Children[0].Uid)
require.EqualValues(t, "mich", gr.Children[0].Xid)
require.Len(t, gr.Children[0].Properties, 4)
require.EqualValues(t, "Michonne",
getProperty(gr.Children[0].Properties, "name").GetStrVal())
var g types.Geo
x.Check(g.UnmarshalBinary(getProperty(gr.Children[0].Properties, "loc").GetGeoVal()))
received, err := g.MarshalText()
require.EqualValues(t, "{'type':'Point','coordinates':[1.1,2]}", string(received))
require.Len(t, gr.Children[0].Children, 5)
child := gr.Children[0].Children[0]
require.EqualValues(t, 23, child.Uid)
require.EqualValues(t, "friend", child.Attribute)
require.Len(t, child.Properties, 1)
require.EqualValues(t, "Rick Grimes",
getProperty(child.Properties, "name").GetStrVal())
require.Empty(t, child.Children)
child = gr.Children[0].Children[1]
require.EqualValues(t, 24, child.Uid)
require.EqualValues(t, "friend", child.Attribute)
require.Len(t, child.Properties, 1)
require.EqualValues(t, "Glenn Rhee",
getProperty(child.Properties, "name").GetStrVal())
require.Empty(t, child.Children)
child = gr.Children[0].Children[4]
require.EqualValues(t, 101, child.Uid)
require.EqualValues(t, "friend", child.Attribute)
require.Len(t, child.Properties, 0)
}