1

I need to store an edgeId-osmWayId Map during import from OSM file, to use it during routing. Is it possible? Any suggestion?

Tarik
  • 4,961
  • 3
  • 36
  • 67

1 Answers1

0

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:

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, ...));
Karussell
  • 17,085
  • 16
  • 97
  • 197
  • Thanks for your answer.
    I create my map in this way :
    [code] protected void storeOsmWayID( int edgeId, long osmWayId ) { if (getOsmWayIdSet().contains(osmWayId)) { getEdgeIdToOsmWayIdMap().put(edgeId, osmWayId); } // Creo associazione tra edgeId e osmWayId osmEdgeIdOsmWayIdMap.put(edgeId, osmWayId); }[code]
    but i have no idea how to store it in my graph and use it during routing. E.g. in a custom Weighting.
    – Antonio Grimaldi Apr 07 '15 at 13:39
  • Have a look into the weighting documentation describing something similar (weighting.md) – Karussell Apr 07 '15 at 13:42
  • I would like to create my custom Weighting in this way: Weighting customWeighting = new MyFastestWeighting(ghEdgeIdToOSMWayIdMap, encoder); But how get ghEdgeIdToOSMWayIdMap created during import? Should i save it like StorableProperties properties? – Antonio Grimaldi Apr 07 '15 at 13:51
  • You can use whatever storage component you like or just GraphHoppers DataAccess implementations – Karussell Apr 07 '15 at 20:35
  • maybe I should have a look into com.graphhopper.storage.GraphExtension interface? – Antonio Grimaldi Apr 08 '15 at 11:23