fn fix_building_driveways(map: &mut Map, input: Vec<BuildingID>, effects: &mut EditEffects) {
    // TODO Copying from make/buildings.rs
    let mut center_per_bldg: BTreeMap<BuildingID, HashablePt2D> = BTreeMap::new();
    let mut query: HashSet<HashablePt2D> = HashSet::new();
    for id in input {
        let center = map.get_b(id).polygon.center().to_hashable();
        center_per_bldg.insert(id, center);
        query.insert(center);
    }

    let sidewalk_buffer = Distance::meters(7.5);
    let mut sidewalk_pts = match_points_to_lanes(
        map.get_bounds(),
        query,
        map.all_lanes(),
        |l| l.is_walkable(),
        // Don't put connections too close to intersections
        sidewalk_buffer,
        // Try not to skip any buildings, but more than 1km from a sidewalk is a little much
        Distance::meters(1000.0),
        &mut Timer::throwaway(),
    );

    for (id, bldg_center) in center_per_bldg {
        match sidewalk_pts.remove(&bldg_center).and_then(|pos| {
            Line::new(bldg_center.to_pt2d(), pos.pt(map))
                .map(|l| (pos, trim_path(&map.get_b(id).polygon, l)))
        }) {
            Some((sidewalk_pos, driveway_geom)) => {
                let b = &mut map.buildings[id.0];
                b.sidewalk_pos = sidewalk_pos;
                b.driveway_geom = driveway_geom.to_polyline();
                // We may need to redraw the road that now has this building snapped to it
                effects
                    .changed_roads
                    .insert(map.get_l(sidewalk_pos.lane()).parent);
            }
            None => {
                // TODO Not sure what to do here yet.
                error!("{} isn't snapped to a sidewalk now!", id);
            }
        }
    }
}
/// Recalculate the driveways of some buildings after map edits.
Recalculate the driveways of some buildings after map edits.
Recalculate the driveways of some buildings after map edits .
fn fix_building_driveways(map: &mut Map, input: Vec<BuildingID>, effects: &mut EditEffects) {
    // TODO Copying from make/buildings.rs
    let mut center_per_bldg: BTreeMap<BuildingID, HashablePt2D> = BTreeMap::new();
    let mut query: HashSet<HashablePt2D> = HashSet::new();
    for id in input {
        let center = map.get_b(id).polygon.center().to_hashable();
        center_per_bldg.insert(id, center);
        query.insert(center);
    }
    let sidewalk_buffer = Distance::meters(7.5);
    let mut sidewalk_pts = match_points_to_lanes(
        map.get_bounds(),
        query,
        map.all_lanes(),
        |l| l.is_walkable(),
        // Don't put connections too close to intersections
        sidewalk_buffer,
        // Try not to skip any buildings, but more than 1km from a sidewalk is a little much
        Distance::meters(1000.0),
        &mut Timer::throwaway(),
    );
    for (id, bldg_center) in center_per_bldg {
        match sidewalk_pts.remove(&bldg_center).and_then(|pos| {
            Line::new(bldg_center.to_pt2d(), pos.pt(map))
                .map(|l| (pos, trim_path(&map.get_b(id).polygon, l)))
        }) {
            Some((sidewalk_pos, driveway_geom)) => {
                let b = &mut map.buildings[id.0];
                b.sidewalk_pos = sidewalk_pos;
                b.driveway_geom = driveway_geom.to_polyline();
                // We may need to redraw the road that now has this building snapped to it
                effects
                    .changed_roads
                    .insert(map.get_l(sidewalk_pos.lane()).parent);
            }
            None => {
                // TODO Not sure what to do here yet.
                error!("{} isn't snapped to a sidewalk now!", id);
            }
        }
    }
}
fn fix_building_driveways ( map : & mut Map , input : Vec < BuildingID > , effects : & mut EditEffects ) { // TODO Copying from make/buildings.rs let mut center_per_bldg : BTreeMap < BuildingID , HashablePt2D > = BTreeMap :: new ( ) ; let mut query : HashSet < HashablePt2D > = HashSet :: new ( ) ; for id in input { let center = map . get_b ( id ) . polygon . center ( ) . to_hashable ( ) ; center_per_bldg . insert ( id , center ) ; query . insert ( center ) ; } let sidewalk_buffer = Distance :: meters ( 7.5 ) ; let mut sidewalk_pts = match_points_to_lanes ( map . get_bounds ( ) , query , map . all_lanes ( ) , | l | l . is_walkable ( ) , // Don't put connections too close to intersections sidewalk_buffer , // Try not to skip any buildings, but more than 1km from a sidewalk is a little much Distance :: meters ( 1000.0 ) , & mut Timer :: throwaway ( ) , ) ; for ( id , bldg_center ) in center_per_bldg { match sidewalk_pts . remove ( & bldg_center ) . and_then ( | pos | { Line :: new ( bldg_center . to_pt2d ( ) , pos . pt ( map ) ) . map ( | l | ( pos , trim_path ( & map . get_b ( id ) . polygon , l ) ) ) } ) { Some ( ( sidewalk_pos , driveway_geom ) ) => { let b = & mut map . buildings [ id . 0 ] ; b . sidewalk_pos = sidewalk_pos ; b . driveway_geom = driveway_geom . to_polyline ( ) ; // We may need to redraw the road that now has this building snapped to it effects . changed_roads . insert ( map . get_l ( sidewalk_pos . lane ( ) ) . parent ) ; } None => { // TODO Not sure what to do here yet. error ! ( " " id ) ; } } } }
Recalculate the driveways of some buildings after map edits.
Recalculate the driveways of some buildings after map edits .
map
&mut Map
input
Vec<BuildingID>
effects
&mut EditEffects