Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner provides a convenient interface reading a stream of osm data from a file or url. Successive calls to the Scan method will step through the data.
Scanning stops unrecoverably at EOF, the first I/O error, the first xml error or the context being cancelled. When a scan stops, the reader may have advanced arbitrarily far past the last token.
The Scanner API is based on bufio.Scanner https://golang.org/pkg/bufio/#Scanner
Example ¶
package main import ( "context" "fmt" "os" "github.com/TucarApp/osm" "github.com/TucarApp/osm/osmxml" ) func main() { scanner := osmxml.New(context.Background(), os.Stdin) for scanner.Scan() { fmt.Println(scanner.Object().(*osm.Changeset)) } if err := scanner.Err(); err != nil { fmt.Fprintln(os.Stderr, "reading standard input:", err) } }
Output:
func (*Scanner) Close ¶
Close causes all future calls to Scan to return false. Does not close the underlying reader.
func (*Scanner) Object ¶
Object returns the most recent token generated by a call to Scan as a new osm.Object. This interface is implemented by:
*osm.Bounds *osm.Node *osm.Way *osm.Relation *osm.Changeset *osm.Note *osm.User
func (*Scanner) Scan ¶
Scan advances the Scanner to the next element, which will then be available through the Object method. It returns false when the scan stops, either by reaching the end of the input, an io error, an xml error or the context being cancelled. After Scan returns false, the Err method will return any error that occurred during scanning, except if it was io.EOF, Err will return nil.