How to retrieve OSM Node ids in sequence along the path of routing result

Is there any way to retrieve OSM node id rather than just coordinates along the path of routing result? That would be very helpful to merge with external data. I have done the search and found, and currently I am able to get OSM way id output.
However as stated in my issue, is it possible to have a list of node ids in OSM along the routing path? The reason for that is, the way is too long sometimes, and the actual routing may only pass through part of them. So I think that representing route as a sequence of OSM nodes is a good idea for external data usage. How would I achieve this, if possible?

The big problem is that one OSM way can map to multiple edge IDs. E.g. if you include OSM way 1 and 2 in the result this could mean that just a tiny part of this OSM way is used in the route. Maybe it make more sense to match your external data more detailed with GraphHopper edge IDs?

Yes I think you get me. It is just because that OSM way could be having a large amount of node and edges along, thus the OSM way really could not reflect the true routing behind. So OSM node sequences may be a good idea for it provides good granularity to represent the routing path.

In my application, what I am really doing is calculating all routes from a list of starting points and ending points, then add a property to every OSM node in the area with how many routing paths passed through the particular node. That’s the reason I would like to find out the OSM node sequence representation of routing path.

Sorry, didn’t properly read the first post and yes, with OSM nodes this would be better.

Doing the same translation from node ids to OSM node ids is similar, then you would have to change the way the json is created in SimpleRouteSerializer. As workaround to avoid changing this class you could populate the hints map with the translated osm node id information.

Maybe we should think about how to include this in the official repository too at some point.

I’m trying to figure out how to store the OSM node id <=> internal node id mapping in OSMReader.
However I didn’t quite find methods similar to storeOsmWayID that could do the trick in your workaround of solving WayID mapping. Any advice on how should I do similar with nodes as the ways do?

Good question. You could use the same method and fetch the EdgeIteratorState via

edge=graph.getEdgeIteratorState(edgeId, Integer.MIN_VALUE); then

… maybe instead of the edgeId we should pass the EdgeIteratorState to avoid this ugliness.