Avoid collection of single street segments with CustomModel

Hi there, I need to block certain street segments for navigation. So far we used block_area in a POST request with the list of points (center of the segment) with a radius of 10. As block_area is now deprecated, we transition to customModel. There we use

Map<String, JsonFeature> areas = new HashMap<>();
areas.put("avoid", new JsonFeature("avoid",
    "Feature",
    null,
    multiPolygon,
    new HashMap<>()));
customModel.setAreas(areas);

and

customModel.addToPriority(Statement.If("in_avoid", Op.MULTIPLY, 0));

As the customModel only works with polygons, we calculate a square around the center point: (blue: segment to block)


Somehow it doesn’t affect the routing. Any idea as why?

Just an initial thought, have you rebuilt your graph? And also are you applying the correct custom model to profile and using it?

Did you notice this: https://github.com/graphhopper/graphhopper/blob/1315ba0df4d3dfaa499ba056768d14ae9e5bba99/docs/core/custom-models.md?plain=1#L443-L447

I don’t know what the ‘multiPolygon’ in your example looks like. Does it fulfill all the conditions mentioned there? And did you try blocking a street segment the way you want to do this on graphhopper.com/maps? Does it work there?

Thanks, with your help I could figure it out. My JSON format for the area definition was wrong, as I named it “area” instead of “custom1”.
Also I noticed, that while GHRequest supports customModel, GraphHopperWeb does not at the time. So my POST requests didn’t even contain the customModels!

Powered by Discourse