Exemple #1
0
    def _create_part(self, attach_lanes, attach_road: Road, radius: float,
                     intersect_nodes: deque, part_idx) -> (StraightLane, bool):
        lane_num = self.lane_num_intersect if part_idx == 0 or part_idx == 2 else self.positive_lane_num
        non_cross = True
        attach_left_lane = attach_lanes[0]
        # first left part
        assert isinstance(
            attach_left_lane, StraightLane
        ), "Can't create a intersection following a circular lane"
        self._create_left_turn(radius, lane_num, attach_left_lane, attach_road,
                               intersect_nodes, part_idx)

        # u-turn
        if self.enable_u_turn:
            adverse_road = -attach_road
            self._create_u_turn(attach_road, part_idx)

        # go forward part
        lanes_on_road = copy.deepcopy(attach_lanes)
        straight_lane_len = 2 * radius + (2 * lane_num -
                                          1) * lanes_on_road[0].width_at(0)
        for l in lanes_on_road:
            next_lane = ExtendStraightLane(l, straight_lane_len,
                                           (LineType.NONE, LineType.NONE))
            self.block_network.add_lane(attach_road.end_node,
                                        intersect_nodes[1], next_lane)

        # right part
        length = self.EXIT_PART_LENGTH
        right_turn_lane = lanes_on_road[-1]
        assert isinstance(
            right_turn_lane, StraightLane
        ), "Can't create a intersection following a circular lane"
        right_bend, right_straight = create_bend_straight(
            right_turn_lane, length, radius, np.deg2rad(self.ANGLE), True,
            right_turn_lane.width_at(0), (LineType.NONE, LineType.SIDE))

        non_cross = (not check_lane_on_road(
            self._global_network,
            right_bend,
            1,
            ignore_intersection_checking=self.ignore_intersection_checking)
                     ) and non_cross
        CreateRoadFrom(
            right_bend,
            min(self.positive_lane_num, self.lane_num_intersect),
            Road(attach_road.end_node, intersect_nodes[0]),
            self.block_network,
            self._global_network,
            toward_smaller_lane_index=True,
            side_lane_line_type=LineType.SIDE,
            inner_lane_line_type=LineType.NONE,
            center_line_type=LineType.NONE,
            ignore_intersection_checking=self.ignore_intersection_checking)

        intersect_nodes.rotate(-1)
        right_straight.line_types = [LineType.BROKEN, LineType.SIDE]
        return right_straight, non_cross
Exemple #2
0
    def _try_plug_into_previous_block(self) -> bool:
        acc_lane_len = self.get_config()[Parameter.length]
        no_cross = True
        fork_lane_num = self.get_config()[Parameter.lane_num] + 1

        # extend road and acc raod part, part 0
        self.set_part_idx(0)
        sin_angle = np.sin(np.deg2rad(self.ANGLE))
        cos_angle = np.cos(np.deg2rad(self.ANGLE))
        longitude_len = sin_angle * self.RADIUS * 2 + cos_angle * self.CONNECT_PART_LEN + self.RAMP_LEN

        extend_lane = ExtendStraightLane(
            self.positive_basic_lane, longitude_len + self.EXTRA_PART,
            [LineType.STRIPED, LineType.CONTINUOUS])
        extend_road = Road(self._pre_block_socket.positive_road.end_node,
                           self.add_road_node())
        no_cross = CreateRoadFrom(extend_lane, self.positive_lane_num,
                                  extend_road, self.block_network,
                                  self._global_network) and no_cross
        no_cross = CreateAdverseRoad(extend_road, self.block_network,
                                     self._global_network) and no_cross

        acc_side_lane = ExtendStraightLane(
            extend_lane, acc_lane_len + self.lane_width,
            [LineType.STRIPED, LineType.CONTINUOUS])
        acc_road = Road(extend_road.end_node, self.add_road_node())
        no_cross = CreateRoadFrom(acc_side_lane, self.positive_lane_num,
                                  acc_road, self.block_network,
                                  self._global_network) and no_cross
        no_cross = CreateAdverseRoad(acc_road, self.block_network,
                                     self._global_network) and no_cross
        acc_road.get_lanes(self.block_network)[-1].line_types = [
            LineType.STRIPED, LineType.STRIPED
        ]
        self.add_sockets(Block.create_socket_from_positive_road(acc_road))

        # ramp part, part 1
        self.set_part_idx(1)
        lateral_dist = (1 - cos_angle
                        ) * self.RADIUS * 2 + sin_angle * self.CONNECT_PART_LEN
        end_point = extend_lane.position(self.EXTRA_PART + self.RAMP_LEN,
                                         lateral_dist + self.lane_width)
        start_point = extend_lane.position(self.EXTRA_PART,
                                           lateral_dist + self.lane_width)
        straight_part = StraightLane(start_point,
                                     end_point,
                                     self.lane_width,
                                     self.LANE_TYPE,
                                     speed_limit=self.SPEED_LIMIT)
        straight_road = Road(self.add_road_node(), self.add_road_node())
        self.block_network.add_lane(straight_road.start_node,
                                    straight_road.end_node, straight_part)
        no_cross = (not check_lane_on_road(self._global_network, straight_part,
                                           0.95)) and no_cross
        self.add_reborn_roads(straight_road)

        # p1 road 0, 1
        bend_1, connect_part = sharpbend(straight_part,
                                         self.CONNECT_PART_LEN,
                                         self.RADIUS,
                                         np.deg2rad(self.ANGLE),
                                         False,
                                         self.lane_width,
                                         self.LANE_TYPE,
                                         speed_limit=self.SPEED_LIMIT)
        bend_1_road = Road(straight_road.end_node, self.add_road_node())
        connect_road = Road(bend_1_road.end_node, self.add_road_node())
        self.block_network.add_lane(bend_1_road.start_node,
                                    bend_1_road.end_node, bend_1)
        self.block_network.add_lane(connect_road.start_node,
                                    connect_road.end_node, connect_part)
        no_cross = CreateRoadFrom(bend_1, fork_lane_num, bend_1_road,
                                  self.block_network, self._global_network,
                                  False) and no_cross
        no_cross = CreateRoadFrom(connect_part, fork_lane_num, connect_road,
                                  self.block_network, self._global_network,
                                  False) and no_cross

        # p1, road 2, 3
        bend_2, acc_lane = sharpbend(connect_part,
                                     acc_lane_len,
                                     self.RADIUS,
                                     np.deg2rad(self.ANGLE),
                                     True,
                                     self.lane_width,
                                     self.LANE_TYPE,
                                     speed_limit=self.SPEED_LIMIT)
        acc_lane.line_types = [LineType.STRIPED, LineType.CONTINUOUS]
        bend_2_road = Road(connect_road.end_node, self.road_node(
            0, 0))  # end at part1 road 0, extend road
        acc_road = Road(self.road_node(0, 0), self.road_node(0, 1))
        self.block_network.add_lane(bend_2_road.start_node,
                                    bend_2_road.end_node, bend_2)
        self.block_network.add_lane(acc_road.start_node, acc_road.end_node,
                                    acc_lane)
        no_cross = CreateRoadFrom(bend_2, fork_lane_num, bend_2_road,
                                  self.block_network, self._global_network,
                                  False) and no_cross
        no_cross = CreateRoadFrom(acc_lane, fork_lane_num, acc_road,
                                  self.block_network, self._global_network,
                                  False) and no_cross
        return no_cross
Exemple #3
0
    def _try_plug_into_previous_block(self) -> bool:
        no_cross = True
        sin_angle = np.sin(np.deg2rad(self.ANGLE))
        cos_angle = np.cos(np.deg2rad(self.ANGLE))
        longitude_len = sin_angle * self.RADIUS * 2 + cos_angle * self.CONNECT_PART_LEN + self.RAMP_LEN

        self.set_part_idx(0)
        # part 0 road 0
        dec_lane_len = self.PARAMETER_SPACE.sample()[Parameter.length]
        dec_lane = ExtendStraightLane(self.positive_basic_lane,
                                      dec_lane_len + self.lane_width,
                                      [LineType.STRIPED, LineType.CONTINUOUS])
        dec_road = Road(self._pre_block_socket.positive_road.end_node,
                        self.add_road_node())
        no_cross = CreateRoadFrom(dec_lane, self.positive_lane_num, dec_road,
                                  self.block_network,
                                  self._global_network) and no_cross
        no_cross = CreateAdverseRoad(dec_road, self.block_network,
                                     self._global_network) and no_cross
        dec_right_lane = dec_road.get_lanes(self.block_network)[-1]
        dec_right_lane.line_types = [LineType.STRIPED, LineType.STRIPED]

        # part 0 road 1
        extend_lane = ExtendStraightLane(
            dec_right_lane, longitude_len,
            [LineType.STRIPED, LineType.CONTINUOUS])
        extend_road = Road(dec_road.end_node, self.add_road_node())
        no_cross = CreateRoadFrom(extend_lane, self.positive_lane_num,
                                  extend_road, self.block_network,
                                  self._global_network) and no_cross
        no_cross = CreateAdverseRoad(extend_road, self.block_network,
                                     self._global_network) and no_cross
        self.add_sockets(self.create_socket_from_positive_road(extend_road))

        # part 1 road 0
        self.set_part_idx(1)
        dec_side_right_lane = self._get_deacc_lane(dec_right_lane)
        self.block_network.add_lane(dec_road.start_node, self.add_road_node(),
                                    dec_side_right_lane)
        no_cross = (not check_lane_on_road(
            self._global_network, dec_side_right_lane, 0.95)) and no_cross

        bend_1, connect_part = sharpbend(dec_side_right_lane,
                                         self.CONNECT_PART_LEN,
                                         self.RADIUS,
                                         np.deg2rad(self.ANGLE),
                                         True,
                                         self.lane_width,
                                         self.LANE_TYPE,
                                         speed_limit=self.SPEED_LIMIT)
        bend_1_road = Road(self.road_node(1, 0), self.add_road_node())
        connect_road = Road(bend_1_road.end_node, self.add_road_node())
        self.block_network.add_lane(bend_1_road.start_node,
                                    bend_1_road.end_node, bend_1)
        self.block_network.add_lane(connect_road.start_node,
                                    connect_road.end_node, connect_part)
        no_cross = (not check_lane_on_road(self._global_network, bend_1,
                                           0.95)) and no_cross
        no_cross = (not check_lane_on_road(self._global_network, connect_part,
                                           0.95)) and no_cross

        bend_2, straight_part = sharpbend(connect_part,
                                          self.RAMP_LEN,
                                          self.RADIUS,
                                          np.deg2rad(self.ANGLE),
                                          False,
                                          self.lane_width,
                                          self.LANE_TYPE,
                                          speed_limit=self.SPEED_LIMIT)
        bend_2_road = Road(
            connect_road.end_node,
            self.add_road_node())  # end at part1 road 0, extend road
        straight_road = Road(bend_2_road.end_node, self.add_road_node())
        self.block_network.add_lane(bend_2_road.start_node,
                                    bend_2_road.end_node, bend_2)
        self.block_network.add_lane(straight_road.start_node,
                                    straight_road.end_node, straight_part)
        no_cross = (not check_lane_on_road(self._global_network, bend_2,
                                           0.95)) and no_cross
        no_cross = (not check_lane_on_road(self._global_network, straight_part,
                                           0.95)) and no_cross

        decoration_part = self._get_merge_part(dec_side_right_lane)
        self.block_network.add_lane(Decoration.start, Decoration.end,
                                    decoration_part)
        return no_cross
Exemple #4
0
    def _try_plug_into_previous_block(self) -> bool:
        acc_lane_len = self.get_config()[Parameter.length]
        no_cross = True

        # extend road and acc raod part, part 0
        self.set_part_idx(0)
        sin_angle = math.sin(np.deg2rad(self.ANGLE))
        cos_angle = math.cos(np.deg2rad(self.ANGLE))
        longitude_len = sin_angle * self.RADIUS * 2 + cos_angle * self.CONNECT_PART_LEN + self.RAMP_LEN

        extend_lane = ExtendStraightLane(
            self.positive_basic_lane, longitude_len + self.EXTRA_PART, [LineType.BROKEN, LineType.CONTINUOUS]
        )
        extend_road = Road(self.pre_block_socket.positive_road.end_node, self.add_road_node())
        no_cross = CreateRoadFrom(
            extend_lane,
            self.positive_lane_num,
            extend_road,
            self.block_network,
            self._global_network,
            side_lane_line_type=LineType.CONTINUOUS,
            ignore_intersection_checking=self.ignore_intersection_checking
        ) and no_cross
        extend_road.get_lanes(self.block_network)[-1].line_types = [
            LineType.BROKEN if self.positive_lane_num != 1 else LineType.CONTINUOUS, LineType.CONTINUOUS
        ]
        no_cross = CreateAdverseRoad(
            extend_road,
            self.block_network,
            self._global_network,
            ignore_intersection_checking=self.ignore_intersection_checking
        ) and no_cross
        _extend_road = -extend_road
        left_lane_line = LineType.NONE if self.positive_lane_num == 1 else LineType.BROKEN
        _extend_road.get_lanes(self.block_network)[-1].line_types = [left_lane_line, LineType.SIDE]

        # main acc part
        acc_side_lane = ExtendStraightLane(
            extend_lane, acc_lane_len + self.lane_width, [extend_lane.line_types[0], LineType.SIDE]
        )
        acc_road = Road(extend_road.end_node, self.add_road_node())
        no_cross = CreateRoadFrom(
            acc_side_lane,
            self.positive_lane_num,
            acc_road,
            self.block_network,
            self._global_network,
            side_lane_line_type=LineType.CONTINUOUS,
            ignore_intersection_checking=self.ignore_intersection_checking
        ) and no_cross
        no_cross = CreateAdverseRoad(
            acc_road,
            self.block_network,
            self._global_network,
            ignore_intersection_checking=self.ignore_intersection_checking
        ) and no_cross
        left_line_type = LineType.CONTINUOUS if self.positive_lane_num == 1 else LineType.BROKEN
        acc_road.get_lanes(self.block_network)[-1].line_types = [left_line_type, LineType.BROKEN]

        # socket part
        socket_side_lane = ExtendStraightLane(acc_side_lane, self.SOCKET_LEN, acc_side_lane.line_types)
        socket_road = Road(acc_road.end_node, self.add_road_node())
        no_cross = CreateRoadFrom(
            socket_side_lane,
            self.positive_lane_num,
            socket_road,
            self.block_network,
            self._global_network,
            side_lane_line_type=LineType.CONTINUOUS,
            ignore_intersection_checking=self.ignore_intersection_checking
        ) and no_cross
        no_cross = CreateAdverseRoad(
            socket_road,
            self.block_network,
            self._global_network,
            ignore_intersection_checking=self.ignore_intersection_checking
        ) and no_cross
        self.add_sockets(PGBlock.create_socket_from_positive_road(socket_road))

        # ramp part, part 1
        self.set_part_idx(1)
        lateral_dist = (1 - cos_angle) * self.RADIUS * 2 + sin_angle * self.CONNECT_PART_LEN
        end_point = extend_lane.position(self.EXTRA_PART + self.RAMP_LEN, lateral_dist + self.lane_width)
        start_point = extend_lane.position(self.EXTRA_PART, lateral_dist + self.lane_width)
        straight_part = StraightLane(
            start_point, end_point, self.lane_width, self.LANE_TYPE, speed_limit=self.SPEED_LIMIT
        )
        straight_road = Road(self.add_road_node(), self.add_road_node())
        self.block_network.add_lane(straight_road.start_node, straight_road.end_node, straight_part)
        no_cross = (
            not check_lane_on_road(
                self._global_network,
                straight_part,
                0.95,
                ignore_intersection_checking=self.ignore_intersection_checking
            )
        ) and no_cross
        self.add_respawn_roads(straight_road)

        # p1 road 0, 1
        bend_1, connect_part = create_bend_straight(
            straight_part,
            self.CONNECT_PART_LEN,
            self.RADIUS,
            np.deg2rad(self.ANGLE),
            False,
            self.lane_width,
            self.LANE_TYPE,
            speed_limit=self.SPEED_LIMIT
        )
        bend_1_road = Road(straight_road.end_node, self.add_road_node())
        connect_road = Road(bend_1_road.end_node, self.add_road_node())
        self.block_network.add_lane(bend_1_road.start_node, bend_1_road.end_node, bend_1)
        self.block_network.add_lane(connect_road.start_node, connect_road.end_node, connect_part)
        no_cross = (
            not check_lane_on_road(
                self._global_network, bend_1, 0.95, ignore_intersection_checking=self.ignore_intersection_checking
            )
        ) and no_cross
        no_cross = (
            not check_lane_on_road(
                self._global_network,
                connect_part,
                0.95,
                ignore_intersection_checking=self.ignore_intersection_checking
            )
        ) and no_cross

        # p1, road 2, 3
        bend_2, acc_lane = create_bend_straight(
            connect_part,
            acc_lane_len,
            self.RADIUS,
            np.deg2rad(self.ANGLE),
            True,
            self.lane_width,
            self.LANE_TYPE,
            speed_limit=self.SPEED_LIMIT
        )
        acc_lane.line_types = [LineType.BROKEN, LineType.CONTINUOUS]
        bend_2_road = Road(connect_road.end_node, self.road_node(0, 0))  # end at part1 road 0, extend road
        self.block_network.add_lane(bend_2_road.start_node, bend_2_road.end_node, bend_2)
        self.block_network.add_lane(acc_road.start_node, acc_road.end_node, acc_lane)
        no_cross = (
            not check_lane_on_road(
                self._global_network, bend_2, 0.95, ignore_intersection_checking=self.ignore_intersection_checking
            )
        ) and no_cross
        no_cross = (
            not check_lane_on_road(
                self._global_network, acc_lane, 0.95, ignore_intersection_checking=self.ignore_intersection_checking
            )
        ) and no_cross

        # p1, road 4, small circular to decorate
        merge_lane, _ = create_bend_straight(
            acc_lane, 10, self.lane_width / 2, np.pi / 2, False, self.lane_width,
            (LineType.BROKEN, LineType.CONTINUOUS)
        )
        self.block_network.add_lane(Decoration.start, Decoration.end, merge_lane)

        return no_cross
Exemple #5
0
    def _try_plug_into_previous_block(self) -> bool:
        no_cross = True
        sin_angle = math.sin(np.deg2rad(self.ANGLE))
        cos_angle = math.cos(np.deg2rad(self.ANGLE))
        longitude_len = sin_angle * self.RADIUS * 2 + cos_angle * self.CONNECT_PART_LEN + self.RAMP_LEN + self.EXTRA_LEN

        self.set_part_idx(0)
        # part 0 road 0
        dec_lane_len = self.get_config()[Parameter.length]
        dec_lane = ExtendStraightLane(
            self.positive_basic_lane, dec_lane_len + self.lane_width,
            [self.positive_basic_lane.line_types[0], LineType.SIDE]
        )
        dec_road = Road(self.pre_block_socket.positive_road.end_node, self.add_road_node())
        no_cross = CreateRoadFrom(
            dec_lane,
            self.positive_lane_num,
            dec_road,
            self.block_network,
            self._global_network,
            side_lane_line_type=LineType.CONTINUOUS,
            ignore_intersection_checking=self.ignore_intersection_checking
        ) and no_cross
        no_cross = CreateAdverseRoad(
            dec_road,
            self.block_network,
            self._global_network,
            ignore_intersection_checking=self.ignore_intersection_checking
        ) and no_cross
        dec_right_lane = dec_road.get_lanes(self.block_network)[-1]
        left_line_type = LineType.CONTINUOUS if self.positive_lane_num == 1 else LineType.BROKEN
        dec_right_lane.line_types = [left_line_type, LineType.NONE]

        # part 0 road 1
        extend_lane = ExtendStraightLane(
            dec_right_lane, longitude_len, [dec_right_lane.line_types[0], LineType.CONTINUOUS]
        )
        extend_road = Road(dec_road.end_node, self.add_road_node())
        no_cross = CreateRoadFrom(
            extend_lane,
            self.positive_lane_num,
            extend_road,
            self.block_network,
            self._global_network,
            side_lane_line_type=LineType.CONTINUOUS,
            ignore_intersection_checking=self.ignore_intersection_checking
        ) and no_cross
        no_cross = CreateAdverseRoad(
            extend_road,
            self.block_network,
            self._global_network,
            ignore_intersection_checking=self.ignore_intersection_checking
        ) and no_cross
        _extend_road = -extend_road
        _extend_road.get_lanes(self.block_network)[-1].line_types = [
            LineType.NONE if self.positive_lane_num == 1 else LineType.BROKEN, LineType.SIDE
        ]
        self.add_sockets(self.create_socket_from_positive_road(extend_road))

        # part 1 road 0
        self.set_part_idx(1)
        dec_side_right_lane = self._get_deacc_lane(dec_right_lane)
        self.block_network.add_lane(dec_road.start_node, dec_road.end_node, dec_side_right_lane)
        no_cross = (
            not check_lane_on_road(
                self._global_network,
                dec_side_right_lane,
                0.95,
                ignore_intersection_checking=self.ignore_intersection_checking
            )
        ) and no_cross

        bend_1, connect_part = create_bend_straight(
            dec_side_right_lane,
            self.CONNECT_PART_LEN,
            self.RADIUS,
            np.deg2rad(self.ANGLE),
            True,
            self.lane_width,
            self.LANE_TYPE,
            speed_limit=self.SPEED_LIMIT
        )
        bend_1_road = Road(dec_road.end_node, self.add_road_node())
        connect_road = Road(bend_1_road.end_node, self.add_road_node())
        self.block_network.add_lane(bend_1_road.start_node, bend_1_road.end_node, bend_1)
        self.block_network.add_lane(connect_road.start_node, connect_road.end_node, connect_part)
        no_cross = (
            not check_lane_on_road(
                self._global_network, bend_1, 0.95, ignore_intersection_checking=self.ignore_intersection_checking
            )
        ) and no_cross
        no_cross = (
            not check_lane_on_road(
                self._global_network,
                connect_part,
                0.95,
                ignore_intersection_checking=self.ignore_intersection_checking
            )
        ) and no_cross

        bend_2, straight_part = create_bend_straight(
            connect_part,
            self.RAMP_LEN,
            self.RADIUS,
            np.deg2rad(self.ANGLE),
            False,
            self.lane_width,
            self.LANE_TYPE,
            speed_limit=self.SPEED_LIMIT
        )
        bend_2_road = Road(connect_road.end_node, self.add_road_node())  # end at part1 road 0, extend road
        straight_road = Road(bend_2_road.end_node, self.add_road_node())
        self.block_network.add_lane(bend_2_road.start_node, bend_2_road.end_node, bend_2)
        self.block_network.add_lane(straight_road.start_node, straight_road.end_node, straight_part)
        no_cross = (
            not check_lane_on_road(
                self._global_network, bend_2, 0.95, ignore_intersection_checking=self.ignore_intersection_checking
            )
        ) and no_cross
        no_cross = (
            not check_lane_on_road(
                self._global_network,
                straight_part,
                0.95,
                ignore_intersection_checking=self.ignore_intersection_checking
            )
        ) and no_cross

        decoration_part = self._get_merge_part(dec_side_right_lane)
        self.block_network.add_lane(Decoration.start, Decoration.end, decoration_part)
        return no_cross
