Documentation
¶
Overview ¶
Package gosmparse is a library for parsing OpenStreetMap binary PBF files.
It has been designed for very fast, flexible, streamed parsing of small and large files.
Index ¶
- func FeatureEnabled(flag string) bool
- type BlobIndex
- func (i *BlobIndex) BlobOffsets(memtype string, id int64) ([]int64, error)
- func (i *BlobIndex) FirstOffsetOfType(memtype string) (int64, error)
- func (i *BlobIndex) ReadFrom(tap io.Reader) (int64, error)
- func (i *BlobIndex) ReadFromFile(path string)
- func (i *BlobIndex) SetBreakpoints()
- func (i *BlobIndex) WriteTo(sink io.Writer) (int64, error)
- func (i *BlobIndex) WriteToFile(path string)
- type BlobInfo
- type Decoder
- type GroupInfo
- type MemberType
- type Node
- type OSMReader
- type Relation
- type RelationMember
- type Way
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FeatureEnabled ¶
FeatureEnabled - return true if feature is enabled, else false
Types ¶
type BlobIndex ¶
BlobIndex - an index of all blocks in the file
func (*BlobIndex) BlobOffsets ¶
BlobOffsets - find the start offset of blob(s) containing desired element
func (*BlobIndex) FirstOffsetOfType ¶
FirstOffsetOfType - find the first offset of blob of desired type
func (*BlobIndex) ReadFromFile ¶
ReadFromFile - read from disk
func (*BlobIndex) SetBreakpoints ¶
func (i *BlobIndex) SetBreakpoints()
SetBreakpoints - set the breakpoints for node/way/relation boundaries
func (*BlobIndex) WriteToFile ¶
WriteToFile - write to disk
type Decoder ¶
type Decoder struct { // QueueSize allows to tune the memory usage vs. parse speed. // A larger QueueSize will consume more memory, but may speed up the parsing process. QueueSize int Mutex *sync.Mutex BytesRead uint64 Index *BlobIndex Triggers []func(int, uint64) // contains filtered or unexported fields }
A Decoder reads and decodes OSM data from an input stream.
func NewDecoder ¶
NewDecoder returns a new decoder that reads from r.
Example ¶
package main import ( "os" "github.com/missinglink/gosmparse" ) // Implement the gosmparser.OSMReader interface here. // Streaming data will call those functions. type dataHandler struct{} func (d *dataHandler) ReadNode(n gosmparse.Node) {} func (d *dataHandler) ReadWay(w gosmparse.Way) {} func (d *dataHandler) ReadRelation(r gosmparse.Relation) {} func main() { r, err := os.Open("filename.pbf") if err != nil { panic(err) } dec := gosmparse.NewDecoder(r) // Parse will block until it is done or an error occurs. err = dec.Parse(&dataHandler{}) if err != nil { panic(err) } }
Output:
func (*Decoder) AutoSaveIndex ¶
func (d *Decoder) AutoSaveIndex()
AutoSaveIndex - automatically save index file if feature is enabled
func (*Decoder) AutoloadIndex ¶
func (d *Decoder) AutoloadIndex()
AutoloadIndex - automatically load index file if one if available
func (*Decoder) Parse ¶
Parse starts the parsing process that will stream data into the given OSMReader.
func (*Decoder) SeekToOffset ¶
SeekToOffset move read pointer to byte offset
type MemberType ¶
type MemberType int
MemberType describes the type of a relation member (node/way/relation).
const ( NodeType MemberType = iota WayType RelationType )
type OSMReader ¶
OSMReader is the interface that needs to be implemented in order to receive Elements from the parsing process.
type Relation ¶
type Relation struct { ID int64 Members []RelationMember Tags map[string]string }
Relation is an OSM data element that contains multiple elements (RelationMember) and has tags (key/value pairs).
type RelationMember ¶
type RelationMember struct { ID int64 Type MemberType Role string }
RelationMember refers to an element in a relation. It contains the ID of the element (node/way/relation) and the role.