#openstreetmap #routing #osm #osrm #parser

osrmreader

A reader for *.osrm files that are used by the routing engine OSRM

2 releases

0.1.1 Sep 17, 2020
0.1.0 Sep 14, 2020

#2090 in Parser implementations

21 downloads per month
Used in nori

MIT/Apache

19KB
154 lines

osrmreader

A fast reader for the *.osrm file format.

These files are used by the routing engine OSRM and are usually extracted from OpenStreetMap data with the tool osrm-extract. An *.osrm file encodes the routing graph as nodes and edges.

Crates.io Documentation

Usage

Add this to your Cargo.toml:

[dependencies]
osrmreader = "0.1"

Example

Here's a simple example that prints all nodes and edges:

use osrmreader::{OsrmReader, Entry};

fn main() -> Result<(), std::io::Error> {
    let f = std::fs::File::open("tests/test.osrm")?;
    let mut reader = OsrmReader::new(f);

    for entry in reader.entries()? {
        match entry {
            Ok(Entry::Nodes(nodes)) => {
                // Read nodes
                for n in nodes {
                    println!("{:?}", n?);
                }
            },
            Ok(Entry::Edges(edges)) => {
                // Read edges
                for e in edges {
                    println!("{:?}", e?);
                }
            },
            _ => {},
        }
    }

    Ok(())
}

License

This project is licensed under either of

at your option.

Dependencies

~2–10MB
~114K SLoC