GraphHopper.com | Forum | GitHub | Maps | Blog

Routing API optimize=true incorrect resultset


#1

Hi,

I have setup graphhopper open source setup locally using this guide. The graphhopper instance is running smoothly on my local environment and I can call the Routing Api.

But when I try to call the Routing Api with optimize=true, it is not returning the paths[0].points_order, as mentioned in the docs here. I have even tried to call the same API using Postman (REST client) and the result is same, no points_order in the resulting json.

Here is my code to call the routing API…

$(document).ready(function (e) {
    jQuery.support.cors = true;

        //
        // Sign-up for free and get your own key: https://graphhopper.com/#directions-api
        //
        var defaultKey; 

        // create a routing client to fetch real routes, elevation.true is only supported for vehicle bike or foot
        _ghRouting = new GraphHopper.Routing({
            key: defaultKey, 
            host: _graphhopperHost, 
            graphhopper_maps_host: _graphhopperHost, 
            vehicle: "car", 
            optimize: true,
            instructions: false,
            elevation: false
        });
        _routingMap = createMap('routing-map');
        setupRoutingAPI();
    });
    function setupRoutingAPI() {
        //somewhere in Copenhagn
        _routingMap.setView([55.637613, 11.959697], 12);

        _routingMap.on('click', addPointOnMap);

        _routingLayer = L.geoJson().addTo(_routingMap);
        _routingLayer.options = {
            style: {color: "#00cc33", "weight": 5, "opacity": 0.6}
        };
    }

Can anyone tell me what am I doing wrong here?

Regards,
Naveed Butt


#2

This guide is about the open source routing engine, not about the GraphHopper Directions API.

You’ll need to combine the open source routing engine with e.g. jsprit. The GraphHopper Directions API already does this for you.


#3

Thanks Russell,

I can still acess the API locally using http://localhost:8989/route. Can you explain how I can setup Graphhopper Directions API and why do I need that for a local instance?


#4

The GraphHopper Directions API is a hosted service and you can find the documentation here. You do not need a local server, just an API key and an API client.


#5

Wouldn’t I have to pay something for the hosted service. Plus, I would like the service in my own premises than adding a dependency on another third party and since graphhopper itself is open source, I should be able to setup the API locally, right?


#6

I was hoping for a reply on this from someone. How can I get that ordered list of points locally ?


#7

The GraphHopper Directions API is a paid service and only available as a hosted service (not for local usage).

See this page that describes what is open source or in the picture below the green parts that are all components that are open source:


So the parameter optimize=true uses a combined service of jsprit and the routing engine and this is not open source.


#8

Thanks a lot for the explanation. :slight_smile: Now, I will see what I can do around the open source and the Directions API.