0

我正在尝试使用 GraphHopperWeb 来查看网络上的路由响应。我可能不知道如何使用它,但我不明白有什么问题。我正在使用以下代码(在 java 中)以找到从一点到另一点的一些路径,如下所示:

    GHRequest req = new GHRequest(32.070113, 34.790266, 32.067103, 34.777861).
            setWeighting("fastest")
            .setVehicle("car");

    GraphHopperWeb gh = new GraphHopperWeb();
    gh.load("http://localhost:8989/route");


    gh.setInstructions(true);
    GHResponse response = gh.route(req);

    System.out.println(response);

我得到以下打印屏幕:

NODES:24:(32.07012,34.79021),(32.07011,34.7902),(32.07006,34.79019),(32.07028,34.78867) ), (32.06931,34.7875), (32.06912,34.78731), (32.06862,34.78667), (32.06756,34.78546), (32.06627,34.78391), (32.06617,34.78375), (32.06604,34.7836), (32.06622,34.78317), (32.06768,34.78009), (32.06769,34.77998), (32.06767,34.77992), (32.06654,34.77915), (32.06624,34.77894), (32.0666,34.77764), (32.06709,34.7778), (32.06708,34.77785), [( 0,继续登上נצנצב,6.186,742),(2,右转到שדרשדרת禁תדד极,164.23,19706),(-2,左转到מנחםמנחםבגבגבג,2,142.253,9310),(0 31039), (2,右转上 לינקולן,394.313,28388), (-1,稍微左转上 יהודה הלוי,183.917,13240), (2,右转上 בלפור,128.87,9278), (2,右转到 שדרות רוטשילד,56.539,4070), (2,右转进入 המגיד,4.589,550), (4,Finish!,0.0,0)]

但是当我使用地址“ http://localhost:8989/route ”打开资源管理器时,我收到以下错误:

{"info":{"copyrights":["GraphHopper","OpenStreetMapcontributors"],"errors":[{"details":"java.lang.IllegalStateException","message":"至少 2 分必须被指定,但是是:0"}]}}

我不明白如何通过资源管理器在地图上看到 GHResponse(我找到的路由路径)?

4

1 回答 1

0

外部GraphHopperWeb 客户端的使用与此处描述的嵌入式路由的使用类似,可视化点可以通过 getPoints 或通过 getInstructions 的转向指令获取:

GHRequest req = new GHRequest(32.070113, 34.790266, 32.067103, 34.777861)
   .setWeighting("fastest")
   .setVehicle("car");

GHResponse res = gh.route(req);

if(res.hasErrors()) {
   // handle or throw exceptions res.getErrors()
   return;
}

// get path geometry information (latitude, longitude and optionally elevation)
PointList pl = res.getPoints();
// distance of the full path, in meter
double distance = res.getDistance();
// time of the full path, in milliseconds
long millis = res.getTime();
// get information per turn instruction
InstructionList il = res.getInstructions();
于 2015-03-21T17:50:04.247 回答