fn recalculate_intersection_polygon(
    map: &mut Map,
    changed_road: RoadID,
    changed_road_width: Distance,
    i: IntersectionID,
) -> Vec<RoadID> {
    use crate::make::initial;

    let intersection = map.get_i(i);

    let mut intersection_roads = BTreeSet::new();
    let mut roads = BTreeMap::new();
    let mut modify_roads = Vec::new();
    for r in &intersection.roads {
        let r = map.get_r(*r);
        modify_roads.push((r.orig_id, r.id));
        intersection_roads.insert(r.orig_id);
        let half_width = if r.id == changed_road {
            changed_road_width / 2.0
        } else {
            r.get_half_width(map)
        };

        let mut trimmed_center_pts = r.center_pts.clone();
        // intersection_polygon assumes the end of the center points extends all of the way into
        // the intersection itself. So untrim in the direction we're about to modify. If for some
        // reason this fails, the size of the intersection might unrealisticalluy grow.
        if r.src_i == i {
            if let Some(pl) = r
                .untrimmed_center_pts
                .safe_get_slice_ending_at(trimmed_center_pts.first_pt())
                .and_then(|pl| pl.extend(trimmed_center_pts.clone()).ok())
            {
                trimmed_center_pts = pl;
            }
        } else if let Some(pl) = r
            .untrimmed_center_pts
            .safe_get_slice_starting_at(trimmed_center_pts.last_pt())
            .and_then(|pl| trimmed_center_pts.clone().extend(pl).ok())
        {
            trimmed_center_pts = pl;
        }

        roads.insert(
            r.orig_id,
            initial::Road {
                id: r.orig_id,
                src_i: r.orig_id.i1,
                dst_i: r.orig_id.i2,
                trimmed_center_pts,
                half_width,
                // Unused
                lane_specs_ltr: Vec::new(),
                osm_tags: r.osm_tags.clone(),
            },
        );
    }

    let polygon = initial::intersection_polygon(
        intersection.orig_id,
        intersection_roads,
        &mut roads,
        // For consolidated intersections, it appears we don't need to pass in
        // trim_roads_for_merging. May revisit this later if needed.
        &BTreeMap::new(),
    )
    .unwrap()
    .0;

    map.intersections[i.0].polygon = polygon;
    // Copy over the re-trimmed road centers
    let mut affected = Vec::new();
    for (orig_id, id) in modify_roads {
        map.roads[id.0].center_pts = roads.remove(&orig_id).unwrap().trimmed_center_pts;
        if id != changed_road {
            affected.push(id);
        }
    }
    affected
}
// Returns the other roads affected by this change, not counting changed_road.
Returns the other roads affected by this change, not counting changed_road.
Returns the other roads affected by this change not counting changed_road .
fn recalculate_intersection_polygon(
    map: &mut Map,
    changed_road: RoadID,
    changed_road_width: Distance,
    i: IntersectionID,
) -> Vec<RoadID> {
    use crate::make::initial;
    let intersection = map.get_i(i);
    let mut intersection_roads = BTreeSet::new();
    let mut roads = BTreeMap::new();
    let mut modify_roads = Vec::new();
    for r in &intersection.roads {
        let r = map.get_r(*r);
        modify_roads.push((r.orig_id, r.id));
        intersection_roads.insert(r.orig_id);
        let half_width = if r.id == changed_road {
            changed_road_width / 2.0
        } else {
            r.get_half_width(map)
        };
        let mut trimmed_center_pts = r.center_pts.clone();
        // intersection_polygon assumes the end of the center points extends all of the way into
        // the intersection itself. So untrim in the direction we're about to modify. If for some
        // reason this fails, the size of the intersection might unrealisticalluy grow.
        if r.src_i == i {
            if let Some(pl) = r
                .untrimmed_center_pts
                .safe_get_slice_ending_at(trimmed_center_pts.first_pt())
                .and_then(|pl| pl.extend(trimmed_center_pts.clone()).ok())
            {
                trimmed_center_pts = pl;
            }
        } else if let Some(pl) = r
            .untrimmed_center_pts
            .safe_get_slice_starting_at(trimmed_center_pts.last_pt())
            .and_then(|pl| trimmed_center_pts.clone().extend(pl).ok())
        {
            trimmed_center_pts = pl;
        }
        roads.insert(
            r.orig_id,
            initial::Road {
                id: r.orig_id,
                src_i: r.orig_id.i1,
                dst_i: r.orig_id.i2,
                trimmed_center_pts,
                half_width,
                // Unused
                lane_specs_ltr: Vec::new(),
                osm_tags: r.osm_tags.clone(),
            },
        );
    }
    let polygon = initial::intersection_polygon(
        intersection.orig_id,
        intersection_roads,
        &mut roads,
        // For consolidated intersections, it appears we don't need to pass in
        // trim_roads_for_merging. May revisit this later if needed.
        &BTreeMap::new(),
    )
    .unwrap()
    .0;
    map.intersections[i.0].polygon = polygon;
    // Copy over the re-trimmed road centers
    let mut affected = Vec::new();
    for (orig_id, id) in modify_roads {
        map.roads[id.0].center_pts = roads.remove(&orig_id).unwrap().trimmed_center_pts;
        if id != changed_road {
            affected.push(id);
        }
    }
    affected
}
fn recalculate_intersection_polygon ( map : & mut Map , changed_road : RoadID , changed_road_width : Distance , i : IntersectionID , ) -> Vec < RoadID > { use crate :: make :: initial ; let intersection = map . get_i ( i ) ; let mut intersection_roads = BTreeSet :: new ( ) ; let mut roads = BTreeMap :: new ( ) ; let mut modify_roads = Vec :: new ( ) ; for r in & intersection . roads { let r = map . get_r ( * r ) ; modify_roads . push ( ( r . orig_id , r . id ) ) ; intersection_roads . insert ( r . orig_id ) ; let half_width = if r . id == changed_road { changed_road_width / 2.0 } else { r . get_half_width ( map ) } ; let mut trimmed_center_pts = r . center_pts . clone ( ) ; // intersection_polygon assumes the end of the center points extends all of the way into // the intersection itself. So untrim in the direction we're about to modify. If for some // reason this fails, the size of the intersection might unrealisticalluy grow. if r . src_i == i { if let Some ( pl ) = r . untrimmed_center_pts . safe_get_slice_ending_at ( trimmed_center_pts . first_pt ( ) ) . and_then ( | pl | pl . extend ( trimmed_center_pts . clone ( ) ) . ok ( ) ) { trimmed_center_pts = pl ; } } else if let Some ( pl ) = r . untrimmed_center_pts . safe_get_slice_starting_at ( trimmed_center_pts . last_pt ( ) ) . and_then ( | pl | trimmed_center_pts . clone ( ) . extend ( pl ) . ok ( ) ) { trimmed_center_pts = pl ; } roads . insert ( r . orig_id , initial :: Road { id : r . orig_id , src_i : r . orig_id . i1 , dst_i : r . orig_id . i2 , trimmed_center_pts , half_width , // Unused lane_specs_ltr : Vec :: new ( ) , osm_tags : r . osm_tags . clone ( ) , } , ) ; } let polygon = initial :: intersection_polygon ( intersection . orig_id , intersection_roads , & mut roads , // For consolidated intersections, it appears we don't need to pass in // trim_roads_for_merging. May revisit this later if needed. & BTreeMap :: new ( ) , ) . unwrap ( ) . 0 ; map . intersections [ i . 0 ] . polygon = polygon ; // Copy over the re-trimmed road centers let mut affected = Vec :: new ( ) ; for ( orig_id , id ) in modify_roads { map . roads [ id . 0 ] . center_pts = roads . remove ( & orig_id ) . unwrap ( ) . trimmed_center_pts ; if id != changed_road { affected . push ( id ) ; } } affected }
Returns the other roads affected by this change, not counting changed_road.
Returns the other roads affected by this change not counting changed_road .
map
&mut Map
changed_road
RoadID
changed_road_width
Distance
i
IntersectionID