I’ve created a simple showcase on how you can retrieve additional information from an external database or similar based on the edgeId which gives you the OSM-Way-IDs which you can use for your external database. (Still keep in mind that OSM-Way-IDs are not stable, e.g. if one way is splitted or removed)
See here
With graphHopper.getOSMWay(edgeId)
you can get the corresponding OSM-Way-ID.
-
Now you can either fetch information after the route calculation, this is shown in MyImport where e.g. also the virtual edges are properly mapped to OSM-Way-IDs. Keep in mind that this is using the unstable API of VirtualEdgeIteratorState which is not yet finalized.
-
OR you can also fetch the information shortly after the import e.g. to use some OSM-Way costs stored in a Postgis direct in a custom Weighting. Just loop through all edges:
AllEdgesIterator iter = getGraphHopperStorage().getAllEdges();
while(iter.next()) {
...
}
and place the code e.g. in the finishedReading method after the edgeMapping.flush()
of the MyGraphHopper class (OSMReader)
For all this the latest version from master is necessary.
See also: Retrieve OSM node and way ID
Hope this helps a bit to hack around!