From 73eff0b3dc14be87098250dc81989fa0e144060d Mon Sep 17 00:00:00 2001 From: Gaurav Sablok Date: Tue, 11 Feb 2025 23:26:01 +0100 Subject: [PATCH] sciencegenome last changes done and only ord and bundesland bug changes left and prepairing for the final release. --- README.md | 13 +++++++++++++ src/ags.rs | 7 +++++++ src/bundesland.rs | 7 +++++++ src/landkries.rs | 11 +++++++++-- src/ord.rs | 7 +++++++ src/osm.rs | 31 ++++++++++++++++++++----------- src/plz.rs | 20 ++++++++++---------- 7 files changed, 73 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 87480f3..46af1bd 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,19 @@ 21:51:40 gauravsablok@genome deutsch-geo-env-mapper main ? ./target/debug/deutsch-geo-env-mapper einwohner 11957 01067 01067 Dresden 11957 6.866839 51.06019 13.71117 + 23:23:53 gauravsablok@genome deutsch-geo-env-mapper main ? + ./target/debug/deutsch-geo-env-mapper osm 1104550 130 ↵ + 78267 1104550 08335001 Aach Landkreis-Konstanz Baden-Württemberg + The results are: "The searched results are as follows" + 23:23:58 gauravsablok@genome deutsch-geo-env-mapper main ? + ./target/debug/deutsch-geo-env-mapper ags 08335001 + 78267 1104550 08335001 -A-a-c-h- Landkreis-Konstanz Baden-Württemberg + The results are: "The searched results are as follows" + 23:24:02 gauravsablok@genome deutsch-geo-env-mapper main ? + ./target/debug/deutsch-geo-env-mapper plz 78267 + 78267 78267 Aach 2179 10.648148 47.84445 8.85725 + 78267 1104550 08335001 Aach Landkreis-Konstanz Baden-Württemberg + The results are: "The searched results are as follows" ``` Gaurav Sablok diff --git a/src/ags.rs b/src/ags.rs index 0e7538a..a151b99 100755 --- a/src/ags.rs +++ b/src/ags.rs @@ -46,5 +46,12 @@ pub fn ags_mapper(ags: &str) -> Result> { } } + for i in searched_plz2.iter() { + println!( + "{}\t{}\t{}\t{}\t{}\t{}", + i.plz, i.osmid, i.ags, i.ord, i.landries, i.bundesland + ); + } + Ok("The searched results are as follows".to_string()) } diff --git a/src/bundesland.rs b/src/bundesland.rs index ea5dcc3..cf5c974 100755 --- a/src/bundesland.rs +++ b/src/bundesland.rs @@ -46,5 +46,12 @@ pub fn bundesland_mapper(bundesland: &str) -> Result> { } } + for i in searched_plz2.iter() { + println!( + "{}\t{}\t{}\t{}\t{}\t{}", + i.plz, i.osmid, i.ags, i.ord, i.landries, i.bundesland + ); + } + Ok("The searched results are as follows".to_string()) } diff --git a/src/landkries.rs b/src/landkries.rs index 497c0f8..f2b12f0 100755 --- a/src/landkries.rs +++ b/src/landkries.rs @@ -28,13 +28,13 @@ pub fn landkries_mapper(landkries: &str) -> Result> { ord: ort_mapper[2].replace(" ", "-").to_string(), plz: ort_mapper[3].to_string(), landries: ort_mapper[4].replace(" ", "-").to_string(), - bundesland: ort_mapper[6].replace(" ", "-").to_string(), + bundesland: ort_mapper[5].replace(" ", "-").to_string(), }) } let mut searched_plz2: Vec = Vec::new(); for i in mapper_ort.iter() { - if i.landries == landkries.to_string().replace(" ", "-").to_string() { + if i.landries == landkries.to_string() { searched_plz2.push(MapperOrt { plz: i.plz.clone(), osmid: i.osmid.clone(), @@ -46,5 +46,12 @@ pub fn landkries_mapper(landkries: &str) -> Result> { } } + for i in searched_plz2.iter() { + println!( + "{}\t{}\t{}\t{}\t{}\t{}", + i.plz, i.osmid, i.ags, i.ord, i.landries, i.bundesland + ); + } + Ok("The searched results are as follows".to_string()) } diff --git a/src/ord.rs b/src/ord.rs index b08179d..e6d99c8 100755 --- a/src/ord.rs +++ b/src/ord.rs @@ -46,5 +46,12 @@ pub fn ord_mapper(ord: &str) -> Result> { } } + for i in searched_plz2.iter() { + println!( + "{}\t{}\t{}\t{}\t{}\t{}", + i.plz, i.osmid, i.ags, i.ord, i.landries, i.bundesland + ); + } + Ok("The searched results are as follows".to_string()) } diff --git a/src/osm.rs b/src/osm.rs index b408f1c..46a77c1 100755 --- a/src/osm.rs +++ b/src/osm.rs @@ -18,20 +18,22 @@ pub fn osm_mapper(osm: &str) -> Result> { let file2read = BufReader::new(file2read); let mut mapper_ort: Vec = Vec::new(); - for i in file2read.lines() { let line = i.expect("file not found"); - let ort_mapper: Vec<_> = line.split(",").collect::>(); - mapper_ort.push(MapperOrt { - osmid: ort_mapper[0].to_string(), - ags: ort_mapper[1].to_string(), - ord: ort_mapper[2].replace(" ", "-").to_string(), - plz: ort_mapper[3].to_string(), - landries: ort_mapper[4].replace(" ", "-").to_string(), - bundesland: ort_mapper[5].replace(" ", "-").to_string(), - }) + if line.starts_with("osm_id") { + continue; + } else if !line.starts_with("osm_id") { + let ort_mapper: Vec<_> = line.split(",").collect::>(); + mapper_ort.push(MapperOrt { + osmid: ort_mapper[0].to_string(), + ags: ort_mapper[1].to_string(), + ord: ort_mapper[2].replace(" ", "-").to_string(), + plz: ort_mapper[3].to_string(), + landries: ort_mapper[4].replace(" ", "-").to_string(), + bundesland: ort_mapper[5].replace(" ", "-").to_string(), + }); + } } - let mut searched_plz2: Vec = Vec::new(); for i in mapper_ort.iter() { if i.osmid == osm.to_string() { @@ -46,5 +48,12 @@ pub fn osm_mapper(osm: &str) -> Result> { } } + for i in searched_plz2.iter() { + println!( + "{}\t{}\t{}\t{}\t{}\t{}", + i.plz, i.osmid, i.ags, i.ord, i.landries, i.bundesland + ); + } + Ok("The searched results are as follows".to_string()) } diff --git a/src/plz.rs b/src/plz.rs index d3193e0..8273125 100755 --- a/src/plz.rs +++ b/src/plz.rs @@ -43,8 +43,8 @@ pub fn plz_mapper(plz: &str) -> Result> { } } - for i in file2read.lines() { - let line = i.expect("file not found"); + for j in file2read.lines() { + let line = j.expect("file not found"); if line.starts_with("osm") { continue; } else if !line.starts_with("osm") { @@ -74,15 +74,15 @@ pub fn plz_mapper(plz: &str) -> Result> { }) } } - for i in mapper_ort.iter() { - if i.plz == plz.to_string() { + for j in mapper_ort.iter() { + if j.plz == plz.to_string() { searched_plz2.push(MapperOrt { - plz: i.plz.clone(), - osmid: i.osmid.clone(), - ags: i.ags.clone(), - ord: i.ord.clone(), - landries: i.landries.clone(), - bundesland: i.bundesland.clone(), + plz: j.plz.clone(), + osmid: j.osmid.clone(), + ags: j.ags.clone(), + ord: j.ord.clone(), + landries: j.landries.clone(), + bundesland: j.bundesland.clone(), }); } }