OSM Way ID Mapping making integrating external data easier

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.

  1. 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.

  2. 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!

2 Likes

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.