Graph Tile structure #5469
-
|
I'm trying to read shapes of the edges in graph tiles. I parsed the graph tile struct, and have the offsets (edge_info_offset, and directed edges count). I wonder what goes where in the edge structs -- Directed edge, or edge info? I see directededge.h has a 25-bit offset of the edgeinfo struct. Does this mean DirectedEdges go first, then at some offset, there are EdgeInfos? I wonder where do DirectedEdges begin in the file? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 6 replies
-
|
I made a calculation of the size of the header, and wonder if it's correct, and if my assumptions are correct. As I understand, the data should be like this:
I conclude that nodes follow the header and then the directed edges. If I understand correctly, edge infos start and a given offset, and in each directed edge, there's the offset to its edge info, and therein lies the shape. Am I correct? My only problem with the sizes right now is that in my calculations the header ends being 272 bytes, rather than a round number. Please, tell me, what did I get wrong? I actually read tile size (bytes 224-228), and in every tile I checked, it's exactly the same as the file size. So, all data up to 228 is correct. The question is why are the empty slots so oddly aligned? |
Beta Was this translation helpful? Give feedback.
-
|
valhalla/valhalla/baldr/graphtile.h Lines 802 to 803 in 59ad155 valhalla/valhalla/baldr/graphtile.h Lines 850 to 852 in 59ad155 There is a good graph reading example in the code base as well: valhalla/src/mjolnir/way_edges_processor.cc Lines 31 to 60 in d59ce43 There are several projects that did a bit of reverse engineering and where you can read Valhalla's tile structure if C++ is too obscure, for example https://github.com/stadiamaps/valinor/blob/main/valhalla-graphtile/src/graph_tile/directed_edge.rs#L252 |
Beta Was this translation helpful? Give feedback.
-
|
Follow up question: I read how you decode the shape, and can't figure out:
|
Beta Was this translation helpful? Give feedback.
-
|
Got it working, thanks a lot for your help, @kinkard! |
Beta Was this translation helpful? Give feedback.
A small project of mine does C++-to-Rust bindings and I've started it to solve exactly same problem - https://github.com/kinkard/valhalla-rs