#osrm #rsc

rsc_osrm

rust wrapper for osrm, folk from TehGoat/rs_osrm

50 releases

new 0.1.50 Feb 29, 2024
0.1.47 Sep 21, 2023
0.1.46 Jun 1, 2023
0.1.44 Mar 10, 2023
0.1.16 Nov 13, 2020

#1 in #osrm

Download history 9/week @ 2023-11-09 7/week @ 2023-11-16 95/week @ 2023-11-23 143/week @ 2023-11-30 3/week @ 2023-12-07 48/week @ 2023-12-14 96/week @ 2023-12-21 2/week @ 2023-12-28 2/week @ 2024-01-11 78/week @ 2024-01-18 48/week @ 2024-01-25 136/week @ 2024-02-01 55/week @ 2024-02-08 685/week @ 2024-02-15 1147/week @ 2024-02-22

2,023 downloads per month

MIT license

155KB
4K SLoC

Rust 2.5K SLoC // 0.0% comments C++ 2K SLoC

rsc_osrm

Crates.io

License: MIT

Rust wrapper for osrm

Requeries that osrm's dependencies is installed

to link final binary, you need: 0. libosrm.a

  1. libboost_filesystem.so
  2. libboost_iostreams.so
  3. libboost_thread.so
  4. libboost_system.so

How to use:

  1. Create an EngineConfig, pass path to .osrm file. You may change other settings, see osrm documentation.
  2. Create an Osrm via Osrm::new and pass in the config.
  3. Create a request object (ex: NearestRequest), recomended to always use ::new to get correct default values.
  4. Call run on the request object and pass in osrm.

Nearest example:

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"),
    }
}

No runtime deps

~215KB