简体   繁体   English

如何从 geojson 数据创建 OSRM 文件?

[英]How can I create an OSRM file from geojson data?

I have a geojson datafile containing highway=footway paths, and I'd like to use OSRM to find routings between multiple points (ie, not just the most efficient path from A to B, but something like the travelling salesman).我有一个包含highway=footway路径的 geojson 数据文件,我想使用 OSRM 来查找多个点之间的路线(即,不仅是从 A 到 B 的最有效路径,还包括旅行推销员之类的路径)。

From the OSRM documentation , I see that to use custom data rather than data from OpenStreetMap I would need an OSRM file, which I can apparently make "by running the OSRM binaries [shipped] in node_modules/osrm/lib/binding/ and default profiles".OSRM 文档中,我看到要使用自定义数据而不是来自 OpenStreetMap 的数据,我需要一个 OSRM 文件,我显然可以“通过在 node_modules/osrm/lib/binding/ 和默认配置文件中运行 OSRM 二进制文件 [shipped] 来制作” ”。

I find that very vague and I don't know how to proceed.我觉得这很模糊,我不知道如何继续。 The documentation linked above refers to the OSRM-backend documentation, but I didn't find anything related to creating OSRM files there.上面链接的文档是指 OSRM 后端文档,但我没有找到与在那里创建 OSRM 文件相关的任何内容。 I got the node_modules/osrm directory through npm, but there's nothing in the osrm/lib/binding directory...我通过npm得到了node_modules/osrm目录,但是osrm/lib/binding目录下什么都没有……

How can I proceed to use my data for OSRM routing?如何继续使用我的数据进行 OSRM 路由? Or if there is an easier solution to what I'm trying to implement, what would it be?或者,如果有一个更简单的解决方案来解决我要实施的问题,那会是什么?

I was able to create an osrm file by following this "pipeline":我能够按照这个“管道”创建一个 osrm 文件:

  1. Convert the geojson file to osm using JOSM (or start with an osm file to begin with).使用JOSM将 geojson 文件转换为 osm(或以 osm 文件开头)。 You can do this by opening the geojson file and clicking on File > Save As... and then selcting OSM file format.您可以通过打开 geojson 文件并单击文件 > 另存为...,然后选择 OSM 文件格式来执行此操作。
  2. Add the version, timestamp and changeset tags with osmconvert :使用osmconvert添加版本、时间戳和变更集标签:
$ osmconvert64 intput_file.osm --fake-author -o=output_file.osm
  1. Make the osm file into a binary file with osmosis :使用osmosis将 osm 文件转换为二进制文件:
$ osmosis --rx input_file.osm --wb output_file.osm.pbf omitmetadata=true
  1. Use the OSRM Docker container to create the osrm file.使用 OSRM Docker 容器创建 osrm 文件。 With Docker desktop installed:安装 Docker 桌面后:
$ docker run -t -v "absolute/path/to/data":/data osrm/osrm-backend osrm-extract -p /opt/profile.lua /data/file_name.osm.pbf
$ docker run -t -v "absolute/path/to/data":/data osrm/osrm-backend osrm-contract /data/file_name.osrm

Notes:笔记:

  • For the docker step, you must create a data directory and the absolute path to data should link to that directory.对于 docker 步骤,您必须创建一个data目录,并且数据的绝对路径应链接到该目录。
  • The file_name used must be the same for the osrm-extract input as for the osrm-contract output, as OSRM will make some other files using that name, which it will try to find in the contract step. osrm-extract输入使用的 file_name 必须与osrm-contract输出相同,因为 OSRM 将使用该名称创建一些其他文件,它将尝试在合同步骤中找到这些文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM