Struct Location

Source
pub struct Location { /* private fields */ }
Expand description

A location is a point on the map that can be used to start or end a route.

Implementations§

Source§

impl Location

Source

pub fn new(longitude: f32, latitude: f32) -> Self

Create a Location from latitude/longitude of the location in degrees.

This is assumed to be both routing location and display location is equal. See Self::display_coordinates to change the display location

Source

pub fn display_coordinates(self, display_lat: f32, display_lon: f32) -> Self

Display Coordinate location in degrees.

Will be used to determine the side of street. Must be valid to achieve the desired effect.

Source

pub fn street_name(self, street: impl ToString) -> Self

Sets the Street name.

May be used to assist finding the correct routing location at the specified coordinate. This is not currently implemented.

Source

pub fn way_id(self, way_id: i64) -> Self

Sets the OpenStreetMap identification number for a polyline way.

The way ID may be used to assist finding the correct routing location at the specified coordinate. This is not currently implemented.

Source

pub fn minimum_reachability(self, minimum_reachability: i32) -> Self

Sets the Minimum number of nodes (intersections) reachable for a given edge (road between intersections) to consider that edge as belonging to a connected region.

When correlating this location to the route network, try to find candidates who are reachable from this many or more nodes (intersections). If a given candidate edge reaches less than this number of nodes it is considered to be a disconnected island, and we will search for more candidates until we find at least one that isn’t considered a disconnected island. If this value is larger than the configured service limit it will be clamped to that limit.

Default: 50 reachable nodes.

Source

pub fn radius(self, radius: i32) -> Self

The number of meters about this input location within which edges (roads between intersections) will be considered as candidates for said location.

When correlating this location to the route network, try to only return results within this distance (meters) from this location. If there are no candidates within this distance it will return the closest candidate within reason. If this value is larger than the configured service limit it will be clamped to that limit.

Default: 0 meters

Source

pub fn rank_candidates(self, rank_candidates: bool) -> Self

Whether or not to rank the edge candidates for this location.

The ranking is used as a penalty within the routing algorithm so that some edges will be penalized more heavily than others:

  • If true, candidates will be ranked according to their distance from the input and various other attributes.
  • If false the candidates will all be treated as equal which should lead to routes that are just the most optimal path with emphasis about which edges were selected.
Source

pub fn preferred_side(self, preferred_side: Side) -> Self

Which side of the road the location should be visited from.

Whether the location should be visited from the Side::Same, Side::Opposite or Side::Either side of the road with respect to the side of the road the given locale drives on:

  • In Germany (driving on the right side of the road), passing a value of same will only allow you to leave from or arrive at a location such that the location will be on your right.
  • In Australia (driving on the left side of the road), passing a value of same will force the location to be on your left.

A value of opposite will enforce arriving/departing from a location on the opposite side of the road from that which you would be driving on while a value of either will make no attempt limit the side of street that is available for the route.

Note: If the location is not offset from the road centerline or is closest to an intersection this option has no effect.

Source

pub fn type(self, type: LocationType) -> Self

Sets the type of the location

Either LocationType::Break, LocationType::Through, LocationType::Via or LocationType::BreakThrough. The types of the first and last locations are ignored and are treated as LocationType::Break. Each type controls two characteristics:

  • whether or not to allow an u-turn at the location and
  • whether or not to generate guidance/legs at the location.

Here is their behaviour:

  • A LocationType::Break is a location at which we allows u-turns and generate legs and arrival/departure maneuvers.
  • A LocationType::Through location is a location at which we neither allow u-turns nor generate legs or arrival/departure maneuvers.
  • A LocationType::Via location is a location at which we allow u-turns, but do not generate legs or arrival/departure maneuvers.
  • A LocationType::BreakThrough location is a location at which we do not allow u-turns, but do generate legs and arrival/departure maneuvers.

Default: LocationType::Break

Source

pub fn heading(self, heading: u32) -> Self

Preferred direction of travel for the start from the location.

This can be useful for mobile routing where a vehicle is traveling in a specific direction along a road, and the route should start in that direction. The heading is indicated in degrees from north in a clockwise direction:

  • where north is ,
  • east is 90°,
  • south is 180°, and
  • west is 270°.
Source

pub fn heading_tolerance(self, heading_tolerance: u32) -> Self

How close in degrees a given street’s heading angle must be in order for it to be considered as in the same direction of the heading parameter.

The heading angle can be set via Self::heading

Default: 60 degrees

Source

pub fn name(self, name: impl ToString) -> Self

Location or business name.

May be used in the route narration directions. Example: "You have arrived at <business name>"

Source

pub fn search_cutoff(self, search_cutoff: f32) -> Self

Cutoff at which we will assume the input is too far away from civilisation to be worth correlating to the nearest graph elements.

Default: 35 km

Source

pub fn node_snap_tolerance(self, node_snap_tolerance: f32) -> Self

During edge correlation this is the tolerance used to determine whether or not to snap to the intersection rather than along the street, if the snap location is within this distance from the intersection is used instead.

Default: 5 meters

Source

pub fn street_side_tolerance(self, street_side_tolerance: f32) -> Self

Sets the tolerance for street side changes.

The value means:

  • If your input coordinate is less than this tolerance away from the edge centerline then we set your side of street to none.
  • Otherwise your side of street will be left or right depending on direction of travel.

Default: 5 meters

Source

pub fn street_side_max_distance(self, street_side_max_distance: f32) -> Self

The max distance in meters that the input coordinates or display ll can be from the edge centerline for them to be used for determining the side of street.

Beyond this distance the side of street is set to none.

Default: 1000 meters

Source

pub fn street_side_cutoff(self, street_side_cutoff: f32) -> Self

Allows configuring the preferred side selection.

Disables the preferred side (set via Self::preferred_side) when set to Side::Same or Side::Opposite, if the edge has a road class less than that provided by this value.

The road class must be one of the following strings:

  • motorway,
  • trunk,
  • primary,
  • secondary,
  • tertiary,
  • unclassified,
  • residential or
  • service_other.

Default: service_other so that the preferred side will not be disabled for any edges

Source

pub fn date_time(self, date_time: NaiveDateTime) -> Self

Expected date/time for the user to be at the location in the local time zone of departure or arrival.

Offers more granularity over setting time than the global Manifest::date_time.

If waiting was set on this location in the request, and it’s an intermediate location, the date_time will describe the departure time at this location.

Source

pub fn waiting(self, waiting: Duration) -> Self

The waiting time at this location.

Only works if [Manifest::r#type] was set to

Example: A route describes a pizza delivery tour. Each location has a service time, which can be respected by setting waiting on the location. Then the departure will be delayed by this duration.

Trait Implementations§

Source§

impl Clone for Location

Source§

fn clone(&self) -> Location

Returns a duplicate 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 Location

Source§

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

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

impl Default for Location

Source§

fn default() -> Location

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Location

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 From<&Location> for Waypoint

Source§

fn from(location: &Location) -> Self

Converts to this type from the input type.
Source§

impl From<(f32, f32)> for Location

Source§

fn from((latitude, longitude): Coordinate) -> Self

Converts to this type from the input type.
Source§

impl Serialize for Location

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§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

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

Source§

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

Source§

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

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T