11extern crate osm_pbf_iter;
22extern crate num_cpus;
33
4- use std:: process;
5-
64use std:: collections:: HashMap ;
75use std:: env:: args;
86use std:: fs:: File ;
9- use std:: io:: { Seek , SeekFrom , BufReader } ;
10- use std:: time:: Instant ;
7+ use std:: io:: { BufReader } ;
118use std:: sync:: mpsc:: { sync_channel, SyncSender , Receiver } ;
129use std:: thread;
1310
@@ -59,10 +56,8 @@ fn main() {
5956 } ) ;
6057 }
6158
62- println ! ( "Open {}" , arg) ;
6359 let f = File :: open ( & arg) . unwrap ( ) ;
6460 let mut reader = BlobReader :: new ( BufReader :: new ( f) ) ;
65- let start = Instant :: now ( ) ;
6661
6762 let mut w = 0 ;
6863 for blob in & mut reader {
@@ -86,132 +81,19 @@ fn main() {
8681
8782 let mut avglat = 0.0 ;
8883 let mut count = 0 ;
89- for ( key , value) in collecteddata. nodeslat . iter ( ) {
84+ for ( _key , value) in collecteddata. nodeslat . iter ( ) {
9085 count += 1 ;
9186 avglat += value;
9287 }
9388 print ! ( "avg lat: {:?}" , avglat / count as f64 ) ;
9489
9590 let mut avglon = 0.0 ;
9691 let mut count = 0 ;
97- for ( key , value) in collecteddata. nodeslon . iter ( ) {
92+ for ( _key , value) in collecteddata. nodeslon . iter ( ) {
9893 count += 1 ;
9994 avglon += value;
10095 }
10196 print ! ( "avg lon: {:?}" , avglon / count as f64 ) ;
10297
103-
104-
105- let stop = Instant :: now ( ) ;
106- let duration = stop. duration_since ( start) ;
107- let duration = duration. as_secs ( ) as f64 + ( duration. subsec_nanos ( ) as f64 / 1e9 ) ;
108- let mut f = reader. to_inner ( ) ;
109- match f. seek ( SeekFrom :: Current ( 0 ) ) {
110- Ok ( pos) => {
111- let rate = pos as f64 / 1024f64 / 1024f64 / duration;
112- println ! ( "Processed {} MB in {:.2} seconds ({:.2} MB/s)" ,
113- pos / 1024 / 1024 , duration, rate) ;
114- } ,
115- Err ( _) => ( ) ,
116- }
117-
118- // println!("{} - {} nodes, {} ways, {} relations", arg, stats[0], stats[1], stats[2]);
11998 }
12099}
121-
122-
123- // extern crate pbf_reader;
124- // use pbf_reader::*;
125-
126- // use std::collections::HashMap;
127- // use std::thread;
128- // use std::sync::mpsc;
129-
130- // #[derive(Debug)]
131- // struct MapData {
132- // nodes: HashMap<IDType, NodeF>,
133- // ways: HashMap<IDType, Way>,
134- // strings: HashMap<IDType, Strings>,
135- // }
136-
137- // fn main() {
138-
139- // let mut map_data = MapData {
140- // nodes: HashMap::with_capacity(900),
141- // ways: HashMap::with_capacity(90),
142- // strings: HashMap::with_capacity(5),
143- // };
144-
145- // let (mut node_tx, node_rx) = mpsc::channel::<PBFData>();
146-
147- // let h = thread::spawn(move || {
148- // return read_pbf(&("./ecuador-latest.osm.pbf".to_string()), 8, &mut node_tx);
149- // });
150-
151- // let mut count = 0;
152- // let mut info = Vec::<PbfInfo>::new();
153-
154- // loop {
155- // match node_rx.recv().unwrap() {
156- // PBFData::NodesSet(set) => {
157- // for (id, node) in set {
158- // count = count + 1;
159-
160- // // if max.lat < node.coord.lat || count == 1 {
161- // // max.lat = node.coord.lat
162- // // }
163- // // if max.lon < node.coord.lon || count == 1 {
164- // // max.lon = node.coord.lon
165- // // }
166- // // if min.lat > node.coord.lat || count == 1 {
167- // // min.lat = node.coord.lat
168- // // }
169- // // if min.lon > node.coord.lon || count == 1 {
170- // // min.lon = node.coord.lon
171- // // }
172- // // println!("node {:?}", node);
173- // match map_data.nodes.insert(id, node) {
174- // Some(onode) => {
175- // // println!("W node id {} exists!!!! {:?} ", id, onode);
176- // }
177- // None => {}
178- // }
179- // }
180- // }
181- // PBFData::WaysSet(set) => {
182- // for (id, way) in set {
183- // // println!("got way {:?}", way );
184- // match map_data.ways.insert(id, way) {
185- // Some(oway) => {
186- // // println!("W node id {} exists!!!! {:?} ", id, oway);
187- // }
188- // None => {}
189- // }
190- // }
191- // }
192- // PBFData::RelationsSet(_) => {}
193- // PBFData::Strings(id, strings) => match map_data.strings.insert(id, strings) {
194- // Some(ostrings) => {
195- // println!("Error: strings id {} exists!!!! {:?} ", id, ostrings);
196- // }
197- // None => {
198- // // println!("got strings {}", id);
199- // }
200- // },
201- // PBFData::PbfInfo(inf) => {
202- // // println!("BBox '{:?}'", inf);
203- // info.push(inf);
204- // }
205-
206- // PBFData::ParseEnd => {
207- // break;
208- // }
209- // }
210- // }
211-
212- // let r = h.join().unwrap();
213- // println!("DONE!!!! {:?}", r);
214- // println!("count {:?}", count);
215-
216-
217- // }
0 commit comments