GraphHopper.com | Forum | GitHub | Maps | Blog

How to make sure block_area is always respected?


#1

I have about 200 lat/lon/radius specified in block_area. However, routing does not always seem to respect the values in block_area. When there are a lot of blocked points, routing still passes through the radius of those points. Any idea why?

The green path shows a clear example: https://image.ibb.co/c8ihaT/Screen_Shot_2018_06_22_at_20_48_06.png

Here’s the relevant code snippet using the Web API:

            var ghRoutingAvoid = new GraphHopper.Routing({
                key: "API_KEY",
                vehicle: "foot",
                elevation: false,
                instructions: false,
                ch: {disable: true},
                block_area: "LONG LIST OF LAT,LON,RADIUS"
            });

            setupRoutingAPIAvoid(map, ghRoutingAvoid);

            function setupRoutingAPIAvoid(map, ghRouting) {
                map.setView([52.093421, 5.073712], 12);
                ghRouting.addPoint(new GHInput(52.08986,5.1113));
                ghRouting.addPoint(new GHInput(52.09086,5.1193099));
                ghRouting.doRequest()
                    .then(function(json) {
                        var path = json.paths[0];
                        routingLayerAvoid.addData({
                            "type": "Feature",
                            "geometry": path.points
                        });

                    }).catch(function(err) {
                        console.log(err);
                    });

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

#2

There is still an open issue that might be relevant: https://github.com/graphhopper/graphhopper/issues/1324

I.e. it can occur in certain situations that a block_area seems to get ignored. If you have a link to GraphHopper Maps where this is the case I could be investigate if it is a known issue or something else.


#3

Hi @karussell,

thanks for your reply. I cannot judge from the issue whether it is related.

The live example can be found here: http://dj.digitalmethods.net/cams/graphhopper.php?van=stationsplein%2C+utrecht&naar=jansdam%2C+utrecht The red line is a route on foot without block_area, the green line is the same route request but with block_area. No route should ever go through the block_areas. If no route can be found, that’s fine.

It’d be great if you could take a look!

Thanks,

Erik