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
impl Location
Sourcepub fn new(longitude: f32, latitude: f32) -> Self
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
Sourcepub fn display_coordinates(self, display_lat: f32, display_lon: f32) -> Self
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.
Sourcepub fn street_name(self, street: impl ToString) -> Self
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.
Sourcepub fn way_id(self, way_id: i64) -> Self
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.
Sourcepub fn minimum_reachability(self, minimum_reachability: i32) -> Self
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.
Sourcepub fn radius(self, radius: i32) -> Self
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
Sourcepub fn rank_candidates(self, rank_candidates: bool) -> Self
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.
Sourcepub fn preferred_side(self, preferred_side: Side) -> Self
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.
Sourcepub fn type(self, type: LocationType) -> Self
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
Sourcepub fn heading(self, heading: u32) -> Self
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
0°
, - east is
90°
, - south is
180°
, and - west is
270°
.
Sourcepub fn heading_tolerance(self, heading_tolerance: u32) -> Self
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
Sourcepub fn name(self, name: impl ToString) -> Self
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>"
Sourcepub fn search_cutoff(self, search_cutoff: f32) -> Self
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
Sourcepub fn node_snap_tolerance(self, node_snap_tolerance: f32) -> Self
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
Sourcepub fn street_side_tolerance(self, street_side_tolerance: f32) -> Self
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
Sourcepub fn street_side_max_distance(self, street_side_max_distance: f32) -> Self
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
Sourcepub fn street_side_cutoff(self, street_side_cutoff: f32) -> Self
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
orservice_other
.
Default: service_other
so that the preferred side will not be disabled for any edges
Sourcepub fn date_time(self, date_time: NaiveDateTime) -> Self
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.
Sourcepub fn waiting(self, waiting: Duration) -> Self
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.