Struct map_model::objects::road::Road

source ·
pub struct Road {
Show 23 fields pub id: RoadID, pub osm_tags: Tags, pub turn_restrictions: Vec<(RestrictionType, RoadID)>, pub complicated_turn_restrictions: Vec<(RoadID, RoadID)>, pub orig_id: OriginalRoad, pub speed_limit: Speed, pub access_restrictions: AccessRestrictions, pub zorder: isize, pub percent_incline: f64, pub lanes: Vec<Lane>, pub center_pts: PolyLine, pub untrimmed_center_pts: PolyLine, pub trim_start: Distance, pub trim_end: Distance, pub src_i: IntersectionID, pub dst_i: IntersectionID, pub crosswalk_forward: bool, pub crosswalk_backward: bool, pub transit_stops: BTreeSet<TransitStopID>, pub modal_filter: Option<RoadFilter>, pub barrier_nodes: Vec<Distance>, pub crossing_nodes: Vec<(Distance, CrossingType)>, pub crossings: Vec<Crossing>,
}
Expand description

A Road represents a segment between exactly two Intersections. It contains Lanes as children.

Fields§

§id: RoadID§osm_tags: Tags§turn_restrictions: Vec<(RestrictionType, RoadID)>

self is ‘from’

§complicated_turn_restrictions: Vec<(RoadID, RoadID)>

self is ‘from’. (via, to). Only BanTurns.

§orig_id: OriginalRoad§speed_limit: Speed§access_restrictions: AccessRestrictions§zorder: isize§percent_incline: f64

[-1.0, 1.0] theoretically, but in practice, about [-0.25, 0.25]. 0 is flat, positive is uphill from src_i -> dst_i, negative is downhill.

§lanes: Vec<Lane>

Invariant: A road must contain at least one child. These are ordered from the left side of the road to the right, with that orientation determined by the direction of center_pts.

§center_pts: PolyLine

The physical center of the road, including sidewalks, after trimming to account for the intersection geometry. The order implies road orientation.

§untrimmed_center_pts: PolyLine

Like center_pts, but before any trimming for intersection geometry. This is preserved so that when modifying road width, intersection polygons can be calculated correctly.

§trim_start: Distance§trim_end: Distance§src_i: IntersectionID§dst_i: IntersectionID§crosswalk_forward: bool

Is there a tagged crosswalk near each end of the road?

§crosswalk_backward: bool§transit_stops: BTreeSet<TransitStopID>

Meaningless order

§modal_filter: Option<RoadFilter>

There’s either a modal filter on this road or not

§barrier_nodes: Vec<Distance>

Some kind of modal filter or barrier this distance along center_pts.

§crossing_nodes: Vec<(Distance, CrossingType)>

Some kind of crossing this distance along center_pts.

§crossings: Vec<Crossing>

Sorted by increasing distance

Implementations§

source§

impl Road

source

pub fn lane_specs(&self) -> Vec<LaneSpec>

source

pub fn shift_from_left_side( &self, width_from_left_side: Distance ) -> Result<PolyLine>

source

pub(crate) fn dir_and_offset(&self, lane: LaneID) -> (Direction, usize)

lane must belong to this road. Offset 0 is the centermost lane on each side of a road, then it counts up from there. Note this is a different offset than offset!

source

pub fn parking_to_driving(&self, parking: LaneID) -> Option<LaneID>

source

pub(crate) fn speed_limit_from_osm(&self) -> Speed

source

pub fn find_closest_lane<F: Fn(&Lane) -> bool>( &self, from: LaneID, filter: F ) -> Option<LaneID>

Includes off-side

source

pub fn get_dir_change_pl(&self, map: &Map) -> PolyLine

This is the FIRST yellow line where the direction of the road changes. If multiple direction changes happen, the result is kind of arbitrary.

source

pub fn get_half_width(&self) -> Distance

source

pub fn get_width(&self) -> Distance

source

pub fn get_thick_polygon(&self) -> Polygon

source

pub fn length(&self) -> Distance

source

pub fn get_half_polygon(&self, dir: Direction, map: &Map) -> Result<Polygon>

Creates the thick polygon representing one half of the road. For roads with multiple direction changes (like a two-way cycletrack adjacent to a regular two-way road), the results are probably weird.

source

pub fn get_name(&self, lang: Option<&String>) -> String

source

pub fn get_rank(&self) -> RoadRank

source

pub fn get_detailed_rank(&self) -> usize

source

pub fn is_light_rail(&self) -> bool

source

pub fn is_footway(&self) -> bool

source

pub fn is_service(&self) -> bool

source

pub fn is_cycleway(&self) -> bool

source

pub fn is_driveable(&self) -> bool

source

pub fn common_endpoint(&self, other: &Road) -> CommonEndpoint

source

pub fn endpoints(&self) -> Vec<IntersectionID>

source

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

Returns the other intersection of this road, panicking if this road doesn’t connect to the input TODO This should use CommonEndpoint

source

pub fn is_private(&self) -> bool

source

pub(crate) fn access_restrictions_from_osm(&self) -> AccessRestrictions

source

pub fn get_zone<'a>(&self, map: &'a Map) -> Option<&'a Zone>

source

pub fn is_extremely_short(&self) -> bool

Many roads wind up with almost no length, due to their representation in OpenStreetMap. In reality, these segments are likely located within the interior of an intersection. This method uses a hardcoded threshold to detect these cases.

source

pub fn directed_id_from(&self, i: IntersectionID) -> DirectedRoadID

Get the DirectedRoadID pointing to the intersection. Panics if the intersection isn’t an endpoint.

source

pub fn directed_id_to(&self, i: IntersectionID) -> DirectedRoadID

Get the DirectedRoadID pointing from the intersection. Panics if the intersection isn’t an endpoint.

source

pub(crate) fn recreate_lanes(&mut self, lane_specs_ltr: Vec<LaneSpec>)

source

pub fn get_lanes_between(&self, l1: LaneID, l2: LaneID) -> Vec<LaneID>

Returns all lanes located between l1 and l2, exclusive.

source

pub fn high_stress_for_bikes(&self, map: &Map, dir: Direction) -> bool

A simple classification of if the directed road is stressful or not for cycling. Arterial roads without a bike lane match this. Why arterial, instead of looking at speed limits? Even on arterial roads with official speed limits lowered, in practice vehicles still travel at the speed suggested by the design of the road.

source

pub fn oneway_for_driving(&self) -> Option<Direction>

source

pub fn is_deadend_for_driving(&self, map: &Map) -> bool

Does either end of this road lead nowhere for cars? (Asking this for a non-driveable road may be kind of meaningless)

source§

impl Road

source

pub(crate) fn children_forwards(&self) -> Vec<(LaneID, LaneType)>

These are ordered from closest to center lane (left-most when driving on the right) to farthest (sidewalk)

source

pub(crate) fn children_backwards(&self) -> Vec<(LaneID, LaneType)>

source

pub(crate) fn children(&self, dir: Direction) -> Vec<(LaneID, LaneType)>

source

pub(crate) fn incoming_lanes( &self, i: IntersectionID ) -> Vec<(LaneID, LaneType)>

Returns lanes from the “center” going out

Trait Implementations§

source§

impl Clone for Road

source§

fn clone(&self) -> Road

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 Debug for Road

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Road

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 Road

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 Freeze for Road

§

impl RefUnwindSafe for Road

§

impl Send for Road

§

impl Sync for Road

§

impl Unpin for Road

§

impl UnwindSafe for Road

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>,