-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid NodeIDs in Route Response #276
Comments
I found that the issue is caused by JSON values storing instead of unpacking. Generated routes will be converted to JSON before output. In below codes, every osrm-backend/include/engine/api/route_api.hpp Lines 324 to 333 in af51dcc
The util::json::Array is a struct containes std::vector<Value> values ,osrm-backend/include/util/json_container.hpp Lines 145 to 148 in af51dcc
and the Value defined byosrm-backend/include/util/json_container.hpp Lines 122 to 128 in af51dcc
Since the Number is the only type that Value matchs with std::uint64_t , the nodes.values.push_back(static_cast<std::uint64_t>(node_id)); will result to convert the node_id and stores into the Number .However, the Number defines as double which may insufficient for extermely long std::uint64_t .osrm-backend/include/util/json_container.hpp Lines 89 to 94 in af51dcc
In this case, the nodeID // Example program
#include <iostream>
#include <string>
#include <cstdint>
#include <iomanip>
int main()
{
std::uint64_t id = 9280805980001101;
double d_id = static_cast<double>(id);
std::uint64_t convert_back_id = static_cast<std::uint64_t>(d_id);
std::cout << id << std::endl;
std::cout << std::fixed << std::setprecision(6) << d_id << std::endl;
std::cout << convert_back_id << std::endl;
}
// output:
9280805980001101
9280805980001100.000000
9280805980001100 |
Have filed issue Project-OSRM#5716 for more discussion. |
A good solution to solve the problem maybe implement various number types in the Before get a reasonable conclusion, I'd like to go with a simple improvement first: return
Anyway, let's have a try to see whether it works or not. |
I tried a long route(about 4700km, from us west to us east) to see whether the response size acceptable, here's some test result: -rw-r--r-- 1 root root 318 Apr 17 03:09 4700km-string.header.log
-rw-r--r-- 1 root root 9.3M Apr 17 03:09 4700km-string.json
-rw-r--r-- 1 root root 2.9M Apr 17 03:09 4700km-string.json.gz
-rw-r--r-- 1 root root 318 Apr 17 01:36 4700km.header.log
-rw-r--r-- 1 root root 9.1M Apr 17 01:36 4700km.json
-rw-r--r-- 1 root root 3.0M Apr 17 01:36 4700km.json.gz The One more problem needs highlight is that nearest also returns |
With
annotations=true
parameter, we can get fullnodes
of each leg in route response. But some of the node IDs are invalid.Here's a example:
GET /route/v1/driving/-122.006349,37.364336;-121.875654,37.313767?alternatives=3&annotations=true
response/routes/legs/annotations/nodes
:49873171102,237301600001101,49939882102,49939887102,1008867724102,1008867725102,955126824102,9280805980001100,49939901102
The ID
9280805980001100
is incorrect. The correct value is9280805980001101
, which is correct in OSRM compiled data:It might be something wrong in unpack step, any may be caused by some IDs overflow: the problem seems only occurred on extermly long IDs.
Will investigate further.
The text was updated successfully, but these errors were encountered: