PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/src/pkg/goshp/point.go

https://code.google.com/p/go-shp/
Go | 28 lines | 21 code | 7 blank | 0 comment | 0 complexity | 13ad29528e1286c71f00efc0f48e04a7 MD5 | raw file
 1package goshp
 2
 3import (
 4	"fmt"
 5	"math"
 6	)
 7
 8
 9func (p *Point) IsValid() bool {
10	return true
11}
12
13func (p *Point) Serialize() []byte {
14	s := make([]byte, 0, 20)
15	shapeType := Int32bytes(POLYGON)
16	x := Uint64bytes(math.Float64bits(p.X))
17	y := Uint64bytes(math.Float64bits(p.Y))
18		
19	s = Append(s, shapeType)
20	s = Append(s, x)
21	s = Append(s, y)	
22		
23	return s
24}
25
26func (p *Point) String() string {
27	return fmt.Sprintf("x:%f y:%f", p.X, p.Y)
28}