GraphhopperWebClient 无法识别 GHRequest 中的配置文件

问题描述

在使用坐标、详细信息参数等创建 GHRequest 并希望通过 GraphhopperWebClient 将其发送到服务器后,我收到一条错误消息:

The requested profile 'name=car|vehicle=car|weighting=fastest|turnCosts=false|hints={}' does not exist.
Available profiles: [foot,car,bike]]

我正在以这种方式创建 GHRequest:

(1) 这里我将读取参数并在 GHRequest 中插入点坐标、细节等信息:

GHRequest ghRequest = getGHRequest(
                param0,param1,param2
        );

(2) 然后我将为 GHRequest 创建配置文件:

Profile profile = new Profile("car")
            .setVehicle("car")
            .setWeighting("false")
            .setTurnCosts(false);

(3) 最后,我将设置 GHRequest 的配置文件:

ghRequest.setProfile(ghProfile.toString());

我的下一步是使用 GraphhopperWebClient 在运行 Graphhopper 实例的服务器上发送请求:

(4) 我将使用我的服务器地址创建 GraphhopperWeb 客户端实例:

GraphHopperWeb client = new GraphHopperWeb("http:baseURL/route");
client.setPostRequest(false);

(5) 我正在服务器上发送创建的 GHRequest 并解析 GHResponse 中的响应:

GHResponse response = client.route(ghRequest);

我不需要插入我的密钥,因为 Graphhopper 正在我的服务器上运行,我只需要在它上面发送一个 GET 请求并解析响应。

有人可以帮我解决这个问题吗?

解决方法

必须在服务器上设置可以使用的配置文件。所以我的服务器上已经有 carfootbike 配置文件。他们已经有了权重、转弯描述等参数。我需要做的是通过编写决定将使用哪些配置文件:

Profile profile = new Profile(profileName);

String profileName 是我要使用的已在服务器上的配置文件的名称。所以就我而言,我只需要使用:

Profile profile = new Profile("car");

GHRequest 将使用已在 Graphhopper 服务器实例上设置的 car 配置文件。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...