Skip to content

Commit

Permalink
Rename Uint32Size to CountSize
Browse files Browse the repository at this point in the history
  • Loading branch information
shaxbee committed Apr 21, 2016
1 parent be8ee47 commit 83c7bab
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions wkb/geometry.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (gc GeometryCollection) Value() (driver.Value, error) {
}

func ReadGeometryCollection(b []byte) ([]byte, GeometryCollection, error) {
if len(b) < HeaderSize+Uint32Size {
if len(b) < HeaderSize+CountSize {
return nil, nil, ErrInvalidStorage
}

Expand All @@ -91,7 +91,7 @@ func ReadGeometryCollection(b []byte) ([]byte, GeometryCollection, error) {
}

func (gc GeometryCollection) ByteSize() int {
size := HeaderSize + Uint32Size
size := HeaderSize + CountSize
for _, g := range gc {
size += g.ByteSize()
}
Expand Down
6 changes: 3 additions & 3 deletions wkb/linestring.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (ls LineString) Value() (driver.Value, error) {
}

func ReadLineString(b []byte) ([]byte, LineString, error) {
if len(b) < HeaderSize+Uint32Size {
if len(b) < HeaderSize+CountSize {
return nil, nil, ErrInvalidStorage
}

Expand Down Expand Up @@ -74,7 +74,7 @@ func (mls MultiLineString) Value() (driver.Value, error) {
}

func ReadMultiLineString(b []byte) ([]byte, MultiLineString, error) {
if len(b) < HeaderSize+Uint32Size {
if len(b) < HeaderSize+CountSize {
return nil, nil, ErrInvalidStorage
}

Expand All @@ -96,7 +96,7 @@ func ReadMultiLineString(b []byte) ([]byte, MultiLineString, error) {
}

func (mls MultiLineString) ByteSize() int {
size := HeaderSize + Uint32Size
size := HeaderSize + CountSize
for _, ls := range mls {
size += ls.ByteSize()
}
Expand Down
4 changes: 2 additions & 2 deletions wkb/point.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (mp MultiPoint) Value() (driver.Value, error) {
}

func ReadMultiPoint(b []byte) ([]byte, MultiPoint, error) {
if len(b) < HeaderSize+Uint32Size {
if len(b) < HeaderSize+CountSize {
return nil, nil, ErrInvalidStorage
}

Expand Down Expand Up @@ -140,7 +140,7 @@ func readPoints(b []byte, dec binary.ByteOrder) ([]byte, Points, error) {
}

func (pts Points) byteSize() int {
return Uint32Size + len(pts)*PointSize
return CountSize + len(pts)*PointSize
}

func (pts Points) write(buf *bytes.Buffer) {
Expand Down
10 changes: 5 additions & 5 deletions wkb/polygon.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (p Polygon) Value() (driver.Value, error) {
}

func ReadPolygon(b []byte) ([]byte, Polygon, error) {
if len(b) < HeaderSize+Uint32Size {
if len(b) < HeaderSize+CountSize {
return nil, nil, ErrInvalidStorage
}

Expand All @@ -41,7 +41,7 @@ func ReadPolygon(b []byte) ([]byte, Polygon, error) {

p := make([]LinearRing, n)
for i := 0; i < n; i++ {
if len(b) < Uint32Size {
if len(b) < CountSize {
return nil, nil, ErrInvalidStorage
}

Expand All @@ -55,7 +55,7 @@ func ReadPolygon(b []byte) ([]byte, Polygon, error) {
}

func (p Polygon) ByteSize() int {
size := HeaderSize + Uint32Size
size := HeaderSize + CountSize
for _, lr := range p {
size += lr.byteSize()
}
Expand Down Expand Up @@ -92,7 +92,7 @@ func (mp MultiPolygon) Value() (driver.Value, error) {
}

func ReadMultiPolygon(b []byte) ([]byte, MultiPolygon, error) {
if len(b) < HeaderSize+Uint32Size {
if len(b) < HeaderSize+CountSize {
return nil, nil, ErrInvalidStorage
}

Expand All @@ -115,7 +115,7 @@ func ReadMultiPolygon(b []byte) ([]byte, MultiPolygon, error) {
}

func (mp MultiPolygon) ByteSize() int {
size := HeaderSize + Uint32Size
size := HeaderSize + CountSize
for _, p := range mp {
size += p.ByteSize()
}
Expand Down
4 changes: 2 additions & 2 deletions wkb/primitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func readUint32(b []byte, dec binary.ByteOrder) ([]byte, uint32) {
return b[Uint32Size:], dec.Uint32(b)
return b[CountSize:], dec.Uint32(b)
}

func readCount(b []byte, dec binary.ByteOrder) ([]byte, int) {
Expand All @@ -16,7 +16,7 @@ func readCount(b []byte, dec binary.ByteOrder) ([]byte, int) {
}

func writeCount(buf *bytes.Buffer, n int) {
b := [Uint32Size]byte{}
b := [CountSize]byte{}
binary.LittleEndian.PutUint32(b[:], uint32(n))
buf.Write(b[:])
}
Expand Down
2 changes: 1 addition & 1 deletion wkb/wkb.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
ByteOrderSize = int(unsafe.Sizeof(ByteOrder(0)))
GeomTypeSize = int(unsafe.Sizeof(Kind(0)))
HeaderSize = ByteOrderSize + GeomTypeSize
Uint32Size = int(unsafe.Sizeof(uint32(0)))
CountSize = int(unsafe.Sizeof(uint32(0)))
Float64Size = int(unsafe.Sizeof(float64(0)))
PointSize = int(unsafe.Sizeof(Point{}))
)
Expand Down

0 comments on commit 83c7bab

Please sign in to comment.