23 releases (11 stable)

1.0.10 Oct 24, 2020
1.0.7 Jun 10, 2020
1.0.3 Mar 28, 2020
0.6.0 Mar 8, 2020

#309 in Parser implementations

Download history 40/week @ 2020-08-09 40/week @ 2020-08-16 1/week @ 2020-08-23 40/week @ 2020-08-30 60/week @ 2020-09-06 20/week @ 2020-09-27 20/week @ 2020-10-04 12/week @ 2020-10-11 32/week @ 2020-10-18 9/week @ 2020-10-25 11/week @ 2020-11-01 20/week @ 2020-11-08 19/week @ 2020-11-15

87 downloads per month

MIT license

8MB
170K SLoC

C++ 97K SLoC // 0.1% comments Gherkin (Cucumber) 29K SLoC // 0.0% comments JavaScript 10K SLoC // 0.3% comments Lua 5K SLoC // 0.1% comments Rust 4K SLoC // 0.0% comments Go 4K SLoC // 0.1% comments Python 3.5K SLoC // 0.2% comments PHP 3K SLoC // 0.4% comments C# 3K SLoC // 0.2% comments Kotlin 2.5K SLoC // 0.0% comments Java 2K SLoC // 0.2% comments TypeScript 1.5K SLoC // 0.4% comments Dart 1.5K SLoC // 0.2% comments Shell 1K SLoC // 0.4% comments Batch 722 SLoC // 0.1% comments FlatBuffers Schema 508 SLoC // 0.1% comments C 501 SLoC // 0.2% comments Coq 485 SLoC Prolog 13 SLoC INI 7 SLoC

rs_osrm

Crates.io

License: MIT

Rust wrapper for osrm

Requeries that osrm's dependencies is installed

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