How to Install Open Source Routing Machine (OSRM) on Windows 10
The Open Source Routing Machine (OSRM) is a high-performance routing engine which is designed to provide the fastest routes in road networks. OSRM is used in a variety of applications such as ride-sharing services, logistics and transportation planning. Installing OSRM on Windows 10 involves several steps which are outlined below.
Step 1: Install Dependencies
Before installing OSRM, it is important to install the following dependencies:
CMake: CMake is an open-source, cross-platform family of tools designed to build, test and package software. It is required to compile OSRM. You can download it from the official website.
Git: Git is a distributed version control system designed for software development. It is used to download the source code of OSRM. You can download Git from the official website.
Boost: Boost is a set of libraries for the C++ programming language that provide support for tasks such as linear algebra, graph algorithms, cryptography, and regular expressions. A specific version of boost is required for OSRM to compile. You can download it from the official website.
LibSSL: LibSSL is a cryptography library that provides cryptographic functions within OSRM. You can download it from the official website.
LibOSRM: LibOSRM is the C++ library used by OSRM to generate routes. You can download it from the official website.
Step 2: Compile OSRM
Once you have installed the dependencies, you can compile OSRM by following these steps:
- Open the command prompt by pressing Windows Key + R and typing cmd.
- Navigate to the directory where you want to install OSRM by running the command
cd <directory>. - Clone the OSRM repository using Git by running the command
git clone https://github.com/Project-OSRM/osrm-backend.git. - Navigate to the cloned directory by running the command
cd osrm-backend. - Create a build directory by running the command
mkdir build. - Navigate to the build directory by running the command
cd build. - Run the command
cmake .. -G "Visual Studio 16 2019" -A x64. - Once the command has finished running, open the generated
.slnfile in Visual Studio. - In Visual Studio, select Build > Build Solution from the menu.
- After the build is completed successfully, the OSRM libraries will be located in
osrm-backend/build/lib/.
Step 3: Generate OSRM Data
The next step is to generate the OSRM data by following these steps:
- Navigate to the directory where you downloaded LibOSRM.
- Extract the downloaded
.osm.pbffile. This file contains the OpenStreetMap data. - Open the command prompt by pressing Windows Key + R and typing cmd.
- Navigate to the directory where you compiled OSRM by running the command
cd <directory>/osrm-backend/build. - Run the command
osrm-extract -p ../profiles/car.lua path/to/your/file.osm.pbf. - Run the command
osrm-partition path/to/your/file.osrm. - Run the command
osrm-customize path/to/your/file.osrm.
After the above steps, the generated OSRM data will be located in the same directory as the .osm.pbf file.
Step 4: Testing
Finally, test if OSRM is working by following these steps:
- Open the command prompt by pressing Windows Key + R and typing cmd.
- Navigate to the directory where you generated the OSRM data by running the command
cd <directory>. - Run the command
osrm-routed path/to/your/file.osrm. - Open a web browser and navigate to
http://localhost:5000/route/v1/driving/<location1>;<location2>?steps=true. Replace<location1>and<location2>with the latitude and longitude of two locations you want to route between. - If everything works correctly, you should get a JSON response containing the route information.
Congratulations, you have installed and tested OSRM on Windows 10. You can now use OSRM in your own applications!