pub struct GraphHopperHttpRequestGenerator { /* private fields */ }Expand description
A route request generator for GraphHopper backends operating over HTTP.
§WaypointKind
The waypoint kind field of Waypoint is not currently supported in GraphHopper,
as there is no multi-leg support.
However, you can configure whether U-turns are allowed with the pass_through parameter.
Refer to the GraphHopper documentation: https://docs.graphhopper.com/openapi/routing/getroute.
§Waypoint properties
The Waypoint properties field is ignored by this route request generator.
§Examples
use serde_json::{json, Map, Value};
use ferrostar::routing_adapters::graphhopper::{GraphHopperHttpRequestGenerator, GraphHopperVoiceUnits};
let options: Map<String, Value> = json!({
"ch.disable": true,
"custom_model": {
"distance_influence": 15,
"speed": [
{
"if": "road_class == MOTORWAY",
"limit_to": "100"
}
]
}
}).as_object().unwrap().to_owned();
let request_generator = GraphHopperHttpRequestGenerator::new(
"https://graphhopper.com/api/1/navigate/?key=YOUR-API-KEY",
"car",
"en",
GraphHopperVoiceUnits::Metric,
options
);Implementations§
Source§impl GraphHopperHttpRequestGenerator
impl GraphHopperHttpRequestGenerator
Sourcepub fn new<U: Into<String>, P: Into<String>, L: Into<String>>(
endpoint_url: U,
profile: P,
locale: L,
voice_units: GraphHopperVoiceUnits,
options: Map<String, JsonValue>,
) -> Self
pub fn new<U: Into<String>, P: Into<String>, L: Into<String>>( endpoint_url: U, profile: P, locale: L, voice_units: GraphHopperVoiceUnits, options: Map<String, JsonValue>, ) -> Self
Creates a new GraphHopper request generator given an endpoint URL, a profile name, and options to include in the request JSON.
§Examples
use serde_json::{json, Map, Value};
use ferrostar::routing_adapters::graphhopper::{GraphHopperHttpRequestGenerator, GraphHopperVoiceUnits};
let options: Map<String, Value> = json!({
"ch.disable": true,
"custom_model": {
"distance_influence": 15,
"speed": [
{
"if": "road_class == MOTORWAY",
"limit_to": "100"
}
]
}
}).as_object().unwrap().to_owned();
let request_generator = GraphHopperHttpRequestGenerator::new(
"https://graphhopper.com/api/1/navigate/?key=YOUR-API-KEY",
"car",
"en",
GraphHopperVoiceUnits::Metric,
options
);Sourcepub fn with_options_json<U: Into<String>, P: Into<String>, L: Into<String>>(
endpoint_url: U,
profile: P,
locale: L,
voice_units: GraphHopperVoiceUnits,
options_json: Option<&str>,
) -> Result<Self, InstantiationError>
pub fn with_options_json<U: Into<String>, P: Into<String>, L: Into<String>>( endpoint_url: U, profile: P, locale: L, voice_units: GraphHopperVoiceUnits, options_json: Option<&str>, ) -> Result<Self, InstantiationError>
Creates a new GraphHopper request generator given an endpoint URL, a profile name, and options to include in the request JSON. Options in this constructor are a JSON fragment representing any options you want to add along with the request.
§Examples
let options = r#"{
"ch.disable": true,
"custom_model": {
"distance_influence": 15,
"speed": [
{
"if": "road_class == MOTORWAY",
"limit_to": "100"
}
]
}
}"#;
// Without options
let request_generator = GraphHopperHttpRequestGenerator::with_options_json(
"https://graphhopper.com/api/1/navigate/?key=YOUR-API-KEY",
"car",
"en",
GraphHopperVoiceUnits::Metric,
None
);
// With options
let request_generator = GraphHopperHttpRequestGenerator::with_options_json(
"https://graphhopper.com/api/1/navigate/?key=YOUR-API-KEY",
"car",
"en",
GraphHopperVoiceUnits::Metric,
Some(options)
);Trait Implementations§
Source§impl RouteRequestGenerator for GraphHopperHttpRequestGenerator
impl RouteRequestGenerator for GraphHopperHttpRequestGenerator
Source§fn generate_request(
&self,
user_location: UserLocation,
waypoints: Vec<Waypoint>,
) -> Result<RouteRequest, RoutingRequestGenerationError>
fn generate_request( &self, user_location: UserLocation, waypoints: Vec<Waypoint>, ) -> Result<RouteRequest, RoutingRequestGenerationError>
Auto Trait Implementations§
impl Freeze for GraphHopperHttpRequestGenerator
impl RefUnwindSafe for GraphHopperHttpRequestGenerator
impl Send for GraphHopperHttpRequestGenerator
impl Sync for GraphHopperHttpRequestGenerator
impl Unpin for GraphHopperHttpRequestGenerator
impl UnsafeUnpin for GraphHopperHttpRequestGenerator
impl UnwindSafe for GraphHopperHttpRequestGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more