Struct map_model::Map [−][src]
pub struct Map {}Show 21 fields
roads: Vec<Road>, intersections: Vec<Intersection>, buildings: Vec<Building>, bus_stops: BTreeMap<BusStopID, BusStop>, bus_routes: Vec<BusRoute>, areas: Vec<Area>, parking_lots: Vec<ParkingLot>, boundary_polygon: Polygon, stop_signs: BTreeMap<IntersectionID, ControlStopSign>, traffic_signals: BTreeMap<IntersectionID, ControlTrafficSignal>, gps_bounds: GPSBounds, bounds: Bounds, config: MapConfig, pathfinder: Pathfinder, pathfinder_dirty: bool, routing_params: RoutingParams, zones: Vec<Zone>, name: MapName, edits: MapEdits, edits_generation: usize, road_to_buildings: MultiMap<RoadID, BuildingID>,
Fields
roads: Vec<Road>
intersections: Vec<Intersection>
buildings: Vec<Building>
bus_stops: BTreeMap<BusStopID, BusStop>
bus_routes: Vec<BusRoute>
areas: Vec<Area>
parking_lots: Vec<ParkingLot>
boundary_polygon: Polygon
stop_signs: BTreeMap<IntersectionID, ControlStopSign>
traffic_signals: BTreeMap<IntersectionID, ControlTrafficSignal>
gps_bounds: GPSBounds
bounds: Bounds
config: MapConfig
pathfinder: Pathfinder
pathfinder_dirty: bool
routing_params: RoutingParams
zones: Vec<Zone>
name: MapName
edits: MapEdits
edits_generation: usize
road_to_buildings: MultiMap<RoadID, BuildingID>
Implementations
Panics on borders
Returns (changed_roads, deleted_lanes, deleted_turns, added_turns, changed_intersections)
fn apply_edits(
&mut self,
new_edits: MapEdits,
enforce_valid: bool,
timer: &mut Timer<'_>
) -> EditEffects
This can expensive, so don’t constantly do it while editing in the UI. But this must happen before the simulation resumes.
Since the player is in the middle of editing, the signal may not be valid. Don’t go through the entire apply_edits flow.
If you need to regenerate anything when the map is edited, use this key to detect edits.
Load a map from a local serialized Map or RawMap. Note this won’t work on web. This should only be used by non-UI tools.
After deserializing a map directly, call this after.
The turns may belong to two different intersections!
pub fn get_turn_between(
&self,
from: LaneID,
to: LaneID,
parent: IntersectionID
) -> Option<&Turn>
pub fn get_next_turns_and_lanes(
&self,
from: LaneID,
parent: IntersectionID
) -> Vec<(&Turn, &Lane)>
pub fn get_movements_for(
&self,
from: DirectedRoadID,
constraints: PathConstraints
) -> Vec<MovementID>
pub fn get_movements_for(
&self,
from: DirectedRoadID,
constraints: PathConstraints
) -> Vec<MovementID>
Find all movements from one road to another that’re usable by someone.
This and all_outgoing_borders are expensive to constantly repeat
Cars trying to park near this building should head for the driving lane returned here, then start their search. Some parking lanes are connected to driving lanes that’re “parking blackholes” – if there are no free spots on that lane, then the roads force cars to a border.
pub fn pathfind_with_params(
&self,
req: PathRequest,
params: &RoutingParams,
cache_custom: bool
) -> Result<Path>
pub fn pathfind_v2_with_params(
&self,
req: PathRequest,
params: &RoutingParams,
cache_custom: bool
) -> Result<PathV2>
pub fn should_use_transit(
&self,
start: Position,
end: Position
) -> Option<(BusStopID, Option<BusStopID>, BusRouteID)>
pub fn all_costs_from(
&self,
req: PathRequest
) -> Option<(Duration, HashMap<DirectedRoadID, Duration>)>
pub fn all_costs_from(
&self,
req: PathRequest
) -> Option<(Duration, HashMap<DirectedRoadID, Duration>)>
Return the cost of a single path, and also a mapping from every directed road to the cost of getting there from the same start. This can be used to understand why an alternative route wasn’t chosen.
pub fn get_movement_for_traffic_signal(
&self,
t: TurnID
) -> Option<(MovementID, CompressedMovementID)>
pub fn get_movement_for_traffic_signal(
&self,
t: TurnID
) -> Option<(MovementID, CompressedMovementID)>
None for SharedSidewalkCorners and turns not belonging to traffic signals
pub fn hack_override_routing_params(
&mut self,
routing_params: RoutingParams,
timer: &mut Timer<'_>
)
pub fn simple_path_btwn(
&self,
i1: IntersectionID,
i2: IntersectionID
) -> Option<(Vec<RoadID>, Vec<IntersectionID>)>
pub fn simple_path_btwn(
&self,
i1: IntersectionID,
i2: IntersectionID
) -> Option<(Vec<RoadID>, Vec<IntersectionID>)>
Simple search along undirected roads. Expresses the result as a sequence of roads and a sequence of intersections.
pub fn simple_path_btwn_v2(
&self,
i1: IntersectionID,
i2: IntersectionID,
constraints: PathConstraints
) -> Option<(Vec<RoadID>, Vec<IntersectionID>)>
pub fn simple_path_btwn_v2(
&self,
i1: IntersectionID,
i2: IntersectionID,
constraints: PathConstraints
) -> Option<(Vec<RoadID>, Vec<IntersectionID>)>
Simple search along directed roads, weighted by distance. Expresses the result as a sequence of roads and a sequence of intersections.
Unlike the main pathfinding methods, this starts and ends at intersections. The first and last step can be on any road connected to the intersection.
Returns the routing params baked into the map.
Finds the road directly connecting two intersections.
Returns the highest elevation in the map
Does a turn at a stop sign go from a smaller to a larger road? (Note this doesn’t look at unprotected movements in traffic signals, since we don’t yet have good heuristics for when those exist)
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Map
impl UnwindSafe for Map
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self