Skip to content

Commit

Permalink
Fix some issues revealed by some spammy routing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Jan 5, 2024
1 parent 9f8ce0a commit 459d240
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions backend/src/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ impl Router {
if modal_filters.contains_key(&road.id) {
continue;
}
// Loops can't be part of a shortest path
if road.src_i == road.dst_i {
continue;
}

let i1 = node_map.get_or_insert(road.src_i);
let i2 = node_map.get_or_insert(road.dst_i);
Expand Down
2 changes: 1 addition & 1 deletion backend/src/scrape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn scrape_osm(input_bytes: &[u8]) -> Result<MapModel> {
node_mapping.insert(id, pt);
}
Element::Way { id, node_ids, tags } => {
if tags.contains_key("highway") {
if tags.contains_key("highway") && tags.get("area") != Some(&"yes".to_string()) {
highways.push(Way {
id,
node_ids,
Expand Down
8 changes: 6 additions & 2 deletions backend/src/shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ impl Shortcuts {
if map.modal_filters.contains_key(r) {
continue;
}

let road = map.get_r(*r);
// Loops can't be part of a shortest path
if road.src_i == road.dst_i {
continue;
}

let i1 = node_map.get_or_insert(road.src_i);
let i2 = node_map.get_or_insert(road.dst_i);
let cost = (road.length() * 100.0) as usize;
Expand Down Expand Up @@ -73,7 +77,7 @@ impl Shortcuts {
impl Path {
pub fn geometry(&self, map: &MapModel) -> LineString {
let mut pts = Vec::new();
for (r, i1, i2) in &self.steps {
for (r, i1, _i2) in &self.steps {
let road = map.get_r(*r);
if *i1 == road.src_i {
pts.extend(road.linestring.0.clone());
Expand Down

0 comments on commit 459d240

Please sign in to comment.