Graphhopper - 如何设置路由配置文件 'foot'

Graphhopper - how to set the routing profile 'foot'

如何设置路线配置文件'foot'?使用默认配置文件 'car' 我无法计算任何位置(在树林中)与附近人行道之间的距离。

我收到的错误信息是:

> Encoding does not match: Graphhopper config:
> foot|speed_factor=1.0|speed_bits=4|turn_costs=false|version=5 Graph:
> car|speed_factor=5.0|speed_bits=5|turn_costs=false|version=2 Change
> configuration to match the graph or delete ...
> gelederland-latest.osm-gh/

我的代码是:

graphHopper = new GraphHopper().forMobile();
EncodingManager encodingManager = EncodingManager.create( FlagEncoderFactory.FOOT);
graphHopper.setEncodingManager(encodingManager);
graphHopper.setProfiles(Arrays.asList( new ProfileConfig("my_foot").setVehicle("foot").setWeighting("fastest")));
graphHopper.load(getRoutingDataFolder());

我使用的路由数据?首先,我通过 http://download.geofabrik.de/europe/netherlands/gelderland.html 检索了原始 OSM 文件。之后我通过命令准备了 Graphhopper 路由数据:

./graphhopper.sh -a import -i gelderland-latest.osm.pbf

更新:这就足够了吗?我正在尝试:

./graphhopper.sh -a import -p foot,bike,car -i netherlands-latest.osm.pbf  

问题是图表(即 graphhopper 生成的路由文件)与应用程序中的配置设置不一致。

在下面的回答中,我想为步行、自行车和汽车提供一个路由工具。当然可以只获取一种类型的 'vehicle' 的路由。我也对路由配置文件 'foot' 进行了测试。

为了对齐,我首先在 graphhopper project 的克隆中编辑了 config.yml 文件。在我更改的配置文件中:

graph.flag_encoders: foot,bike,car

和:

profiles:
  - name: foot
    vehicle: foot
    weighting: fastest

profiles_ch:
  - profile: foot

我用这个命令生成了图表数据:

./graphhopper.sh -a import -p foot,bike,car -i netherlands-latest.osm.pbf  

然后使用相同的配置文件配置您的应用程序很重要。因此,即使在您的应用程序中仅使用 'foot' 配置文件也会产生不匹配——正如错误消息所暗示的那样。

该应用程序包含用于测量任意点到路径的距离的代码:

graphHopper = new GraphHopper().forMobile();
EncodingManager encodingManager = EncodingManager.create( FlagEncoderFactory.FOOT + "," + FlagEncoderFactory.BIKE + "," + FlagEncoderFactory.CAR);
graphHopper.setEncodingManager(encodingManager);
graphHopper.setProfiles(Arrays.asList(
        new ProfileConfig("my_foot").setVehicle("foot").setWeighting("fastest"),
        new ProfileConfig("my_bike").setVehicle("bike").setWeighting("fastest"),
        new ProfileConfig("my_car").setVehicle("car").setWeighting("fastest")));
graphHopper.load(routingDataFolder);