【问题标题】:How to see GHResponse on map by using GraphHopperWeb如何使用 GraphHopper Web 在地图上查看响应
【发布时间】:2015-03-22 01:50:04
【问题描述】:

我正在尝试使用 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);

我得到以下打印屏幕:

节点:24:(32.07012,34.79021),(32.07011,34.7902),(32.07006,34.79019),(32.07028,34.78867),(32.07029,07029,34.788852) 32.06942,34.78761), (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) , [(0,继续上 הנציב,6.186,742), (2,右转上 שדרות יהודית,164.23,19706), (-2,左转上 מנחם בגין, 2,142.253,9310), (0,继续上,517.411,31039), (2,右转进入 לינקולן,394.313,28388), (-1,稍微左转进入 יהודה הלוי,183.917,13240), (2,右转进入 בלפור,128.87,9278) ,右转上 שדרות רוטשילד,56.539,4070), (2,右转上 המגיד,4.589,550), (4,Finish!,0.0,0)]

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

{"info":{"copyrights":["GraphHopper","OpenStreetMap 贡献者"],"errors":[{"details":"java.lang.IllegalStateException","message":"至少 2必须指定点,但是是:0"}]}}

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

【问题讨论】:

    标签: java graphhopper


    【解决方案1】:

    外部GraphHopperWeb client的用法与内嵌路由described here的用法类似,可视化点可以通过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();
    

    【讨论】:

    • 是的,我对此很熟悉,但我如何通过资源管理器查看地图上标记的 PointList?
    猜你喜欢
    • 2018-10-20
    • 2011-07-22
    • 1970-01-01
    • 1970-01-01
    • 2013-03-10
    • 1970-01-01
    • 2018-10-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多