#osrm

rs_osrm

rust wrapper for osrm

15 releases (3 stable)

✓ Uses Rust 2018 edition

new 1.0.2 Mar 25, 2020
0.6.0 Mar 8, 2020
Download history 59/week @ 2020-02-07 57/week @ 2020-02-14 19/week @ 2020-02-21 84/week @ 2020-02-28 114/week @ 2020-03-06 56/week @ 2020-03-13

146 downloads per month

MIT license

8.5MB
178K 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 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

rs_osrm

Crates.io

License: MIT

Rust wrapper for osrm

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 rs_osrm::{EngineConfig, Osrm, Algorithm, Status, nearest::NearestRequest};

fn main() {
    let mut config = EngineConfig::new("<PATH TO .osrm file>");
    config.use_shared_memory = false;
    config.algorithm = Algorithm::MLD;
    let osrm = Osrm::new(&mut config);
    
    let mut request = NearestRequest::new(57.804404, 13.448601);
    request.number_of_results =  3;

    let result = request.run(&osrm);

    if result.0 == Status::Ok {
        if result.1.code.is_some() {
            println!("code: {}", result.1.code.unwrap());
        }

        if result.1.waypoints.is_some() {
            for waypoint in result.1.waypoints.unwrap() {
                println!("lat: {}, lon: {}, name: {}", waypoint.location[1], waypoint.location[0], waypoint.name);
            }
        }
    } else {
        if result.1.code.is_some() {
            println!("code: {}", result.1.code.unwrap());
        }
        if result.1.message.is_some() {
            println!("message: {}", result.1.message.unwrap());
        }
    }

}


No runtime deps