LoginSignup
1
6

More than 5 years have passed since last update.

Open Source Routing Machine (OSRM) 利用で道路経路探索

Last updated at Posted at 2017-08-18

こんにちは。
Open Source Routing Machine (OSRM) を使って道路経路探索を試してみました1。インストールには HomeBrew を使いました。

複数経路候補を探索し、その結果から simplestyle の GeoJSON ファイルを作りました(jq コマンド利用)。表示には http://geojson.io を利用しました。

map.png

$ brew install jq osrm-backend
$ mkdir osrm && cd osrm
$ find /usr/local/Cellar/osrm-backend -name profiles | head -n 1 | xargs ln -s
$ wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
$ osrm-extract berlin-latest.osm.pbf
$ osrm-partition berlin-latest.osrm
$ osrm-customize berlin-latest.osrm
$ osrm-routed --algorithm=MLD berlin-latest.osrm &
$ curl 'http://localhost:5000/route/v1/driving/13.246353470716485,52.43405136831916;13.39309242380466,52.56433207398476?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.json

  1. 探索を試すだけならば、http://map.project-osrm.org/Leaflet Routing Machine のサイトで試せます。 

1
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
6