Skip to content

Commit

Permalink
sciencegenome
Browse files Browse the repository at this point in the history
last changes done and only ord and bundesland  bug changes left and prepairing for the final release.
  • Loading branch information
sciencegenome committed Feb 11, 2025
1 parent 6d46b88 commit 73eff0b
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 23 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions src/ags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,12 @@ pub fn ags_mapper(ags: &str) -> Result<String, Box<dyn Error>> {
}
}

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())
}
7 changes: 7 additions & 0 deletions src/bundesland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,12 @@ pub fn bundesland_mapper(bundesland: &str) -> Result<String, Box<dyn Error>> {
}
}

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())
}
11 changes: 9 additions & 2 deletions src/landkries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ pub fn landkries_mapper(landkries: &str) -> Result<String, Box<dyn Error>> {
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<MapperOrt> = 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(),
Expand All @@ -46,5 +46,12 @@ pub fn landkries_mapper(landkries: &str) -> Result<String, Box<dyn Error>> {
}
}

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())
}
7 changes: 7 additions & 0 deletions src/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,12 @@ pub fn ord_mapper(ord: &str) -> Result<String, Box<dyn Error>> {
}
}

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())
}
31 changes: 20 additions & 11 deletions src/osm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,22 @@ pub fn osm_mapper(osm: &str) -> Result<String, Box<dyn Error>> {
let file2read = BufReader::new(file2read);

let mut mapper_ort: Vec<MapperOrt> = Vec::new();

for i in file2read.lines() {
let line = i.expect("file not found");
let ort_mapper: Vec<_> = line.split(",").collect::<Vec<_>>();
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::<Vec<_>>();
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<MapperOrt> = Vec::new();
for i in mapper_ort.iter() {
if i.osmid == osm.to_string() {
Expand All @@ -46,5 +48,12 @@ pub fn osm_mapper(osm: &str) -> Result<String, Box<dyn Error>> {
}
}

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())
}
20 changes: 10 additions & 10 deletions src/plz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ pub fn plz_mapper(plz: &str) -> Result<String, Box<dyn Error>> {
}
}

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") {
Expand Down Expand Up @@ -74,15 +74,15 @@ pub fn plz_mapper(plz: &str) -> Result<String, Box<dyn Error>> {
})
}
}
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(),
});
}
}
Expand Down

0 comments on commit 73eff0b

Please sign in to comment.