openrouteservice 0.2.0

rust interface to openrouteservice instances
docs.rs failed to build openrouteservice-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: openrouteservice-0.1.0

openrouteservice

Documentation

Rust interface to the openrouteservice API

Currently targeting the v2 API.

Quickstart

See examples/ or the crate docs for more details.

Library use

$ cargo add openrouteservice --features async,isochrones
use openrouteservice::{
    Client, ClientConfigBuilder, Coord, 
    Profile, isochrones::RequestBuilder,
};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let api_key = "0xdeadbeef"; // replace with your key
    let cfg = ClientConfigBuilder::default()
        .api_key(Some(api_key))
        .build()?;
    let ors = Client::new(cfg)?;
    let req = RequestBuilder::default()
        .profile(Profile::DrivingCar)
        .locations(vec![(11.57, 48.13).into()])
        .range(vec![200])
        .build()?;
    let resp = ors.execute(&req).await?;
    println!("{}", resp.to_string());
    Ok(())
}

Or sync, if you want. Same general interface, just use --features blocking and the blocking::Client.

Command-line interface

Use API_KEY and BASE_URL as environment variables or pass them directly.

$ cargo build --features cli

Test your local instance:

$ ors --base-url http://localhost:8080/ors/ health
{"status":"ready"}
$ ors --base-url http://localhost:8080/ors/ status
... large json response ... 

Run queries on the public instance:

$ ors --api-key ORS_KEY \
      isochrones \
      --profile driving-car \
      --locations 11.6,48 \
      --range 100
... geojson response ...
$ API_KEY=ORS_KEY ors \ # env variables!
      isochrones \
      --profile driving-car \
      --locations 11.6,48 \
      --range 100
... geojson response ...
$ ors --base-url http://localhost:8080/ors/ \
      isochrones \
      --profile driving-car \
      --locations [[11.6,48.0]] \
      --range 100
... geojson response ...

License

MIT License

Contribution

Project management is at Gitlab