a-b-street/abstreet · error · anyhow::Error
parking lot center didn't snap to a sidewalk
Error message
parking lot center didn't snap to a sidewalk
What it means
During parking lot import, snap_driveway looks up a precomputed sidewalk point for the parking lot's centroid in the sidewalk_pts map. If the centroid has no nearby sidewalk point entry, the snapping cannot proceed and this error is thrown. It indicates the parking lot is too far from (or unindexed against) any sidewalk for a driveway to be generated.
Solutions
- Verify the parking lot centroid is within the snap distance used to build sidewalk_pts; enlarge the search radius or snap from the lot boundary instead of the center
- Skip lots with no nearby sidewalk and keep them driveway-less instead of failing the whole import
- Ensure sidewalk data was imported for the map area (check the sidewalk layer exists and isn't empty)
- Manually adjust the lot polygon in the input data so its center is nearer a sidewalk
Example fix
// before
let sidewalk_pos = sidewalk_pts.get(¢er).ok_or_else(|| anyhow!("parking lot center didn't snap to a sidewalk"))?;
// after
let sidewalk_pos = match sidewalk_pts.get(¢er) {
Some(p) => *p,
None => {
warn!("parking lot at {:?} has no nearby sidewalk; skipping driveway", center);
return Ok(None);
}
}; Defensive patterns
Strategy: validation
Validate before calling
// before calling make_all_parking_lots
if !sidewalk_pts.contains_key(&lot_center) {
warn!("lot center {:?} has no snapped sidewalk; will be skipped", lot_center);
} Type guard
fn has_snapped_sidewalk(center: Position, sidewalk_pts: &BTreeMap<Position, SidewalkPos>) -> bool {
sidewalk_pts.contains_key(¢er)
} Try / catch
match make_all_parking_lots(...) { Err(e) if e.to_string().contains("didn't snap to a sidewalk") => warn!("skipping lot: {}", e), r => r? } Prevention
- Ensure sidewalk data is imported for every map area you process
- Snap from lot boundary points, not just the centroid
- Treat individual lot failures as warnings, not hard errors
- Log lot centers that fail snapping so input data can be corrected
When it happens
Trigger: Calling make_all_parking_lots or fix_parking_lot_driveways when a parking lot polygon's center is not a key in the provided sidewalk_pts BTreeMap — typically because the nearest-sidewalk-scan radius excluded it or the lot lies in an area with no sidewalks at all.
Common situations: Importing OSM parking lots in suburbs/industrial zones where lots front directly onto roads with no sidewalks; importing a map where sidewalk data was filtered out; very large lots whose centroid sits far from any sidewalk edge.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- ( ) is a border, but is connected to >1 road
- front path has 0 length
- snapped to sidewalk , but no driving connection
- couldn't find where shape enters map
- couldn't find where shape leaves map
AI-assisted analysis of a-b-street/abstreet@0964f29315 (2026-09-13).
Data as JSON: /api/errors/c4b733b3d5c464b9.
Report an issue: GitHub.
Appendix: source
Thrown at map_model/src/make/parking_lots.rs:143
lot
});
timer.stop("convert parking lots");
results
}
/// Returns (driveway_line, driving_pos, sidewalk_line, sidewalk_pos)
pub fn snap_driveway(
center: HashablePt2D,
polygon: &Polygon,
sidewalk_pts: &HashMap<HashablePt2D, Position>,
map: &Map,
) -> Result<(PolyLine, Position, Line, Position)> {
let driveway_buffer = Distance::meters(7.0);
let sidewalk_pos = sidewalk_pts
.get(¢er)
.ok_or_else(|| anyhow!("parking lot center didn't snap to a sidewalk"))?;
let sidewalk_line = match Line::new(center.to_pt2d(), sidewalk_pos.pt(map)) {
Ok(l) => trim_path(polygon, l),
Err(_) => {
bail!("front path has 0 length");
}
};
// Can this lot have a driveway? If it's not next to a driving lane, then no.
let mut driveway: Option<(PolyLine, Position)> = None;
let sidewalk_lane = sidewalk_pos.lane();
if let Some(driving_pos) = map
.get_parent(sidewalk_lane)
.find_closest_lane(sidewalk_lane, |l| PathConstraints::Car.can_use(l, map))
.and_then(|l| {
sidewalk_pos
.equiv_pos(l, map)
.buffer_dist(driveway_buffer, map)
})View on GitHub (pinned to 0964f29315)