import_osm: fixes to multipolygons
This commit is contained in:
parent
2958855a2b
commit
5ed6a336df
|
@ -96,10 +96,7 @@ fn process_osm<F: FnOnce(PrimSource) -> R + 'static + Send + Clone, R: Send + 's
|
||||||
match f.seek(SeekFrom::Current(0)) {
|
match f.seek(SeekFrom::Current(0)) {
|
||||||
Ok(pos) => {
|
Ok(pos) => {
|
||||||
let rate = pos as f64 / 1024f64 / 1024f64 / duration;
|
let rate = pos as f64 / 1024f64 / 1024f64 / duration;
|
||||||
progress.set_message(format!(
|
progress.set_message(format!("{:.2} MB/s", rate));
|
||||||
"Processed {} MB in {:.2} seconds ({:.2} MB/s)",
|
|
||||||
pos / 1024 / 1024, duration, rate
|
|
||||||
));
|
|
||||||
},
|
},
|
||||||
Err(_) => (),
|
Err(_) => (),
|
||||||
}
|
}
|
||||||
|
@ -200,17 +197,20 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
println!("{} ways", way_paths.len());
|
||||||
let way_paths = Arc::new(way_paths);
|
let way_paths = Arc::new(way_paths);
|
||||||
|
|
||||||
// phase 3: rels
|
// phase 3: rels
|
||||||
|
let mut multipoly_count = 0;
|
||||||
for arg in args().skip(1) {
|
for arg in args().skip(1) {
|
||||||
let way_paths = way_paths.clone();
|
let way_paths = way_paths.clone();
|
||||||
process_osm(&arg, move |prim_src| {
|
multipoly_count += process_osm(&arg, move |prim_src| {
|
||||||
const DB_URL: &str = "host=10.233.1.2 dbname=treeadvisor user=treeadvisor password=123";
|
const DB_URL: &str = "host=10.233.1.2 dbname=treeadvisor user=treeadvisor password=123";
|
||||||
|
|
||||||
let mut db = postgres::Client::connect(DB_URL, postgres::NoTls)
|
let mut db = postgres::Client::connect(DB_URL, postgres::NoTls)
|
||||||
.expect("DB");
|
.expect("DB");
|
||||||
|
|
||||||
|
let mut count = 0;
|
||||||
let mut running = true;
|
let mut running = true;
|
||||||
while running {
|
while running {
|
||||||
running = prim_src.recv_primitives(|iter| {
|
running = prim_src.recv_primitives(|iter| {
|
||||||
|
@ -223,6 +223,10 @@ fn main() {
|
||||||
let tags: serde_json::Map<String, serde_json::Value> = rel.tags()
|
let tags: serde_json::Map<String, serde_json::Value> = rel.tags()
|
||||||
.map(|(k, v)| (k.to_string(), serde_json::Value::String(v.to_string())))
|
.map(|(k, v)| (k.to_string(), serde_json::Value::String(v.to_string())))
|
||||||
.collect();
|
.collect();
|
||||||
|
if tags.get("type").and_then(|val| val.as_str()) == Some("multipolygon") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let get_members = |target_role| rel.members()
|
let get_members = |target_role| rel.members()
|
||||||
.filter_map(|(role, id, member_type)| {
|
.filter_map(|(role, id, member_type)| {
|
||||||
if member_type == RelationMemberType::Way && role == target_role {
|
if member_type == RelationMemberType::Way && role == target_role {
|
||||||
|
@ -260,6 +264,8 @@ fn main() {
|
||||||
&[&(rel.id as i64), &(member_id as i64), &path]
|
&[&(rel.id as i64), &(member_id as i64), &path]
|
||||||
).unwrap();
|
).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,6 +275,9 @@ fn main() {
|
||||||
true
|
true
|
||||||
}).unwrap_or(false);
|
}).unwrap_or(false);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
count
|
||||||
|
}).iter().sum::<usize>();
|
||||||
}
|
}
|
||||||
|
println!("{} multipolygons", multipoly_count);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue