def temp_test_straight_centerline_to_polygon() -> None:
    """
    Try converting a simple straight polyline into a polygon. Represents
    the conversion from a centerline to a lane segment polygon.

    Note that the returned polygon will ba a Numpy array of
    shape (2N+1,2), with duplicate first and last vertices.
    Dots below signify the centerline coordinates.

            |   .   |
            |   .   |
            |   .   |
            |   .   |
    """
    # create centerline: Numpy array of shape (N,2)
    centerline = np.array([[0, 2.0], [0.0, 0.0], [0.0, -2.0]])

    polygon = centerline_to_polygon(centerline)
    # polygon wraps around with right boundary, then reversed
    # left boundary, then back to start vertex
    gt_polygon = np.array(
        [
            [-3.8, 2.0],
            [-3.8, 0.0],
            [-3.8, -2.0],
            [3.8, -2.0],
            [3.8, 0.0],
            [3.8, 2.0],
            [-3.8, 2.0],
        ]
    )

    assert np.array_equal(polygon, gt_polygon)
Beispiel #2
0
    def get_lane_segment_polygon(self, lane_segment_id: int, city_name: str) -> np.ndarray:
        """
        Hallucinate a 3d lane polygon based around the centerline. We rely on the average
        lane width within our cities to hallucinate the boundaries. We rely upon the
        rasterized maps to provide heights to points in the xy plane.

        Args:
            lane_segment_id: unique identifier for a lane segment within a city
            city_name: either 'MIA' or 'PIT' for Miami or Pittsburgh

        Returns:
            lane_polygon: Array of polygon boundary (K,3), with identical and last boundary points
        """
        lane_centerline = self.city_lane_centerlines_dict[city_name][lane_segment_id].centerline
        lane_polygon = centerline_to_polygon(lane_centerline[:, :2])
        return self.append_height_to_2d_city_pt_cloud(lane_polygon, city_name)