|
|
@@ -10,11 +10,11 @@ use std::path::Path;
|
|
10
|
10
|
|
|
11
|
11
|
/// A reader for PBF files that gives access to the stored elements: nodes, ways and relations.
|
|
12
|
12
|
#[derive(Clone, Debug)]
|
|
13
|
|
-pub struct ElementReader<R: Read> {
|
|
|
13
|
+pub struct ElementReader<R: Read + Send> {
|
|
14
|
14
|
blob_iter: BlobReader<R>,
|
|
15
|
15
|
}
|
|
16
|
16
|
|
|
17
|
|
-impl<R: Read> ElementReader<R> {
|
|
|
17
|
+impl<R: Read + Send> ElementReader<R> {
|
|
18
|
18
|
/// Creates a new `ElementReader`.
|
|
19
|
19
|
///
|
|
20
|
20
|
/// # Example
|
|
|
@@ -68,11 +68,9 @@ impl<R: Read> ElementReader<R> {
|
|
68
|
68
|
where
|
|
69
|
69
|
F: for<'a> FnMut(Element<'a>),
|
|
70
|
70
|
{
|
|
71
|
|
- let blobs = self.blob_iter.collect::<Result<Vec<_>>>()?;
|
|
72
|
|
-
|
|
73
|
71
|
//TODO do something useful with header blocks
|
|
74
|
|
- for blob in &blobs {
|
|
75
|
|
- match blob.decode() {
|
|
|
72
|
+ for blob in self.blob_iter {
|
|
|
73
|
+ match blob?.decode() {
|
|
76
|
74
|
Ok(BlobDecode::OsmHeader(_)) | Ok(BlobDecode::Unknown(_)) => {}
|
|
77
|
75
|
Ok(BlobDecode::OsmData(block)) => {
|
|
78
|
76
|
block.for_each_element(&mut f);
|
|
|
@@ -125,11 +123,9 @@ impl<R: Read> ElementReader<R> {
|
|
125
|
123
|
ID: Fn() -> T + Sync + Send,
|
|
126
|
124
|
T: Send,
|
|
127
|
125
|
{
|
|
128
|
|
- let blobs = self.blob_iter.collect::<Result<Vec<_>>>()?;
|
|
129
|
|
-
|
|
130
|
|
- blobs
|
|
131
|
|
- .into_par_iter()
|
|
132
|
|
- .map(|blob| match blob.decode() {
|
|
|
126
|
+ self.blob_iter
|
|
|
127
|
+ .par_bridge()
|
|
|
128
|
+ .map(|blob| match blob?.decode() {
|
|
133
|
129
|
Ok(BlobDecode::OsmHeader(_)) | Ok(BlobDecode::Unknown(_)) => Ok(identity()),
|
|
134
|
130
|
Ok(BlobDecode::OsmData(block)) => Ok(block
|
|
135
|
131
|
.elements()
|