| Forum | GitHub | Maps | Blog

Blocking edges on Android Application



I am using the Graphhopper library in my Android project and I would like to dynamically block certain edges on the map for when there are some roadworks. To do this I am using the follow function to block “edge”.

edge.setFlags(carEncoder.setAccess(edge.getFlags(), false, false));

When I am doing this I am getting the following error message. Does anyone know what’s wrong?

Caused by: java.lang.IllegalStateException: Calculating time should not require to read speed from edge in wrong direction. Reverse:false, fwd:false, bwd:false

I am not sure what they mean by this error. I tried to change some values and checking the direction by using:

if (edge.isForward(carEncoder)) {
                    edge.setFlags(carEncoder.setAccess(edge.getFlags(), false, true));


The error message means that the path was calculated via Weighting.calcWeight and then in calcMillis it was detected that the edge has not sufficient access. This probably means that calcWeight did consider the speed but not the access restrictions (if restricted it should return infinity)


Thank you.

Do you maybe know what I could change to fix this problem?
I would like to block the acces of the edge totally so Graphopper is forced to calculate a route around it.
I am using maps that are from the Netherlands

        Point point = entry.getPoints().get(entry.getPoints().size() / 2);
        QueryResult qr = locationIndex.findClosest(point.getX(), point.getY(), EdgeFilter.ALL_EDGES);
        if (!qr.isValid()) {

        int edgeId = qr.getClosestEdge().getEdge();
        if (edgeIds.contains(edgeId)) {

        EdgeIteratorState edge = graph.getEdgeIteratorState(edgeId, Integer.MIN_VALUE);
        Boolean closed = entry.isClosed();
        if (closed) {
            try {
                edge.setFlags(carEncoder.setAccess(edge.getFlags(), false, false));
            } catch (Exception e){


Next to dynamically blocking a edge in Graphopper based on coordinates where I am still getting the same IllegalStateException when calculating a route after I closed it. I checked other posts about this problem but I didn’t find any solution yet.

I was also wondering if it’s possible to make the closure of the access to an edge temporary? If I close the edge now it’s permanently changed on the map until I change it again at that same edge. But I would like that everytime I close my application the map restores to it’s orginal state since the blockades I would like to enter are only temporary.