Beispiel #1
1
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)
}
Beispiel #2
1
func TestKeyGeneratorPolygon(t *testing.T) {
	p, err := loadPolygon("zip.json")
	require.NoError(t, err)
	data, err := wkb.Marshal(p, binary.LittleEndian)
	require.NoError(t, err)

	var g types.Geo
	err = g.UnmarshalBinary(data)
	require.NoError(t, err)
	keys, err := IndexTokens(&g)
	require.NoError(t, err)
	require.Len(t, keys, 65)
}
Beispiel #3
0
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)
}
Beispiel #4
0
func BenchmarkKeyGeneratorPoint(b *testing.B) {
	p := geom.NewPoint(geom.XY).MustSetCoords(geom.Coord{-122.082506, 37.4249518})
	data, err := wkb.Marshal(p, binary.LittleEndian)
	if err != nil {
		b.Error(err)
	}
	var g types.Geo
	g.UnmarshalBinary(data)
	b.ResetTimer()
	for n := 0; n < b.N; n++ {
		IndexTokens(&g)
	}
}
Beispiel #5
0
func TestKeyGeneratorPoint(t *testing.T) {
	p := geom.NewPoint(geom.XY).MustSetCoords(geom.Coord{-122.082506, 37.4249518})
	data, err := wkb.Marshal(p, binary.LittleEndian)
	require.NoError(t, err)

	var g types.Geo
	err = g.UnmarshalBinary(data)
	require.NoError(t, err)

	keys, err := IndexTokens(&g)
	require.NoError(t, err)
	require.Len(t, keys, MaxCellLevel-MinCellLevel+1+1) // +1 for the cover
}
Beispiel #6
0
func BenchmarkKeyGeneratorPolygon(b *testing.B) {
	p, err := loadPolygon("zip.json")
	if err != nil {
		b.Error(err)
	}
	data, err := wkb.Marshal(p, binary.LittleEndian)
	if err != nil {
		b.Error(err)
	}
	var g types.Geo
	g.UnmarshalBinary(data)
	b.ResetTimer()
	for n := 0; n < b.N; n++ {
		IndexTokens(&g)
	}
}
Beispiel #7
0
// MarshalBinary marshals to binary
func (v Geo) MarshalBinary() ([]byte, error) {
	return wkb.Marshal(v.T, binary.LittleEndian)
}