Routing API
There is a standalone app that can be used as a routing-api:
https://github.com/itinero/routing-api
Setup
Basically you need build the project and place a RouterDb file into the configured data folder.
- Install .NET core for your platform.
- Run the build script, build.sh or build.bat on windows.
- Then download a RouterDb file or create one using the Itinero data processing tool.
- Place the RouterDb file into the configured data folder, by default this is ./src/Itinero.API/data. Configuration file is here.
- Run the run script, run.sh or run.bat on windows.
You should new see the service reporting messages on loading the RouterDb's you configured:
[Bootstrapper] information - Loading all routerdb's from path: \path\to\src\Itinero.API\data
[Bootstrapper] information - Loaded instance luxembourg from: \path\to\src\Itinero.API\data\luxembourg.c.cf.routerdb
Hosting environment: Production
Content root path: \path\to\src\Itinero.API
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
[Bootstrapper] information - Loaded instance belgium from: \path\to\src\Itinero.API\data\belgium.c.cf.routerdb
[Bootstrapper] information - Loaded instance netherlands from: \path\to\rc\Itinero.API\data\netherlands.c.cf.routerd
API
When the service is setup one instance per RouterDb will be available. The name of the instance is identical to the name of the file until the first '.'. For example, 'belgium.c.cf.routerdb' will be 'belgium'.
By default when opening your browser at http://localhost:5000/ there will be a list with loaded instances. When you click one of the instances a map will open centered on the loaded area, clicking on the map still set a startpoint and clicking again an instance.
The following is available:
- http://localhost:5000/ : A list of loaded instances.
- http://localhost:5000/{instance} : The map centered on the loaded area in the instance with routing enable for cars.
The API:
http://localhost:5000/{instance}/routing : Accepts requests using the following parameters:
- profile: One of the profiles loaded in the RouterDb, think car, bicycle or pedestrian.
- loc: Add this parameter at least twice, first is startpoint, last is the destination.
Make sure to ask the API for JSON by adding Content-Type: application/json header. The route is returned as GeoJson.
Example: http://localhost:5000/belgium/routing?profile=car&loc=51.055207,3.722992&loc=50.906497,4.194031