Off diagonal matrix elements

Hi, I am currently interested in many to many one-way routes. This means that I need only the upper off-diagonal terms of the time/distance matrix. Is it possible to get only this information? If not, would it be possible to add it as a feature? The problem is that when I perform a matrix request with all terms it could take some time dependent on the amount of locations N. If I request only the off-diagonal terms one could, in principle, shorten the request time since the amount of routes calculated are only (NxN)/2 - N.

use the destinations and sources parameters

HI Amandus, thanks for your reply and sorry for my delayed response.

I have tried using the destination/sources parameters as you suggested, but I still get the full matrix. I need only the upper off-diagonal part of it, something like this:

| --, 1-2, 1-3, 1-4, …, 1-N |
| --, – , 2-3, 2-4, …, 2-N |
| --, – , – , 3-4, …, 3-N |
| --, – , – , – , …, – |

For a 4X4 matrix request the response should look something like this:

"distances": [
        [0.0, 3572.83, 7164.08, 6356.68],
        [None, 0.0, 4950.99, 6854.24],
        [None, None, 0.0, 4501.45],
        [ None, None, None, 0.0]

This is what I get:

"distances": [
        [ 0.0, 3572.83, 7164.08, 6356.68 ],
        [ 3877.18, 0.0, 4950.99, 6854.24 ],
        [ 7157.5, 4865.41, 0.0, 4501.45 ],
        [ 6176.51, 6256.31, 3365.84, 0.0 ]

Maybe I am not using the destination/sources correctly?

Could you please post an actual request (no api key) so i can see how you are sending it ?

curl -X POST \’ \

–header ‘Accept: application/json’ \

–header ‘Content-Type: application/json’ \

–header ‘Authorization: <>’ \

–data-raw ‘{“locations”:[[11.576124, 48.137154],[11.5525190087527, 48.1421100653177],[11.5533411070489, 48.1749289173995],[11.5915151958309, 48.1769966060513]],“metrics”:[“distance”], “sources”:[0,1,2,3],“destinations”:[0,1,2,3]}’

hmm i just realized that you have a very special use case.

Normally you would have places that are sources and places that are destinations.
But what you are trying to do is having places switching their status as destination during the call.
Like if the source is 1 you want all to be destinations but if the source is 2 you don’t want 1 as destination anymore, when 3 you don’t want 1 and 2 as destination.

Why do you want to reduce the number of destination points for every following point?

I’m just wondering what the use case is. if you deal with many to many matrices you normally are also interested in the reverse routes as they can differ in the other direction.

Well I am interested on Routing Problems that go in one direction, where destination is not the start location (no round trip) and that there are possible intermediate stops but all towards the final destination.

Currently I am using the full matrix response but when there are many locations, the request can take some time. That is why I wanted to have only the upper off diagonal in order to save compitation time. I have tried source and destinations using nested lists but it does not work.

Sorry, that is currently not possible.
The usecase is also too specific to make it as a feature.

Depending on the amount of locations you could do multiple single requests where you specify one source each time and reduce the destinations:

  • 1: sources: [0], destinations: [1,2,...N]
  • 2: sources: [1], destinations: [2,3,...N]
  • 3: sources: [2], destinations: [3,4,...N]

Then it might be faster, but you will also reach the quota limit more quickly

Oh, thats a pitty. I will still try what you suggest, It might work. Thanks and regards

but we are open source after all, feel free to implement a one directional matrix parameter and send us a pull requst :wink:

Hi Amandus, just wanted to ask a quick question. By building ORS locally would it be possible to change the configuration so that the performance of the distance/time matrix calculation is enhanced. If yes, how?

I have read that modifying the index.high_resolution and the index.max_region_search might help. If that is correct, which values should I try? Any other idea?


Maybe @HendrikLeuschner, @andrzej or @sascha can answer this.