smarts.core.route_cache module

class smarts.core.route_cache.RouteWithCache(road_map: RoadMap, start_lane: Lane | None = None, end_lane: Lane | None = None)[source]

A cache for commonly-needed but expensive-to-compute information about RoadMap.Routes.

add_to_cache()[source]

Add information about this Route to the cache if not already there.

distance_between(start: RoutePoint, end: RoutePoint) float | None[source]

Distance along route between two points.

distance_from(cur_lane: RouteLane, route_road: Road | None = None) float | None[source]

Returns the distance along the route from the beginning of the current lane to the beginning of the next occurrence of route_road, or if route_road is None, then to the end of the route.

property end_lane: Lane | None

Route’s end lane.

static from_road_ids(road_map, road_ids: Sequence[str], resolve_intermediaries: bool = False) Route[source]

Factory to generate a new RouteWithCache from a sequence of road ids.

property is_cached: bool

Returns True if information about this Route has been cached.

next_junction(cur_lane: RouteLane, offset: float) Tuple[Lane | None, float][source]

Returns a lane within the next junction along the route from beginning of the current lane to the returned lane it connects with in the junction, and the distance to it from this offset, or (None, inf) if there aren’t any.

project_along(start: RoutePoint, distance: float) Set[Tuple[Lane, float]] | None[source]

Starting at point on the route, returns a set of possible locations (lane and offset pairs) further along the route that are distance away, not including lane changes.

remove_from_cache()[source]

Remove information about this Route from the cache.

property road_ids: List[str]

Get the road IDs for this route.

Returns:

A list of the road IDs for the Roads in this Route.

Return type:

(List[str])

property start_lane: Lane | None

Route’s start lane.