{"record":{"id":"c4b733b3d5c464b9","repo":"a-b-street/abstreet","slug":"parking-lot-center-didn-t-snap-to-a-sidewalk","errorCode":null,"errorMessage":"parking lot center didn't snap to a sidewalk","messagePattern":"parking lot center didn't snap to a sidewalk","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"map_model/src/make/parking_lots.rs","lineNumber":143,"sourceCode":"\n        lot\n    });\n    timer.stop(\"convert parking lots\");\n    results\n}\n\n/// Returns (driveway_line, driving_pos, sidewalk_line, sidewalk_pos)\npub fn snap_driveway(\n    center: HashablePt2D,\n    polygon: &Polygon,\n    sidewalk_pts: &HashMap<HashablePt2D, Position>,\n    map: &Map,\n) -> Result<(PolyLine, Position, Line, Position)> {\n    let driveway_buffer = Distance::meters(7.0);\n\n    let sidewalk_pos = sidewalk_pts\n        .get(&center)\n        .ok_or_else(|| anyhow!(\"parking lot center didn't snap to a sidewalk\"))?;\n    let sidewalk_line = match Line::new(center.to_pt2d(), sidewalk_pos.pt(map)) {\n        Ok(l) => trim_path(polygon, l),\n        Err(_) => {\n            bail!(\"front path has 0 length\");\n        }\n    };\n\n    // Can this lot have a driveway? If it's not next to a driving lane, then no.\n    let mut driveway: Option<(PolyLine, Position)> = None;\n    let sidewalk_lane = sidewalk_pos.lane();\n    if let Some(driving_pos) = map\n        .get_parent(sidewalk_lane)\n        .find_closest_lane(sidewalk_lane, |l| PathConstraints::Car.can_use(l, map))\n        .and_then(|l| {\n            sidewalk_pos\n                .equiv_pos(l, map)\n                .buffer_dist(driveway_buffer, map)\n        })","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/a-b-street/abstreet/blob/0964f29315820c91b171b585eb51e300164e9197/map_model/src/make/parking_lots.rs#L125-L161","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nlet sidewalk_pos = sidewalk_pts.get(&center).ok_or_else(|| anyhow!(\"parking lot center didn't snap to a sidewalk\"))?;\n// after\nlet sidewalk_pos = match sidewalk_pts.get(&center) {\n    Some(p) => *p,\n    None => {\n        warn!(\"parking lot at {:?} has no nearby sidewalk; skipping driveway\", center);\n        return Ok(None);\n    }\n};","handlingStrategy":"validation","validationCode":"// before calling make_all_parking_lots\nif !sidewalk_pts.contains_key(&lot_center) {\n    warn!(\"lot center {:?} has no snapped sidewalk; will be skipped\", lot_center);\n}","typeGuard":"fn has_snapped_sidewalk(center: Position, sidewalk_pts: &BTreeMap<Position, SidewalkPos>) -> bool {\n    sidewalk_pts.contains_key(&center)\n}","tryCatchPattern":"match make_all_parking_lots(...) { Err(e) if e.to_string().contains(\"didn't snap to a sidewalk\") => warn!(\"skipping lot: {}\", e), r => r? }","preventionTips":["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"],"tags":["gis","map-import","geometry","snap-failure"],"backgroundTag":"resource-not-found","analyzedSha":"0964f29315820c91b171b585eb51e300164e9197","analyzedAt":"2026-09-13T18:02:03.421Z","contentChangedAt":"2026-09-13T18:02:03.421Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}