GraphHopper.com | Forum | GitHub | Maps | Blog

New feature: exclude "bad" locations


#1

Sometimes there are locations that cannot be accessed by any vehicle over the road network. Currently, the API fails to solve the involved vehicle routing problem and responds with an error saying that it cannot find the specified location.

The new approach is that we exclude this “bad” location from the routing problem and solve the problem without it. This “bad” location then ends up being unassigned like this:

{
        "id": "hamburg",
        "code": 50,
        "reason": "underlying location cannot be accessed over road network by at least one vehicle"
 }

However, we only try to exclude “bad” locations twice. If there are more than 2 “bad” locations, the API responds with an error like this:

{
  "message": "Bad Request",
  "hints": [
    {
      "message": "Cannot find the following locations:  service location (lon: 5.734863, lat: 54.455989) of service 'hamburg'",
      "details": "class com.graphhopper.util.exceptions.DetailedIllegalArgumentException"
    },
    {
      "message": "Cannot find the following locations:  service location (lon: 4.54834, lat: 54.174011) of service 'munich'",
      "details": "class com.graphhopper.util.exceptions.DetailedIllegalArgumentException"
    },
    {
      "message": "Cannot find the following locations:  service location (lon: 5.075684, lat: 55.026763) of service 'cologne'",
      "details": "class com.graphhopper.util.exceptions.DetailedIllegalArgumentException"
    }
  ]
}

#2

We decided to make this feature configurable. By default, it is not allowed to exclude bad locations as described above, but the Optimization API fails fast, i.e. return an error that a certain location cannot be connected to the network. If you want to exclude bad locations as described above, you need to specify it as follows:

"configuration": {
    "routing": {
      "fail_fast":false
    }
}