Crates.io | rsc_osrm |
lib.rs | rsc_osrm |
version | 0.1.50 |
source | src |
created_at | 2020-10-06 08:06:24.861294 |
updated_at | 2024-02-29 06:47:22.252534 |
description | rust wrapper for osrm, folk from TehGoat/rs_osrm |
homepage | |
repository | https://src.nextbillion.io/map/rsc_osrm |
max_upload_size | |
id | 296531 |
size | 174,655 |
to link final binary, you need: 0. libosrm.a
use rsc_osrm::{EngineConfig, Osrm, Algorithm, Status, route::RouteRequest, general::Coordinate};
fn main() {
let mut config = EngineConfig::new("<path to your .osrm file>");
config.use_shared_memory = false;
config.algorithm = Algorithm::MLD;
let osrm = Osrm::new(&mut config).unwrap();
let coords = vec!(Coordinate{latitude:12.98657118,longitude:77.56644753}, Coordinate{latitude:12.97436012,longitude:77.62567071});
let mut request = RouteRequest::new(&coords);
let (status,result) = request.run(&osrm);
match status{
Status::Ok => {
let route0 = &result.routes[0];
println!("eta: {}, eda: {}, geometry: {}",route0.duration, route0.distance, (route0.geometry).as_ref().unwrap());
}
_ => println!("call osrm failed"),
}
}