l5kit.data.map_api module

class l5kit.data.map_api.InterpolationMethod(value)

Bases: enum.IntEnum

An enumeration.

INTER_ENSURE_LEN = 1
INTER_METER = 0
class l5kit.data.map_api.MapAPI(protobuf_map_path: str, world_to_ecef: numpy.ndarray)

Bases: object

static from_cfg(data_manager: l5kit.data.local_data_manager.DataManager, cfg: dict) l5kit.data.map_api.MapAPI

Build a MapAPI object starting from a config file and a data manager

Parameters
  • data_manager – a data manager object ot resolve paths

  • cfg – the config dict

Returns

a MapAPI object

get_bounds() dict

For each elements of interest returns bounds [[min_x, min_y],[max_x, max_y]] and proto ids Coords are computed by the MapAPI and, as such, are in the world ref system.

Returns

keys are classes of elements, values are dict with bounds and ids keys

Return type

dict

get_color_for_face(face_id: str) str

Utility function. It calls is_traffic_face_color for a set of colors until it gets an answer. If no color is found, then face_id is not the id of a traffic light face (and we raise ValueError).

Parameters

face_id (str) – the element id

Returns

the color as string for this traffic face

Return type

str

get_crosswalk_coords(element_id: str) dict

Get XYZ coordinates in world ref system for a crosswalk given its id lru_cached for O(1) access

Parameters

element_id (str) – crosswalk element id

Returns

a dict with the polygon coordinates as an (Nx3) XYZ array

Return type

dict

get_lane_as_interpolation(element_id: str, step: float, method: l5kit.data.map_api.InterpolationMethod) dict

Perform an interpolation of the left and right lanes and compute the midlane. See interpolate for details about the different interpolation methods

Parameters
  • element_id (str) – lane id

  • step (float) – step param for the method

  • method (InterpolationMethod) – one of the accepted methods

Returns

same as get_lane_coords but overwrite xyz values for the lanes

Return type

dict

get_lane_coords(element_id: str) dict

Get XYZ coordinates in world ref system for a lane given its id lru_cached for O(1) access

Parameters

element_id (str) – lane element id

Returns

a dict with the two boundaries coordinates as (Nx3) XYZ arrays

Return type

dict

get_lane_traffic_control_ids(element_id: str) set
get_tl_feature_for_lane(lane_id: str, active_tl_face_to_color: dict) int

Get traffic light feature for a lane given its active tl faces and a constant priority map.

static id_as_str(element_id: road_network_pb2.GlobalId) str

Get the element id as a string. Elements ids are stored as a variable len sequence of bytes in the protobuf

Parameters

element_id (GlobalId) – the GlobalId in the protobuf

Returns

the id as a str

Return type

str

static interpolate(xyz: numpy.ndarray, step: float, method: l5kit.data.map_api.InterpolationMethod) numpy.ndarray

Interpolate points based on cumulative distances from the first one. Two modes are available: INTER_METER: interpolate using step as a meter value over cumulative distances (variable len result) INTER_ENSURE_LEN: interpolate using a variable step such that we always get step values :param xyz: XYZ coords :type xyz: np.ndarray :param step: param for the interpolation :type step: float :param method: method to use to interpolate :type method: InterpolationMethod

Returns

the new interpolated coordinates

Return type

np.ndarray

static is_crosswalk(element: road_network_pb2.MapElement) bool

Check whether an element is a valid crosswalk

Parameters

element (MapElement) – a proto element

Returns

True if the element is a valid crosswalk

Return type

bool

static is_lane(element: road_network_pb2.MapElement) bool

Check whether an element is a valid lane

Parameters

element (MapElement) – a proto element

Returns

True if the element is a valid lane

Return type

bool

is_traffic_face(element_id: str) bool

Check if the element is a traffic light face (of any color)

Parameters

element_id (str) – the id (utf-8 encode) of the element

Returns

True if the element is a traffic light face, False otherwise

is_traffic_face_color(element_id: str, color: str) bool

Check if the element is a traffic light face of the given color

Parameters
  • element_id (str) – the id (utf-8 encode) of the element

  • color (str) – the color to check

Returns

True if the element is a traffic light face with the given color

is_traffic_light(element_id: str) bool

Check if the element is a traffic light :param element_id: the id (utf-8 encode) of the element :type element_id: str

Returns

True if the element is a traffic light

unpack_deltas_cm(dx: Sequence[int], dy: Sequence[int], dz: Sequence[int], frame: road_network_pb2.GeoFrame) numpy.ndarray

Get coords in world reference system (local ENU->ECEF->world). See the protobuf annotations for additional information about how coordinates are stored

Parameters
  • dx (Sequence[int]) – X displacement in centimeters in local ENU

  • dy (Sequence[int]) – Y displacement in centimeters in local ENU

  • dz (Sequence[int]) – Z displacement in centimeters in local ENU

  • frame (GeoFrame) – geo-location information for the local ENU. It contains lat and long origin of the frame

Returns

array of shape (Nx3) with XYZ coordinates in world ref system

Return type

np.ndarray

class l5kit.data.map_api.TLFacesColors(value)

Bases: enum.IntEnum

An enumeration.

GREEN = 1
RED = 0
YELLOW = 2