sources_to_targets returns different results when splitting request
- Dominant language
- C++
- Stars
- 6.2k
- Forks
- 981
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 14
Description
Valhalla sources_to_targets returns different results if the request is split up. In the example below it returns different values when a 4 x 4 matrix is instead requested as four 1 x 4 matrices. The difference in this case is in request 1 with the 3rd value, 975 seconds and 8.08km instead of 1024 seconds and 9.188 km.
For each source->target connection Valhalla should return the same values every time, regardless of sources or targets in the request.
test script
```sh
#!/bin/sh
url=https://valhalla1.openstreetmap.de/sources_to_targets
# One request 4x4 matrix
curl "$url" -o 4x4.json -X POST -H 'Content-Type: application/json' -d '{"costing": "auto","costing_options": {"auto": {"top_speed": 80}},"sources": [{"lon": 11.2126,"lat": 52.71203},{"lon": 11.07077,"lat": 52.87108},{"lon": 11.158565,"lat": 52.850734},{"lon": 11.158199,"lat": 52.851318}],"targets": [{"lon": 11.2126,"lat": 52.71203},{"lon": 11.07077,"lat": 52.87108},{"lon": 11.158565,"lat": 52.850734},{"lon": 11.158199,"lat": 52.851318}],"verbose": false}'
# Four requests 1x4 matrix
curl "$url" -o 1x4-0.json -X POST -H 'Content-Type: application/json' -d '{"costing": "auto","costing_options": {"auto": {"top_speed": 80}},"sources": [{"lon": 11.212600,"lat": 52.712030}],"targets": [{"lon": 11.2126,"lat": 52.71203},{"lon": 11.07077,"lat": 52.87108},{"lon": 11.158565,"lat": 52.850734},{"lon": 11.158199,"lat": 52.851318}],"verbose": false}'
curl "$url" -o 1x4-1.json -X POST -H 'Content-Type: application/json' -d '{"costing": "auto","costing_options": {"auto": {"top_speed": 80}},"sources": [{"lon": 11.070770,"lat": 52.871080}],"targets": [{"lon": 11.2126,"lat": 52.71203},{"lon": 11.07077,"lat": 52.87108},{"lon": 11.158565,"lat": 52.850734},{"lon": 11.158199,"lat": 52.851318}],"verbose": false}'
curl "$url" -o 1x4-2.json -X POST -H 'Content-Type: application/json' -d '{"costing": "auto","costing_options": {"auto": {"top_speed": 80}},"sources": [{"lon": 11.158565,"lat": 52.850734}],"targets": [{"lon": 11.2126,"lat": 52.71203},{"lon": 11.07077,"lat": 52.87108},{"lon": 11.158565,"lat": 52.850734},{"lon": 11.158199,"lat": 52.851318}],"verbose": false}'
curl "$url" -o 1x4-3.json -X POST -H 'Content-Type: application/json' -d '{"costing": "auto","costing_options": {"auto": {"top_speed": 80}},"sources": [{"lon": 11.158199,"lat": 52.851318}],"targets": [{"lon": 11.2126,"lat": 52.71203},{"lon": 11.07077,"lat": 52.87108},{"lon": 11.158565,"lat": 52.850734},{"lon": 11.158199,"lat": 52.851318}],"verbose": false}'
```
response 4x4
```json
{
"sources_to_targets":{
"durations":[
[ 0, 2522, 1648, 1666],
[2510, 0, 1024, 1042],
[1625, 966, 0, 17],
[1645, 986, 17, 0]
],
"distances":[
[ 0.0, 27.881, 19.503, 19.574],
[27.832, 0.0, 9.188, 9.259],
[19.248, 8.044, 0.0, 0.071],
[19.319, 8.115, 0.071, 0.0 ]
]
},
"units":"kilometers",
"algorithm":"costmatrix"
}
```
response 0 1x4
```json
{
"sources_to_targets":{
"durations":[
[ 0, 2522, 1648, 1666]
],
"distances":[
[0.0, 27.881, 19.503, 19.574]
]
},
"units":"kilometers",
"algorithm":"costmatrix"
}
```
response 1 1x4
```json
{
"sources_to_targets":{
"durations":[
[2510, 0, 975, 1042]
],
"distances":[
[27.832, 0.0, 8.08, 9.259]
]
},
"units":"kilometers",
"algorithm":"costmatrix"
}
```
response 2 1x4
```json
{
"sources_to_targets":{
"durations":[
[1625, 966, 0, 17]
],
"distances":[
[19.248, 8.044, 0.0, 0.071]
]
},
"units":"kilometers",
"algorithm":"costmatrix"
}
```
response 3 1x4
```json
{
"sources_to_targets":{
"durations":[
[1645, 986, 17, 0]
],
"distances":[
[19.319, 8.115, 0.071, 0.0 ]
]
},
"units":"kilometers",
"algorithm":"costmatrix"
}
```
Different locations in the request make the differences appear at different places in the matrix.
For exmple removing the costing_options here would change the distance value in response of the 4x4 matrix from 19.319 to 19.317, but in the response 3 it remained at 19.319, conversely the response difference for request 1 from above would disappear.
Contributor guide
Assessment
This issue has not been assessed yet.