Build .rd5 routing file for BRouter from .pbf file
I assume that the following code examples are run in a Linux terminal. I use a 64 bit Debian 12 operating system and openjdk 17.0.11 for running Java bytecode on an X86 Acer Aspire 5742 laptop manufactured in 2009 with 240 GB SSD and 4 GB ram.- Download the BRouter source code. Open a terminal, create a new folder and navigate to it
To download the most recent code executemkdir brouter cd brouter
git clone https://github.com/abrensch/brouter.git
. You might have to install git first.Alternatively download and unzip the code fom 2024-05-30 from my website [2.1 MB]
wget --continue https://trafficpixel.tk/share/2024/brouter/brouter_source-2024-05-30.zip unzip brouter_source-2024-05-30.zip mv brouter-master brouter
- Compile BRouter without the app. You need to have installed Java. Check if you have installed Java:
java -version
if it says command not found then you have to install Java first. - Switch the folder
cd brouter/
then start compiling. This needed 3.5 minutes on my laptop../gradlew clean build fatJar
- Download an extract of OpenStreetMap data in .pbf format from Geofabrik, for example Liechtenstein (because it is small and fast to process). You can also merge multiple pbf files.
rename the file to planet-latest.osm.pbfcd misc/scripts/mapcreation/ wget --continue https://download.geofabrik.de/europe/liechtenstein-latest.osm.pbf
mv *.osm.pbf planet-latest.osm.pbf
- The supplied script process_pbf_planet.sh does not work properly because some programs it uses changed and now expect different file name extensions. I changed the script a bit. It copies files and uses more storage but at least it works. Download my adapted script.
wget https://trafficpixel.tk/share/2024/brouter/process_pbf_planet_2024-06-09.sh
This step can be skipped if you already downloaded it earlier. - start the script and start the map creation
sh process_pbf_planet_2024-06-09.sh
- After some time if no error occurs the resulting E5_N45.rd5 files is in the directory tmp/segments.
- If you want to change the lookups.dat file, change the file at brouter/misc/profiles2/lookups.dat. After that you can run the map creation script. Finally copy the changed lookups.dat file to the profiles2 folder on your server, computer or smartphone and the resulting .rd5 files to the segments4 folder.. The lookups.dat file currently contains 2 non-UTF8 characters. This can lead to errors when editing the file. You can download a corrected version from my server
cd ../../profiles2 #changes 2 folders up, then to profiles2 directory mv lookups.dat lookups.dat.bak #saves a backup of the current lookups.dat file at lookups.dat.bak wget https://trafficpixel.tk/share/2024/brouter/lookups.dat #downloads corrected file cd ../scripts/mapcreation #changes back to mapcreation directory
How to install git in Debian based systems
- open a terminal and type
sudo apt install git
, hit the Enter key, enter your password if asked, answer the question if you want to install by pressing the Y key and then hit Enter. After downloading and installing you can download the code. - Alternatively switch to the root account
su root
, enter your password, typeapt install git
and follow the previous procedure. After installing, exit from the root account by typingexit
and hitting the Enter key.
How to install java in a Debian based system
- open a terminal and type
sudo apt install default-jre
, hit the Enter key, enter your password if asked, answer the question if you want to install by pressing the Y key and then hit Enter. After downloading and installing you can use java. - Alternatively switch to the root account
su root
, enter your password, typeapt install default-jre
and follow the previous procedure. After installing, exit from the root account by typingexit
and hitting the Enter key. Back to compiling
How to merge multiple pbf files
- Download all needed .pbf files from Geofabrik merge them using osmium
osmium merge *.pbf -o merged.pbf
- Now copy the file merged.pbf to brouter/misc/scripts/mapcreation/ and rename to planet-latest.osm.pbf . You might have to install osmium first. After that start the map creation
How to install osmium in Debian based systems
- open a terminal and type
sudo apt install osmium-tool
, hit the Enter key, enter your password if asked, answer the question if you want to install by pressing the Y key and then hit Enter. - Alternatively switch to the root account
su root
, enter your password, typeapt install osmium-tool
and follow the previous procedure. After installing, exit from the root account by typingexit
and hitting the Enter key. Back to merge pbf