parameters: (cls)
docstring: Process the roads before exportation.
docstring_summary: Process the roads before exportation.
docstring_tokens: Process the roads before exportation .
function: def process(cls):
          """Process the roads before exportation."""
          # split the roads at crossroads
          while True:
              modified = False
  
              for roadA in Road.roads:
                  for refA in roadA.refs:
                      for roadB in Road.roads:
                          for refB in roadB.refs:
                              if refA == refB and not roadA == roadB:
                                  ref = refA
                                  for r in [roadA, roadB]:
                                      if r.refs[0] != ref and r.refs[-1] != ref:
                                          [r1, r2] = r.split_at(ref)
                                          Road.roads.remove(r)
                                          r1.id = Road.generate_unique_road_id(r.osmid)
                                          Road.roads.append(r1)
                                          r2.id = Road.generate_unique_road_id(r.osmid)
                                          Road.roads.append(r2)
                                          modified = True
                                  if modified:
                                      break
                          if modified:
                              break
                      if modified:
                          break
                  if modified:
                      break
  
              if not modified:
                  break
  
          # create crossroads, and link road <-> crossroad.
          cls.crossroads = {}
          for roadA in Road.roads:
              for refA in roadA.refs:
                  for roadB in Road.roads:
                      for refB in roadB.refs:
                          if refA == refB and not roadA == roadB:
                              crossroad = None
                              if refA in cls.crossroads:
                                  crossroad = cls.crossroads[refA]
                              else:
                                  crossroad = Crossroad(refA)
                                  cls.crossroads[refA] = crossroad
                              crossroad.add_road(roadA)
                              crossroad.add_road(roadB)
          for crossroad in cls.crossroads.values():
              for road in crossroad.roads:
                  if road.refs[0] == crossroad.nodeRef:
                      road.startJunction = crossroad
                  if road.refs[-1] == crossroad.nodeRef:
                      road.endJunction = crossroad
  
          # The speed limit can only be computed at this point, because the final network need to be known
          # to evaluate if the road is inside or outside a city.
          if cls.speedLimit is not None:
              for road in Road.roads:
                  road.maxSpeed = cls.speedLimit.compute_speed_limit(road)
  
          # process the path of each road, and the corresponding shapely geometry.
          for road in Road.roads:
              road.process_path()
              road.smooth_sharp_angles()
              road.process_shape()
          # process shapely geometry for each crossroad, and substract them to the road paths.
          for crossroad in cls.crossroads.values():
              crossroad.process_shape()
              crossroad.cut_roads()
function_tokens: def process ( cls ) : # split the roads at crossroads while True : modified = False for roadA in Road . roads : for refA in roadA . refs : for roadB in Road . roads : for refB in roadB . refs : if refA == refB and not roadA == roadB : ref = refA for r in [ roadA , roadB ] : if r . refs [ 0 ] != ref and r . refs [ - 1 ] != ref : [ r1 , r2 ] = r . split_at ( ref ) Road . roads . remove ( r ) r1 . id = Road . generate_unique_road_id ( r . osmid ) Road . roads . append ( r1 ) r2 . id = Road . generate_unique_road_id ( r . osmid ) Road . roads . append ( r2 ) modified = True if modified : break if modified : break if modified : break if modified : break if not modified : break # create crossroads, and link road <-> crossroad. cls . crossroads = { } for roadA in Road . roads : for refA in roadA . refs : for roadB in Road . roads : for refB in roadB . refs : if refA == refB and not roadA == roadB : crossroad = None if refA in cls . crossroads : crossroad = cls . crossroads [ refA ] else : crossroad = Crossroad ( refA ) cls . crossroads [ refA ] = crossroad crossroad . add_road ( roadA ) crossroad . add_road ( roadB ) for crossroad in cls . crossroads . values ( ) : for road in crossroad . roads : if road . refs [ 0 ] == crossroad . nodeRef : road . startJunction = crossroad if road . refs [ - 1 ] == crossroad . nodeRef : road . endJunction = crossroad # The speed limit can only be computed at this point, because the final network need to be known # to evaluate if the road is inside or outside a city. if cls . speedLimit is not None : for road in Road . roads : road . maxSpeed = cls . speedLimit . compute_speed_limit ( road ) # process the path of each road, and the corresponding shapely geometry. for road in Road . roads : road . process_path ( ) road . smooth_sharp_angles ( ) road . process_shape ( ) # process shapely geometry for each crossroad, and substract them to the road paths. for crossroad in cls . crossroads . values ( ) : crossroad . process_shape ( ) crossroad . cut_roads ( )