File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,10 +80,23 @@ def update_road_ids(self):
8080 """
8181 Updates the road_ids of the lane to the segment ID
8282 """
83- for i , lane in enumerate (self .lanes .values ()):
83+ # Create a list of items to avoid modifying dictionary during iteration
84+ lanes_items = list (self .lanes .items ())
85+
86+ for original_key , lane in lanes_items :
8487 lane_id = lane .idx .lane_id
8588 if lane_id in self .lane_segment_dict and self .lane_segment_dict [lane_id ].segment is not None :
86- lane .idx = OsiLaneId (road_id = self .lane_segment_dict [lane_id ].segment .idx , lane_id = lane_id )
89+ # Create the new namedtuple with updated road_id
90+ new_idx = lane .idx ._replace (road_id = self .lane_segment_dict [lane_id ].segment .idx )
91+
92+ # Create a new lane object with the updated idx
93+ updated_lane = lane
94+ updated_lane .idx = new_idx
95+
96+ # Update the dictionary - remove old entry and add new one
97+ self .lanes [new_idx ] = updated_lane
98+ if original_key != new_idx :
99+ del self .lanes [original_key ] # Delete the old key if it's different
87100 else :
88101 # print(f"Lane {lane_id} is not part of an intersection, so it has no segment ID")
89102 pass
You can’t perform that action at this time.
0 commit comments