[−][src]Struct osmpbf::reader::ElementReader
A reader for PBF files that gives access to the stored elements: nodes, ways and relations.
Implementations
impl<R: Read + Send> ElementReader<R>
[src]
pub fn new(reader: R) -> ElementReader<R>
[src]
Creates a new ElementReader
.
Example
use osmpbf::*; let f = std::fs::File::open("tests/test.osm.pbf")?; let buf_reader = std::io::BufReader::new(f); let reader = ElementReader::new(buf_reader);
pub fn for_each<F>(self, mut f: F) -> Result<()> where
F: for<'a> FnMut(Element<'a>),
[src]
F: for<'a> FnMut(Element<'a>),
Decodes the PBF structure sequentially and calls the given closure on each element.
Consider using par_map_reduce
instead if you need better performance.
Errors
Returns the first Error encountered while parsing the PBF structure.
Example
use osmpbf::*; let reader = ElementReader::from_path("tests/test.osm.pbf")?; let mut ways = 0_u64; // Increment the counter by one for each way. reader.for_each(|element| { if let Element::Way(_) = element { ways += 1; } })?; println!("Number of ways: {}", ways);
pub fn par_map_reduce<MP, RD, ID, T>(
self,
map_op: MP,
identity: ID,
reduce_op: RD
) -> Result<T> where
MP: for<'a> Fn(Element<'a>) -> T + Sync + Send,
RD: Fn(T, T) -> T + Sync + Send,
ID: Fn() -> T + Sync + Send,
T: Send,
[src]
self,
map_op: MP,
identity: ID,
reduce_op: RD
) -> Result<T> where
MP: for<'a> Fn(Element<'a>) -> T + Sync + Send,
RD: Fn(T, T) -> T + Sync + Send,
ID: Fn() -> T + Sync + Send,
T: Send,
Parallel map/reduce. Decodes the PBF structure in parallel, calls the closure map_op
on
each element and then reduces the number of results to one item with the closure
reduce_op
. Similarly to the init
argument in the fold
method on iterators, the
identity
closure should produce an identity value that is inserted into reduce_op
when
necessary. The number of times that this identity value is inserted should not alter the
result.
Errors
Returns the first Error encountered while parsing the PBF structure.
Example
use osmpbf::*; let reader = ElementReader::from_path("tests/test.osm.pbf")?; // Count the ways let ways = reader.par_map_reduce( |element| { match element { Element::Way(_) => 1, _ => 0, } }, || 0_u64, // Zero is the identity value for addition |a, b| a + b // Sum the partial results )?; println!("Number of ways: {}", ways);
impl ElementReader<BufReader<File>>
[src]
Trait Implementations
impl<R: Clone + Read + Send> Clone for ElementReader<R>
[src]
pub fn clone(&self) -> ElementReader<R>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<R: Debug + Read + Send> Debug for ElementReader<R>
[src]
Auto Trait Implementations
impl<R> RefUnwindSafe for ElementReader<R> where
R: RefUnwindSafe,
[src]
R: RefUnwindSafe,
impl<R> Send for ElementReader<R>
[src]
impl<R> Sync for ElementReader<R> where
R: Sync,
[src]
R: Sync,
impl<R> Unpin for ElementReader<R> where
R: Unpin,
[src]
R: Unpin,
impl<R> UnwindSafe for ElementReader<R> where
R: UnwindSafe,
[src]
R: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,