a-b-street/abstreet · error

Giving up looking for a driving lane near

Error message

Giving up looking for a driving lane near {}, searched {} roads: {:?}

What it means

find_driving_lane_near_building does a BFS from the building's nearest road over the road graph looking for any road with a driving lane reachable without crossing non-driving lanes. If the queue empties, no driving lane was found within the searched component, so it panics with the list of visited roads.

Solutions

  1. Check the visited road list in the message and ensure at least one road has a driving lane connected to the building.
  2. Fix OSM tags near the building so a drivable way connects to it (e.g. correct highway=* on the access road).
  3. Remove or relocate the offending building if it genuinely has no road access.
  4. If modeling a transit/pedestrian map intentionally without driving lanes, avoid calling driving-lane-dependent APIs for such buildings.

Example fix

// before
let goal = map.find_driving_lane_near_building(b);
// after
let ok = map.get_b(b).accessed_by_roads(map).iter()
    .any(|r| !map.get_r(*r).lanes(map, Direction::Fwd).is_empty());
if !ok { return Err(anyhow!("building {} has no reachable driving lane", b)); }
let goal = map.find_driving_lane_near_building(b);
Defensive patterns

Strategy: fallback

Validate before calling

// ensure some connected road has a driving lane before calling
let has_driving = map.get_b(b).accessed_by_roads(map).iter()
    .any(|r| map.get_r(*r).incoming_lanes(map.get_r(*r).src_i).iter().any(|(_, lt)| lt.is_driving()));

Try / catch

// panic! is not catchable; wrap the call site in catch_unwind only as last resort
let result = std::panic::catch_unwind(|| map.find_driving_lane_near_building(b));
match result {
    Ok(pt) => pt,
    Err(_) => fallback_to_nearest_road_center(map, b),
}

Prevention

When it happens

Trigger: Calling Map::find_driving_lane_near_building (or its callers goal_pos, walking_path_to_nearest_parking_spot, Building::pos) for a building whose connected roads contain only footpaths/service roads without driving lanes.

Common situations: Importing maps with pedestrian-only zones, private driveways tagged as footways, or synthetic buildings attached to disconnected paths; also after map edits that strip driving lanes near a building.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of a-b-street/abstreet@0964f29315 (2026-09-13). Data as JSON: /api/errors/c8a3bbe2590cf96a. Report an issue: GitHub.

Appendix: source

Thrown at map_model/src/map.rs:628

            .get_parent(sidewalk)
            .find_closest_lane(sidewalk, |l| PathConstraints::Car.can_use(l, self))
        {
            if !self.get_l(l).driving_blackhole {
                return l;
            }
        }

        let mut roads_queue: VecDeque<RoadID> = VecDeque::new();
        let mut visited: HashSet<RoadID> = HashSet::new();
        {
            let start = self.building_to_road(b).id;
            roads_queue.push_back(start);
            visited.insert(start);
        }

        loop {
            if roads_queue.is_empty() {
                panic!(
                    "Giving up looking for a driving lane near {}, searched {} roads: {:?}",
                    b,
                    visited.len(),
                    visited
                );
            }
            let r = self.get_r(roads_queue.pop_front().unwrap());

            for (l, lt) in r
                .children_forwards()
                .into_iter()
                .chain(r.children_backwards().into_iter())
            {
                if lt == LaneType::Driving && !self.get_l(l).driving_blackhole {
                    return l;
                }
            }

View on GitHub (pinned to 0964f29315)