-
Notifications
You must be signed in to change notification settings - Fork 0
Running OSRM
###Fetch the source
Fetch the source code form GitHub repository
git clone https://github.com/DennisOSRM/Project-OSRM.git
Compilation of the source is usually done through scons. The source comes with a SConstruct that takes care of dependency checking. The SConstruct accepts several optional parameters.
-
--stxxl=/path/to/root_of_stxxlsets the root directory of stxxl when it resides in a non-default path. -
--cxx=/path/to/compiler/g++sets the C++ compiler. GCC and LLVM/Clang work, but Clang has no OpenMP support. -
--build=debug/releaseeither builds in debug (no optimization) or release mode (full optimizations). -
--no-marchwithout any values controls whether to use platform specific optimizations or not. May be handy on (misconfigured) virtual machines that do not support the full instruction set of the underlying hardware.
To launch compilation process just do
$ scons
On Ubuntu with dependencies installed from the repositories there is no need to set any parameters.
If compiling on Red Hat Enterprise Linux, Fedora, or CentOS then you will need to enable the EPEL repositories in order to satisfy dependencies.
To compile on Fedora 14 you will need to first install at least the following dependencies:
yum install sparsehash-devel gcc-c++ libxml2-devel stxxl-devel boost-devel bzip2-devel protobuf-devel scons
To compile on Fedora 15 you will need to first install the following dependencies:
yum install sparsehash-devel gcc-c++ libxml2-devel stxxl-devel boost-devel boost-regex bzip2-devel libzip-devel protobuf-devel sparsehash-devel stxxl-devel ImageMagick-c++-devel libpng libpng-devel
To compile on Cent OS 6 / RHEL 6 you will need to first install the following dependencies:
yum install gcc-c++ libxml2-devel boost-devel bzip2-devel protobuf-devel scons subversion
stxxl-devel and sparsehash-devel are not available in the repositories for these distributions a the time of writing, and must be obtained separately. A sparsehash package can be installed from rpm.pbone.net, ie for 64-bit systems download and install sparsehash-devel-1.10-2.fc15.x86_64.rpm. stxxl will needs to be manually downloaded, extracted and installed on your system as a non root user (clear instructions can be found in the stxxl documentation). You then need to specify the location of your stxxl installation when you use scons using the --stxxl= flag (see below).
OSRM cannot be compiled on RHEL 5 / CentOS 5 without manually compiling a recent version of libboost.
To compile on Debian 6 "Squeeze" you will first need to first install at least the following dependencies:
sudo apt-get install git libboost1.42-dev gcc=4:4.4.5-1 g++=4:4.4.5-1 scons libstxxl-dev libxml2-dev libsparsehash-dev libbz2-dev zlib1g-dev libzip-dev libboost-thread-dev libboost-system-dev libboost-regex-dev libgomp1 libpng-dev
On Debian Squeeze the lib protobuf is in version numebr 6 when OSRM required verison 7, you can install the needed version by your own or install an unofficial backport for Debian/Squeeze. Add the following line to you sources.list to install unofficial backports
deb http://rodolphe.quiedeville.org/debian/ squeeze-backports main
And install the right version's packages.
sudo apt-get install libprotoc7 libprotobuf-dev protobuf-compiler
sudo apt-get install build-essential git scons libprotoc-dev libprotobuf7 protobuf-compiler libprotobuf-dev libpng-dev libbz2-dev libstxxl-dev libstxxl-doc libstxxl1 libxml2-dev libzip-dev libboost-thread-dev libboost-system-dev libboost-regex-dev
To compile the source on a Mac, please install the homebrew package system. It will provide all necessary dependencies:
brew install boost git scons protobuf-c protobuf libzip libstxxl libxml2
Exported OSM data files can be obtained from providers such as Geofabrik. OSM data comes in a variety of formats including XML and PBF, and contain a plethora of data. The data includes information which is irrelevant to routing, such as positions of public waste baskets. Also, the data does not conform to a hard standard and important information can be described in various ways. Thus it is necessary to extract the routing data into a normalized format. The is done by the OSRM tool named extractor. It parses the contents of the exported OSM file and writes out a file with the suffix .osrm which contains the routing data.
The speed profile can be parameterized as explained here.
Imagine that you download an OSM data file with the name map.osm (an XML file with an .osm extension). You would extract this file using OSRM with the following command: ./osrm-extract map.osm. Extracting an file which contains data pertaining to the entire planet will take a few hours, mostly depending on the speed of the harddisks. On a Core i7 with 8GB RAM and (slow) 5400 RPM Samsung SATA hard disks it took about 65 minutes to do so from a PBF formatted planet. Please note that your mileage may vary and the faster your disks and processory the faster it will be. SSDs are certainly an advantage here. Most of the data is kept on disk, because RAM is scarce and extracting the data of a planet file will take up dozens of gigabytes of RAM. Currently about 35 GB or so. The tool is also able to handle bzip2 compressed files as well as PBF files: ./osrm-extract map.osm.bz2 and ./osrm-extract map.osm.pbf will work fine. PBF is the generally the better choice. Note that preprocessing the planet, i.e. the next step, is much more resource-hungry.
External memory accesses are handles by the stxxl library. Although you can run the code without any special configuration you might see a warning similar to "[STXXL-ERRMSG] Warning: no config file found". Given you have enough free disk space, you can happily ignore the warning or create a config file called .stxxl in the same directory where the extractor tool sits. The following is taken from the stxxl manual:
You must define the disk configuration for an STXXL program in a file named '.stxxl' that must reside in the same directory where you execute the program. You can change the default file name for the configuration file by setting the enviroment variable STXXLCFG .
Each line of the configuration file describes a disk. A disk description uses the following format: disk=full_disk_filename,capacity,access_method
-
full_disk_filename : full disk filename. In order to access disks STXXL uses file access methods. Each disk is respresented as a file. If you have a disk that is mapped in unix to the path /mnt/disk0/, then the correct value for the full_disk_filename would be /mnt/disk0/some_file_name , -
capacity : maximum capacity of the disk in megabytes -
access_method : STXXL has a number of different file access implementations, choose one of them: -
syscall uses read and write system calls which perform disk transfers directly on user memory pages without superfluous copy (currently the fastest method) -
mmap : performs disks transfers using mmap and munmap system calls -
simdisk : simulates timings of the IBM IC35L080AVVA07 disk, full_disk_filename must point to a file on a RAM disk partition with sufficient space
An example config file looks like this: disk=/tmp/stxxl,25000,syscall
It is generally a good idea to have the planet file on a seperate partition since this avoids a large number of concurrent (read: slow, thanks Dennis S.) read/write disk accesses. Creating the Hierarchy
The so-called Hierarchy is a lot of precomputed data, that enables the routing engine to find shortest path within short time. It is created by the the command-line ./osrm-prepare map.osrm map.restrictions, where map.osrm is the extracted road network and map.restrictions is a set of turn restrictions. Both are generated by the previous step. A nearest-neighbor data structure and a node map are created alongside the hierarchy. Once computation has finished, there should be another four files: map.osrm.hsgr (the Hierarchy), map.osrm.nodes (the nodemap), map.osrm.ramIndex (stage 1 index), map.osrm.fileIndex (stage 2 index).
See also the config files page for additional parameters to configure the extractor.
Run the command ./osrm-routed without any parameters. It is fully controlled by a config file named server.ini. See also the config files page for the parameters.
OSRM comes with a number of tests using the cucumber framework. Further information on how to run the tests can be found here.