Multiple services that are neighbours

I have a question about the ‘relations’ object, specifically the “neighbour” type.

For example, I have a route with 20 locations/services that need to be visited. Location 5, 6, 7, 8 and 9 are really close by each other, same street or really close adjacent. 9 out of 10 times, GraphHopper is smart enough to add these locations next to each other when calling the optimize API. But that one time it doesn’t.

There is an option to add a relations array where I can specify services that are neighbors. The problem is when setting type to neighbor, I can only add 2 ID’s to the “ids’ array. I can of-course add multiple neighbor objects, with 5&6 being neigbors, 6&7, 7&8, etc.. But I don’t care what order 5, 6, 7, 8 and 9 are visited. Maybe it’s more logical that 6&8 are neighbors, or 5&9. I don’t know, I just know they are really close neighbors.

I saw there is also an option to use ‘GroupRelation’, but this also won’t really work. I can add 5,6,7,8,9 to a group, but I need 2 groups in the relations object. Adding all the other stops that are not neighbors in a separate group is a possibility but that will result in the neighbour group to be always the first or last group of stops. It might be better to have them in the middle of the route (1,4,17,[neigbours],2,11…..)

Is there anyway to handle this and have multiple services be each others neighbor?

Can you send the problematic request JSON here (via private message or to support@gh)? I would like to identify why GraphHopper does not plan the one service close to the others :slight_smile: Are you already using the street_hint parameter for every service?

We have solved this with groups.

1 Like