pub struct Map {Show 21 fields
pub(crate) roads: Vec<Road>,
pub(crate) intersections: Vec<Intersection>,
pub(crate) buildings: Vec<Building>,
pub(crate) transit_stops: BTreeMap<TransitStopID, TransitStop>,
pub(crate) transit_routes: Vec<TransitRoute>,
pub(crate) areas: Vec<Area>,
pub(crate) parking_lots: Vec<ParkingLot>,
pub(crate) boundary_polygon: Polygon,
pub(crate) stop_signs: BTreeMap<IntersectionID, ControlStopSign>,
pub(crate) traffic_signals: BTreeMap<IntersectionID, ControlTrafficSignal>,
pub(crate) gps_bounds: GPSBounds,
pub(crate) bounds: Bounds,
pub(crate) config: MapConfig,
pub(crate) pathfinder: Pathfinder,
pub(crate) pathfinder_dirty: bool,
pub(crate) routing_params: RoutingParams,
pub(crate) zones: Vec<Zone>,
pub(crate) name: MapName,
pub(crate) edits: MapEdits,
pub(crate) edits_generation: usize,
pub(crate) road_to_buildings: MultiMap<RoadID, BuildingID>,
}
Fields
roads: Vec<Road>
intersections: Vec<Intersection>
buildings: Vec<Building>
transit_stops: BTreeMap<TransitStopID, TransitStop>
transit_routes: Vec<TransitRoute>
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
sourceimpl Map
impl Map
pub fn new_edits(&self) -> MapEdits
pub fn get_edits(&self) -> &MapEdits
pub fn unsaved_edits(&self) -> bool
pub fn get_r_edit(&self, r: RoadID) -> EditRoad
pub fn edit_road_cmd<F: Fn(&mut EditRoad)>(&self, r: RoadID, f: F) -> EditCmd
sourcepub fn get_i_edit(&self, i: IntersectionID) -> EditIntersection
pub fn get_i_edit(&self, i: IntersectionID) -> EditIntersection
Panics on borders
pub fn save_edits(&self)
sourcepub fn must_apply_edits(
&mut self,
new_edits: MapEdits,
timer: &mut Timer<'_>
) -> EditEffects
pub fn must_apply_edits(
&mut self,
new_edits: MapEdits,
timer: &mut Timer<'_>
) -> EditEffects
Returns (changed_roads, deleted_lanes, deleted_turns, added_turns, changed_intersections)
pub fn try_apply_edits(&mut self, new_edits: MapEdits, timer: &mut Timer<'_>)
fn apply_edits(
&mut self,
new_edits: MapEdits,
enforce_valid: bool,
timer: &mut Timer<'_>
) -> EditEffects
sourcepub fn recalculate_pathfinding_after_edits(&mut self, timer: &mut Timer<'_>)
pub fn recalculate_pathfinding_after_edits(&mut self, timer: &mut Timer<'_>)
This can expensive, so don’t constantly do it while editing in the UI. But this must happen before the simulation resumes.
sourcepub fn incremental_edit_traffic_signal(&mut self, signal: ControlTrafficSignal)
pub fn incremental_edit_traffic_signal(&mut self, signal: ControlTrafficSignal)
Since the player is in the middle of editing, the signal may not be valid. Don’t go through the entire apply_edits flow.
sourcepub fn get_edits_change_key(&self) -> usize
pub fn get_edits_change_key(&self) -> usize
If you need to regenerate anything when the map is edited, use this key to detect edits.
sourceimpl Map
impl Map
pub fn create_from_raw(
raw: RawMap,
opts: RawToMapOptions,
timer: &mut Timer<'_>
) -> Map
sourceimpl Map
impl Map
sourcepub fn load_synchronously(path: String, timer: &mut Timer<'_>) -> Map
pub fn load_synchronously(path: String, timer: &mut Timer<'_>) -> Map
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.
sourcepub fn map_loaded_directly(&mut self, timer: &mut Timer<'_>)
pub fn map_loaded_directly(&mut self, timer: &mut Timer<'_>)
After deserializing a map directly, call this after.
pub fn all_roads(&self) -> &Vec<Road>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn all_lanes(&self) -> impl Iterator<Item = &Lane>
pub fn all_intersections(&self) -> &Vec<Intersection>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn all_turns(&self) -> impl Iterator<Item = &Turn>
pub fn all_buildings(&self) -> &Vec<Building>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn all_areas(&self) -> &Vec<Area>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn all_parking_lots(&self) -> &Vec<ParkingLot>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn all_zones(&self) -> &Vec<Zone>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn maybe_get_r(&self, id: RoadID) -> Option<&Road>
pub fn maybe_get_l(&self, id: LaneID) -> Option<&Lane>
pub fn maybe_get_i(&self, id: IntersectionID) -> Option<&Intersection>
pub fn maybe_get_t(&self, id: TurnID) -> Option<&Turn>
pub fn maybe_get_b(&self, id: BuildingID) -> Option<&Building>
pub fn maybe_get_pl(&self, id: ParkingLotID) -> Option<&ParkingLot>
pub fn maybe_get_a(&self, id: AreaID) -> Option<&Area>
pub fn maybe_get_ts(&self, id: TransitStopID) -> Option<&TransitStop>
pub fn maybe_get_stop_sign(
&self,
id: IntersectionID
) -> Option<&ControlStopSign>
pub fn maybe_get_traffic_signal(
&self,
id: IntersectionID
) -> Option<&ControlTrafficSignal>
pub fn maybe_get_tr(&self, route: TransitRouteID) -> Option<&TransitRoute>
pub fn get_r(&self, id: RoadID) -> &Road
pub fn get_l(&self, id: LaneID) -> &Lane
pub(crate) fn mut_lane(&mut self, id: LaneID) -> &mut Lane
pub(crate) fn mut_road(&mut self, id: RoadID) -> &mut Road
pub fn get_i(&self, id: IntersectionID) -> &Intersection
pub fn get_t(&self, id: TurnID) -> &Turn
pub fn get_b(&self, id: BuildingID) -> &Building
pub fn get_a(&self, id: AreaID) -> &Area
pub fn get_pl(&self, id: ParkingLotID) -> &ParkingLot
pub fn get_stop_sign(&self, id: IntersectionID) -> &ControlStopSign
pub fn get_traffic_signal(&self, id: IntersectionID) -> &ControlTrafficSignal
sourcepub fn get_turns_from_lane(&self, l: LaneID) -> Vec<&Turn>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn get_turns_from_lane(&self, l: LaneID) -> Vec<&Turn>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
The turns may belong to two different intersections!
pub fn get_turns_to_lane(&self, l: LaneID) -> Vec<&Turn>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_turn_between(
&self,
from: LaneID,
to: LaneID,
parent: IntersectionID
) -> Option<&Turn>
pub fn get_next_turns_and_lanes(&self, from: LaneID) -> Vec<(&Turn, &Lane)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_next_turns_and_lanes_for(
&self,
from: LaneID,
constraints: PathConstraints
) -> Vec<(&Turn, &Lane)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_turns_for(
&self,
from: LaneID,
constraints: PathConstraints
) -> Vec<&Turn>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourcepub fn get_movements_for(
&self,
from: DirectedRoadID,
constraints: PathConstraints
) -> Vec<MovementID>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn get_movements_for(
&self,
from: DirectedRoadID,
constraints: PathConstraints
) -> Vec<MovementID>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Find all movements from one road to another that’re usable by someone.
pub fn get_next_roads(&self, from: RoadID) -> BTreeSet<RoadID>
pub fn get_parent(&self, id: LaneID) -> &Road
pub fn get_gps_bounds(&self) -> &GPSBounds
pub fn get_bounds(&self) -> &Bounds
pub fn get_city_name(&self) -> &CityName
pub fn get_name(&self) -> &MapName
pub fn all_transit_stops(&self) -> &BTreeMap<TransitStopID, TransitStop>
pub fn get_ts(&self, stop: TransitStopID) -> &TransitStop
pub fn get_tr(&self, route: TransitRouteID) -> &TransitRoute
pub fn all_transit_routes(&self) -> &Vec<TransitRoute>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn get_transit_route(&self, name: &str) -> Option<&TransitRoute>
pub fn get_routes_serving_stop(&self, stop: TransitStopID) -> Vec<&TransitRoute>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn building_to_road(&self, id: BuildingID) -> &Road
sourcepub fn all_incoming_borders(&self) -> Vec<&Intersection>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn all_incoming_borders(&self) -> Vec<&Intersection>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
This and all_outgoing_borders are expensive to constantly repeat
pub fn all_outgoing_borders(&self) -> Vec<&Intersection>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn save(&self)
sourcepub fn find_driving_lane_near_building(&self, b: BuildingID) -> LaneID
pub fn find_driving_lane_near_building(&self, b: BuildingID) -> LaneID
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 get_boundary_polygon(&self) -> &Polygon
pub fn get_pathfinder(&self) -> &Pathfinder
pub fn pathfind(&self, req: PathRequest) -> Result<Path>
pub fn pathfind_with_params(
&self,
req: PathRequest,
params: &RoutingParams,
cache_custom: PathfinderCaching
) -> Result<Path>
pub fn pathfind_v2(&self, req: PathRequest) -> Result<PathV2>
pub fn pathfind_v2_with_params(
&self,
req: PathRequest,
params: &RoutingParams,
cache_custom: PathfinderCaching
) -> Result<PathV2>
pub fn should_use_transit(
&self,
start: Position,
end: Position
) -> Option<(TransitStopID, Option<TransitStopID>, TransitRouteID)>
sourcepub 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.
sourcepub 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 find_r_by_osm_id(&self, id: OriginalRoad) -> Result<RoadID>
pub fn find_i_by_osm_id(&self, id: NodeID) -> Result<IntersectionID>
pub fn find_b_by_osm_id(&self, id: OsmID) -> Option<BuildingID>
pub fn find_tr_by_gtfs(&self, gtfs_id: &str) -> Option<TransitRouteID>
pub fn hack_override_offstreet_spots(&mut self, spots_per_bldg: usize)
pub fn hack_override_offstreet_spots_individ(
&mut self,
b: BuildingID,
spots: usize
)
pub fn hack_override_bldg_type(
&mut self,
b: BuildingID,
bldg_type: BuildingType
)
pub fn hack_override_orig_spawn_times(
&mut self,
br: TransitRouteID,
times: Vec<Time>
)
pub fn hack_add_area(
&mut self,
area_type: AreaType,
polygon: Polygon,
osm_tags: Tags
)
sourcepub fn keep_pathfinder_despite_edits(&mut self)
pub fn keep_pathfinder_despite_edits(&mut self)
Normally after applying edits, you must call recalculate_pathfinding_after_edits
.
Alternatively, you can keep the old pathfinder exactly as it is. Use with caution – the
pathfinder and the map may be out-of-sync in arbitrary ways.
pub fn get_languages(&self) -> BTreeSet<String>
pub fn get_config(&self) -> &MapConfig
sourcepub 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.
sourcepub 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.
sourcepub fn routing_params(&self) -> &RoutingParams
pub fn routing_params(&self) -> &RoutingParams
Returns the routing params baked into the map.
pub fn road_to_buildings(&self, r: RoadID) -> &BTreeSet<BuildingID>
pub(crate) fn recalculate_road_to_buildings(&mut self)
pub(crate) fn recalculate_all_movements(&mut self, timer: &mut Timer<'_>)
sourcepub fn find_road_between(
&self,
i1: IntersectionID,
i2: IntersectionID
) -> Option<RoadID>
pub fn find_road_between(
&self,
i1: IntersectionID,
i2: IntersectionID
) -> Option<RoadID>
Finds the road directly connecting two intersections.
sourcepub fn max_elevation(&self) -> Distance
pub fn max_elevation(&self) -> Distance
Returns the highest elevation in the map
sourcepub fn is_unprotected_turn(
&self,
from: RoadID,
to: RoadID,
turn_type: TurnType
) -> bool
pub fn is_unprotected_turn(
&self,
from: RoadID,
to: RoadID,
turn_type: TurnType
) -> bool
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)
sourcepub fn minify(&mut self, timer: &mut Timer<'_>)
pub fn minify(&mut self, timer: &mut Timer<'_>)
Modifies the map in-place, removing parts not essential for the bike network tool.
sourcepub fn minify_buildings(&mut self, timer: &mut Timer<'_>)
pub fn minify_buildings(&mut self, timer: &mut Timer<'_>)
Modifies the map in-place, removing buildings.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Map
impl<'de> Deserialize<'de> for Map
sourcefn 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 Send for Map
impl Sync for Map
impl Unpin for Map
impl UnwindSafe for Map
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more