func (r *BlockReader) ReadBlock() (n int, block Block, err error) {
	for {
		nn, rblock, err := r.rr.ReadBlock()
		if err != nil {
			return 0, Block{}, err
		}
		n += nn
		if rblock.Type != "OSMData" {
			continue
		}
		data, err := inflate(rblock.Data)
		if err != nil {
			return 0, Block{}, err
		}
		block, err := procBlock(Everything, data)
		if err != nil {
			return 0, Block{}, err
		}
		return n, block, nil
	}
}
ReadBlock reads the next OSMData block.
Returns the number of bytes read and the block.
package osmfile
import (
	"bytes"
	"compress/zlib"
	"encoding/binary"
	"errors"
	"io"
	"io/ioutil"
	"github.com/tidwall/osmfile/internal/pbf"
)
type rawBlockReader struct {
	r   io.Reader
	err error
	pos int64
}
func newRawBlockReader(r io.Reader) *rawBlockReader {
	return &rawBlockReader{r: r}
}
type rawBlock struct {
	Type string
	Data []byte
}
func (r *rawBlockReader) ReadBlock() (n int, block rawBlock, err error) {
	if r.err != nil {
		return 0, rawBlock{}, r.err
	}
	bpos := r.pos
	var buf [4]byte
	if _, err := io.ReadFull(r.r, buf[:]); err != nil {
		r.err = err
		return 0, rawBlock{}, r.err
	}
	r.pos += 4
	hdrLen := binary.BigEndian.Uint32(buf[:])
	hdr := make([]byte, hdrLen)
	if _, err := io.ReadFull(r.r, hdr); err != nil {
		r.err = err
		return 0, rawBlock{}, r.err
	}
	r.pos += int64(hdrLen)
	var btype string
	var bsize int
	err = pbf.ForEachField(hdr, func(f pbf.Field) error {
		switch f.Num() {
		case 1:
			btype = string(f.Data())
		case 3:
			bsize = int(f.Uint64())
		}
		return nil
	})
	if err != nil {
		r.err = err
		return 0, rawBlock{}, err
	}
	bdata := make([]byte, bsize)
	if _, err := io.ReadFull(r.r, bdata); err != nil {
		r.err = err
		return 0, rawBlock{}, r.err
	}
	r.pos += int64(bsize)
	return int(r.pos - bpos), rawBlock{Type: btype, Data: bdata}, nil
}
type BlockReader struct {
	rr *rawBlockReader
}
func NewBlockReader(r io.Reader) *BlockReader {
	return &BlockReader{rr: newRawBlockReader(r)}
}