|
|
@@ -1,9 +1,11 @@
|
|
1
|
1
|
// Count the number of nodes, ways and relations in a PBF file given as the
|
|
2
|
2
|
// first command line argument.
|
|
3
|
3
|
|
|
|
4
|
+extern crate error_chain;
|
|
4
|
5
|
extern crate osmpbf;
|
|
5
|
6
|
|
|
6
|
7
|
use osmpbf::*;
|
|
|
8
|
+use error_chain::ChainedError;
|
|
7
|
9
|
|
|
8
|
10
|
fn main() {
|
|
9
|
11
|
let arg = std::env::args_os().nth(1).expect("need a *.osm.pbf file as argument");
|
|
|
@@ -12,7 +14,7 @@ fn main() {
|
|
12
|
14
|
|
|
13
|
15
|
println!("Counting...");
|
|
14
|
16
|
|
|
15
|
|
- let result = reader.par_map_reduce(
|
|
|
17
|
+ match reader.par_map_reduce(
|
|
16
|
18
|
|element| {
|
|
17
|
19
|
match element {
|
|
18
|
20
|
Element::Node(_) | Element::DenseNode(_) => (1, 0, 0),
|
|
|
@@ -22,9 +24,14 @@ fn main() {
|
|
22
|
24
|
},
|
|
23
|
25
|
|| (0u64, 0u64, 0u64),
|
|
24
|
26
|
|a, b| (a.0 + b.0, a.1 + b.1, a.2 + b.2)
|
|
25
|
|
- ).unwrap();
|
|
26
|
|
-
|
|
27
|
|
- println!("Nodes: {}", result.0);
|
|
28
|
|
- println!("Ways: {}", result.1);
|
|
29
|
|
- println!("Relations: {}", result.2);
|
|
|
27
|
+ ) {
|
|
|
28
|
+ Ok((nodes, ways, relations)) => {
|
|
|
29
|
+ println!("Nodes: {}", nodes);
|
|
|
30
|
+ println!("Ways: {}", ways);
|
|
|
31
|
+ println!("Relations: {}", relations);
|
|
|
32
|
+ },
|
|
|
33
|
+ Err(e) => {
|
|
|
34
|
+ println!("{}", e.display_chain().to_string());
|
|
|
35
|
+ },
|
|
|
36
|
+ }
|
|
30
|
37
|
}
|