#osrm

rsc_osrm

rust wrapper for osrm, folk from TehGoat/rs_osrm

11 releases

new 0.1.10 Oct 19, 2020
0.1.9 Oct 17, 2020

#231 in Parser implementations

Download history 107/week @ 2020-10-01 50/week @ 2020-10-08 92/week @ 2020-10-15

62 downloads per month

MIT license

8.5MB
179K SLoC

C++ 98K SLoC // 0.1% comments Gherkin (Cucumber) 29K SLoC // 0.0% comments JavaScript 10K SLoC // 0.3% comments Lua 5K SLoC // 0.1% comments Dart 5K SLoC // 0.1% comments C# 5K SLoC // 0.2% comments Rust 4.5K SLoC // 0.0% comments Go 4.5K SLoC // 0.1% comments Python 4K SLoC // 0.2% comments PHP 3.5K SLoC // 0.4% comments Java 3K SLoC // 0.3% comments Kotlin 2.5K SLoC // 0.0% comments TypeScript 2K SLoC // 0.5% comments Shell 1K SLoC // 0.4% comments Batch 722 SLoC // 0.1% comments FlatBuffers Schema 508 SLoC // 0.1% comments C 294 SLoC // 0.2% comments INI 7 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