A routing system (using algorithms such as Djikstra, A*, Bellman-Ford, etc.) in Rust. It supports loading from OSM data, or from a SQL database (at the moment, Postgres). The application was primarily created to have a flexible routing algorithm for electric vehicles (where distance and duration are equally important as energy use). If we want to compute the energy requirements along a certain route, its edge weights can become negative, which prevents the use of many graph routing algorithms such as Djikstra.
The Bellman-Ford algorithm was thus originally used for route computation within this application. In the meantime, other routing algorithms have been implemented and it's up to the user to choose an appropriate one.
This v0.0.1
is not thought to be used in a production environment (obviously?)! It changed a lot from the initial version and is basically untested at the moment. Also, reachability and route requests take quite some time on large graphs (it uses Bellman-Ford by default...)!
Attention: You need to have rust-geotiff cloned into a folder next to the e-routing one for anything below to work! You can check this in the Cargo.toml
file, where you'll see a lib
entry specifying this! This will be resolved in the future at some point 😊.
You can run the application directly using cargo
. Run using one of the following two commands:
cargo run build-graph config-file.json
cargo run run-server config-file.json
The first will take an OpenStreetMap file and build a graph from it. The second uses this graph to host a web server that can be used for routing. The specification of the OSM file and server configuration can be supplied with the optional config-file.json
file; otherwise the default file default-conf.json
will be used. You can look at this default file to see what can be specified how.
To have a faster-running executable, use the following code to build, and then execute the application (the example is on Windows):
cargo build --release
target\release\bellman_osm.exe build-graph config-file.json
Attention: Make sure to be in the right directory, as the implementation uses the current directory to look for index.html
, i.e., under src/static
.
Running one of the above commands (either cargo run
or cargo build
plus running) sets up a server with the following endpoints (default port 5001):
-
http://127.0.0.1:5001: Interactive map to showcase routing.
-
/api/route: Handles routing requests. Takes the following parameters:
source-lon
(e.g.,=8.545
): The source longitude.source-lat
(e.g.,=47.407
): The source latitude.target-lon
(e.g.,=8.531
): The target longitude.target-lat
(e.g.,=47.366
): The target latitude.
-
/api/route-using-ids: Handles routing requests, if the node IDs are known:
source-id
(e.g.,=1
): The source ID.target-id
(e.g.,=5
): The target ID.
-
/api/reachability: Computes a reachability graph. Takes the following parameters:
source-lon
(e.g.,=8.545
): The source longitude.source-lat
(e.g.,=47.407
): The source latitude.capacity
(e.g.,=50.0
): The capacity in terms of edge weights (e.g., an electric vehicle could have some kWh of capacity, which would determine the maximal distance it can drive).
Clone the repository and run cargo test
to get started! Pull requests are welcome, don't forget to add yourself to the AUTHORS.md
file.
This application uses transport mode specifications written in Gluon. As for now, there is only a single transport mode supported: car.glu
. Feel free to create new ones!
The use of the spade
crate is a bit involved. Basically, whenever spade upgrades (as for now, it's fixed in Cargo.toml
), you have to take the version of cgmath
from the spade
repository, and enter it in Cargo.toml
. Otherwise cargo
will complain that Point2
does not implement PointN
(from spade
).