1919logger = logging .getLogger (__name__ )
2020
2121
22-
23-
24-
25- def add_lanexy_to_graph (G : nx .Graph , lanes ):
22+ def add_lanexy_to_graph (G : nx .Graph , lanes ):
2623 """
2724 Adds lane coordinates to the graph as node attributes.
2825
@@ -40,7 +37,7 @@ def add_lanexy_to_graph(G : nx.Graph, lanes):
4037 return G
4138
4239
43- def plot_graph (G : nx .Graph , output : Path ):
40+ def plot_graph (G : nx .Graph , output : Path ):
4441 """
4542 Plots the graph with lane coordinates.
4643
@@ -71,7 +68,7 @@ def _get_lane_geometry(self, lane) -> shapely.LineString:
7168 def set_trafficlight (self ):
7269 trafficlight = []
7370 for lane in self .lanes :
74- if hasattr (lane , ' trafficlight' ) and lane .trafficlight :
71+ if hasattr (lane , " trafficlight" ) and lane .trafficlight :
7572 trafficlight .append (lane .trafficlight )
7673 self .trafficlights = trafficlight
7774
@@ -90,7 +87,7 @@ def __init__(self, recording, lane_buffer=None, intersection_overlap_buffer=None
9087 self .lane_buffer = lane_buffer if lane_buffer is not None else 0.3
9188 self .intersection_overlap_buffer = intersection_overlap_buffer if intersection_overlap_buffer is not None else 1
9289 self .do_combine_intersections = True
93-
90+
9491 for tl_state in recording .traffic_light_states .values ():
9592 for tl in tl_state :
9693 if tl .id .value not in self .trafficlight_ids :
@@ -108,17 +105,15 @@ def _get_lane_centerline(self, lane) -> shapely.LineString:
108105
109106 def _get_lane_successors (self , lane ) -> list :
110107 """Extract successor IDs from OSI centerline lane."""
111- return [succ_id .lane_id if hasattr (succ_id , "lane_id" ) else succ_id
112- for succ_id in lane .successor_ids ]
108+ return [succ_id .lane_id if hasattr (succ_id , "lane_id" ) else succ_id for succ_id in lane .successor_ids ]
113109
114110 def _get_lane_predecessors (self , lane ) -> list :
115111 """Extract predecessor IDs from OSI centerline lane."""
116- return [pred_id .lane_id if hasattr (pred_id , "lane_id" ) else pred_id
117- for pred_id in lane .predecessor_ids ]
112+ return [pred_id .lane_id if hasattr (pred_id , "lane_id" ) else pred_id for pred_id in lane .predecessor_ids ]
118113
119114 def _has_traffic_light (self , lane ) -> bool :
120115 """Check if OSI centerline lane has traffic light."""
121- return hasattr (lane , ' trafficlight' ) and lane .trafficlight is not None
116+ return hasattr (lane , " trafficlight" ) and lane .trafficlight is not None
122117
123118 def _get_traffic_light (self , lane ):
124119 """Get traffic light object from OSI centerline lane."""
@@ -134,7 +129,7 @@ def _set_lane_is_approaching(self, lane, value: bool):
134129
135130 def _get_lane_on_intersection (self , lane ) -> bool :
136131 """Get the on_intersection status of OSI centerline lane."""
137- return lane .on_intersection if hasattr (lane , ' on_intersection' ) else False
132+ return lane .on_intersection if hasattr (lane , " on_intersection" ) else False
138133
139134 def init_intersections (self ):
140135 """
@@ -523,7 +518,9 @@ def combine_intersection_on_polygon(self, intersection1, intersection2):
523518 """
524519 if self .intersections_overlap (intersection1 , intersection2 ):
525520 # Create a new intersection object with the lanes from both intersections
526- combined_intersection = Intersection (intersection1 .lanes + intersection2 .lanes , concave_hull_ratio = self .concave_hull_ratio )
521+ combined_intersection = Intersection (
522+ intersection1 .lanes + intersection2 .lanes , concave_hull_ratio = self .concave_hull_ratio
523+ )
527524
528525 return combined_intersection
529526 else :
@@ -652,7 +649,11 @@ def find_isolated_connections(self):
652649 new_connections = []
653650 for component in nx .connected_components (G ):
654651 if len (component ) > 0 :
655- isolated_connections .append (ConnectionSegment ([self .lane_dict [i ] for i in component ], concave_hull_ratio = self .concave_hull_ratio ))
652+ isolated_connections .append (
653+ ConnectionSegment (
654+ [self .lane_dict [i ] for i in component ], concave_hull_ratio = self .concave_hull_ratio
655+ )
656+ )
656657 # Check if any of the lanes in the isolated connections are part of an intersection
657658 for connection in isolated_connections :
658659 pre = False
@@ -909,7 +910,7 @@ def plot(
909910 plt .savefig (output_path )
910911 plt .close ()
911912
912- def plot_intersections (self , output_plot : Path ):
913+ def plot_intersections (self , output_plot : Path ):
913914 """
914915 Plots all intersections and saves them to the output path.
915916 Args:
0 commit comments