1. How to install and use OSRM backend?
1.1 Why we should use OSRM instead of Google Maps.
Currently, API of Google maps only support for a response from request, thus we must futher add money for many requests in production. Thus, a OSRM solution is open-source project which help for personal projects (mobile/ web) or small projects without add more money.
1.2 OSRM solution.
OSRM is Open Source Routing Machine.
Step 1: Download maps: http://download.geofabrik.de/index.html
Note: - Use ``.osm`` file
- docker-hub: https://hub.docker.com/r/osrm/osrm-backend/
- Github link: https://github.com/Project-OSRM/osrm-backend
Step 2: Get Vietnam osm data from Geofabrik website
$wget http://download.geofabrik.de/asia/vietnam-latest.osm.bz2 # For Vietnam
Step 3: Extract maps data via docker command
$docker run -t -i -p 5000:5000 -v "${PWD}:/data" osrm/osrm-backend osrm-extract -p /opt/car.lua /data/vietnam-latest.osm
Step 4: Run partition and customize along with other containers
$docker run -t -i -v $(pwd):/data osrm/osrm-backend osrm-partition /data/vietnam-latest.osrm
$docker run -t -i -v $(pwd):/data osrm/osrm-backend osrm-customize /data/vietnam-latest.osrm
Step 5: Launch a routed map server (online map server)
$docker run -t -i -p 5000:5000 -d -v $(pwd):/data osrm/osrm-backend osrm-routed --algorithm mld /data/vietnam-latest.osrm
$docker ps -a
Step 5: Check running osrm map server
2. Build OSRM front-end.
$docker run -p 9966:9966 osrm/osrm-frontend
Result:
Let’s enjoy with OSRM !!!
Author: Nguyen Van Trung - IRC: trungnv