SYNOPSIS
osrm-extract data [profile.lua]osrm-prepare file.osrm file.osrm.restrictions profile.lua
osrm-routed server.ini
osrm-components data.osrm data.osrm.restrictions
DESCRIPTION
The Open Source Routing Machine (OSRM) is a high performance routing engine for road networks.Setting up OSRM requires first preprocessing OpenStreetMap (OSM) data in to a format which can be used for routing. The speed profile (profile.lua) is used during the process to determine what can and cannot be routed along, and input the speed information in to OSRM.
EXAMPLE
The following example uses an OSM file called planet-latest.osm.pbf, however this will work with raw OSM data, or pbf data. The prefix for the osrm files will be planet-latest, this is taken from the name of the OSM file, if you use a differently named file, you must change the prefix in the below commands. The files used will be placed in /var/cache/osrm, as this is the default location, as set in /etc/osrm/server.ini, the configuration file used by the osrm service.The latest planet file can be downloaded from the planet.openstreetmap.org site by using the following command (run in the /var/lib/osrm directory). Note that you may need to run these commands as root, or change the permissions on the directory:
wget http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf
The following commands assume that the OSM data is in the /var/lib/osrm directory.
For this example, the profile /etc/osrm/profiles/car.lua will be used, but this can either be changed, or a different profile can be used. There are additional sample profiles available in /etc/osrm/profiles. To run the extraction, run:
osrm-extract planet-latest.osm.pbf --profile /etc/osrm/profiles/car.lua
Once finished, you should have the files planet-latest.osrm, planet-latest.osrm.names, planet-latest.osrm.restrictions present. You will also have some stxxl related files, but these are not directly related to osrm.
To proceed, use osrm-prepare to generate the hierarchy:
osrm-prepare planet-latest.osrm --restrictions planet-latest.osrm.restrictions --profile /etc/osrm/profiles/car.lua
In the working directory, you should now have in addition to the above files planet-latest.osrm.hsgr, planet-latest.osrm.edges, planet-latest.osrm.nodes, planet-latest.osrm.ramindex and planet-latest.osrm.fileIndex. You can then start the service.
service osrm restart
If the service starts successfully, you should be able to use the API, if not, check the log file at /var/log.osrm/routed.log, and if necessary, report a bug against the osrm package.
SERVER API
The service api is similar to query strings for HTTP. Three types of query are possible:locate |
Takes latitude and longitude and returns the nearest node in the data to that point.
|
nearest |
Takes latitude and longitude and returns the nearest point on a street segment to that point.
|
viaroute |
Takes multiple latitude, longitude points, and returns a route from the first, through to the last.
|
table |
Takes multiple latitude, longitude points, and returns a distance matrix for each point.
|