pub struct Road {Show 17 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 src_i: IntersectionID,
pub dst_i: IntersectionID,
pub crosswalk_forward: bool,
pub crosswalk_backward: bool,
pub transit_stops: BTreeSet<TransitStopID>,
}
Expand description
A Road represents a segment between exactly two Intersections. It contains Lanes as children.
Fields
id: RoadID
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.
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
Implementations
sourceimpl Road
impl Road
pub(crate) fn lane_specs(&self) -> Vec<LaneSpec>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn shift_from_left_side(
&self,
width_from_left_side: Distance
) -> Result<PolyLine>
sourcepub(crate) fn dir_and_offset(&self, lane: LaneID) -> (Direction, usize)
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
!
pub fn parking_to_driving(&self, parking: LaneID) -> Option<LaneID>
pub(crate) fn speed_limit_from_osm(&self) -> Speed
sourcepub fn find_closest_lane<F: Fn(&Lane) -> bool>(
&self,
from: LaneID,
filter: F
) -> Option<LaneID>
pub fn find_closest_lane<F: Fn(&Lane) -> bool>(
&self,
from: LaneID,
filter: F
) -> Option<LaneID>
Includes off-side
sourcepub fn get_dir_change_pl(&self, map: &Map) -> PolyLine
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.
pub fn get_half_width(&self) -> Distance
pub fn get_width(&self) -> Distance
pub fn get_thick_polygon(&self) -> Polygon
pub fn length(&self) -> Distance
sourcepub fn get_half_polygon(&self, dir: Direction, map: &Map) -> Result<Polygon>
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 multipe direction changes (like a two-way cycletrack adjacent to a regular two-way road), the results are probably weird.
pub fn get_name(&self, lang: Option<&String>) -> String
pub fn get_rank(&self) -> RoadRank
pub fn get_detailed_rank(&self) -> usize
pub fn is_light_rail(&self) -> bool
pub fn is_footway(&self) -> bool
pub fn is_service(&self) -> bool
pub fn is_cycleway(&self) -> bool
pub fn is_driveable(&self) -> bool
pub fn common_endpoint(&self, other: &Road) -> CommonEndpoint
sourcepub fn other_endpt(&self, i: IntersectionID) -> IntersectionID
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
pub fn is_private(&self) -> bool
pub(crate) fn access_restrictions_from_osm(&self) -> AccessRestrictions
pub fn get_zone<'a>(&self, map: &'a Map) -> Option<&'a Zone>
sourcepub fn is_extremely_short(&self) -> bool
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.
sourcepub fn directed_id_from(&self, i: IntersectionID) -> DirectedRoadID
pub fn directed_id_from(&self, i: IntersectionID) -> DirectedRoadID
Get the DirectedRoadID pointing to the intersection. Panics if the intersection isn’t an endpoint.
sourcepub fn directed_id_to(&self, i: IntersectionID) -> DirectedRoadID
pub fn directed_id_to(&self, i: IntersectionID) -> DirectedRoadID
Get the DirectedRoadID pointing from the intersection. Panics if the intersection isn’t an endpoint.
pub(crate) fn recreate_lanes(&mut self, lane_specs_ltr: Vec<LaneSpec>)
sourcepub fn get_lanes_between(&self, l1: LaneID, l2: LaneID) -> Vec<LaneID>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn get_lanes_between(&self, l1: LaneID, l2: LaneID) -> Vec<LaneID>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns all lanes located between l1 and l2, exclusive.
sourcepub fn high_stress_for_bikes(&self, map: &Map, dir: Direction) -> bool
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.
sourceimpl Road
impl Road
sourcepub(crate) fn children_forwards(&self) -> Vec<(LaneID, LaneType)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub(crate) fn children_forwards(&self) -> Vec<(LaneID, LaneType)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
These are ordered from closest to center lane (left-most when driving on the right) to farthest (sidewalk)
pub(crate) fn children_backwards(&self) -> Vec<(LaneID, LaneType)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub(crate) fn children(&self, dir: Direction) -> Vec<(LaneID, LaneType)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Road
impl<'de> Deserialize<'de> for Road
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 Road
impl Send for Road
impl Sync for Road
impl Unpin for Road
impl UnwindSafe for Road
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