4

Is it possible? I need to jump to a way from any edge. Way ID seems very convenient mechanism considering it's already generated in OSM. However I can't find anything yet. If you wonder why I need this, it's simple - a way can be used as a container of common properties for a set of edges. It eliminates need to duplicate information.

    AllEdgesIterator ei = graph.getGraph().getAllEdges();

    logger.info("Wring {} edges...", ei.getMaxId());

    while (ei.next()) {
                // TODO (ds): get way ID here
                ...
    }
Schultz9999
  • 8,717
  • 8
  • 48
  • 87
  • Hey, did you end up implementing a solution where you can backwards access OSM way and node meta data after they have been imported into Graphhopper? – LeoR Feb 20 '15 at 01:17
  • Sorry, I don't remember what I ended up with -- it's been a while – Schultz9999 Feb 20 '15 at 18:51

1 Answers1

4

The OSM way id is not stored in GraphHopper. You'll need to create e.g. an array of long values while import to maintain them:

arr[edgeId]=osmId
Karussell
  • 17,085
  • 16
  • 97
  • 197
  • Yeah... I started adding that in OSMReader. It's a little bit involved because only OSMReader handles that when it creates edges. I am storing them with an edge and that requires a bit of work on serialization part. – Schultz9999 Jun 12 '14 at 19:08
  • Yeah, probably we should provide a hook for that. What do you mean with storing them with an edge? Do you mean you extend GraphHopperStorage to do that? You probably just need a DataAccess object (kind of an array but with serialization) – Karussell Jun 13 '14 at 07:36
  • Not really. I added `wayId` to the edge and a couple accessors, `getWayId`, `setWayId`. Works fine. Unfortunately it caused significant hit on size :S Apparently adding 8 bytes, doubles size of the edge class and the edge file. From this perspective I wonder if I need `long` for way ID at all. GH defines it as `long` but I don't think OSM data goes beyond max int. The next thing is getting way tags available for analysis. GH is awesome, and I am sure I can make it be more informative. – Schultz9999 Jun 13 '14 at 17:01
  • 1
    BTW, I did try using approach similar to how way names are stored but then backed off because there isn't much but way ID to store. However for tags I will probably have to use `DataAccess` as you recommended because tags are numerous. – Schultz9999 Jun 13 '14 at 17:06
  • 1
    Yeah way ids are only 200K http://wiki.openstreetmap.org/wiki/Stats ... re tags: would also be nice to have in core GH e.g. via configuration. Maybe you can provide a PR :) – Karussell Jun 15 '14 at 10:22