 <p>You could store this information to a map while import. As it grows really big I suggest using a preallocated long-array with as many entries as there are edges. E.g. use a custom encoder:</p> <pre><code>CarFlagEncoder carEncoder = new CarFlagEncoder(5, 5, 3) { @Override public void applyWayTags(OSMWay way, EdgeIteratorState edge) { ghEdgeIdToOSMWayIdMap[edge.getEdge()] = way.getId(); super.applyWayTags(way, edge); } }; setEncodingManager(new EncodingManager(carEncoder, ...)); </code></pre>