Closed mkumarb closed 8 months ago
The table
API doesn't support what you describe. It does have NxM support using the sources
and destinations
parameters (e.g. 3x10, or 8x3), but if all you want is an arbitrary list of pairs, then it'll still return more than what you want.
What you're asking for is what I'd call a "sparse matrix". I'm not sure the API response for /table
is particularly efficient for this, it would be full of a lot of null
entries and just a few useful values. I suppose as long as it's not too many pairs, it'd be ok, but it wouldn't scale very nicely to large pair lists.
I seem to remember writing up a description for an API like this a long time ago, but I can't find it. From memory, my suggestion was to add pairs=A,B;D,E;...
to the API, mutually exclusive with sources/destinations
.
Either way, someone would need to implement it - we don't have it today.
Thank you for your response @danpat . In our case, we have a use case where we compute N N matrix where all we need is N pairs of distances. N N seems like too much computation for our use case and also slows down the response times as a result. So, we were looking to optimize this by just using pairs Do you see any concerns if we try & provide support for pairs?
we compute N * N matrix where all we need is N pairs of distances.
Looks like the table
endpoint is overkill for your use-case. Did you simply try to run N
independent route
requests across the required pairs? Would probably be worth benchmarking this approach as it is much simpler than adjusting the existing code for table
, plus you could run a lot of the requests in parallel.
As part of OSRM table API, we can pass multiple sources & destinations and in turn we get back a matrix of sources * destinations.
Is there any way I can pass only the pairs that I want OSRM to compute & fetch distance/durations for. For example (used JSON as a representation for easier understanding):
as opposed to the existing table API which accepts input as below:
In the existing table API, I get 2 * 2 = 4 combinations whereas I only want the distance/duration for the 2 pairs specified as part of
sourceDestinationPairs
I could not find any API which returns distance/durations only for the specified source & destination pairs. Is this not added due to any potential performance issues?