Crate routx

Crate routx 

Source
Expand description

Simple routing over OpenStreetMap data.

Routx converts OSM data into a standard weighted directed graph representation, and runs A* to find shortest paths between nodes. Interpretation of OSM data is customizable via profiles. Routx supports one-way streets, access tags (on ways only) and turn restrictions.

§Example

let mut g = routx::Graph::new();
let osm_options = routx::osm::Options {
    profile: &routx::osm::CAR_PROFILE,
    file_format: routx::osm::FileFormat::Unknown,
    bbox: [0.0; 4],
};
routx::osm::add_features_from_file(
    &mut g,
    &osm_options,
    "path/to/monaco.osm.pbf",
).expect("failed to load monaco.osm");

let start_node = g.find_nearest_node(43.7384, 7.4246).unwrap();
let end_node = g.find_nearest_node(43.7478, 7.4323).unwrap();
let route = routx::find_route_without_turn_around(&g, start_node.id, end_node.id, routx::DEFAULT_STEP_LIMIT)
    .expect("failed to find route");

println!("Route: {:?}", route);

Modules§

c
C bindings for this library.
osm
OpenStreetMap data parsing into a Graph.

Structs§

Edge
Represents an outgoing (one-way) connection from a specific Node.
Graph
Represents an OpenStreetMap network as a set of Nodes and Edges between them.
KDTree
KDTree implements the k-d tree data structure, which can be used to speed up nearest-neighbor search for large datasets.
Node
Represents an element of the Graph.

Enums§

AStarError
Error conditions which may occur during find_route or find_route_without_turn_around.

Constants§

DEFAULT_STEP_LIMIT
Recommended number of allowed node expansions in find_route and find_route_without_turn_around before AStarError::StepLimitExceeded is returned.

Functions§

earth_distance
Calculates the great-circle distance between two lat-lon positions on Earth using the haversine formula. Returns the result in kilometers.
find_route
Uses the A* algorithm to find the shortest route between two nodes in the provided graph.
find_route_without_turn_around
Uses the A* algorithm to find the shortest route between two points in the provided graph.