Exemple #1
0
func ExampleChangesetScanner() {
	scanner := osmxml.New(context.Background(), os.Stdin)
	for scanner.Scan() {
		fmt.Println(scanner.Element().Changeset) // Println will add back the final '\n'
	}

	if err := scanner.Err(); err != nil {
		fmt.Fprintln(os.Stderr, "reading standard input:", err)
	}
}
Exemple #2
0
func readBz2(filename string) *osm.OSM {
	log.Printf("Reading bz2 file %v", filename)
	f, err := os.Open(filename)
	if err != nil {
		panic(err)
	}
	defer f.Close()

	r := bzip2.NewReader(f)
	scanner := osmxml.New(context.Background(), r)
	return scanner2osm(scanner)
}
Exemple #3
0
// Changesets returns the complete list of changesets in for the given replication sequence.
func (ds *Datasource) Changesets(ctx context.Context, n ChangesetSeqNum) (osm.Changesets, error) {
	r, err := ds.changesetReader(ctx, n)
	if err != nil {
		return nil, err
	}
	defer r.Close()

	gzReader, err := gzip.NewReader(r)
	if err != nil {
		return nil, err
	}
	defer gzReader.Close()

	var changesets []*osm.Changeset
	scanner := osmxml.New(ctx, gzReader)
	for scanner.Scan() {
		e := scanner.Element()
		changesets = append(changesets, e.Changeset)
	}

	return changesets, scanner.Err()
}