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 ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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 Workers int // 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/mattes/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 NewDecoderWithInfo ¶
NewDecoderWithInfo returns a new decoder similar to NewDecoder, but will populate the Info field in the elements. Use this if you need meta data.
func (*Decoder) Parse ¶
Parse starts the parsing process that will stream data into the given OSMReader.
func (*Decoder) ProcessedBytes ¶
ProcessedBytes returns and resets processed bytes
type Element ¶
type Element struct { ID int64 Tags map[string]string // Info is only populated if you use NewDecoderWithInfo. Info *Info }
Element contains common attributes of an OSM element (node/way/relation).
type Info ¶
type Info struct { Version int Timestamp time.Time Changeset int64 UID int User string Visible bool }
Info contains the metadata of an element.
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 { Element Members []RelationMember }
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.