Struct osmpbfreader::reader::OsmPbfReader
[−]
[src]
pub struct OsmPbfReader<R> { /* fields omitted */ }
Methods
impl<R: Read> OsmPbfReader<R>
[src]
fn new(r: R) -> OsmPbfReader<R>
fn into_inner(self) -> R
fn blobs<'a>(&'a mut self) -> Blobs<'a, R>
fn primitive_blocks<'a>(&'a mut self) -> PrimitiveBlocks<'a, R>
fn iter<'a>(&'a mut self) -> Iter<'a, R>
fn par_iter<'a>(&'a mut self) -> Iter<'a, R>
fn rewind(&mut self) -> Result<()> where R: Seek
fn get_objs_and_deps<F>(&mut self, pred: F) -> Result<BTreeMap<OsmId, OsmObj>> where R: Seek, F: FnMut(&OsmObj) -> bool
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 mut pbf = osmpbfreader::OsmPbfReader::new(std::io::Cursor::new([])); let objs = pbf.get_objs_and_deps(is_admin).unwrap(); for (id, obj) in &objs { println!("{:?}: {:?}", id, obj); }