GIScience / openrouteservice

🌍 The open source route planner api with plenty of features.
https://openrouteservice.org
GNU General Public License v3.0
1.42k stars 389 forks source link

Inconsistent responses from matrix API when route not found #191

Closed rrrnld closed 5 years ago

rrrnld commented 6 years ago

I am receiving a duration of null when requesting the time-distance matrix between these two points:

$  http https://api.openrouteservice.org/matrix profile==driving-car api_key==my-api-key range==1 locations=='14.101061,53.29817|12.808634,52.927325' sources==0

Response:

{
  "durations": [
    [
      0,
      null
    ]
  ],
  "destinations": [
    {
      "location": [
        14.101061,
        53.29817
      ],
      "snapped_distance": 0.03
    },
    {
      "location": [
        12.808634,
        52.927325
      ],
      "snapped_distance": 0
    }
  ],
  "sources": [
    {
      "location": [
        14.101061,
        53.29817
      ],
      "snapped_distance": 0.03
    }
  ],
  "info": {
    "service": "matrix",
    "engine": {
      "version": "4.5.0",
      "build_date": "2018-03-26T14:15:39Z"
    },
    "attribution": "openrouteservice.org | OpenStreetMap contributors",
    "timestamp": 1528366746044,
    "osm_file_md5_hash": "783b5a0ed086d6cc3eb6f98df9d5d79b",
    "query": {
      "profile": "driving-car",
      "units": "m"
    }
  }
}

How should I interpret this? I didn't find anything about it in the API docs.

aoles commented 6 years ago

null indicates no route was found, as documented:

The result is null if a value can't be determined.

A query to directions with the same coordinates returns

"error": {
    "code": 2009,
    "message": "Route could not be found - Unable to find a route between points 1 (14.1010610 53.2981700) and 2 (12.8086340 52.9273250)."
  }

so actually the result you are receiving from matrix is the expected one.

However, there seem to be some problem with the response because for sources=1 I get

"error": {
    "code": 6099,
    "message": "Unable to compute a distance/duration matrix."
  }

while sources=all yields

"durations": [
    [
      0,
      0
    ],
    [
      0,
      0
    ]
  ]

It' also puzzling why no route between the given coordinates can be found in first place, even though the locations seem to be legit.

HendrikLeuschner commented 6 years ago

I will have a look at it in the next couple of weeks.

rabidllama commented 6 years ago

@HendrikLeuschner any news on this yet?

HendrikLeuschner commented 6 years ago

I have built the Brandenburg graphs locally and run the routing query that give the route not found, but it works for me. The matrix query does also produce correct (the same as the routing) results. Need more investigation for why it does not work on the api. It might have something to do with the osm file...

rabidllama commented 5 years ago

@HendrikLeuschner Is this still an issue after the 4.7 update?

HendrikLeuschner commented 5 years ago

Will check out this week. Sorry for the delay @rabidllama

HendrikLeuschner commented 5 years ago

The problem is something with the second node at Karl-Marx-Strasse. A normal routing query https://maps.openrouteservice.org/directions?n1=52.927022&n2=12.809844&n3=17&a=52.926485,12.80758,53.29817,14.101061&b=0&c=0&k1=en-US&k2=km does not find the route either. Setting the point to a different location in Neuruppin works fine. It seems there are two nodes the iterator on the virtual node can go to (as expected). But both return infinite weighting, no matter if shortest or fastest. Will look further into this.

HendrikLeuschner commented 5 years ago

I think the problem is that the speed is calculated from an initial value of 5 down to 2.25. Then there is an if(speed < speedEncoder.factor/2) which is 2.25<2.5. Therefore it sets it to 0. That results in an edge that cannot be accessed.

Edit: Yeah, the residential penalty that is added drops the speed below the required minimum. Maybe we should apply the residential thing only when the actual speed is higher than lets say 10? @rabidllama

HendrikLeuschner commented 5 years ago

Fixed by #357

rabidllama commented 5 years ago

Will reopen until the code is in the master branch and released on the front end