26 releases (14 stable)

2.0.1 Nov 18, 2022
1.0.11 May 19, 2021
1.0.10 Oct 24, 2020
1.0.7 Jun 10, 2020
0.6.0 Mar 8, 2020

#488 in Parser implementations

30 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 Rust 5K SLoC // 0.0% comments Lua 5K SLoC // 0.1% comments Go 4K SLoC // 0.1% comments Python 3.5K SLoC // 0.2% comments C# 3.5K SLoC // 0.2% comments PHP 3K SLoC // 0.4% 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 422 SLoC // 0.2% comments Bazel 375 SLoC // 0.2% comments Prolog 226 SLoC // 0.2% comments K 67 SLoC // 0.0% comments D 43 SLoC // 0.1% comments INI 7 SLoC Forge Config 2 SLoC Bitbake 1 SLoC // 0.8% comments

rs_osrm

Crates.io

License: MIT

Rust wrapper for osrm

Requeries that osrm's dependencies is installed

How to use:

  1. Create an EngineConfigBulter, pass path to .osrm file. You may change other settings, see osrm documentation.
  2. Create a request object (ex: NearestRequest) using builder (ex: NearestRequestBuilder)
  3. Call run on the request object and pass in osrm.

Nearest example:

 use crate::{
    engine_config::engine_config_builder::EngineConfigBuilder,
    nearest_api::nearest_request_builder::NearestRequestBuilder, Status,
};

fn main() {
    let osrm_result = EngineConfigBuilder::new("<PATH TO .osrm FILE>")
        .set_use_shared_memory(false)
        .set_algorithm(crate::Algorithm::MLD)
        .build();

    match osrm_result {
        Ok(osrm) => {
            let request = NearestRequestBuilder::new(57.804404, 13.448601)
                .set_number_of_results(3)
                .build();

            match request {
                Ok(mut nearest_request) => {
                    let (status, nearest_result) = nearest_request.run(&osrm);

                    if status == Status::Ok {
                        if nearest_result.code.is_some() {
                            println!("code: {}", nearest_result.code.unwrap());
                        }

                        if nearest_result.waypoints.is_some() {
                            for waypoint in nearest_result.waypoints.unwrap() {
                                println!(
                                    "lat: {}, lon: {}, name: {}",
                                    waypoint.location[1], waypoint.location[0], waypoint.name
                                );
                            }
                        }
                    } else {
                        if nearest_result.code.is_some() {
                            println!("code: {}", nearest_result.code.unwrap());
                        }
                        if nearest_result.message.is_some() {
                            println!("message: {}", nearest_result.message.unwrap());
                        }
                    }
                }
                Err(request_error) => {
                    eprintln!("{request_error}");
                }
            }
        }
        Err(osrm_error) => {
            eprintln!("{osrm_error}");
        }
    }
}


No runtime deps