|
|
@@ -17,17 +17,17 @@ pub struct ElementReader<R: Read> {
|
|
17
|
17
|
|
|
18
|
18
|
impl<R: Read> ElementReader<R> {
|
|
19
|
19
|
/// Creates a new `ElementReader`.
|
|
20
|
|
- ///
|
|
|
20
|
+ ///
|
|
21
|
21
|
/// # Example
|
|
22
|
22
|
/// ```
|
|
23
|
23
|
/// use osmpbf::*;
|
|
24
|
|
- ///
|
|
|
24
|
+ ///
|
|
25
|
25
|
/// # fn foo() -> Result<()> {
|
|
26
|
26
|
/// let f = std::fs::File::open("tests/test.osm.pbf")?;
|
|
27
|
27
|
/// let buf_reader = std::io::BufReader::new(f);
|
|
28
|
|
- ///
|
|
|
28
|
+ ///
|
|
29
|
29
|
/// let reader = ElementReader::new(buf_reader);
|
|
30
|
|
- ///
|
|
|
30
|
+ ///
|
|
31
|
31
|
/// # Ok(())
|
|
32
|
32
|
/// # }
|
|
33
|
33
|
/// ```
|
|
|
@@ -39,14 +39,14 @@ impl<R: Read> ElementReader<R> {
|
|
39
|
39
|
|
|
40
|
40
|
/// Decodes the PBF structure sequentially and calls the given closure on each element.
|
|
41
|
41
|
/// Consider using `par_map_reduce` instead if you need better performance.
|
|
42
|
|
- ///
|
|
|
42
|
+ ///
|
|
43
|
43
|
/// # Errors
|
|
44
|
44
|
/// Returns the first Error encountered while parsing the PBF structure.
|
|
45
|
|
- ///
|
|
|
45
|
+ ///
|
|
46
|
46
|
/// # Example
|
|
47
|
47
|
/// ```
|
|
48
|
48
|
/// use osmpbf::*;
|
|
49
|
|
- ///
|
|
|
49
|
+ ///
|
|
50
|
50
|
/// # fn foo() -> Result<()> {
|
|
51
|
51
|
/// let reader = ElementReader::from_path("tests/test.osm.pbf")?;
|
|
52
|
52
|
/// let mut ways = 0_u64;
|
|
|
@@ -57,9 +57,9 @@ impl<R: Read> ElementReader<R> {
|
|
57
|
57
|
/// ways += 1;
|
|
58
|
58
|
/// }
|
|
59
|
59
|
/// })?;
|
|
60
|
|
- ///
|
|
|
60
|
+ ///
|
|
61
|
61
|
/// println!("Number of ways: {}", ways);
|
|
62
|
|
- ///
|
|
|
62
|
+ ///
|
|
63
|
63
|
/// # Ok(())
|
|
64
|
64
|
/// # }
|
|
65
|
65
|
/// ```
|
|
|
@@ -101,14 +101,14 @@ impl<R: Read> ElementReader<R> {
|
|
101
|
101
|
/// `identity` closure should produce an identity value that is inserted into `reduce_op` when
|
|
102
|
102
|
/// necessary. The number of times that this identity value is inserted should not alter the
|
|
103
|
103
|
/// result.
|
|
104
|
|
- ///
|
|
|
104
|
+ ///
|
|
105
|
105
|
/// # Errors
|
|
106
|
106
|
/// Returns the first Error encountered while parsing the PBF structure.
|
|
107
|
|
- ///
|
|
|
107
|
+ ///
|
|
108
|
108
|
/// # Example
|
|
109
|
109
|
/// ```
|
|
110
|
110
|
/// use osmpbf::*;
|
|
111
|
|
- ///
|
|
|
111
|
+ ///
|
|
112
|
112
|
/// # fn foo() -> Result<()> {
|
|
113
|
113
|
/// let reader = ElementReader::from_path("tests/test.osm.pbf")?;
|
|
114
|
114
|
///
|
|
|
@@ -123,7 +123,7 @@ impl<R: Read> ElementReader<R> {
|
|
123
|
123
|
/// || 0_u64, // Zero is the identity value for addition
|
|
124
|
124
|
/// |a, b| a + b // Sum the partial results
|
|
125
|
125
|
/// )?;
|
|
126
|
|
- ///
|
|
|
126
|
+ ///
|
|
127
|
127
|
/// println!("Number of ways: {}", ways);
|
|
128
|
128
|
/// # Ok(())
|
|
129
|
129
|
/// # }
|
|
|
@@ -154,7 +154,7 @@ impl<R: Read> ElementReader<R> {
|
|
154
|
154
|
let rels = block.groups()
|
|
155
|
155
|
.flat_map(|g| g.relations())
|
|
156
|
156
|
.map(|r| map_op(Element::Relation(r)));
|
|
157
|
|
-
|
|
|
157
|
+
|
|
158
|
158
|
Ok(dnodes.chain(nodes)
|
|
159
|
159
|
.chain(ways)
|
|
160
|
160
|
.chain(rels)
|
|
|
@@ -173,14 +173,14 @@ impl<R: Read> ElementReader<R> {
|
|
173
|
173
|
|
|
174
|
174
|
impl ElementReader<BufReader<File>> {
|
|
175
|
175
|
/// Tries to open the file at the given path and constructs an `ElementReader` from this.
|
|
176
|
|
- ///
|
|
|
176
|
+ ///
|
|
177
|
177
|
/// # Errors
|
|
178
|
178
|
/// Returns the same errors that `std::fs::File::open` returns.
|
|
179
|
|
- ///
|
|
|
179
|
+ ///
|
|
180
|
180
|
/// # Example
|
|
181
|
181
|
/// ```
|
|
182
|
182
|
/// use osmpbf::*;
|
|
183
|
|
- ///
|
|
|
183
|
+ ///
|
|
184
|
184
|
/// # fn foo() -> Result<()> {
|
|
185
|
185
|
/// let reader = ElementReader::from_path("tests/test.osm.pbf")?;
|
|
186
|
186
|
/// # Ok(())
|