Struct osmpbfreader::reader::OsmPbfReader [] [src]

pub struct OsmPbfReader<R> { /* fields omitted */ }

Methods

impl<R: Read> OsmPbfReader<R>
[src]

This function give you the ability to find all the objects validating a predicate and all there dependencies.

Examples

If you want to extract all the administrative boundaries and all there dependencies you can do something like that:

fn is_admin(obj: &osmpbfreader::OsmObj) -> bool {
    // get relations with tags[boundary] == administrative
    obj.relation()
        .and_then(|rel| rel.tags.get("boundary"))
        .map_or(false, |v| v == "administrative")
}

let path = std::path::Path::new("/dev/null");
let r = std::fs::File::open(&path).unwrap();
let mut pbf = osmpbfreader::OsmPbfReader::new(r);
let objs = pbf.get_objs_and_deps(is_admin).unwrap();
for (id, obj) in &objs {
    println!("{:?}: {:?}", id, obj);
}