-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Introduce osm_nodes annotations for 64-bit OSM Node Ids #6341
base: master
Are you sure you want to change the base?
Conversation
util::json::Array osm_nodes; | ||
osm_nodes.values.emplace_back(std::to_string(node_values.first)); | ||
osm_nodes.values.emplace_back(std::to_string(node_values.second)); | ||
waypoint.values["osm_nodes"] = std::move(osm_nodes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the nearest API we unconditionally add this new osm_nodes
array, i.e. always have kind of duplication.
nodes.values.reserve(leg_geometry.node_ids.size()); | ||
for (const auto node_id : leg_geometry.node_ids) | ||
{ | ||
nodes.values.push_back( | ||
static_cast<std::uint64_t>(facade.GetOSMNodeIDOfNode(node_id))); | ||
const auto osm_node_id = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of annotations we add this osm_nodes
if it was explicitly requested(annotations=osm_nodes,...
) or in case of annotations=true
@@ -10,6 +10,8 @@ table Annotation { | |||
duration: [uint]; | |||
datasources: [uint]; | |||
nodes: [uint]; | |||
osm_nodes: [ulong]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flatbuffers implementation is not ready yet, but general idea will be the same
@mjjbell would be great if you will take a look and share your opinion |
On another hand as per this site the largest node id at the moment is only >2^33, i.e. we seems to be okay with 2^53 limitation of JS(that's the probably main reason why we would need to migrate to string from number). I.e. we can probably only make fix in flatbuffers. But on another hand I personally know the cases when companies enrich OSM data with their own data and in order to avoid conflicts they start their IDs "from the end"(i.e. 2^64 - 1 goes first). |
Another option I see is to explicitly enable/disable this via CLI parameter/config(and have it disabled by default). |
OSM Node IDs are 34-bit internally
Related issue #5644 |
Let me summarise to see if I understand.
Is this right? |
Exactly. At the same time for some reason initially I was thinking that OSM ids are already > 2^53, now it turned out that the problem is not so serious - after all those people can start from 2^53 - 1, but not from 2^64-1. But when it comes to Flatbuffers I think we need to fix that. |
Issue
potentially closes #5970 and #5716
The question here is how to preserve backward compatibility, that's why I want to discuss this before doing final "polishing".
What I am doing at the moment I add additional field
osm_nodes
which in some cases may be returned along with oldnodes
field which is kind of ugly and wasteful(but we cannot just remove this oldnodes
without breaking backward compatibility). Another option would be to add parameter(e.g.use_64bit_node_ids=true
) and start returning node ids as strings in this case.Also worth noting that JSON itself seems to support 64-bit numbers and we could just fix our JSON serialization to not convert numbers to double before serialization, but JS itself safely supports only integers up to 53-bit(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER) and
Tasklist
Requirements / Relations
Link any requirements here. Other pull requests this PR is based on?