Exemple #6
0
def CreateRoadFrom(
    lane: Union["AbstractLane", "StraightLane", "CircularLane"],
    lane_num: int,
    road: "Road",
    roadnet_to_add_lanes: "RoadNetwork",  # mostly, block network
    roadnet_to_check_cross: "RoadNetwork",  # mostly, previous global_network
    toward_smaller_lane_index: bool = True,
    ignore_start: str = None,
    ignore_end: str = None,
    center_line_type=LineType.CONTINUOUS,  # Identical to Block.CENTER_LINE_TYPE
    detect_one_side=True,
    side_lane_line_type=LineType.SIDE,
    inner_lane_line_type=LineType.STRIPED
) -> bool:
    """
        | | | |
        | | | |
        | | | |
        | | | |
    <-----smaller direction = inside direction
    Usage: give the far left lane, then create lane_num lanes including itself
    :return if the lanes created cross other lanes
    """
    lane_num -= 1  # include lane itself
    origin_lane = lane
    lanes = []
    lane_width = lane.width_at(0)
    for i in range(lane_num, 0, -1):
        side_lane = copy.deepcopy(lane)
        if isinstance(lane, StraightLane):
            width = -lane_width if toward_smaller_lane_index else lane_width
            start = side_lane.position(0, width)
            end = side_lane.position(side_lane.length, width)
            side_lane.start = start
            side_lane.end = end
        elif isinstance(lane, CircularLane):
            clockwise = True if lane.direction == 1 else False
            radius1 = lane.radius
            if not toward_smaller_lane_index:
                radius2 = radius1 - lane_width if clockwise else radius1 + lane_width
            else:
                radius2 = radius1 + lane_width if clockwise else radius1 - lane_width
            side_lane.radius = radius2
            side_lane.update_properties()
        if i == 1:
            side_lane.line_types = [center_line_type, inner_lane_line_type] if toward_smaller_lane_index else \
                [inner_lane_line_type, side_lane_line_type]
        else:
            side_lane.line_types = [inner_lane_line_type, inner_lane_line_type]
        lanes.append(side_lane)
        lane = side_lane
    if toward_smaller_lane_index:
        lanes.reverse()
        lanes.append(origin_lane)
    else:
        lanes.insert(0, origin_lane)

    # check the left lane and right lane
    ignore = (ignore_start, ignore_end)
    factor = (BlockDefault.SIDE_WALK_WIDTH + BlockDefault.SIDE_WALK_LINE_DIST + lane_width / 2.0) * 2.0 / lane_width
    if not detect_one_side:
        # Because of side walk, the width of side walk should be consider
        no_cross = not (
            check_lane_on_road(roadnet_to_check_cross, origin_lane, factor, ignore)
            or check_lane_on_road(roadnet_to_check_cross, lanes[0], -0.95, ignore)
        )
    else:
        no_cross = not check_lane_on_road(roadnet_to_check_cross, origin_lane, factor, ignore)
    for l in lanes:
        roadnet_to_add_lanes.add_lane(road.start_node, road.end_node, l)
    if lane_num == 0:
        lanes[-1].line_types = [center_line_type, side_lane_line_type]
    return no_cross