1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

osrmのルート検索を関東データでお試し

Posted at

0. 前提

  1. osrmのセットアップが終わっている事
  2. curlが使えること(ブラウザでもいいけど)
  3. wgetが使えること(ブラウザでもいいけど)

ディレクトリ構成

    /home/tomonobu/work/
                        osrm-backend/ ... osrmをインストールしたディレクトリ
                        osm/          ... osmデータ用ディレクトリ
                           kanto/     ... 関東
                           berlin/    ... ベルリン

1. OSMデータのダウンロード

関東 http://download.geofabrik.de/asia/japan/kanto-latest.osm.pbf

  $ pwd
  /home/tomonobu/work/osm/kanto <== ここのディレクトリにダウンロードする

  $ wget http://download.geofabrik.de/asia/japan/kanto-latest.osm.pbf

2. OSMデータの展開

実行は osrmをインストールしたディレイクトリで

$ pwd
/home/tomonobu/work/osrm-backend

$ osrm-extract   ../osm/kanto/kanto-latest.osm.pbf
$ osrm-partition ../osm/kanto/kanto-latest.osrm
$ osrm-customize ../osm/kanto/kanto-latest.osrm

3. サーバ起動

$ osrm-routed --ip 127.0.0.1 --port 5000 --algorithm mld ../osm/kanto/kanto-latest.osrm

4. 始点と終点の緯度経度を決めよう

Googleマップ → 右クリックで「この場所について」

  • 始点 35.1617517,139.728336
  • 終点 35.656327,139.792895

5. ルート作成

$ curl --noproxy 127.0.0.1 'http://127.0.0.1:5000/route/v1/driving/139.728222,35.617534;139.792895,35.656327?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_kanto2.json

==> 成功

6. ルート表示

出来上がった routes_kanto2.json を
http://geojson.io
に食わせれば、ルートが表示される

EOF

1
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?