Struct citymapper::Client
[−]
[src]
pub struct Client { /* fields omitted */ }
Interface to the CityMapper API
Methods
impl Client
[src]
The main interface for making calls to CityMapper
fn travel_time<T: Into<Option<TimeConstraint>>>(
&self,
start_coord: (f64, f64),
end_coord: (f64, f64),
time_constraint: T
) -> Box<Future<Item = i32, Error = Error>>
&self,
start_coord: (f64, f64),
end_coord: (f64, f64),
time_constraint: T
) -> Box<Future<Item = i32, Error = Error>>
Returns a future containing the travel time from start coord to end coord as per the citymapper api documented at https://citymapper.3scale.net/docs
Arguments
start_coord
- The (latitude, longitude) pair to start fromend_coord
- The (latitude, longitude) pair to start fromtime_constraint
- If specified is an instance ofTimeConstraint
specifying time constraints on the calculation of the travel time.
Returns
A future which will resolve to the number of minutes to travel.
Example
let start_coord = (51.525246, 0.084672); let end_coord = (51.559098, 0.074503); let response_without_time_constraint = client.travel_time(start_coord, end_coord, None); let time_info = citymapper::TimeConstraint::arrival_by( chrono::Utc::now() + chrono::Duration::seconds(1800), ); let response_with_time_constraint = client.travel_time(start_coord, end_coord, time_info);
fn single_point_coverage(
&self,
point: (f64, f64)
) -> Box<Future<Item = PointCoverage, Error = Error>>
&self,
point: (f64, f64)
) -> Box<Future<Item = PointCoverage, Error = Error>>
Check whether a single (latitude, longitude) pair is covered by citymapper
Arguments
- coord - The (latitiude, longitude) pair to check for coverage
Returns
A future which resolves to a PointCoverage
struct.
Example
let coord = (51.525246, 0.084672); let response = client.single_point_coverage(coord);
fn coverage(
&self,
points: Vec<MultiPointCoverageQuery>
) -> Box<Future<Item = Vec<PointCoverage>, Error = Error>>
&self,
points: Vec<MultiPointCoverageQuery>
) -> Box<Future<Item = Vec<PointCoverage>, Error = Error>>
Check whether multiple (latitude, longitude) pairs are covered by citymapper
Arguments
- points - A set of
MultiPointCoverageQuery
to check for coverage
Returns
A future which resolves to a Vec<PointCoverage>
Example
let coord = (51.525246, 0.084672); let point1 = MultiPointCoverageQuery::new(coord, "someid".to_string()); let coord2 = (52.345, 0.0745); let point2 = MultiPointCoverageQuery::new(coord2, None); let response = client.coverage(vec![point1, point2]);