pub struct Route { /* private fields */ }Expand description
A planned passage.
Implementations§
Source§impl Route
impl Route
Sourcepub fn new(waypoints: Vec<Position>, kind: LegKind) -> Result<Self>
pub fn new(waypoints: Vec<Position>, kind: LegKind) -> Result<Self>
Builds a route from an ordered list of waypoints.
§Errors
Returns NavigationError::InsufficientNodes for fewer than two
waypoints, since one position is a destination and not a passage.
Sourcepub fn legs(&self) -> Result<Vec<RouteLeg>>
pub fn legs(&self) -> Result<Vec<RouteLeg>>
The legs, each with its course and distance.
§Errors
Propagates a sailing failure, notably a rhumb line through a pole.
Sourcepub fn total_distance(&self) -> Result<Distance>
pub fn total_distance(&self) -> Result<Distance>
Sourcepub fn passage_time(&self, speed: Speed) -> Result<Duration>
pub fn passage_time(&self, speed: Speed) -> Result<Duration>
How long the passage takes at a given speed.
§Errors
As Route::legs, plus NavigationError::Indeterminate if the speed
is zero or runs the wrong way.
Sourcepub fn speed_required(&self, available: Duration) -> Result<Speed>
pub fn speed_required(&self, available: Duration) -> Result<Speed>
The speed needed to run the whole route in a given time.
§Errors
As Route::legs, plus NavigationError::Indeterminate if no time is
allowed.
Sourcepub fn split_legs(&self, interval: Distance) -> Result<Self>
pub fn split_legs(&self, interval: Distance) -> Result<Self>
The same route with every leg broken into pieces no longer than interval.
This is how a great-circle route is made steerable: each piece is short enough that holding one course over it costs nothing worth having.
§Errors
NavigationError::OutOfRangeifintervalis not positive, or is so small that the route would not fit in memory.- Propagates a sailing failure.
Sourcepub fn progress(&self, position: Position) -> Result<Progress>
pub fn progress(&self, position: Position) -> Result<Progress>
Where a position is in relation to the route.
The leg chosen is the one the ship is actually on — the first whose along-track distance falls within it. If she is off the end of every leg, the nearest leg is used instead, so the answer is always about something.
§Errors
Propagates a sailing failure, and returns
NavigationError::Indeterminate if a leg has no length.