update to github.com/gogo/protobuf

master
Oliver Tonnhofer 2017-11-15 13:57:30 +01:00
parent 9be1e5abc3
commit 88bca58fd1
12 changed files with 6451 additions and 287 deletions

View File

@ -42,7 +42,7 @@ system-test-files:
(cd test && make files)
%.pb.go: %.proto
protoc --go_out=. $^
protoc --proto_path=$(GOPATH)/src:$(GOPATH)/src/github.com/gogo/protobuf/protobuf:. --gogofaster_out=. $^
docs:
(cd docs && make html)

View File

@ -3,7 +3,6 @@ package binary
import (
"math"
"math/rand"
"runtime"
"testing"
"github.com/omniscale/imposm3/element"
@ -49,6 +48,7 @@ func TestMarshalDeltaCoords(t *testing.T) {
}
func BenchmarkMarshalDeltaCoords(b *testing.B) {
b.ReportAllocs()
var buf []byte
for n := 0; n < b.N; n++ {
@ -57,10 +57,10 @@ func BenchmarkMarshalDeltaCoords(b *testing.B) {
nodes2, _ := UnmarshalDeltaNodes(buf, nil)
compareNodes(b, nodes, nodes2)
runtime.GC()
}
func BenchmarkUnmarshalDeltaCoords(b *testing.B) {
b.ReportAllocs()
buf := MarshalDeltaNodes(nodes, nil)
var nodes2 []element.Node
@ -69,6 +69,5 @@ func BenchmarkUnmarshalDeltaCoords(b *testing.B) {
}
compareNodes(b, nodes, nodes2)
runtime.GC()
}

File diff suppressed because it is too large Load Diff

14
cache/binary/nodes.go vendored
View File

@ -1,14 +1,12 @@
package binary
func (this *Node) wgsCoord() (lon float64, lat float64) {
lon = IntToCoord(this.GetLong())
lat = IntToCoord(this.GetLat())
func (nd *Node) wgsCoord() (lon float64, lat float64) {
lon = IntToCoord(nd.GetLong())
lat = IntToCoord(nd.GetLat())
return
}
func (this *Node) fromWgsCoord(lon float64, lat float64) {
longInt := CoordToInt(lon)
latInt := CoordToInt(lat)
this.Long = &longInt
this.Lat = &latInt
func (nd *Node) fromWgsCoord(lon float64, lat float64) {
nd.Long = CoordToInt(lon)
nd.Lat = CoordToInt(lat)
}

View File

@ -1,7 +1,6 @@
package binary
import (
"github.com/golang/protobuf/proto"
"github.com/omniscale/imposm3/element"
)
@ -15,25 +14,16 @@ func IntToCoord(coord uint32) float64 {
return float64((float64(coord) / COORD_FACTOR) - 180.0)
}
func Marshal(elem interface{}) ([]byte, error) {
switch typedElem := elem.(type) {
case element.Node:
return MarshalNode(&typedElem)
default:
panic("invalid elem to marshal")
}
}
func MarshalNode(node *element.Node) ([]byte, error) {
pbfNode := &Node{}
pbfNode.fromWgsCoord(node.Long, node.Lat)
pbfNode.Tags = tagsAsArray(node.Tags)
return proto.Marshal(pbfNode)
return pbfNode.Marshal()
}
func UnmarshalNode(data []byte) (node *element.Node, err error) {
pbfNode := &Node{}
err = proto.Unmarshal(data, pbfNode)
err = pbfNode.Unmarshal(data)
if err != nil {
return nil, err
}
@ -69,12 +59,12 @@ func MarshalWay(way *element.Way) ([]byte, error) {
deltaPack(way.Refs)
pbfWay.Refs = way.Refs
pbfWay.Tags = tagsAsArray(way.Tags)
return proto.Marshal(pbfWay)
return pbfWay.Marshal()
}
func UnmarshalWay(data []byte) (way *element.Way, err error) {
pbfWay := &Way{}
err = proto.Unmarshal(data, pbfWay)
err = pbfWay.Unmarshal(data)
if err != nil {
return nil, err
}
@ -97,12 +87,12 @@ func MarshalRelation(relation *element.Relation) ([]byte, error) {
pbfRelation.MemberRoles[i] = m.Role
}
pbfRelation.Tags = tagsAsArray(relation.Tags)
return proto.Marshal(pbfRelation)
return pbfRelation.Marshal()
}
func UnmarshalRelation(data []byte) (relation *element.Relation, err error) {
pbfRelation := &Relation{}
err = proto.Unmarshal(data, pbfRelation)
err = pbfRelation.Unmarshal(data)
if err != nil {
return nil, err
}

View File

@ -69,6 +69,35 @@ func TestMarshalWay(t *testing.T) {
}
func BenchmarkMarshalWay(b *testing.B) {
b.ReportAllocs()
way := &element.Way{}
way.Id = 12345
way.Tags = make(element.Tags)
way.Tags["name"] = "test"
way.Tags["highway"] = "trunk"
way.Refs = append(way.Refs, 1, 2, 3, 4)
for i := 0; i < b.N; i++ {
_, _ = MarshalWay(way)
}
}
func BenchmarkUnmarshalWay(b *testing.B) {
b.ReportAllocs()
way := &element.Way{}
way.Id = 12345
way.Tags = make(element.Tags)
way.Tags["name"] = "test"
way.Tags["highway"] = "trunk"
way.Refs = append(way.Refs, 1, 2, 3, 4)
data, _ := MarshalWay(way)
for i := 0; i < b.N; i++ {
_, _ = UnmarshalWay(data)
}
}
func TestMarshalRelation(t *testing.T) {
rel := &element.Relation{}
rel.Id = 12345

View File

@ -1,41 +1,50 @@
// Code generated by protoc-gen-go.
// source: parser/pbf/osmpbf/fileformat.proto
// DO NOT EDIT!
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: parser/pbf/internal/osmpbf/fileformat.proto
/*
Package osmpbf is a generated protocol buffer package.
Package osmpbf is a generated protocol buffer package.
It is generated from these files:
parser/pbf/osmpbf/fileformat.proto
It is generated from these files:
parser/pbf/internal/osmpbf/fileformat.proto
It has these top-level messages:
Blob
BlobHeader
It has these top-level messages:
Blob
BlobHeader
*/
package osmpbf
import proto "github.com/golang/protobuf/proto"
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type Blob struct {
Raw []byte `protobuf:"bytes,1,opt,name=raw" json:"raw,omitempty"`
RawSize *int32 `protobuf:"varint,2,opt,name=raw_size" json:"raw_size,omitempty"`
Raw []byte `protobuf:"bytes,1,opt,name=raw" json:"raw"`
RawSize int32 `protobuf:"varint,2,opt,name=raw_size,json=rawSize" json:"raw_size"`
// Possible compressed versions of the data.
ZlibData []byte `protobuf:"bytes,3,opt,name=zlib_data" json:"zlib_data,omitempty"`
ZlibData []byte `protobuf:"bytes,3,opt,name=zlib_data,json=zlibData" json:"zlib_data"`
// PROPOSED feature for LZMA compressed data. SUPPORT IS NOT REQUIRED.
LzmaData []byte `protobuf:"bytes,4,opt,name=lzma_data" json:"lzma_data,omitempty"`
LzmaData []byte `protobuf:"bytes,4,opt,name=lzma_data,json=lzmaData" json:"lzma_data"`
// Formerly used for bzip2 compressed data. Depreciated in 2010.
OBSOLETEBzip2Data []byte `protobuf:"bytes,5,opt,name=OBSOLETE_bzip2_data" json:"OBSOLETE_bzip2_data,omitempty"`
XXX_unrecognized []byte `json:"-"`
OBSOLETEBzip2Data []byte `protobuf:"bytes,5,opt,name=OBSOLETE_bzip2_data,json=OBSOLETEBzip2Data" json:"OBSOLETE_bzip2_data"`
}
func (m *Blob) Reset() { *m = Blob{} }
func (m *Blob) String() string { return proto.CompactTextString(m) }
func (*Blob) ProtoMessage() {}
func (m *Blob) Reset() { *m = Blob{} }
func (m *Blob) String() string { return proto.CompactTextString(m) }
func (*Blob) ProtoMessage() {}
func (*Blob) Descriptor() ([]byte, []int) { return fileDescriptorFileformat, []int{0} }
func (m *Blob) GetRaw() []byte {
if m != nil {
@ -45,8 +54,8 @@ func (m *Blob) GetRaw() []byte {
}
func (m *Blob) GetRawSize() int32 {
if m != nil && m.RawSize != nil {
return *m.RawSize
if m != nil {
return m.RawSize
}
return 0
}
@ -73,19 +82,19 @@ func (m *Blob) GetOBSOLETEBzip2Data() []byte {
}
type BlobHeader struct {
Type *string `protobuf:"bytes,1,req,name=type" json:"type,omitempty"`
Indexdata []byte `protobuf:"bytes,2,opt,name=indexdata" json:"indexdata,omitempty"`
Datasize *int32 `protobuf:"varint,3,req,name=datasize" json:"datasize,omitempty"`
XXX_unrecognized []byte `json:"-"`
Type string `protobuf:"bytes,1,req,name=type" json:"type"`
Indexdata []byte `protobuf:"bytes,2,opt,name=indexdata" json:"indexdata"`
Datasize int32 `protobuf:"varint,3,req,name=datasize" json:"datasize"`
}
func (m *BlobHeader) Reset() { *m = BlobHeader{} }
func (m *BlobHeader) String() string { return proto.CompactTextString(m) }
func (*BlobHeader) ProtoMessage() {}
func (m *BlobHeader) Reset() { *m = BlobHeader{} }
func (m *BlobHeader) String() string { return proto.CompactTextString(m) }
func (*BlobHeader) ProtoMessage() {}
func (*BlobHeader) Descriptor() ([]byte, []int) { return fileDescriptorFileformat, []int{1} }
func (m *BlobHeader) GetType() string {
if m != nil && m.Type != nil {
return *m.Type
if m != nil {
return m.Type
}
return ""
}
@ -98,11 +107,609 @@ func (m *BlobHeader) GetIndexdata() []byte {
}
func (m *BlobHeader) GetDatasize() int32 {
if m != nil && m.Datasize != nil {
return *m.Datasize
if m != nil {
return m.Datasize
}
return 0
}
func init() {
proto.RegisterType((*Blob)(nil), "osmpbf.Blob")
proto.RegisterType((*BlobHeader)(nil), "osmpbf.BlobHeader")
}
func (m *Blob) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *Blob) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Raw != nil {
dAtA[i] = 0xa
i++
i = encodeVarintFileformat(dAtA, i, uint64(len(m.Raw)))
i += copy(dAtA[i:], m.Raw)
}
dAtA[i] = 0x10
i++
i = encodeVarintFileformat(dAtA, i, uint64(m.RawSize))
if m.ZlibData != nil {
dAtA[i] = 0x1a
i++
i = encodeVarintFileformat(dAtA, i, uint64(len(m.ZlibData)))
i += copy(dAtA[i:], m.ZlibData)
}
if m.LzmaData != nil {
dAtA[i] = 0x22
i++
i = encodeVarintFileformat(dAtA, i, uint64(len(m.LzmaData)))
i += copy(dAtA[i:], m.LzmaData)
}
if m.OBSOLETEBzip2Data != nil {
dAtA[i] = 0x2a
i++
i = encodeVarintFileformat(dAtA, i, uint64(len(m.OBSOLETEBzip2Data)))
i += copy(dAtA[i:], m.OBSOLETEBzip2Data)
}
return i, nil
}
func (m *BlobHeader) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *BlobHeader) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
dAtA[i] = 0xa
i++
i = encodeVarintFileformat(dAtA, i, uint64(len(m.Type)))
i += copy(dAtA[i:], m.Type)
if m.Indexdata != nil {
dAtA[i] = 0x12
i++
i = encodeVarintFileformat(dAtA, i, uint64(len(m.Indexdata)))
i += copy(dAtA[i:], m.Indexdata)
}
dAtA[i] = 0x18
i++
i = encodeVarintFileformat(dAtA, i, uint64(m.Datasize))
return i, nil
}
func encodeVarintFileformat(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *Blob) Size() (n int) {
var l int
_ = l
if m.Raw != nil {
l = len(m.Raw)
n += 1 + l + sovFileformat(uint64(l))
}
n += 1 + sovFileformat(uint64(m.RawSize))
if m.ZlibData != nil {
l = len(m.ZlibData)
n += 1 + l + sovFileformat(uint64(l))
}
if m.LzmaData != nil {
l = len(m.LzmaData)
n += 1 + l + sovFileformat(uint64(l))
}
if m.OBSOLETEBzip2Data != nil {
l = len(m.OBSOLETEBzip2Data)
n += 1 + l + sovFileformat(uint64(l))
}
return n
}
func (m *BlobHeader) Size() (n int) {
var l int
_ = l
l = len(m.Type)
n += 1 + l + sovFileformat(uint64(l))
if m.Indexdata != nil {
l = len(m.Indexdata)
n += 1 + l + sovFileformat(uint64(l))
}
n += 1 + sovFileformat(uint64(m.Datasize))
return n
}
func sovFileformat(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozFileformat(x uint64) (n int) {
return sovFileformat(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *Blob) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowFileformat
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Blob: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Blob: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Raw", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowFileformat
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthFileformat
}
postIndex := iNdEx + byteLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Raw = append(m.Raw[:0], dAtA[iNdEx:postIndex]...)
if m.Raw == nil {
m.Raw = []byte{}
}
iNdEx = postIndex
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field RawSize", wireType)
}
m.RawSize = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowFileformat
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.RawSize |= (int32(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ZlibData", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowFileformat
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthFileformat
}
postIndex := iNdEx + byteLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ZlibData = append(m.ZlibData[:0], dAtA[iNdEx:postIndex]...)
if m.ZlibData == nil {
m.ZlibData = []byte{}
}
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field LzmaData", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowFileformat
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthFileformat
}
postIndex := iNdEx + byteLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.LzmaData = append(m.LzmaData[:0], dAtA[iNdEx:postIndex]...)
if m.LzmaData == nil {
m.LzmaData = []byte{}
}
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field OBSOLETEBzip2Data", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowFileformat
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthFileformat
}
postIndex := iNdEx + byteLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.OBSOLETEBzip2Data = append(m.OBSOLETEBzip2Data[:0], dAtA[iNdEx:postIndex]...)
if m.OBSOLETEBzip2Data == nil {
m.OBSOLETEBzip2Data = []byte{}
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipFileformat(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthFileformat
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *BlobHeader) Unmarshal(dAtA []byte) error {
var hasFields [1]uint64
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowFileformat
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: BlobHeader: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: BlobHeader: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowFileformat
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthFileformat
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Type = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
hasFields[0] |= uint64(0x00000001)
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Indexdata", wireType)
}
var byteLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowFileformat
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
byteLen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if byteLen < 0 {
return ErrInvalidLengthFileformat
}
postIndex := iNdEx + byteLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Indexdata = append(m.Indexdata[:0], dAtA[iNdEx:postIndex]...)
if m.Indexdata == nil {
m.Indexdata = []byte{}
}
iNdEx = postIndex
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Datasize", wireType)
}
m.Datasize = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowFileformat
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Datasize |= (int32(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
hasFields[0] |= uint64(0x00000002)
default:
iNdEx = preIndex
skippy, err := skipFileformat(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthFileformat
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if hasFields[0]&uint64(0x00000001) == 0 {
return proto.NewRequiredNotSetError("type")
}
if hasFields[0]&uint64(0x00000002) == 0 {
return proto.NewRequiredNotSetError("datasize")
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipFileformat(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowFileformat
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowFileformat
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowFileformat
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthFileformat
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowFileformat
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipFileformat(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthFileformat = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowFileformat = fmt.Errorf("proto: integer overflow")
)
func init() {
proto.RegisterFile("parser/pbf/internal/osmpbf/fileformat.proto", fileDescriptorFileformat)
}
var fileDescriptorFileformat = []byte{
// 294 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x8f, 0xb1, 0x6a, 0xeb, 0x30,
0x14, 0x86, 0x23, 0xdb, 0xc9, 0x4d, 0x0e, 0xb7, 0x43, 0x55, 0x28, 0x9a, 0x1c, 0x27, 0x53, 0xa0,
0x90, 0x40, 0x87, 0x3e, 0x80, 0x69, 0x20, 0x43, 0x21, 0x90, 0x74, 0x0f, 0x47, 0x8d, 0x0c, 0x02,
0xd9, 0x32, 0xb2, 0xc0, 0xb5, 0x9f, 0xa2, 0x2f, 0xd4, 0x3d, 0x63, 0x9f, 0xa0, 0x14, 0xf7, 0x45,
0x8a, 0xec, 0x34, 0xf5, 0x24, 0xf4, 0x9d, 0xef, 0x48, 0xff, 0x0f, 0x77, 0x39, 0x9a, 0x42, 0x98,
0x55, 0xce, 0x93, 0x95, 0xcc, 0xac, 0x30, 0x19, 0xaa, 0x95, 0x2e, 0x52, 0x77, 0x4f, 0xa4, 0x12,
0x89, 0x36, 0x29, 0xda, 0x65, 0x6e, 0xb4, 0xd5, 0x74, 0xd4, 0x0d, 0xe6, 0xef, 0x04, 0x82, 0x58,
0x69, 0x4e, 0x6f, 0xc1, 0x37, 0x58, 0x32, 0x12, 0x91, 0xc5, 0xff, 0x38, 0x38, 0x7d, 0x4e, 0x07,
0x3b, 0x07, 0xe8, 0x14, 0xc6, 0x06, 0xcb, 0x43, 0x21, 0x6b, 0xc1, 0xbc, 0x88, 0x2c, 0x86, 0xe7,
0xe1, 0x3f, 0x83, 0xe5, 0x5e, 0xd6, 0x82, 0xce, 0x60, 0x52, 0x2b, 0xc9, 0x0f, 0x47, 0xb4, 0xc8,
0xfc, 0xde, 0xfa, 0xd8, 0xe1, 0x47, 0xb4, 0xe8, 0x14, 0x55, 0xa7, 0xd8, 0x29, 0x41, 0x5f, 0x71,
0xb8, 0x55, 0x1e, 0xe0, 0x66, 0x1b, 0xef, 0xb7, 0x4f, 0xeb, 0xe7, 0xf5, 0x81, 0xd7, 0x32, 0xbf,
0xef, 0xe4, 0x61, 0x2b, 0x8f, 0x9c, 0xcc, 0xc8, 0xee, 0xfa, 0x57, 0x89, 0x9d, 0xe1, 0xf6, 0xe6,
0x0a, 0xc0, 0xc5, 0xdf, 0x08, 0x3c, 0x0a, 0x43, 0x19, 0x04, 0xb6, 0xca, 0x05, 0x23, 0x91, 0xb7,
0x98, 0x9c, 0xff, 0x68, 0x09, 0x9d, 0xc3, 0x44, 0x66, 0x47, 0xf1, 0xda, 0xbe, 0xea, 0xf5, 0x22,
0xfc, 0x61, 0x1a, 0xc1, 0xd8, 0x9d, 0x6d, 0x55, 0x3f, 0xf2, 0x2e, 0x55, 0x2f, 0x34, 0x9e, 0x9d,
0x9a, 0x90, 0x7c, 0x34, 0x21, 0xf9, 0x6a, 0x42, 0xf2, 0xf6, 0x1d, 0x0e, 0xe0, 0xea, 0xc5, 0xe8,
0x82, 0x57, 0x4b, 0x2e, 0x33, 0x34, 0xd5, 0xc6, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0xac, 0xea,
0xf3, 0xa9, 0x86, 0x01, 0x00, 0x00,
}

File diff suppressed because it is too large Load Diff

View File

@ -19,6 +19,7 @@ option optimize_for = LITE_RUNTIME;
option java_package = "crosby.binary";
package osmpbf;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
/* OSM Binary file format
This is the master schema file of the OSM binary file format. This
@ -114,11 +115,11 @@ message PrimitiveBlock {
// Group of OSMPrimitives. All primitives in a group must be the same type.
message PrimitiveGroup {
repeated Node nodes = 1;
repeated Node nodes = 1 [(gogoproto.nullable) = false];
optional DenseNodes dense = 2;
repeated Way ways = 3;
repeated Relation relations = 4;
repeated ChangeSet changesets = 5;
repeated Way ways = 3 [(gogoproto.nullable) = false];
repeated Relation relations = 4 [(gogoproto.nullable) = false];
repeated ChangeSet changesets = 5 [(gogoproto.nullable) = false];
}
@ -195,7 +196,7 @@ message Node {
repeated uint32 keys = 2 [packed = true]; // String IDs.
repeated uint32 vals = 3 [packed = true]; // String IDs.
optional Info info = 4; // May be omitted in omitmeta
optional Info info = 4 [(gogoproto.nullable) = false]; // May be omitted in omitmeta
required sint64 lat = 8;
required sint64 lon = 9;
@ -233,7 +234,7 @@ message Way {
repeated uint32 keys = 2 [packed = true];
repeated uint32 vals = 3 [packed = true];
optional Info info = 4;
optional Info info = 4 [(gogoproto.nullable) = false];
repeated sint64 refs = 8 [packed = true]; // DELTA coded
}
@ -250,7 +251,7 @@ message Relation {
repeated uint32 keys = 2 [packed = true];
repeated uint32 vals = 3 [packed = true];
optional Info info = 4;
optional Info info = 4 [(gogoproto.nullable) = false];
// Parallel arrays
repeated int32 roles_sid = 8 [packed = true];

View File

@ -11,7 +11,7 @@ import (
"os"
"time"
"github.com/golang/protobuf/proto"
"github.com/gogo/protobuf/proto"
"github.com/omniscale/imposm3/parser/pbf/internal/osmpbf"
)

View File

@ -93,7 +93,7 @@ func parseTags(stringtable stringTable, keys []uint32, vals []uint32) map[string
}
func readNodes(
nodes []*osmpbf.Node,
nodes []osmpbf.Node,
block *osmpbf.PrimitiveBlock,
stringtable stringTable) ([]element.Node, []element.Node) {
@ -105,9 +105,9 @@ func readNodes(
coordScale := 0.000000001
for i := range nodes {
id := *nodes[i].Id
lon := *nodes[i].Lon
lat := *nodes[i].Lat
id := nodes[i].Id
lon := nodes[i].Lon
lat := nodes[i].Lat
coords[i].Id = id
coords[i].Long = (coordScale * float64(lonOffset+(granularity*lon)))
coords[i].Lat = (coordScale * float64(latOffset+(granularity*lat)))
@ -139,14 +139,14 @@ func parseDeltaRefs(refs []int64) []int64 {
}
func readWays(
ways []*osmpbf.Way,
ways []osmpbf.Way,
block *osmpbf.PrimitiveBlock,
stringtable stringTable) []element.Way {
result := make([]element.Way, len(ways))
for i := range ways {
id := *ways[i].Id
id := ways[i].Id
result[i].Id = id
result[i].Tags = parseTags(stringtable, ways[i].Keys, ways[i].Vals)
result[i].Refs = parseDeltaRefs(ways[i].Refs)
@ -154,7 +154,7 @@ func readWays(
return result
}
func parseRelationMembers(rel *osmpbf.Relation, stringtable stringTable) []element.Member {
func parseRelationMembers(rel osmpbf.Relation, stringtable stringTable) []element.Member {
result := make([]element.Member, len(rel.Memids))
var lastId int64
@ -168,14 +168,14 @@ func parseRelationMembers(rel *osmpbf.Relation, stringtable stringTable) []eleme
}
func readRelations(
relations []*osmpbf.Relation,
relations []osmpbf.Relation,
block *osmpbf.PrimitiveBlock,
stringtable stringTable) []element.Relation {
result := make([]element.Relation, len(relations))
for i := range relations {
id := *relations[i].Id
id := relations[i].Id
result[i].Id = id
result[i].Tags = parseTags(stringtable, relations[i].Keys, relations[i].Vals)
result[i].Members = parseRelationMembers(relations[i], stringtable)

View File

@ -8,7 +8,8 @@ import (
"os"
"testing"
"github.com/golang/protobuf/proto"
"github.com/gogo/protobuf/proto"
"github.com/omniscale/imposm3/element"
"github.com/omniscale/imposm3/parser/pbf/internal/osmpbf"
)
@ -38,6 +39,44 @@ func BenchmarkHello(b *testing.B) {
}
func BenchmarkParser(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
p, err := NewParser("./monaco-20150428.osm.pbf")
if err != nil {
b.Fatal(err)
}
coords := make(chan []element.Node)
nodes := make(chan []element.Node)
ways := make(chan []element.Way)
relations := make(chan []element.Relation)
go func() {
for _ = range coords {
}
}()
go func() {
for _ = range nodes {
}
}()
go func() {
for _ = range ways {
}
}()
go func() {
for _ = range relations {
}
}()
p.Parse(coords, nodes, ways, relations)
close(coords)
close(nodes)
close(ways)
close(relations)
}
}
func BenchmarkPrimitiveBlock(b *testing.B) {
b.StopTimer()