Skip to content

Commit

Permalink
improve code with clippy hints
Browse files Browse the repository at this point in the history
  • Loading branch information
jperelli committed Aug 26, 2024
1 parent 92317f6 commit ee6d44a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,10 +661,7 @@ impl Parser {
.unwrap();

// returns relations_ways + areas_ways
relations_ways
.into_iter()
.chain(areas_ways.into_iter())
.collect()
relations_ways.into_iter().chain(areas_ways).collect()
}

/// Builds the Relation from the provided osm_id `id`
Expand Down
6 changes: 3 additions & 3 deletions src/parser/relation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use serde_json::json;
use std::collections::HashMap;
use std::f64::INFINITY;
use std::fmt;

use super::parse_status::ParseStatus;
Expand Down Expand Up @@ -154,13 +153,14 @@ fn first_pass(ways: &Vec<Vec<Node>>) -> Result<Vec<Vec<Node>>, ()> {
/// Also joins the way if extreme points are the same
/// - This is not "expected" by osm. We are trying to fix the way now
/// - Nevertheless I think this is also done by ST_LineMerge()
///
/// TODO: this can probably be made with some std function like vec.sort(|nodesa, nodesb| edgedistance(nodesa, nodesb))
fn sort_ways(ways: &Vec<Vec<Node>>) -> Result<Vec<Vec<Node>>, ()> {
let mut ws = ways.to_owned();
let mut sorted_ways = vec![ws[0].clone()];
ws = ws[1..].to_vec();
while !ws.is_empty() {
let mut mindist = INFINITY;
let mut mindist = f64::INFINITY;
let mut minidx = 0usize;
for (i, _) in ws.iter().enumerate() {
let w = ws[i].clone();
Expand Down Expand Up @@ -202,7 +202,7 @@ fn dist_haversine(p1: &Node, p2: &Node) -> f64 {
/// - I'm not sure if this conserves the direction from first to last
fn join_ways(ways: &Vec<Vec<Node>>, tolerance: f64) -> Result<Vec<Vec<Node>>, ()> {
let mut joined = vec![ways[0].clone()];
for w in ways[1..].to_vec() {
for w in ways[1..].iter().cloned() {
let joined_len = joined.len();
let joinedlast = joined[joined_len - 1].clone();
if dist_haversine(&joinedlast[joinedlast.len() - 1], &w[0]) < tolerance {
Expand Down

0 comments on commit ee6d44a

Please sign in to comment.