graphhopper / directions-api

Issues for the GraphHopper Directions API
https://graphhopper.com/api/1/docs/
60 stars 25 forks source link

Matrix API pass less than 3 points #54

Closed boldtrn closed 7 years ago

boldtrn commented 7 years ago

When passing less than 3 points to the matrix api the results are just empty:

{
distances: [
[
0
]
],
times: [
[
0
]
],
weights: [
[
0
]
],
info: {
copyrights: [
"GraphHopper",
"OpenStreetMap contributors"
]
}
}

I would have expected an exception?

When passing no points, I get an exception:

{
message: "Bad Request",
hints: [
{
message: "Too few points. From:0, to:0"
}
]
}
karussell commented 7 years ago

When passing less than 3 points to the matrix api the results are just empty:

That would be a bug, do you have an example request?

boldtrn commented 7 years ago

That would be a bug, do you have an example request?

Sure, here is a sample request:

https://graphhopper.com/api/1/matrix?point=49.932707%2C11.588051&type=json&vehicle=car&debug=true&out_array=weights&out_array=times&out_array=distances&key=[KEY]
oblonski commented 7 years ago

When you pass one point, I d expect an array of a single element that is 0 since the distance from point A to point A is always 0. This is exactly what you get:

"distances": [

    [
        0
    ]
]

When you pass two equal points, you ll get:

"distances": [

    [
        0,
        0
    ],
    [
        0,
        0
    ]

]

This makes sense. Doesnt it?

boldtrn commented 7 years ago

@oblonski thanks for clearing this up.

When you pass one point, I d expect an array of a single element that is 0 since the distance from point A to point A is always 0.

That makes sense, yes.

When you pass two equal points, you ll get ... - This makes sense. Doesnt it?

Yes, if they are equal, that makes sense. To be honest, I haven't thought about the meaning of the request. I think the reason why I expected an error is this statement in the docs:

Specify at least three points

Maybe we should change the docs in this case?

oblonski commented 7 years ago

Yes, you are correct. We should change the docs. I suggest to change the exception when specifying zero points to "Specify at least a single point" or similar.

karussell commented 7 years ago

Will do!

karussell commented 7 years ago

This should be deployed now. Is this better?

oblonski commented 7 years ago

Super. Thanks.