osrm-extract
osrm 第一步,将 osm.pbf 文件取出来需要用的数据
docker run -t -v "${PWD}:/data" ghcr.io/project-osrm/osrm-backend osrm-extract -p /opt/car.lua /data/thailand-latest.osm.pbf || echo "osrm-extract failed"
执行前数据
➜ Data ls
thailand-latest.osm.pbf
执行后文件目录
➜ Data ls
thailand-latest.osm.pbf thailand-latest.osrm.names
thailand-latest.osrm.cnbg thailand-latest.osrm.nbg_nodes
thailand-latest.osrm.cnbg_to_ebg thailand-latest.osrm.properties
thailand-latest.osrm.ebg thailand-latest.osrm.ramIndex
thailand-latest.osrm.ebg_nodes thailand-latest.osrm.restrictions
thailand-latest.osrm.edges thailand-latest.osrm.timestamp
thailand-latest.osrm.enw thailand-latest.osrm.tld
thailand-latest.osrm.fileIndex thailand-latest.osrm.tls
thailand-latest.osrm.geometry thailand-latest.osrm.turn_duration_penalties
thailand-latest.osrm.icd thailand-latest.osrm.turn_penalties_index
thailand-latest.osrm.maneuver_overrides thailand-latest.osrm.turn_weight_penalties
osrm-partition(mld)
分区
docker run -t -v "${PWD}:/data" --name=osrm-partition ghcr.io/project-osrm/osrm-backend osrm-partition /data/thailand-latest.osrm || echo "osrm-partition failed"
执行后文件目录
➜ Data ls
thailand-latest.osm.pbf thailand-latest.osrm.names
thailand-latest.osrm.cells thailand-latest.osrm.nbg_nodes
thailand-latest.osrm.cnbg thailand-latest.osrm.partition
thailand-latest.osrm.cnbg_to_ebg thailand-latest.osrm.properties
thailand-latest.osrm.ebg thailand-latest.osrm.ramIndex
thailand-latest.osrm.ebg_nodes thailand-latest.osrm.restrictions
thailand-latest.osrm.edges thailand-latest.osrm.timestamp
thailand-latest.osrm.enw thailand-latest.osrm.tld
thailand-latest.osrm.fileIndex thailand-latest.osrm.tls
thailand-latest.osrm.geometry thailand-latest.osrm.turn_duration_penalties
thailand-latest.osrm.icd thailand-latest.osrm.turn_penalties_index
thailand-latest.osrm.maneuver_overrides thailand-latest.osrm.turn_weight_penalties
多了thailand-latest.osrm.cells 和 thailand-latest.osrm.partition 俩文件
osrm-customize(mld)
合并
docker run -t -v "${PWD}:/data" --name=osrm-customize ghcr.io/project-osrm/osrm-backend osrm-customize /data/thailand-latest.osrm || echo "osrm-customize failed"
执行后目录
➜ Data ls
thailand-latest.osm.pbf thailand-latest.osrm.mldgr
thailand-latest.osrm.cell_metrics thailand-latest.osrm.names
thailand-latest.osrm.cells thailand-latest.osrm.nbg_nodes
thailand-latest.osrm.cnbg thailand-latest.osrm.partition
thailand-latest.osrm.cnbg_to_ebg thailand-latest.osrm.properties
thailand-latest.osrm.datasource_names thailand-latest.osrm.ramIndex
thailand-latest.osrm.ebg thailand-latest.osrm.restrictions
thailand-latest.osrm.ebg_nodes thailand-latest.osrm.timestamp
thailand-latest.osrm.edges thailand-latest.osrm.tld
thailand-latest.osrm.enw thailand-latest.osrm.tls
thailand-latest.osrm.fileIndex thailand-latest.osrm.turn_duration_penalties
thailand-latest.osrm.geometry thailand-latest.osrm.turn_penalties_index
thailand-latest.osrm.icd thailand-latest.osrm.turn_weight_penalties
thailand-latest.osrm.maneuver_overrides
又多了几个文件
osrm-contract(ch)
计算
docker run -t -v $(pwd):/data ghcr.io/project-osrm/osrm-backend osrm-contract /data/thailand-latest.osrm || echo "osrm-contract failed"
执行后
thailand-latest.osm.pbf thailand-latest.osrm.maneuver_overrides
thailand-latest.osrm.cnbg thailand-latest.osrm.names
thailand-latest.osrm.cnbg_to_ebg thailand-latest.osrm.nbg_nodes
thailand-latest.osrm.datasource_names thailand-latest.osrm.properties
thailand-latest.osrm.ebg thailand-latest.osrm.ramIndex
thailand-latest.osrm.ebg_nodes thailand-latest.osrm.restrictions
thailand-latest.osrm.edges thailand-latest.osrm.timestamp
thailand-latest.osrm.enw thailand-latest.osrm.tld
thailand-latest.osrm.fileIndex thailand-latest.osrm.tls
thailand-latest.osrm.geometry thailand-latest.osrm.turn_duration_penalties
thailand-latest.osrm.hsgr thailand-latest.osrm.turn_penalties_index
thailand-latest.osrm.icd thailand-latest.osrm.turn_weight_penalties
osrm-routed
提供服务
mld
docker run -t -i --name=osrm-routed-mld -p 6010:5000 -v "${PWD}:/data" ghcr.io/project-osrm/osrm-backend osrm-routed --algorithm mld /data/thailand-latest.osrm
ch
docker run -d -t -i -p 6020:5000 -v "${PWD}:/data" ghcr.io/project-osrm/osrm-backend osrm-routed --algorithm ch /data/thailand-latest.osrm || echo "osrm-touted failed"
问题
2024-03-01 的 osm 数据有问题,解压失败,后面再查
参考
https://afi.io/blog/introduction-to-osrm-setting-up-osrm-backend-using-docker/
https://medium.com/logistimo-engineering-blog/osrm-data-generation-and-deployment-2f5a66269342
https://github.com/Project-OSRM/osrm-backend/wiki/Traffic