pub struct Map {Show 25 fields
pub(crate) roads: Vec<Road>,
pub(crate) intersections: Vec<Intersection>,
pub(crate) intersection_quad_tree: Arc<RwLock<Option<FindClosest<IntersectionID>>>>,
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) bus_routes_on_roads: MultiMap<WayID, String>,
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) census_zones: Vec<(Polygon, CensusZone)>,
pub(crate) extra_pois: Vec<ExtraPOI>,
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>
§intersection_quad_tree: Arc<RwLock<Option<FindClosest<IntersectionID>>>>
§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>
§bus_routes_on_roads: MultiMap<WayID, String>
§gps_bounds: GPSBounds
§bounds: Bounds
§config: MapConfig
§pathfinder: Pathfinder
§pathfinder_dirty: bool
§routing_params: RoutingParams
§zones: Vec<Zone>
§census_zones: Vec<(Polygon, CensusZone)>
§extra_pois: Vec<ExtraPOI>
§name: MapName
§edits: MapEdits
§edits_generation: usize
§road_to_buildings: MultiMap<RoadID, BuildingID>
Implementations§
source§impl Map
impl Map
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<'_>)
sourcepub fn treat_edits_as_basemap(&mut self)
pub fn treat_edits_as_basemap(&mut self)
Whatever edits have been applied, treat as the basemap. This erases all commands and knowledge of what roads/intersections/etc looked like before.
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.
source§impl 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: FnOnce(&mut EditRoad)>( &self, r: RoadID, f: F ) -> EditCmd
pub fn get_i_edit(&self, i: IntersectionID) -> EditIntersection
pub fn edit_intersection_cmd<F: FnOnce(&mut EditIntersection)>( &self, i: IntersectionID, f: F ) -> EditCmd
pub fn save_edits(&self)
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.
source§impl Map
impl Map
pub fn create_from_raw( raw: RawMap, opts: RawToMapOptions, timer: &mut Timer<'_> ) -> Map
source§impl 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.
sourcepub fn almost_blank() -> Self
pub fn almost_blank() -> Self
A dummy map that won’t crash UIs, but has almost nothing in it.
pub fn all_roads(&self) -> &Vec<Road>
pub fn all_roads_with_modal_filter( &self ) -> impl Iterator<Item = (&Road, &RoadFilter)>
pub fn all_lanes(&self) -> impl Iterator<Item = &Lane>
pub fn all_intersections(&self) -> &Vec<Intersection>
pub fn all_turns(&self) -> impl Iterator<Item = &Turn>
pub fn all_buildings(&self) -> &Vec<Building>
pub fn all_areas(&self) -> &Vec<Area>
pub fn all_parking_lots(&self) -> &Vec<ParkingLot>
pub fn all_zones(&self) -> &Vec<Zone>
pub fn all_census_zones(&self) -> &Vec<(Polygon, CensusZone)>
pub fn all_extra_pois(&self) -> &Vec<ExtraPOI>
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_turn(&mut self, id: TurnID) -> &mut Turn
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_movement(&self, id: MovementID) -> Option<&Movement>
pub fn get_movement(&self, id: MovementID) -> Option<&Movement>
This will return None for SharedSidewalkCorners
sourcepub fn get_turns_from_lane(&self, l: LaneID) -> Vec<&Turn>
pub fn get_turns_from_lane(&self, l: LaneID) -> Vec<&Turn>
The turns may belong to two different intersections!
pub fn get_turns_to_lane(&self, l: LaneID) -> Vec<&Turn>
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)>
pub fn get_next_turns_and_lanes_for( &self, from: LaneID, constraints: PathConstraints ) -> Vec<(&Turn, &Lane)>
pub fn get_turns_for( &self, from: LaneID, constraints: PathConstraints ) -> Vec<&Turn>
sourcepub 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.
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>
pub fn get_transit_route(&self, name: &str) -> Option<&TransitRoute>
pub fn get_routes_serving_stop(&self, stop: TransitStopID) -> Vec<&TransitRoute>
pub fn building_to_road(&self, id: BuildingID) -> &Road
sourcepub fn all_incoming_borders(&self) -> Vec<&Intersection>
pub fn all_incoming_borders(&self) -> Vec<&Intersection>
This and all_outgoing_borders are expensive to constantly repeat
pub fn all_outgoing_borders(&self) -> Vec<&Intersection>
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>
fn populate_intersection_quad_tree(&self)
pub fn localise_lon_lat_to_map(&self, point: LonLat) -> Pt2D
pub fn find_i_by_pt2d(&self, pnt: Pt2D) -> 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.
sourcepub fn routing_params_respecting_modal_filters(&self) -> RoutingParams
pub fn routing_params_respecting_modal_filters(&self) -> RoutingParams
Adjusts the routing params baked into the map by accounting for any modal filters created since. TODO It’s weird that these don’t already take effect!
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.
sourcepub fn export_geometry(&self) -> GeoJson
pub fn export_geometry(&self) -> GeoJson
Export all road and intersection geometry to GeoJSON, transforming to WGS84
sourcepub fn get_bus_routes_on_road(&self, r: RoadID) -> &BTreeSet<String>
pub fn get_bus_routes_on_road(&self, r: RoadID) -> &BTreeSet<String>
What’re the names of bus routes along a road? Note this is best effort, not robust to edits or transformations.
sourcepub fn get_available_amenity_types(&self) -> BTreeSet<AmenityType>
pub fn get_available_amenity_types(&self) -> BTreeSet<AmenityType>
Find all amenity types that at least 1 building contains