Struct map_model::Map

source ·
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

source

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)

source

pub fn try_apply_edits(&mut self, new_edits: MapEdits, timer: &mut Timer<'_>)

source

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.

source

fn apply_edits( &mut self, new_edits: MapEdits, enforce_valid: bool, timer: &mut Timer<'_> ) -> EditEffects

source

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

source

pub fn new_edits(&self) -> MapEdits

source

pub fn get_edits(&self) -> &MapEdits

source

pub fn unsaved_edits(&self) -> bool

source

pub fn get_r_edit(&self, r: RoadID) -> EditRoad

source

pub fn edit_road_cmd<F: FnOnce(&mut EditRoad)>( &self, r: RoadID, f: F ) -> EditCmd

source

pub fn get_i_edit(&self, i: IntersectionID) -> EditIntersection

source

pub fn edit_intersection_cmd<F: FnOnce(&mut EditIntersection)>( &self, i: IntersectionID, f: F ) -> EditCmd

source

pub fn save_edits(&self)

source

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.

source

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

source

pub fn create_from_raw( raw: RawMap, opts: RawToMapOptions, timer: &mut Timer<'_> ) -> Map

source§

impl Map

source

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.

source

pub fn map_loaded_directly(&mut self, timer: &mut Timer<'_>)

After deserializing a map directly, call this after.

source

pub fn blank() -> Map

Just for temporary std::mem::replace tricks.

source

pub fn almost_blank() -> Self

A dummy map that won’t crash UIs, but has almost nothing in it.

source

pub fn all_roads(&self) -> &Vec<Road>

source

pub fn all_roads_with_modal_filter( &self ) -> impl Iterator<Item = (&Road, &RoadFilter)>

source

pub fn all_lanes(&self) -> impl Iterator<Item = &Lane>

source

pub fn all_intersections(&self) -> &Vec<Intersection>

source

pub fn all_turns(&self) -> impl Iterator<Item = &Turn>

source

pub fn all_buildings(&self) -> &Vec<Building>

source

pub fn all_areas(&self) -> &Vec<Area>

source

pub fn all_parking_lots(&self) -> &Vec<ParkingLot>

source

pub fn all_zones(&self) -> &Vec<Zone>

source

pub fn all_census_zones(&self) -> &Vec<(Polygon, CensusZone)>

source

pub fn all_extra_pois(&self) -> &Vec<ExtraPOI>

source

pub fn maybe_get_r(&self, id: RoadID) -> Option<&Road>

source

pub fn maybe_get_l(&self, id: LaneID) -> Option<&Lane>

source

pub fn maybe_get_i(&self, id: IntersectionID) -> Option<&Intersection>

source

pub fn maybe_get_t(&self, id: TurnID) -> Option<&Turn>

source

pub fn maybe_get_b(&self, id: BuildingID) -> Option<&Building>

source

pub fn maybe_get_pl(&self, id: ParkingLotID) -> Option<&ParkingLot>

source

pub fn maybe_get_a(&self, id: AreaID) -> Option<&Area>

source

pub fn maybe_get_ts(&self, id: TransitStopID) -> Option<&TransitStop>

source

pub fn maybe_get_stop_sign( &self, id: IntersectionID ) -> Option<&ControlStopSign>

source

pub fn maybe_get_traffic_signal( &self, id: IntersectionID ) -> Option<&ControlTrafficSignal>

source

pub fn maybe_get_tr(&self, route: TransitRouteID) -> Option<&TransitRoute>

source

pub fn get_r(&self, id: RoadID) -> &Road

source

pub fn get_l(&self, id: LaneID) -> &Lane

source

pub(crate) fn mut_lane(&mut self, id: LaneID) -> &mut Lane

source

pub fn mut_road(&mut self, id: RoadID) -> &mut Road

Public for importer. Do not abuse!

source

pub(crate) fn mut_turn(&mut self, id: TurnID) -> &mut Turn

source

pub fn get_i(&self, id: IntersectionID) -> &Intersection

source

pub fn get_t(&self, id: TurnID) -> &Turn

source

pub fn get_b(&self, id: BuildingID) -> &Building

source

pub fn get_a(&self, id: AreaID) -> &Area

source

pub fn get_pl(&self, id: ParkingLotID) -> &ParkingLot

source

pub fn get_stop_sign(&self, id: IntersectionID) -> &ControlStopSign

source

pub fn get_traffic_signal(&self, id: IntersectionID) -> &ControlTrafficSignal

source

pub fn get_movement(&self, id: MovementID) -> Option<&Movement>

This will return None for SharedSidewalkCorners

source

pub fn get_turns_from_lane(&self, l: LaneID) -> Vec<&Turn>

The turns may belong to two different intersections!

source

pub fn get_turns_to_lane(&self, l: LaneID) -> Vec<&Turn>

source

pub fn get_turn_between( &self, from: LaneID, to: LaneID, parent: IntersectionID ) -> Option<&Turn>

source

pub fn get_next_turns_and_lanes(&self, from: LaneID) -> Vec<(&Turn, &Lane)>

source

pub fn get_next_turns_and_lanes_for( &self, from: LaneID, constraints: PathConstraints ) -> Vec<(&Turn, &Lane)>

source

pub fn get_turns_for( &self, from: LaneID, constraints: PathConstraints ) -> Vec<&Turn>

source

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.

source

pub fn get_next_roads(&self, from: RoadID) -> BTreeSet<RoadID>

source

pub fn get_parent(&self, id: LaneID) -> &Road

source

pub fn get_gps_bounds(&self) -> &GPSBounds

source

pub fn get_bounds(&self) -> &Bounds

source

pub fn get_city_name(&self) -> &CityName

source

pub fn get_name(&self) -> &MapName

source

pub fn all_transit_stops(&self) -> &BTreeMap<TransitStopID, TransitStop>

source

pub fn get_ts(&self, stop: TransitStopID) -> &TransitStop

source

pub fn get_tr(&self, route: TransitRouteID) -> &TransitRoute

source

pub fn all_transit_routes(&self) -> &Vec<TransitRoute>

source

pub fn get_transit_route(&self, name: &str) -> Option<&TransitRoute>

source

pub fn get_routes_serving_stop(&self, stop: TransitStopID) -> Vec<&TransitRoute>

source

pub fn building_to_road(&self, id: BuildingID) -> &Road

source

pub fn all_incoming_borders(&self) -> Vec<&Intersection>

This and all_outgoing_borders are expensive to constantly repeat

source

pub fn all_outgoing_borders(&self) -> Vec<&Intersection>

source

pub fn save(&self)

source

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.

source

pub fn get_boundary_polygon(&self) -> &Polygon

source

pub fn get_pathfinder(&self) -> &Pathfinder

source

pub fn pathfind(&self, req: PathRequest) -> Result<Path>

source

pub fn pathfind_with_params( &self, req: PathRequest, params: &RoutingParams, cache_custom: PathfinderCaching ) -> Result<Path>

source

pub fn pathfind_v2(&self, req: PathRequest) -> Result<PathV2>

source

pub fn pathfind_v2_with_params( &self, req: PathRequest, params: &RoutingParams, cache_custom: PathfinderCaching ) -> Result<PathV2>

source

pub fn should_use_transit( &self, start: Position, end: Position ) -> Option<(TransitStopID, Option<TransitStopID>, TransitRouteID)>

source

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.

source

pub fn get_movement_for_traffic_signal( &self, t: TurnID ) -> Option<(MovementID, CompressedMovementID)>

None for SharedSidewalkCorners and turns not belonging to traffic signals

source

pub fn find_r_by_osm_id(&self, id: OriginalRoad) -> Result<RoadID>

source

pub fn find_i_by_osm_id(&self, id: NodeID) -> Result<IntersectionID>

source

fn populate_intersection_quad_tree(&self)

source

pub fn localise_lon_lat_to_map(&self, point: LonLat) -> Pt2D

source

pub fn find_i_by_pt2d(&self, pnt: Pt2D) -> Result<IntersectionID>

source

pub fn find_b_by_osm_id(&self, id: OsmID) -> Option<BuildingID>

source

pub fn find_tr_by_gtfs(&self, gtfs_id: &str) -> Option<TransitRouteID>

source

pub fn hack_override_offstreet_spots(&mut self, spots_per_bldg: usize)

source

pub fn hack_override_offstreet_spots_individ( &mut self, b: BuildingID, spots: usize )

source

pub fn hack_override_bldg_type( &mut self, b: BuildingID, bldg_type: BuildingType )

source

pub fn hack_override_orig_spawn_times( &mut self, br: TransitRouteID, times: Vec<Time> )

source

pub fn hack_add_area( &mut self, area_type: AreaType, polygon: Polygon, osm_tags: Tags )

source

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.

source

pub fn get_languages(&self) -> BTreeSet<String>

source

pub fn get_config(&self) -> &MapConfig

source

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.

source

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.

source

pub fn routing_params(&self) -> &RoutingParams

Returns the routing params baked into the map.

source

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!

source

pub fn road_to_buildings(&self, r: RoadID) -> &BTreeSet<BuildingID>

source

pub(crate) fn recalculate_road_to_buildings(&mut self)

source

pub(crate) fn recalculate_all_movements(&mut self, timer: &mut Timer<'_>)

source

pub fn find_road_between( &self, i1: IntersectionID, i2: IntersectionID ) -> Option<RoadID>

Finds the road directly connecting two intersections.

source

pub fn max_elevation(&self) -> Distance

Returns the highest elevation in the map

source

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)

source

pub fn minify(&mut self, timer: &mut Timer<'_>)

Modifies the map in-place, removing parts not essential for the bike network tool.

source

pub fn minify_buildings(&mut self, timer: &mut Timer<'_>)

Modifies the map in-place, removing buildings.

source

pub fn export_geometry(&self) -> GeoJson

Export all road and intersection geometry to GeoJSON, transforming to WGS84

source

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.

source

pub fn get_available_amenity_types(&self) -> BTreeSet<AmenityType>

Find all amenity types that at least 1 building contains

source

pub fn get_ban_turn_info( &self, r1: &Road, r2: &Road, icon_counter: &HashMap<IntersectionID, i32> ) -> (TurnType, Pt2D, Angle, IntersectionID)

Trait Implementations§

source§

impl Clone for Map

source§

fn clone(&self) -> Map

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'de> Deserialize<'de> for Map

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Map

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

§

fn is_within(&self, b: &G2) -> bool

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,