Once again, I found it very useful to use Docker (container), so I decided to organize the case as a memorandum.
I wanted to easily use ** OSRM (Open Source Routing Machine) **, a route search engine that uses ** OpenStreetMap (OSM) **, but it seems that it is troublesome to build the environment, so I can not do anything. I was investigating.
In Project-OSRM / osrm-backend, there was the following description.
The easiest and quickest way to setup your own routing engine is to use Docker images we provide.
docker run -t -i -p 5000:5000 -v "${PWD}:/data" osrm/osrm-backend osrm-routed --algorithm mld /data/kanto-latest.osrm &
In this example, ** osrm / osrm-backend ** is the container image and ** osrm-routed ** is the command to run inside the container.
However, the following work is required in advance for this execution. Among them, the following formatting and optimization processing is executed by starting a new container from osrm / osrm-backend (starting the command for that processing as a container).
--Download the map (OSM) used by OSRM --Formatted for use with OSRM --Optimization of speed for walking, cars, bicycles, etc. --Other
Originally, it is said that processing other than ** 2. 6. 7. is required ** by the following procedure, so you can see that you can try it faster and more reliably by using Docker.
For reference, I executed the following command on the route search engine launched above to get the route information (JSON format).
In this example, in order to get the walking route from Kita-Kamakura to the Great Buddha of Kamakura, each location information is thrown to the search engine as a parameter.
curl --noproxy 127.0.0.1 'http://127.0.0.1:5000/route/v1/walking/139.545056,35.337103;139.535689,35.316696?alternatives=3&geometries=geojson' | jq 'def hexdec(i): "0123456789abcdef"[i:i+1]; {"type": "FeatureCollection", "features": [[.routes[].geometry] | [., keys] | transpose[] | {"geometry": .[0], "type": "Feature", "properties": {"stroke-width": 2, "stroke": ("#" + hexdec(15-.[1]*2) + hexdec(.[1]*2) + hexdec(.[1]*2))}}]}' > routes_kamakura.json
Then, when the acquired Json format file is loaded on ** geojson.io **, there are multiple walking courses from Kita-Kamakura to the Great Buddha of Kamakura as shown below. I got the route. (This is a separate article that I would like to organize)
Recommended Posts